Closed brynwolfe closed 2 years ago
Hi, The library automatically manages any spurious data received. Therefore, purging the ring buffer is not necessary under any circumstances. If you have a sample code where I can reproduce your issue I can take a look. Besides, be sure to handle the notification value returned by each modbus query. If the master does not receive an answer you should handle it, e.g., implementing a delay before sending another request or something like that.
Sorry, I never saw a notification indicating you had responded. Thanks for the clarification.
My code uses this library by sending a command and immediately waiting for a response, so each transaction is one-to-one. However, I am seeing responses getting out of sync with requests by 5, i.e., a modbus request doesn't see the corresponding response for 5 subsequent transactions. I assume data in the RX buffer is due to some initial noise on the UART receive inputs as the modbus device on the other end of the wires is powering up.
Regardless of the cause, is there a recommended way to purge the receive ring buffer? Calling RingClear on the receive buffer (xRingBuffer) won't work reliably because it doesn't have the locks around it to block simultaneous interrupts.