We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents cf81971 + 8abcefa commit 17d9c5bCopy full SHA for 17d9c5b
arduino-modbus-rtu-tcp-gateway/03-modbus-rtu.ino
@@ -127,7 +127,13 @@ void recvSerial() {
127
static byte serialIn[MODBUS_SIZE];
128
while (mySerial.available() > 0) {
129
byte b = mySerial.read();
130
- if (rxNdx < MODBUS_SIZE) {
+ if (rxNdx == 0 && queueData[0] != b) {
131
+ if(recvMicroTimer.isOver())
132
+ break;
133
+ // wait a bit to the buffer to clean up
134
+ recvMicroTimer.sleep(charTimeOut());
135
+ }
136
+ else if (rxNdx < MODBUS_SIZE) {
137
serialIn[rxNdx] = b;
138
rxNdx++;
139
} // if frame longer than maximum allowed, CRC will fail and data.errorCnt[ERROR_RTU] will be recorded down the road
0 commit comments