EasyModbusTCP.NET icon indicating copy to clipboard operation
EasyModbusTCP.NET copied to clipboard

RX Buffer was being cleared with correct data in it.

Open bjornComate opened this issue 2 years ago • 2 comments

The transmit buffer was send before the RX buffer was being cleared. When a slave device was answering faster then the lib was clearing the buffer. correct data was being removed, and the packet was lost.

bjornComate avatar May 09 '23 06:05 bjornComate

AFAIK, I don't think this is the right way to do it. Never had this issue before. Check if slave is abiding to the correct timings. Sometimes, embedded devices are able to answer before the UART switches TX/RX lines.

Padanian avatar May 09 '23 09:05 Padanian

Slave is abiding timings. We've checked this with a saleae logic analyzer. I can also see the data in the buffer that as being answered back (also checked this). before it's being deleted. We're also using RS232. so no switching of RX/TX lines

Clearing your buffer before sending solves this. and I can't see a reason why you would want to first send and then clear the receive buffer, since modbus is half duplex, a slave will never answer before the master sends so there isn't going to be rogue data in the buffer if you clear it beforehand.

bjornComate avatar May 09 '23 10:05 bjornComate