-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESP32 Support #98
Comments
Thank you for the issue |
Update: I try to re-sort my fork into different branches ...
The rest goes way beyond this ...
|
hi Werner |
Hi Erfan, sorry for not exactly understanding your message ... btw: In the meantime I re-organized my fork https://github.com/tinkering4fun/ArduinoModbusSlave-ESP32-fork ArduinoModbusSlave-ESP32-fork/examples/specific/ESP32/plainSlave |
thanks dear Werner I want to put an ESP32 module as a slave by Yaacov's library (Modbusslave.h) and read the analog data by Modbus pull in my pc. can you help me? |
dear Werner. |
Hi Erfan, See line 445 I assume you are already familiar with Modbus and have some Modbus client software at your PC- There is also a straight-forward and simple example in Yaacov's lib It is made for Arduino board, but the code should also run on ESP32 after changing the ADC pin definitions. I never used STM32, if you own one, just give it a try and see ... btw: Hope this helped to some extend. Regards |
Thanks dear Werner. yes, i used Yaacov's lib and read analog on Modbus pull. i could use from Yaakov's library on ESP32 with your guide. very good issue. thank you and dear Dr zemir Regards |
Hi Yaacov,
thanks for this great Modbus Slave library (the best I found so far for building a Modbus RTU Slave).
While using the code on ESP32 I found a minor regression from issue #97:
The signature of the callback functions has changed, while the examples do not yet adopt to it.
Easy to fix, just append the missing
, void *context
in the signature of the example's callback functions.(Btw. When compiling for AVR there is no error on compile time, but I didn't try to run the code on AVR.)
Besides this, I would suggest another small fix in ModbusSlave.cpp:
The class constructor should initialize all
cbVector[]
entries with NULL.To be honest, I'm currently unsure about the best single (?) place in the constructor(s) where to do it.
Without the init the slave crashes when a Modbus request is received, with a FC where no appropriate callback vector has been set for.
Because the
if(callback)
in the code snippet below does not evaluate to false for this case, maybe this is also just a ESP32 issue.What do you think about official ESP32 support for your code?
The benefit with ESP32 as Modbus RTU Slave is imho the 2nd hardware Serial port available (and of course some projects may also benefit from WiFi etc.).
See my working ESP32 Slave example code below (derived from simple.ino).
Requires the trivial fix in ModbusSlave.cpp desribed above.
Kind regards
Werner
simpleESP32.ino.txt
edit:
As an absolute beginner at GitHub, I just try to follow this documentation https://docs.github.com/en/get-started/quickstart/contributing-to-projects ...
Did a fork, and pushed my changes in branch ESP32, hope it helps.
The text was updated successfully, but these errors were encountered: