if (myChannel.update()) {
digitalWrite (LED_PIN, LOW); // no error
memcpy (
buf,
myChannel.getData(),
myChannel.getLength()
);
if (buf[1] == 1) {
Distance = buf[2];
}
}
if (!myChannel.update()) {
digitalWrite (LED_PIN, HIGH); // turn on LED if error
}
When there is no serial connection, or there i a problem i want the build-in led to light on.
If i dont use the
if (!myChannel.update()) {
digitalWrite (LED_PIN, HIGH); // turn on LED if error
}
The code works ok, but if i use the not true statement the build in led always stay on and no data are exchanged, any idea why the program just skips the if (myChannel.update() ?
I was wrong, i was looking in the RS485_protocol.cpp line 97-101 and i found this
byte recvMsg (AvailableCallback fAvailable, // return available count
ReadCallback fRead, // read one byte
byte * data, // buffer to receive into
const byte length, // maximum buffer size
unsigned long timeout) // milliseconds before timing out
So it checks for a timeout in the RS485_protocol library but not the RS485_non_blocking library.
Do i need to edit the library? or does he check for a timeout in a different way in the non_blocking library?