rs485 csma/cd
For multimaster the problem is complicated for all masters. Slaves have only to do their business and they just have to check an incoming address, with the 9 bit set. If two byte address are sent (both with 9 bit set) , slaves have to check both. If you plan to use no more than 16 masters and 16 slaves, then you can still use one byte for address (high nibble-master addr, low nibble-slave addr), or any combination which result in 8 bit word (ex. 8 masters+32 slaves=3+5bits). Unadressed slaves are unsensitive to all traffic with 9 bit cleared. But masters have to be sensitive to all traffic. Masters can send dummy addressing from time to time, to syncronise other masters. The main issue is to prevent two or more masters to talk at the same time. Example: after startup the master with tslot0 send dummy packet in the network (ex. for a non-existant slave, important is to know which master sent the packet). This synchronises other masters (use timers). When a certain master have to send data, waits untill its timeslot became active, then sends address to slave. The communication begins. In the mean time, other masters must sniff the traffic, and forget any action if a data transfer is in progress (use 9th bit to see this). After the data transfer is closed, the master which ended transmission can send again another dummy packer to resynchronise the timeslot algorythm in other masters. About hot swapping, it is more complicated, I can give you only general hints. I would not reccoment this, because if you insert a device into 485 net when a data transfer is in progress, most probably you will corrupt the data. This means you'll have to implement CRC/checksums. If you want to use dynamic addresses for masters and slaves, then...dunno...you'll have a loooot of work to do. Try first to avoid hotswaping and use static addresses for devices.
/pisoiu