Assign a Serial Port to a specific Serial Device

Felix's icon

Hello List!.
I think that I have read threads about this issue in the past, but I don’t find them right now …
I would like to know the best way to assign serial devices to serial ports via max in a dynamic way. In other words, I would like to know a system in OSX and Windows to control via max the assignation of serial Devices to Serial ports. In my case I want to use 4 Arduinos and assign them always to the same ports in any computer.
I need this function to:
1. Never lose the assignation in a long term interactive installation. Example: if anyone disconnect - connect serial devices in different order … etc.
2. Always assign the devices correctly when you change from one computer to another.
I hope I have made myself clear ,-)
I understand the use of the message print to create menus of serial ports available, and the use of port message to select-open them. What I don’t find is an automatic (software controlled) way to assign a specific device to a specific port. I know how to do this by hand in the OS, but not from max. How do you manage this?
Many thanks for your time and help.
Cheers.
Felix

Peter Reid's icon

Felix,

Sorry I can't give you a definitive answer, but I don't think it's possible to do what you describe. Until someone more knowledgable than myself says otherwise I think you should work on the assumption that the serial port is assigned on a pot luck basis.

You seem to already be aware of the solution I am about to propose of using the print message and the "port a/b/c..." message. I can see why hardwiring the port assignment would be more reliable but I offer this solution as something I happen to have lying around.

Below is a piece of code that I wrote to do the assigning automatically. Unfortunately, your arduino devices will need to show up with different names in the list produced by the print message. Maybe they already do show up differently, but if not you probably have to do some thing like hack their firmware to give them unique names.

Another less than ideal solution for differentiating them would be to wire two spare sensor inputs on each arduino in such a way as to give them each their own binary number. ie 0-0 0-1 1-0 1-1

Sorry if this doesn't answer your question!

good luck
Peter

Max Patch
Copy patch and select New From Clipboard in Max.


Felix's icon

Hi Peter and Eva.
Thanks for sharing ,-)
I think that Eva's second idea is interesting, but if i understand correctly there could still be a problem because the 4 serial max objects have to point always to the 4 arduinos (and not to other serial devices). If one of the 4 open ports in max(in 4 serial objects) points to other devices, then it doesn't work correctly.

If the 4 ports point to the 4 arduinos, then it doesn't matter which port is which arduino, because i use headers to route each arduino's data.

I'm getting it right?.

In any case i would like to ask you both for a confirmation about how computers manage serial devices:
when you connect a new device to a computer they assign automatically a new free port (ex:COM2), and then whenever you reconnect that device to the same computer, she will always assign the same serial port or name (thanks to the firmware serial number of the device). Is this correct?
Thanks again.
Felix