Hi everyone,
Please can someone guide me that how can a master send a message to multiple slaves using RS 485 non blocking library by Nick Gammon.
here is the link
As I am trying to understand the code but I am unable find a variable where we could define the slave to which we want to send the message. As in the blocking code the message includes i.e
Both Blocking and non blocking libraries are in the above link,
byte msg [] = {
1, // device 1 (slave) address
3 // turn light on command received
};
// assemble message
byte msg [] = {
1, // device 1
2, // turn light on
level // to what level
};
The first byte of the message says which slave is supposed to deal with that message. There are two ways to send messages to multiple slaves, depending on whether multiple means all o more than one.
If it means all, decide what slave number means all, and send the message to that number. Each slave would be programmed to react to its own number and the one that means all.
If it means more than one (but not all), you send multiple messages, each to a specific slave.
I understand the point where the first byte represents the address of the slave but i cannot understand how to represent this in the non blocking library.
this the link for the library. At the bottom of the page there is non blocking library.
and this is the example code given there for sending and receiving data but i cannot seem to understand the address part here.
You are sending an array of bytes in both cases. In one case, a protocol has been defined. In the other case, it hasn't. There is nothing magic about the array of bytes in either case.
If you want, in the non blocking case, to say that the 7th byte represents an address, feel free to do that. Or the 24th. Or, even the 1st.
Ah yes, I was leaving that as an exercise for the reader. Plus I didn't want to give the impression that the struct in question was the only way of using the library.
Does this library have advantages over EasyTransfer?
In the examples, the code is very similar. Which is better to use?
Can I transmit int and String in one struct?
Do I need to perform additional steps to ensure the quality of the transmission (CRC checking, delivery verification, etc.), or is it all happening inside the library?
The library does a CRC check, however it does not do delivery verification. There isn't a handshaking protocol as such, it merely guarantees that if a packet is received it is a valid packet. You might need to send some sort of acknowledgement back (eg. received packet 5) and if the sender doesn't get that, it sends it again after a certain delay.