computerlyrik / dymoprint

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

Magic spell crashes printer :O #87

Closed tomek-szczesny closed 11 months ago

tomek-szczesny commented 11 months ago

I cannot explain how this happens, but I found a set of magic words that crash the printer. For any reason, the crash happens only with them and I didn't find any other working combination!

This combination works: dymoprint dddd ccccc cccc And this one doesn't: dymoprint dupa cycki chuj (all those are profanities, please don't translate. That happens to be my usual test pattern)

The printer prints the first batch of data (what looks like three small c's in one row, and then times out. The printer must be turned off and on again to send a new task to it.

obraz

I also determined that "dup cyc chu" still works, but crashes after fourth letters are added to each word. I suspected the matrix optimization issues but nope, if "dd cc cc" works I'd rule that out.

Maybe the new image parsing code will solve it.

Found one Dymo device: <DEVICE ID 0922:1001 on Bus 001 Address 014>
  manufacturer: Dymo
  product: DYMO LabelManager PnP
  serial: 15431630032012
  configurations:
  - <CONFIGURATION 1: 500 mA>
    interfaces:
    - <INTERFACE 0: Human Interface Device>
    - <INTERFACE 1: Mass Storage>

Recognized device as LabelManager PnP (no mode switch)
Active device configuration already found.
Opened HID interface: <INTERFACE 0: Human Interface Device>
Printing label..
Sending chunk of 345 bytes
Traceback (most recent call last):
  File "/home/mctom/.local/bin/dymoprint", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/mctom/.local/pipx/venvs/dymoprint/lib/python3.11/site-packages/dymoprint/command_line.py", line 252, in main
    print_label(label_bitmap, margin_px=args.m, tape_size_mm=args.t)
  File "/home/mctom/.local/pipx/venvs/dymoprint/lib/python3.11/site-packages/dymoprint/dymo_print_engines.py", line 271, in print_label
    lm.printLabel(label_matrix, margin_px=margin_px)
  File "/home/mctom/.local/pipx/venvs/dymoprint/lib/python3.11/site-packages/dymoprint/labeler.py", line 213, in printLabel
    self.rawPrintLabel(lines, margin_px=margin_px)
  File "/home/mctom/.local/pipx/venvs/dymoprint/lib/python3.11/site-packages/dymoprint/labeler.py", line 234, in rawPrintLabel
    response = self.sendCommand()
               ^^^^^^^^^^^^^^^^^^
  File "/home/mctom/.local/pipx/venvs/dymoprint/lib/python3.11/site-packages/dymoprint/labeler.py", line 74, in sendCommand
    rspBin = self.devin.read(8)
             ^^^^^^^^^^^^^^^^^^
  File "/home/mctom/.local/pipx/venvs/dymoprint/lib/python3.11/site-packages/usb/core.py", line 423, in read
    return self.device.read(self, size_or_buffer, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mctom/.local/pipx/venvs/dymoprint/lib/python3.11/site-packages/usb/core.py", line 1029, in read
    ret = fn(
          ^^^
  File "/home/mctom/.local/pipx/venvs/dymoprint/lib/python3.11/site-packages/usb/backend/libusb1.py", line 864, in intr_read
    return self.__read(self.lib.libusb_interrupt_transfer,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mctom/.local/pipx/venvs/dymoprint/lib/python3.11/site-packages/usb/backend/libusb1.py", line 954, in __read
    _check(retval)
  File "/home/mctom/.local/pipx/venvs/dymoprint/lib/python3.11/site-packages/usb/backend/libusb1.py", line 602, in _check
    raise USBTimeoutError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBTimeoutError: [Errno 110] Operation timed out
tomek-szczesny commented 11 months ago

Okay my test pattern generating code does the same with parameter "32", worth noting.

maresb commented 11 months ago

please don't translate :joy:

Nice find, I can reproduce it. It seems the PnP is rather prudish.

Maybe the new image parsing code will solve it.

What new image parsing code?

with parameter "32"

Which parameter?

tomek-szczesny commented 11 months ago

The new image parsing code I've declared to work on in 420p support. I think something's wrong with data sent to the printer, it must be getting more bytes than it anticipated or something.

My test pattern procedure, when run with parameter "32" reproduces similar behavior.

tomek-szczesny commented 11 months ago

I removed matrix optimization code and this issue appears to be resolved. The printer prints profanities just great, and --test-pattern 32 works as well. I pushed it into my test pattern pull request.