I have a bus network (RS485 based) with one master and N slaves. Each slav e has a different unique 32-bits serial number.
I was thinking on a method for the master to autodetect the serial numbers of the connected slaves. Of course, the brute force method isn't acceptable for the time to test ALL the serial numbers.
A more intelligent approach could be to discover the serial numbers on a bi t basis (similar to 1-wire discovery algorithm).
Starting from bit 0, the master could send a broadcast request: are there s laves with bit 0 set to 1? If the serial number matches the request, the sl ave answers with its complete serial number. If no answer is detected, the result is simple: all the serial numbers have the bit 0 set to 0. If N corrected answers are received (so they don't overlap), the master has detected N slaves. If some bytes are received, but the message isn't correct, most probably mo re than one slave has a serial number with the same characteristic (bit 0 t o 1) and the answers are overlapped. The master should move to bit 1 to sol ve the collision, sending a request similar to the following: are there ser ial numbers with bits 1-0 set to 1-1? And so on...
Do you think this could work in a real situation? Are there implementations similar to this?
Are there other better methods to implement an auto-discovery feature?