I have a device that I want to be able to communicate with serially. On Linux, I can see that when I plug in the device to my computer, I see that /dev/ttyUSB0
pops up, which I know to be the device; however, what I am not sure about is how would I go about finding out what port my device is connected to in the general sense? Say if I were to go to another machine and plug it in, or if I had multiple serial devices already plugged in to this computer; I wouldn't be able to rely on it always being /dev/ttyUSB0
.
I plan on using PySerial to be communicate with the device (I couldn't find any other officially supported method with python to communicate with a serial device), and when you open a serial connection, you of course must specify the path to the device. On Windows it would be COM
something, and Linux /dev/tty
something. I want to be able to automatically find this out through the program. What is the best method to go about this?