computerlyrik / dymoprint

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

LabelManager PC "ValueError: The device has no langid" #93

Closed Silverstar closed 7 months ago

Silverstar commented 7 months ago

I've been following the project hoping my old labelmanager PC will be supported one day and I was lucky #83 - now I'm trying to get it working, but it doesn't. I can't tell for sure if the device is working anymore at all since I don't have any windows xp around anymore and at the last windows system in this house (W10) it's just toggling connected/disconnected all the time but I guess due to different driver architecture nowadays.

dymoprint 2.2.1.post1.dev20+g0a33ed7

silverstar@Utopia-Planitia:~$ dymoprint "test"
Traceback (most recent call last):
  File "/home/silverstar/.local/pipx/venvs/dymoprint/lib/python3.10/site-packages/dymoprint/detect.py", line 30, in device_info
    dev.manufacturer
  File "/home/silverstar/.local/pipx/venvs/dymoprint/lib/python3.10/site-packages/usb/core.py", line 898, in manufacturer
    self._manufacturer = util.get_string(self, self.iManufacturer)
  File "/home/silverstar/.local/pipx/venvs/dymoprint/lib/python3.10/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/silverstar/.local/bin/dymoprint", line 8, in <module>
    sys.exit(main())
  File "/home/silverstar/.local/pipx/venvs/dymoprint/lib/python3.10/site-packages/dymoprint/command_line.py", line 261, in main
    print_label(label_bitmap, margin_px=args.m, tape_size_mm=args.t)
  File "/home/silverstar/.local/pipx/venvs/dymoprint/lib/python3.10/site-packages/dymoprint/dymo_print_engines.py", line 270, in print_label
    detected_device = detect_device()
  File "/home/silverstar/.local/pipx/venvs/dymoprint/lib/python3.10/site-packages/dymoprint/detect.py", line 69, in detect_device
    print(f"Found one Dymo device: {device_info(dev)}")
  File "/home/silverstar/.local/pipx/venvs/dymoprint/lib/python3.10/site-packages/dymoprint/detect.py", line 32, in device_info
    instruct_on_access_denied(dev)
  File "/home/silverstar/.local/pipx/venvs/dymoprint/lib/python3.10/site-packages/dymoprint/detect.py", line 137, in instruct_on_access_denied
    instruct_on_access_denied_linux(dev)
  File "/home/silverstar/.local/pipx/venvs/dymoprint/lib/python3.10/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}=="0011", MODE="0666"' | sudo tee /etc/udev/rules.d/91-dymo-11.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.

Permissions should be alright since

silverstar@Utopia-Planitia:~$ cat /etc/udev/rules.d/50-dymo-11.rules
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="0922", ATTRS{idProduct}=="0011", MODE="0666", GROUP="users"

and

silverstar@Utopia-Planitia:~$ groups $USER
silverstar : silverstar adm tty lp dialout cdrom sudo dip plugdev users lpadmin sambashare vboxusers libvirt

udevadm commands are done as given, plug out/in, logout/login, reboot, ...

dmesg snippet:

[  402.607304] usb 1-7: unable to read config index 0 descriptor/all
[  402.607307] usb 1-7: can't read configurations, error -61
[  402.731760] usb 1-7: new low-speed USB device number 7 using xhci_hcd
[  402.883642] usb 1-7: unable to read config index 0 descriptor/start: -61
[  402.883659] usb 1-7: can't read configurations, error -61
[  402.883768] usb usb1-port7: attempt power cycle
[  403.299737] usb 1-7: new low-speed USB device number 8 using xhci_hcd
[  403.327442] usb 1-7: config 1 interface 0 altsetting 0 endpoint 0x81 is Bulk; changing to Interrupt
[  403.393393] usb 1-7: string descriptor 0 read error: -71
[  403.393397] usb 1-7: New USB device found, idVendor=0922, idProduct=0011, bcdDevice= 1.00
[  403.393398] usb 1-7: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  403.394705] usb 1-7: can't set config #1, error -71
[  403.394750] usb 1-7: USB disconnect, device number 8
[  403.699741] usb 1-7: new low-speed USB device number 9 using xhci_hcd
[  403.852196] usb 1-7: config 1 interface 0 altsetting 0 endpoint 0x81 is Bulk; changing to Interrupt
[  403.950948] usb 1-7: string descriptor 0 read error: -71
[  403.950962] usb 1-7: New USB device found, idVendor=0922, idProduct=0011, bcdDevice= 1.00
[  403.950970] usb 1-7: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  403.952764] usb 1-7: can't set config #1, error -71
[  403.953059] usb 1-7: USB disconnect, device number 9
[  404.259699] usb 1-7: new low-speed USB device number 10 using xhci_hcd
[  404.415276] usb 1-7: config 1 interface 0 altsetting 0 endpoint 0x81 is Bulk; changing to Interrupt
[  404.429560] usb 1-7: New USB device found, idVendor=0922, idProduct=0011, bcdDevice= 1.00
[  404.429574] usb 1-7: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  404.429580] usb 1-7: Product: DYMO LabelMANAGER PC
[  404.485285] usbcore: registered new interface driver usblp

and lsusb -v:

Bus 001 Device 015: ID 0922:0011 Dymo-CoStar Corp. DYMO LabelMANAG
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0922 Dymo-CoStar Corp.
  idProduct          0x0011 
  bcdDevice            1.00
  iManufacturer           1 DYMO
  iProduct                2 DYMO LabelMANAG
  iSerial                 3 01020412345621
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0021
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xc0
      Self Powered
    MaxPower                2mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         7 Printer
      bInterfaceSubClass      1 Printer
      bInterfaceProtocol      2 Bidirectional
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 8
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               4
Device Status:     0x0001
  Self Powered

Thank you in advance!

tomek-szczesny commented 7 months ago

Looks like this model is already supported and your printer is just borked. If it has a built in battery, I would start by checking its voltage.

You acan also install XP on a virtual machine and see if it's even working with original software.

Silverstar commented 7 months ago

Thanks tomek, I didn't want to jump hoops to get a old xp working on bare metal just to test it, because I can not attach the device to any virtualbox VM/OS on my linux mint host. Maybe it is really broken; due to the error I was rather considering I hit a bug than having a device coming up on the bus but not bringing one specific field all the time. I will test it someday in prehistoric, erm, "natural" conditions. Thank you anyway!

tomek-szczesny commented 7 months ago

I can hardly stretch the fault to dymoprint if this printer can't even maintain a stable USB connection with an OS. After all, dymoprint is not a driver. :)

There are a few simple hardware things worth checking. If it is battery equipped, like I said before, I would measure its voltage. Maybe it should just sit connected via USB long enough to precharge said battery. Maybe USB cable is crap and can't deliver enough current. Battery and bad USB cable are the two sole things I can think of that deteriorate with time. Not that cables age, just we tend to lose them and replace with .. imported goods of inferior quality.

Silverstar commented 7 months ago

Thank you for your tips, as far as I know it is not battery equipped and it has an external psu, so I guess voltage is not an issue. After some more research I just learned, that the error is by pyusb rather than dymoprint, I thought dymoprint requested the langid but it seems pyusb does and there are devices not confirming to usb spec and throwing this error in pyusb.

So it's an pyusb issue if any. Sorry for that, thank you for your time.

maresb commented 7 months ago

~Does this mean that we broke #83 when we switched to PyUSB? :disappointed:~

EDIT: I got confused and thought that #83 was from a year ago rather than a month ago.

maresb commented 7 months ago

Thanks a lot for your investigations @Silverstar!

If the issue is that the LabelManager PC leaves langid undefined, then I wonder if we could get around it with the approach of https://github.com/pyusb/pyusb/issues/139#issuecomment-565114069.

Silverstar commented 7 months ago

Thank you @maresb (and @tomek-szczesny of course) for your work on dymoprint!

I do not know if it's a faulty device or "regular" (non spec) behaviour of the device.

I found pyusb/pyusb#139 as well when I learned about non conforming devices.

I might try to patch pyusb according #139 but I have to dig into it. Can't tell when that will be. I'll report back.

@JBBgameich may I ask you, do you have the Labelmanager PC with or without "II"? My device has no "II" on it so it might be dymo made the II conforming to the specs if JBBgameich has the II or my device is faulty. I will test it (someday) with a realsteel windows xp machine when I happen to get one up in my scarce spare time.

tomek-szczesny commented 7 months ago

Just saying, if something has the USB logo on it or its packaging, it must conform to USB standards. So I wouldn't count on some Dymo product being nonconformant. However the standards might have changed, but as far as I can remember all changes to date were backward compatible. I'd rather blame PyUSB for demanding things not covered by old standards.

maresb commented 7 months ago

if something has the USB logo on it or its packaging, it must conform to USB standards

:raised_eyebrow: I think Benson Leung would disagree

tomek-szczesny commented 7 months ago

Well, we must not kill each other, but some people do it anyway. What I meant is that a big corporation launching products with USB trademark used in their advertising may count on legal action from USB guys if their products don't conform. That's the part of the agreement - the trademark may be used only on conforming products. Those who take the risk of breaking that agreement are mostly unknown and untraceable manufacturers of knock off cables.

jbruechert commented 7 months ago

@Silverstar The device is not my own, but from a hackerspace I'm sometimes at. Iirc it does not have II printed on it, but I can have another look and check USB metadata when I'm there next time. Feel free to ping me in case I forget.

tomek-szczesny commented 7 months ago

Or maybe you guys are right and Dymo did release a nonconformant product. But I see in that PyUSB thread that workarounds are there so if one of them works it may be implemented.

Silverstar commented 7 months ago

Regarding usb standard, I think in 2001 (? year from the manual I could find) due to Windows was the dominant platform and usb just really started going and such errors in implementation of the device were simply fixed in the windows driver.

Hacky drivers been standard these days, remember that there were no general drivers and most stuff needed a reboot.

But still, maybe my unit is faulty, so I'll still test that ancient piece under the classic conditions (and or patched pyusb).

Thank for checking @JBBgameich no hurry, I won't be so fast either ;)

One of the things I want to add: thank you for your participation. I know that thing is old and I could just buy a new model but if it's not broken, it prints the same stuff as a PnP would and also even bigger, 24mm, tapes. That's my motivation to get this thing working.

Silverstar commented 7 months ago

I couldn't go to sleep without at least testing one thing: manually setting a langid in util.py lines 314ff by commenting out the raise ValueError and langid = langids[0] and setting langid = 0x409 sometimes gives me a overflow or typeerror (I'm in no way familiar with python) but on the next try it starts... to rattle. Maybe the motor or drive/gear is stuck or something (yes, its old, I know), but something happens! I might have to disassemble the unit...

jbruechert commented 7 months ago

My printer still works with the current version of dymoprint.

2023-11-15-14-38-37-126

It is reported as:

Bus 001 Device 003: ID 0922:0011 Dymo-CoStar Corp. DYMO LabelMANAGER PC
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x0922 Dymo-CoStar Corp.
  idProduct          0x0011 
  bcdDevice            1.00
  iManufacturer           1 DYMO
  iProduct                2 DYMO LabelMANAGER PC
  iSerial                 3 01020412345621
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0021
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xc0
      Self Powered
    MaxPower                2mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         7 Printer
      bInterfaceSubClass      1 Printer
      bInterfaceProtocol      2 Bidirectional
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 8
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval               4
Device Status:     0x0001
  Self Powered
Silverstar commented 7 months ago

Small update: I just obtained another LabelManager PC for testing. When switching the units, I found that I'm dumb. I powered my one with a wrong power supply - 9V~ ... However, even with the power supply of the "new" unit, it doesn't work. I disassembled it, found that the small cogwheel next to the worm gear of the drive motor is broken, so it gets stuck. I don't know if I'll ever find the right size wheel for that (and time to repair it). The new unit is printing, sometimes. It gives me langid errors, overflows, ... but every now and then, it prints, and I hope that's due to the power supply I got with it, its way underpowered (700mA max). I will look for another supply and come back. Maybe its just working then. Thank you for your help!

jbruechert commented 7 months ago

At some point someone hacked a power delivery trigger into the one at my hackerspace, so its now USB-C powered. Maybe that is an option for you as well.