Arduino to Max - making serial port same each time
Hi,
I am working on a patch that receiving data from the arduino via the serial port.
How can I make sure that each time Max patch is starting it will choose thr write port for the arduino?
sometimes when restarting the computer/max it can happen a different port of the arduino will be choose?
I would like that same port will be choose.
How can I do so?
Thanks
1st step would be to write which OS , then which arduino model
Raspberry Pi OS with desktop, 32 bit on Pi 4
Arduino nano
You run Max on Pi OS ?
I can help you with mac or windows only
and nano - there are so many variants, ftdi, ch340,
nano green etc.
that one is ftdi, which can even get renamed
to use own indentifier.
But if you say "like" maybe your one uses CH340,
are you sure about that ?
Becuse that 2 usbserial chips inentify themself completely different
to system.
On Mac that is easy , because serial object on Mac does post
more than simple COM whatever on windows.
You need to print out avilable devices, match your model
and if found send port "your model" message to serial object.
Connect your nano to different USB ports - hubs etc,
and each time send print mesage to serial object,
but don't activat it.
That will show you more info in max console.
But if you say "like" maybe your one uses CH340, are you sure about that ?
Yes
So in order to set the right port for establishing communication over serial, I don't necessarily need to send data from the arduino itself to max, rather I can set the right port from max itself? something like this maybe?
Assuming the desired port name will always be the same? just is index can change?
your patch shows COM5 which is windows only, and COM could fail,
because every time you plug that board into different USB port,
or if you have several arduinos connected, COM number might change.
You mentioned Mac OS first, now you show windows stuff.
What is it really ?
On windows, serial object does not print device names
like "USB Serial Port" (nano with ftdi),
"usbmodem4211" (leonardo, pro micro etc with 32u4 chip)
"USB-SERIAL CH340" (any board with CH340 chip)
or similar, but ony that stupid COM shit.
You must capture console output instead of serial object output when printing available ports.
And then try to link device name with COM port.There are also tools that allow to permanently assign COM port number to specific device.
Do you want to get into that ?
for example
https://www.uwe-sieber.de/ComPortMan_e.html
as first run this patch to compare serial port output
to console with right outlet of serial object
Output is same as to max console itself, but like this you can match device name from console object output.
your patch shows COM5 which is windows only, and COM could fail, because every time you plug that board into different USB port, or if you have several arduinos connected, COM number might change. You mentioned Mac OS first, now you show windows stuff. What is it really ?
I'm working both on my personal mac computer and my work computer which is windows. I'm at work now so this is why I have try with windows. At home I will use mac.
You must capture console output instead of serial object output when printing available ports. And then try to link device name with COM port
I see, so if the port name COMx is include the name of my board then it is the right port and that port should be my serial object port ?
If output is f: COM7 "USB Serial Port" or g: COM3 "USB Serial Port"
you match "USB Serial Port" to extract COM or port letter
that is so stupid on windows.
On mac you can use port "USB Serial Port"
on windows - no way, only port g or port COM3
Problem actually is only if you use several boards
of same kind and need to use them at same time, and
need to tell which is which without having to chase them manually.
Thanks!.
So here is my patch on Mac computer. It seems the right way?
did you try what I suggesed in my first post ?
plug that arduino into differnt USB slots and each time
run print on serial port, without activating serial port.
If numbers after usbmodem change, your patch will not work.
in that case you need to separate numeric part and see if
usbmodem and that numeric part fall into your arduino model report.
On different Mac systems that port names get reported differently.
usbmodem14211 is not ftdi nano, but some 32u4..16 variant.
when using windows here is how my printing looks like;
it seems that when arduino is connected (in this case arduino uno) the serial will write that name.

how can I set the right port if the name arduino is found in the printing?
Do you really can't figure it out ?
if you know that whatever COM or letter gets assigned to your arduino,
printout also adds (Arduino Uno) to the list, then what do you do with it ?
maybe reorder the list, pass match and use the letter or COMnn?
or match nn (Arduino Uno) to port $2
and many other options