Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RX Buffer was being cleared with correct data in it. #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bjornComate
Copy link

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.

@Padanian
Copy link

Padanian commented May 9, 2023

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.

@bjornComate
Copy link
Author

bjornComate commented May 9, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants