paukstelis / octoprint_deploy

Bash script for rapid deployment of multiple octoprint instance on a single machine
MIT License
394 stars 39 forks source link

Trouble setting up without serial # #1

Closed 4jesse closed 3 years ago

4jesse commented 3 years ago

I'm tring to setup several printers on a NUC with 4 USB ports. The first one (PRINTER1) is detected with its serial number, but the next one (PRINTER2) is not finding a serial # and is showing XXXXXXXXXX.

I edited the /etc/udev/rules.d/99-octoprint.rules file to read:

SUBSYSTEM=="tty", ATTRS{serial}=="A506VOOE", SYMLINK+="octo_Printer1"
SUBSYSTEM=="tty", ATTRS{devpath}=="1-1:1.0", SYMLINK+="octo_Printer2"

When viewing the Octoprint page for PRINTER1 (:5001) it shows /dev/octo_Printer1 under the Serial Port. When I view the page for PRINTER2 (:5002), it doesn't show a /dev/octo_Printer2 (or anything with ...octo_PrinterX. It does, however work on /dev/USB0.

Here is the last few lines from my dmesg just after unplugging/replugging my problem printer usb cable:

[   58.233094] usb 1-1: USB disconnect, device number 2
[   58.233359] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
[   58.233416] ch341 1-1:1.0: device disconnected
[   61.729432] usb 1-1: new full-speed USB device number 6 using xhci_hcd
[   61.878365] usb 1-1: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.63
[   61.878373] usb 1-1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[   61.878378] usb 1-1: Product: USB2.0-Serial
[   61.880890] ch341 1-1:1.0: ch341-uart converter detected
[   61.884712] usb 1-1: ch341-uart converter now attached to ttyUSB0
paukstelis commented 3 years ago

Have you reloaded the rules since you edited your udev rules file?

try: sudo udevadm control --reload-rules sudo udevadm trigger

You can then check to see what you have in /dev with: ls /dev/octo*

4jesse commented 3 years ago

Still only Printer1. From my dmesg post, am I using the correct devpath attribute?

paukstelis commented 3 years ago

It looks like it, but if you could unplug/plug the printer again in the same location, immediately do a dmesg and just take the last 20 or so lines from dmesg it might be more instructive.

paukstelis commented 3 years ago

You might be better off using idProduct and idVendor.

SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTR{idProduct}=="7523", SYMLINK+="octo_Printer2"

Do the udevadm commands again. Then check what is in the dev directory.

4jesse commented 3 years ago

I tried adding Printer3 (also not detecting the serial#) - it came up as 3-1,1.0 but has the exact same idVendor and idProduct as Printer2. I tried both the {devpath} option as well as the suggestion above and it still won't create the SymLink. I did the udevadm commands again and rebooted the machine. No joy.

These are both original Creality boards. I'm going to try to update the firmware and see if anything changes.

paukstelis commented 3 years ago

Hmm...I don't use devpath for my printers since they all have serial numbers. For cameras I have used KERNELS, which you could try. Something like:

SUBSYSTEM="tty",KERNELS=="1-1:1.0",SUBSYSTEMS=="usb",SYMLINK+="octo_Printer2"

EDIT: Output from udevadm info --attribute-walk --name=/dev/ttyUSBXXX would also be useful.

4jesse commented 3 years ago

I tried the Kernels line above (with 1-2) with no luck...

I used USB1 and got this output:

octouser@OctoNUC:~$ udevadm info --attribute-walk --name=/dev/ttyUSB1

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0/ttyUSB1/tty/ttyUSB1':
    KERNEL=="ttyUSB1"
    SUBSYSTEM=="tty"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0/ttyUSB1':
    KERNELS=="ttyUSB1"
    SUBSYSTEMS=="usb-serial"
    DRIVERS=="ftdi_sio"
    ATTRS{port_number}=="0"
    ATTRS{latency_timer}=="16"

  looking at parent device '/devices/pci0000:00/0000:00:15.0/usb1/1-2/1-2:1.0':
    KERNELS=="1-2:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="ftdi_sio"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bNumEndpoints}=="02"
    ATTRS{bInterfaceProtocol}=="ff"
    ATTRS{bInterfaceClass}=="ff"
    ATTRS{supports_autosuspend}=="1"
    ATTRS{interface}=="FT232R USB UART"
    ATTRS{authorized}=="1"
    ATTRS{bInterfaceSubClass}=="ff"

  looking at parent device '/devices/pci0000:00/0000:00:15.0/usb1/1-2':
    KERNELS=="1-2"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bMaxPacketSize0}=="8"
    ATTRS{speed}=="12"
    ATTRS{manufacturer}=="FTDI"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{product}=="FT232R USB UART"
    ATTRS{version}==" 2.00"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{devnum}=="3"
    ATTRS{quirks}=="0x0"
    ATTRS{bcdDevice}=="0600"
    ATTRS{authorized}=="1"
    ATTRS{bmAttributes}=="a0"
    ATTRS{tx_lanes}=="1"
    ATTRS{idVendor}=="0403"
    ATTRS{maxchild}=="0"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bDeviceClass}=="00"
    ATTRS{devpath}=="2"
    ATTRS{configuration}==""
    ATTRS{ltm_capable}=="no"
    ATTRS{busnum}=="1"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bMaxPower}=="90mA"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{idProduct}=="6001"
    ATTRS{urbnum}=="16"
    ATTRS{removable}=="removable"
    ATTRS{serial}=="A506VOOE"
    ATTRS{rx_lanes}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:15.0/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{idVendor}=="1d6b"
    ATTRS{product}=="xHCI Host Controller"
    ATTRS{authorized_default}=="1"
    ATTRS{configuration}==""
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{tx_lanes}=="1"
    ATTRS{bDeviceClass}=="09"
    ATTRS{urbnum}=="99"
    ATTRS{maxchild}=="8"
    ATTRS{idProduct}=="0002"
    ATTRS{bmAttributes}=="e0"
    ATTRS{interface_authorized_default}=="1"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{authorized}=="1"
    ATTRS{version}==" 2.00"
    ATTRS{bMaxPower}=="0mA"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{quirks}=="0x0"
    ATTRS{ltm_capable}=="no"
    ATTRS{bcdDevice}=="0508"
    ATTRS{removable}=="unknown"
    ATTRS{serial}=="0000:00:15.0"
    ATTRS{speed}=="480"
    ATTRS{devpath}=="0"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{devnum}=="1"
    ATTRS{bDeviceProtocol}=="01"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{busnum}=="1"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{manufacturer}=="Linux 5.8.0-43-generic xhci-hcd"
    ATTRS{rx_lanes}=="1"

  looking at parent device '/devices/pci0000:00/0000:00:15.0':
    KERNELS=="0000:00:15.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="xhci_hcd"
    ATTRS{subsystem_vendor}=="0x8086"
    ATTRS{broken_parity_status}=="0"
    ATTRS{enable}=="1"
    ATTRS{class}=="0x0c0330"
    ATTRS{consistent_dma_mask_bits}=="64"
    ATTRS{revision}=="0x0b"
    ATTRS{d3cold_allowed}=="1"
    ATTRS{local_cpus}=="f"
    ATTRS{vendor}=="0x8086"
    ATTRS{numa_node}=="-1"
    ATTRS{subsystem_device}=="0x2067"
    ATTRS{msi_bus}=="1"
    ATTRS{device}=="0x5aa8"
    ATTRS{ari_enabled}=="0"
    ATTRS{dbc}=="disabled"
    ATTRS{irq}=="126"
    ATTRS{local_cpulist}=="0-3"
    ATTRS{driver_override}=="(null)"
    ATTRS{dma_mask_bits}=="64"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

octouser@OctoNUC:~$ 
paukstelis commented 3 years ago

This should work (assuming you still have them plugged into the same usb ports):

KERNELS==""1-1:1.0",SUBSYSTEMS=="usb",SYMLINK+="octo_Printer2" KERNELS==""1-2:1.0",SUBSYSTEMS=="usb",SYMLINK+="octo_Printer3"

I tested this on my system and it worked. To clarify, you don't need the SUBSYSTEM=="tty".

4jesse commented 3 years ago

Thanks for all the options, but that didn't work either. I've just finished updating the firmware with TH3D and wanted to try the addnew script again, but it says "Already have an entry for Printer2. Exiting." I had already removed the two extra printers (left PRINTER1) from the 99-octoprint.rules file.

So, how do I remove a previous attempt?

paukstelis commented 3 years ago

It is not firmware dependent (as far as I know) so you aren't likely to have any luck with that. You can plug it in and check the end of the dmesg again to see if there is a serial number, but I doubt it.

What I gave you definitely works in a general sense, so perhaps there is some issue with how the udev line is formatted.

Removing whole instances requires deleting: /home/x/.INSTANCE_NAME /etc/default/INSTANCE_NAME /etc/init.d/INSTANCE_NAME and removing the port of that instance from /etc/octoprint_ports.

4jesse commented 3 years ago

Yep, you're right. No change after the firmware change. Previously I did copy/paste of your KERNELS option above and it didn't work, but I JUST looked at the syntax and I should have removed an extra quote mark after KERNELS==.

KERNELS==""1-1:1.0",SUBSYSTEMS=="usb",SYMLINK+="octo_Printer2"
KERNELS==""1-2:1.0",SUBSYSTEMS=="usb",SYMLINK+="octo_Printer3"

It's now all good - your suggestion worked great! I'm not sure why the other methods didn't work for me, but I'm thrilled you kept trying to find options for me. Thanks MUCH.

paukstelis commented 3 years ago

Sorry about that. Copy/paste errors! Good luck!