Bob - can’t say I understand the fancy line of code in your script to get the serial communication working, but I’m willing to accept it on faith since it works!? Question: I’m about to connect multiple Arduinos into a single serial port using RS485 communication (easy code available for this) and an RS485-to-USB converter.? How would I keep the multiple streams separate coming into your Jython script in JMRI?? I can tag each string with a header indicating which Arduino it is coming from, but then what?
To your PC, there aren't multiple streams coming in.? ?There's just one port (can't really tell the difference from RS-232 [or any other serial protocol] at this level).? ?It's up to you (and your devices) to make sure they don't stomp over each other on the incoming data.? ?One of the simplest models is polling:? No device (except the PC) speaks until it is explicitly spoken to.? ?The PC just enumerates all of the expected devices, in order, and asks for the data.? ?Lather, rinse, repeat.? ?
Your code then keeps track of which device it recently asked for data, and then associates the newly incoming data with that device.? ?But that's at the data parsing level, since it's all one serial stream coming in.