I am sending data between a master and several slaves with RS485 with bytes (8 bit) messages with a very simple frame inspired on Modbus ASCII:
0x3A 0x30 0x31 0x32 0x3F 0x0D 0x0A
in which the bytes are the frame sections 1) Start
0x3A, 2) Sender ID
0x30, 3) Receiver ID
0x31, 4) Function to execute
0x32, 5) Data
0x3F, and 6) End
With one master and multiple slaves, a receiver slave only sends messages when reads a message with its ID, and is silent otherwise, for discarding any collision.
When the master is the last device to be turned on, everything is ok. All slaves read the full message, and reply accordingly.
But if not, some late in wake up slaves will not detect the
Start byte correctly, do not read a full frame at some point, and I don't have any way to make them know where to start.
Data part in the message can perfectly include the
0x3A randomly, I cannot figure a robust way to deal with this.
I feel this problem is like "escaping" an special character inside a string...
How should I program the frame detection for not having this problem?