or you could use similar to the can bus, where following a signal to say its initialised on the line, it spits out its serial number and reads back while doing it, if any high bits are read back as low, it waits till the other devices with a lower serial number is allocated and tries again (though with can it has a set ID, but serial numbers can be a convenient non repeating id)