arduino-libraries / ArduinoModbus

258 stars 123 forks source link

client connect issue #56

Open Molrich opened 3 years ago

Molrich commented 3 years ago

I am working with this library I can connect to the client fine , read and update holding registers in the while loop if the client disconnects the code jumps out of the while loop as it should. The problem I am having is that if the clients then tries to reconnect the server does not respond and the client times out for the client I am using a PC running MODBUS Poll. I am using the library version 1.0.3 downloaded from Arduino site to Arduino ide. using the feather m4. so after the first connection was made the function ethernetserver Available();always returns zero

client = server.available(); if(client){ modbusTCPServer.accept(client); while (client.connected()) {

any help will be appreciated

modbus_sserver.zip

Johi-b commented 3 years ago

Hello, I am working on the same topic but I have no issues connecting and disconnecting even with Modbus poll.

// servicing TCP modbus: void modbusTcpLoop() { EthernetClient client = server.available(); if (client) { modbusTCPServer.accept(client); if (client.connected()) modbusTCPServer.poll(); } } furter assistance: see my www.SylvesterSolutions.com, there you find mail address if you want to take it further. Best Regards, Johi-b