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

usRcvBufferPos reset only in STATE_RX_IDLE in mbrtu.c #23

Open
tortuoise opened this issue Nov 18, 2020 · 1 comment
Open

usRcvBufferPos reset only in STATE_RX_IDLE in mbrtu.c #23

tortuoise opened this issue Nov 18, 2020 · 1 comment

Comments

@tortuoise
Copy link

tortuoise commented Nov 18, 2020

Firstly, thanks to the authors for this nice concise modbus slave ported to multiple devices. I tested it on a MSP430F5529 so made a few changes to the provided MSP430F169 port. I got it working but only after addressing a couple of issues which I think should impact all devices.
The issue I had to fix had to do with the current position of the buffer use to store received bytes (usRcvBufferPos) which only gets reset in STATE_RX_IDLE. If for whatever reason a slave doesn't respond to a request then the start position of the buffer doesn't get reset and is in an unknown state when the next request comes in. Setting it back to zero at the end of receiving the current frame seems to fix the problem though I'm not sure whether it introduces other problems.

eMBErrorCode eMBRTUReceive( UCHAR * pucRcvAddress, UCHAR ** pucFrame, USHORT * pusLength ) { ... usRcvBufferPos = 0; return eStatus; }

There's probably a better solution to this. Anybody else encounter this issue?

@CyrilJiang
Copy link

the timer and if no character is received within t3.5 we change to STATE_RX_IDLE. This makes sure that we delay startup of the modbus protocol stack until the bus is free.

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

No branches or pull requests

2 participants