Closed fink-at-trmc-dk closed 1 year ago
Hi @fink-at-trmc-dk , this error happens because there is specific of using your modbus slave software simulator.
The esp-modbus master supports multiple slave connection and it establishes connection to all slaves first then starts communication. In your case the error happens because your slave simulator closes connection after timeout when master opens it. Please try to play with the options -o # Master activity time-out in seconds (1.0 - 100, 3 s is default)
and -c # Connection time-out in seconds (1.0 - 3600, 60 s is default)
of your diagslave simulator.
Thanks a lot for the pointer which led me to analyzing with wireshark. It turned out that the slave ID sent is zero even though the slave ID was set to 0x47.
I fixed it by adding pucMBTCPFrame[MB_TCP_UID] = (UCHAR)(pxInfo->ucSlaveAddr);
in xMBMasterTCPPortSendResponse
line 990 and the slave ID is now correctly set.
I do not know if this is the right place to put the fix, but you should be able to reproduce it and come up with a proper fix.
Thanks for the help :-)
@fink-at-trmc-dk ,
Thank you for update. The UID was added long time ago then gone on some merge stage. It will be updated soon as well as other pending MRs.
@fink-at-trmc-dk ,
The issue will be closed automatically once the fix is merged. The fix has been implemented in v1.0.9, commit 8e3771847f826aad37491b96b2b4a2de8d2cbf76. The issue is closed.
Hi,
I cannot for the life of me make a simple ModbusTCP Master application running. I think I have read through alle the Modbus Controller documentation, but I must have missed something.
This is the ModbusTCP class I'm using:
I'm testing up against diagslave.exe, which shows the master connecting, but then nothing more happens. Starting the master simulator up reveals that the disagslave is working just fine.
In the ESP32 terminal it can be seen that it connects to the slave alright, but then disconnects.
Any pointers to help me understand how to make the ModbusTCP Master controller work is really appreciated - but also pointers to where in the documentation I should be able to find the necessary information to acheive a stable connection.
Thanks in advance!