For this system I am using an ASCII formatted header,
STX (or was it SOH I forget), then
3 bytes address, these being a byte for
device type
device unique address
sub function address.
byte count, I needed variable length packets so I added the byte count. The payload is not ascii, hence not just using ETX
First byte of payload was a message type ID
after the payload I added a footer
XOR Checksum,
EOT
I found the SOH, ADDR combination sufficient that nodes (including idle masters) only synch'd with start of real messages. If I ever latched onto the wrong thing, data looking like header, worst case byte counter would get set to 255, Check sum typically failed, and I missed a few messages in between.
As for line idle, I was simply going to restart an idle timer in the RX ISR. If this timer expires, then line is idle. Of course, I could only detect after the shifter in the SCI captured the byte, so I could possibly have an outgoing byte in the pipe at the same time. Hmm, isn't there a receiver active flag I could look at?
A comparator between TX and RX lines (with delay buffers) would be excellent, especially if it was hardwired to the TX enable of the RS485 driver, that would stop that commotion.
I agree with Mac, a round robin scheme, where the Master A reliquishes bus control, explicitly giving it to Master B, who gives to Master C etc. Trouble is starting the system, everyone having to register. A static configuration will allow this, but needs either NVRAM/FLASH/EEPROM set up or dip switch/jumper setting.
One thing that has helped in the past is giving a "random delay" to units when they start registering. This needs to be appropriately scaled for your app. Thankfully I'm in infotainment, not engine management, so I have time.
I was hoping to find a standard way of doing things, but neither Modbus, DMX nor NMEA 0183 seemed to help me. Did I miss an existing mulit drop "multi master" standard while looking?