AndBondStyle / niimprint

Python library for Niimbot label printers. Supports D11/B21/B1 via bluetooth or USB.
MIT License
215 stars 31 forks source link

OSError: [Errno 93] Protocol not supported when trying Bluetooth connection #2

Closed orissus closed 11 months ago

orissus commented 11 months ago

Hi was wondering if someone could help with following problem. I cannot connect to my B1 neither via USB nor Bluetooth.

When using BT: I see two MACs related

[printer]# devices
Device 16:F9:13:17:15:B7 printer
Device 13:16:F9:17:15:B7 B1-F916130567

I am paired and connected to printer. When I bluetoothcl conneect, the device beeps (same as it when connecting via phone). However when I try to run eg. using either of the MACs eg. python ./__main__.py -m b1 -c bluetooth -a 16:F9:13:17:15:B7 -i ../examples/B21_30x15mm_240x120px.png

I get

$ sudo python ./__main__.py -m b1 -c bluetooth -a 13:16:F9:17:15:B7  -i ../examples/B21_30x15mm_240x120px.png
Traceback (most recent call last):
  File "/home/user/workspace/niimprint/niimprint/./__main__.py", line 80, in <module>
    print_cmd()
  File "/home/user/.cache/pypoetry/virtualenvs/niimprint-PR6jxpar-py3.11/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.cache/pypoetry/virtualenvs/niimprint-PR6jxpar-py3.11/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/user/.cache/pypoetry/virtualenvs/niimprint-PR6jxpar-py3.11/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.cache/pypoetry/virtualenvs/niimprint-PR6jxpar-py3.11/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/workspace/niimprint/niimprint/./__main__.py", line 59, in print_cmd
    transport = BluetoothTransport(addr)
                ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/workspace/niimprint/niimprint/printer.py", line 61, in __init__
    self._sock = socket.socket(
                 ^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/socket.py", line 232, in __init__
    _socket.socket.__init__(self, family, type, proto, fileno)
OSError: [Errno 93] Protocol not supported

USB is not detecting serial port although the printer is listed

lsusb
Bus 002 Device 009: ID 3513:0002 NIIMBOT B1 LABEL PRINTER

and dmesg

[8520142.593368] usb 2-1: new full-speed USB device number 9 using xhci_hcd
[8520142.734201] usb 2-1: New USB device found, idVendor=3513, idProduct=0002, bcdDevice= 1.00
[8520142.734211] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[8520142.734214] usb 2-1: Product: B1 LABEL PRINTER
[8520142.734217] usb 2-1: Manufacturer: NIIMBOT

and udevadm info -a /dev/bus/usb/002/009

  looking at device '/devices/pci0000:00/0000:00:14.0/usb2/2-1':
    KERNEL=="2-1"
    SUBSYSTEM=="usb"
    DRIVER=="usb"
    ATTR{authorized}=="1"
    ATTR{avoid_reset_quirk}=="0"
    ATTR{bConfigurationValue}=="1"
    ATTR{bDeviceClass}=="ef"
    ATTR{bDeviceProtocol}=="01"
    ATTR{bDeviceSubClass}=="02"
    ATTR{bMaxPacketSize0}=="64"
    ATTR{bMaxPower}=="100mA"
    ATTR{bNumConfigurations}=="1"
    ATTR{bNumInterfaces}==" 3"
    ATTR{bcdDevice}=="0100"
    ATTR{bmAttributes}=="c0"
    ATTR{busnum}=="2"
    ATTR{configuration}==""
    ATTR{devnum}=="9"
    ATTR{devpath}=="1"
    ATTR{idProduct}=="0002"
    ATTR{idVendor}=="3513"
    ATTR{ltm_capable}=="no"
    ATTR{manufacturer}=="NIIMBOT"
    ATTR{maxchild}=="0"
    ATTR{physical_location/dock}=="no"
    ATTR{physical_location/horizontal_position}=="left"
    ATTR{physical_location/lid}=="no"
    ATTR{physical_location/panel}=="back"
    ATTR{physical_location/vertical_position}=="center"
    ATTR{power/active_duration}=="1111704"
    ATTR{power/autosuspend}=="2"
    ATTR{power/autosuspend_delay_ms}=="2000"
    ATTR{power/connected_duration}=="1111704"
    ATTR{power/control}=="on"
    ATTR{power/level}=="on"
    ATTR{power/persist}=="1"
    ATTR{power/runtime_active_time}=="1111440"
    ATTR{power/runtime_status}=="active"
    ATTR{power/runtime_suspended_time}=="0"
    ATTR{product}=="B1 LABEL PRINTER"
    ATTR{quirks}=="0x0"
    ATTR{removable}=="removable"
    ATTR{remove}=="(not readable)"
    ATTR{rx_lanes}=="1"
    ATTR{serial}=="B1-F91613056"
    ATTR{speed}=="12"
    ATTR{tx_lanes}=="1"
    ATTR{urbnum}=="12"
    ATTR{version}==" 1.10"

Any pointers greatly welcomed :)

orissus commented 11 months ago

I solved it by modprobe usbserial for some reason it wasn't loaded.