I have 2 Arduino Mega 2560 connected via USB to my Ubuntu 18.04 machine. When I boot, one connects to /dev/ttyACM0 and the other connects to /dev/ttyACM1.
Communication works perfectly. However, randomly on boot, the Arduino boards connect to the opposite port of what is coded into the script. I use Python 3.6 to communicate with the boards.
Is there any way to force these boards to always connect to the same port? Or is there a way for Python to detect the board that it's talking to?