Serial Association changes on Linux System

Corona Virus banner illustration - Microbiology And Virology Concept - by Mike Fouque


You have multiple printers connected and sometimes a printer that was assigned to a port starts to control the other printer.


All serial devices get mounted to the /dev folder. Depending on the used driver they have names like ttyACMx or ttyUSBx where x is a number 0 .. number of serials available. Here the number is not fixed to a special device – it only depends on which usb was mounted first. So if you have printers A and B, both disabled and you enable A it will get ttyACM0 and if you then enable printer B it gets ttyACM1. If you enable them in reverse order B will get ttyACM0 and A gets ttyAMC0. So this is why your mapping gets wrong.


The good news is that linux has 2 links to these real devices. They can be found in the folder /dev/serial/by-id and /dev/serial/by-path.


The driver gets reported a id from the serial. If the id of the printers are al different, it is best to use the device names in that folder. They are always the same regardless on where you plug in the printer. It can happen that a printer model has a fixed id and if you have multiple printers of the same kind all have the same id, so only one link appears here. In that case this solution will not work and you must use the by-path solution.


There is one fool proof solution to always distinguish a device. And that is the mapping based on the usb port, where you plugged in the printer. This even works with usb hubs, which cause the name just to get longer. The only drawback of this solution is, that you must always plug in the printer into the same usb port or it will not be found.