Hello, i am trying to implement an example code taken from Gammon Forum : Electronics : Microprocessors : RS485 communications
The blocking library has an example which sends multiple parameters to the reciever e.g
byte buf [10];
byte received = recvMsg (fAvailable, fRead, buf, sizeof (buf));
if (received)
{
if (buf [0] != 1)
return; // not my device
if (buf [1] != 2)
return; // unknown command
byte msg [] = {
0, // device 0 (master)
3, // turn light on command received
};
delay (1); // give the master a moment to prepare to receive
digitalWrite (ENABLE_PIN, HIGH); // enable sending
sendMsg (fWrite, msg, sizeof msg);
digitalWrite (ENABLE_PIN, LOW); // disable sending
analogWrite (11, buf [2]); // set light level
} // end if something received
However on the non-blocking library the example is much simpler:
[/code]
if (myChannel.update ())
{
Serial.write (myChannel.getData (), myChannel.getLength ());
Serial.println ();
}
[/code]
Is there a way to retrieve the data just like on the blocking library example or is it even possible with the specific library to do that ? If so can you provide an example of how can this be done?
Thanks in advance