
UDEV Rules for Static Port Assignment
When you plug a 3D printer (or any serial device) into a computer, it assigns it a symlink of /dev/ttyUSB[0..99] or /dev/ttyACM[0..99]. The numbering of these symlinks is dependant on the order the devices are plugged in. This can cause problems when you want a device to be tied to a specific link, like when setting up octoprint in dockers for your printers.
To solve this issue, I used a custom UDEV rule created at /etc/udev/rules.d/99-static-port-assignment.rules
ACTION=="add", SUBSYSTEM=="tty", SUBSYSTEMS=="usb", DRIVERS=="usb", SYMLINK+="tty.usb-$attr{devpath}"I then create a soft link from the new symlink to a human readable link so it doesnt go away when the device is disconnected:
#ln -s /dev/tty.usb-8.4.1 /dev/3D_printers/monoprice-maker-selectand pass that human readable link into the container using Docker Compose:
devices:
- /dev/3D_printers/monoprice-maker-select:/dev/ttyUSB0This remedies needing to have all the printers up for the containers to start, and keeps the assigned printer connected to the right instance of octoprint.