I am trying to get a modbus server using the modbus-esp8266 library running on an esp32 and need help. I am using callback functions and have both set and get registers (Function type 4 calls) working as expected. I am applying the same logic to set and get coils (Function type 1 calls) and have no success at all. The get coil status always returns 0 to the client, regardless of what the callback function returns. There's clearly something about this I don't understand. Thanks to anyone who can set me straight.
I have made a small test sketch to illustrate my problem:
Any progress on this?
I've been reluctant to comment on this because of my lack of knowledge of the Modbus protocol. I've done a bit of research on it (with Mazurel/Modbus: Modbus library for modern C++, emelianov/modbus-esp8266, and Simply Modbus Software FAQ) and I think I have enough information for intelligent comment.
Are you basing this on a DBWS article? If so, which one?
You give a sketch of a Modbus server but not the client, so that's only half the picture. You should post the code of complete example you're using. otherwise, I can't replicate the results. Speaking of which, you should also post the results of the program output. Again, for comparison.
As a guideline, via a quote:
...frothy eloquence neither convinces nor satisfies me.
I am from Missouri. You have got to show me.
- U.S. Congressman Willard Duncan Vandiver
So, for example,
I am using callback functions and have both set and get registers (Function type 4 calls) working as expected.
You should show all the code that demonstrates this and the output to prove it.
My suspicion is this is a communication, not a protocol problem. Still, my mental picture of the protocol isn't perfectly clear, and I need to do more experimenting with it.
(Sorry if this sounds pompous. I don't mean it to.)
The one who has the most fun, wins!