computerlyrik / dymoprint

Linux Software to print with LabelManager PnP from Dymo
Apache License 2.0
151 stars 51 forks source link

Error when multiple devices are attached #109

Closed systeemkabouter closed 5 months ago

systeemkabouter commented 8 months ago

Before anything else: I am VERY happy with this tool and the high quality output I get from this. Never had similar easy results using the official Mac/Windows software.

When connecting only my LabelManager-PnP, this excellent software works as documented/expected.

But apparentlly when I connect both my LabelManager-PnP and my LabelWriter-450 concurrently, dymoprint has an unhandled error.

For me the fix would be to just always have it point at the LabelManger-PnP because I use glabel for the 450 model right now.

eelco@tux:~$ dymoprint -s b -qr https://github.com/computerlyrik/dymoprint test this 
Found multiple Dymo devices:
<DEVICE ID 0922:1002 on Bus 003 Address 016>
  manufacturer: Dymo
  product: DYMO LabelManager PnP
  serial: 01534802072010
  configurations:
  - <CONFIGURATION 1: 500 mA>
    interfaces:
    - <INTERFACE 0: Printer>
    - <INTERFACE 1: Mass Storage>
    - <INTERFACE 2: Human Interface Device>

Traceback (most recent call last):
  File "/home/eelco/.local/pipx/venvs/dymoprint/lib/python3.11/site-packages/dymoprint/detect.py", line 30, in device_info
    dev.manufacturer
  File "/home/eelco/.local/pipx/venvs/dymoprint/lib/python3.11/site-packages/usb/core.py", line 898, in manufacturer
    self._manufacturer = util.get_string(self, self.iManufacturer)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/eelco/.local/pipx/venvs/dymoprint/lib/python3.11/site-packages/usb/util.py", line 313, in get_string
    raise ValueError("The device has no langid"
ValueError: The device has no langid (permission issue, no string descriptors supported or device error)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/eelco/.local/bin/dymoprint", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/eelco/.local/pipx/venvs/dymoprint/lib/python3.11/site-packages/dymoprint/command_line.py", line 265, in main
    print_label(label_bitmap, margin_px=args.m, tape_size_mm=args.t)
  File "/home/eelco/.local/pipx/venvs/dymoprint/lib/python3.11/site-packages/dymoprint/dymo_print_engines.py", line 324, in print_label
    detected_device = detect_device()
                      ^^^^^^^^^^^^^^^
  File "/home/eelco/.local/pipx/venvs/dymoprint/lib/python3.11/site-packages/dymoprint/detect.py", line 64, in detect_device
    print(device_info(dev))
          ^^^^^^^^^^^^^^^^
  File "/home/eelco/.local/pipx/venvs/dymoprint/lib/python3.11/site-packages/dymoprint/detect.py", line 32, in device_info
    instruct_on_access_denied(dev)
  File "/home/eelco/.local/pipx/venvs/dymoprint/lib/python3.11/site-packages/dymoprint/detect.py", line 137, in instruct_on_access_denied
    instruct_on_access_denied_linux(dev)
  File "/home/eelco/.local/pipx/venvs/dymoprint/lib/python3.11/site-packages/dymoprint/detect.py", line 214, in instruct_on_access_denied_linux
    raise RuntimeError("\n\n" + "\n".join(lines) + "\n")
RuntimeError: 

You do not have sufficient access to the device. You probably want to add the a udev rule in /etc/udev/rules.d with the following command:

  echo 'ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="0922", ATTRS{idProduct}=="0020", MODE="0666"' | sudo tee /etc/udev/rules.d/91-dymo-20.rules

Next refresh udev with:

  sudo udevadm control --reload-rules
  sudo udevadm trigger --attr-match=idVendor="0922"

Finally, turn your device off and back on again to activate the new permissions.

If this still does not resolve the problem, you might need to reboot. In case rebooting is necessary, please report this at <https://github.com/computerlyrik/dymoprint/pull/56>. We are still trying to figure out a simple procedure which works for everyone. In case you still cannot connect, or if you have any information or ideas, please post them at that link.
systeemkabouter commented 8 months ago

my device listing:

eelco@tux:~$ lsusb | grep Dymo Bus 003 Device 016: ID 0922:1002 Dymo-CoStar Corp. DYMO LabelManager PnP Bus 003 Device 019: ID 0922:0020 Dymo-CoStar Corp. LabelWriter 450

maresb commented 8 months ago

Thanks so much @systeemkabouter for the detailed report! Glad you are enjoying this project.

Sorry about the error you are getting. You seem to have a luxurious abundance of Dymo printers! 😂 We just haven't tested for this situation yet.

I am wondering how we should handle this and similar situations where more than one device is available. In your particular situation the 450 is not yet supported, but we are looking to offer support.

Maybe we should define a section in dymoprint.ini for defining priorities of various devices? I am open to suggestions and PRs.

maresb commented 8 months ago

Would you be interested in seeing if you can get the 450 to print from dymoprint?

systeemkabouter commented 8 months ago

To have the 450 in scope/supported, that would be nice. It is working for me now using glabels, so it is not really urgent. At first to have it working without the need to disconnect anything would be sufficient. I think I will check out the project next weekend to see if there is anything I could do myself in this regard.

maresb commented 5 months ago

Closed by #12, and will be available shortly in Labelle v1.2.0. Thanks @systeemkabouter and @tomers!