Disgraceful disconnection over TCP Modbus connection

21 views
Skip to first unread message

hfelek

unread,
Dec 15, 2023, 6:23:58 AM12/15/23
to libmodbus
Hi everyone, 
Hope you are all doing great. 
I have a situation where I can't comment on more with the level I have now. I am driving a slave device from my master linux os computer over TCP connection.
 If I don't call modbus_close and modbus_free before termination of the driving process, on my next reruns of the program, one scan cycle executed in a shorter time within the program. On the fourth rerun tho, I get connection reset by peer error when I try to communicate with the slave.  Unplugging and replugging the tcp socket resets the state and master can communicate with the slave within the lognest cycle duration.

As mentioned not releasing sources result in shorter scan cycles until 'Connection reset by peer error' occurs. I have come to realize this problem from the speed of communication between master and slave. Slave has 10 read-only registers and, in one cycle I read these registers. 100 cycles approximately last 1.5 second on the first run. On the second it drops down to 1 second and 0.49 second on the third run. Fourth rerun returns 'Connection reset by error' and my program terminates upon error. 

Does anyone have an idea on what is the exact problem? By getting more insight on this I think, it is more probable to understand what communication is slow between master and slave.

Best regards




Reply all
Reply to author
Forward
0 new messages