ogelpre / labelprinterkit

Apache License 2.0
16 stars 6 forks source link

Error with P750W connected over USB #4

Open RokyB3 opened 5 months ago

RokyB3 commented 5 months ago

Hello, I am able to print labels on my P750W using labelprinterkit over wifi, but when I try to print over USB I get this weird error:

Traceback (most recent call last):
  File "C:\Users\rokob\anaconda3\envs\sdb\lib\site-packages\usb\core.py", line 236, in get_interface_and_endpoint
    return self._ep_info[endpoint_address]
KeyError: 2

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\rokob\Desktop\SterilizationDB\Code\app.py", line 627, in submit
    printCassetteLabel(self.txtScan.text(), cassetteID, colors)
  File "c:\Users\rokob\Desktop\SterilizationDB\Code\functions\printFunctions.py", line 107, in printCassetteLabel
    printer.print(job)
  File "C:\Users\rokob\anaconda3\envs\sdb\lib\site-packages\labelprinterkit\printers.py", line 168, in print
    self.reset()
  File "C:\Users\rokob\anaconda3\envs\sdb\lib\site-packages\labelprinterkit\printers.py", line 145, in reset
    self._backend.write(b'\x00' * 100)  # Invalidate command
  File "C:\Users\rokob\anaconda3\envs\sdb\lib\site-packages\labelprinterkit\backends\usb.py", line 27, in write
    self._dev.write(0x2, data)
  File "C:\Users\rokob\anaconda3\envs\sdb\lib\site-packages\usb\core.py", line 986, in write
    intf, ep = self._ctx.setup_request(self, endpoint)
  File "C:\Users\rokob\anaconda3\envs\sdb\lib\site-packages\usb\core.py", line 113, in wrapper
    return f(self, *args, **kwargs)
  File "C:\Users\rokob\anaconda3\envs\sdb\lib\site-packages\usb\core.py", line 228, in setup_request
    intf, ep = self.get_interface_and_endpoint(device, endpoint_address)
  File "C:\Users\rokob\anaconda3\envs\sdb\lib\site-packages\usb\core.py", line 113, in wrapper
    return f(self, *args, **kwargs)
  File "C:\Users\rokob\anaconda3\envs\sdb\lib\site-packages\usb\core.py", line 238, in get_interface_and_endpoint
    for intf in self.get_active_configuration(device):
  File "C:\Users\rokob\anaconda3\envs\sdb\lib\site-packages\usb\core.py", line 113, in wrapper
    return f(self, *args, **kwargs)
  File "C:\Users\rokob\anaconda3\envs\sdb\lib\site-packages\usb\core.py", line 249, in get_active_configuration
    self.managed_open()
  File "C:\Users\rokob\anaconda3\envs\sdb\lib\site-packages\usb\core.py", line 113, in wrapper
    return f(self, *args, **kwargs)
  File "C:\Users\rokob\anaconda3\envs\sdb\lib\site-packages\usb\core.py", line 131, in managed_open
    self.handle = self.backend.open_device(self.dev)
  File "C:\Users\rokob\anaconda3\envs\sdb\lib\site-packages\usb\backend\libusb1.py", line 804, in open_device
    return _DeviceHandle(dev)
  File "C:\Users\rokob\anaconda3\envs\sdb\lib\site-packages\usb\backend\libusb1.py", line 652, in __init__
    _check(_lib.libusb_open(self.devid, byref(self.handle)))
  File "C:\Users\rokob\anaconda3\envs\sdb\lib\site-packages\usb\backend\libusb1.py", line 600, in _check
    raise NotImplementedError(_strerror(ret))
NotImplementedError: Operation not supported or unimplemented on this platform

The code that causes the error is the following:

# Use TCP backend to connect to printer
# backend = TCPBackend(printerIP)
# Use USB backend to connect to printer
backend = USBBackend()
printer = P750W(backend)

# Print job
printer.print(job)

I've installed the libusb-1.0.dll into System32 to recognize the printer but it still doesn't work.

Any help is appreciated!

Thanks, Roko