I am receiving a request packet that is 8 bytes long, and I am using BufferedSerial.read, but I am only getting one byte of data and seems like the other bytes are getting discarded. My code is as below
...
int i = 0;
while (serial_rs485.readable() && (i < 8)) {
i += serial_rs485.read(&requestBuffer[i], REQUEST_LENGTH - i);
}
if (i == 8) {
crc_received = (requestBuffer[6] << 8) | requestBuffer[7];
}
...