I have:
Bug description
I've got a sample python-escpos code that worked fine on my OrangePi microcomputer running Ubuntu. I didn't touch it for couple of months, and now it throws an error Invalid endpoint address 0x1 - which is weird since I have different endpoint addresses explicitly set in my code.
Steps to reproduce
My OS version:
# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.4 LTS"
Python3:
# python3 --version
Python 3.6.9
python-escpos:
# pip3 install python-escpos
Requirement already satisfied: python-escpos in /usr/local/lib/python3.6/dist-packages
Requirement already satisfied: future in /usr/local/lib/python3.6/dist-packages (from python-escpos)
Requirement already satisfied: qrcode>=4.0 in /usr/local/lib/python3.6/dist-packages (from python-escpos)
Requirement already satisfied: PyYAML in /usr/local/lib/python3.6/dist-packages (from python-escpos)
Requirement already satisfied: argcomplete in /usr/local/lib/python3.6/dist-packages (from python-escpos)
Requirement already satisfied: argparse in /usr/local/lib/python3.6/dist-packages (from python-escpos)
Requirement already satisfied: pyserial in /usr/local/lib/python3.6/dist-packages (from python-escpos)
Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from python-escpos)
Requirement already satisfied: pyusb>=1.0.0 in /usr/local/lib/python3.6/dist-packages (from python-escpos)
Requirement already satisfied: viivakoodi>=0.8 in /usr/local/lib/python3.6/dist-packages (from python-escpos)
Requirement already satisfied: Pillow>=2.0 in /usr/lib/python3/dist-packages (from python-escpos)
Requirement already satisfied: appdirs in /usr/local/lib/python3.6/dist-packages (from python-escpos)
Requirement already satisfied: importlib-metadata<2,>=0.23; python_version == "3.6" in /usr/local/lib/python3.6/dist-packages (from argcomplete->python-escpos)
Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.6/dist-packages (from importlib-metadata<2,>=0.23; python_version == "3.6"->argcomplete->python-escpos)
Requirement already satisfied: more-itertools in /usr/local/lib/python3.6/dist-packages (from zipp>=0.5->importlib-metadata<2,>=0.23; python_version == "3.6"->argcomplete->python-escpos)
# python-escpos version
3.0a6
My Citizen CT-S2000 printer is plugged in:
# lsusb
Bus 006 Device 002: ID 2730:0fff Citizen
I've determined the endpoints:
# lsusb -v -d 2730:0fff
Bus 006 Device 002: ID 2730:0fff Citizen
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 1.10
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x2730 Citizen
idProduct 0x0fff
bcdDevice 0.02
iManufacturer 1 CITIZEN
iProduct 2 Thermal Printer
iSerial 3 00000000
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xc0
Self Powered
MaxPower 0mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
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 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Device Status: 0x0000
(Bus Powered)
(as you can see, "in" endpoint is 0x81 and "out" is 0x02).
I've se up dialout group:
# cat /etc/udev/rules.d/99-escpos.rules
SUBSYSTEM=="usb", ATTRS{idVendor}=="2730", ATTRS{idProduct}=="0fff", MODE="0664", GROUP="dialout"
And added current user, root, to it:
# groups
root dialout i2c
My test code is:
import datetime
x = datetime.datetime.today()
from escpos.printer import Usb
p = Usb(0x2730, 0x0fff, 0, 0x81, 0x02) ' Note that endpoints are set correctly
p.text('\nDate: ' + x.strftime("%b %d %Y %H:%M:%S") + '\n')
Yet I receive an error:
# python3 test.py
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/usb/core.py", line 223, in get_interface_and_endpoint
return self._ep_info[endpoint_address]
KeyError: 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 8, in <module>
p.text('\nDate: ' + x.strftime("%b %d %Y %H:%M:%S") + '\n')
File "/usr/local/lib/python3.6/dist-packages/escpos/escpos.py", line 514, in text
self.magic.write(txt)
File "/usr/local/lib/python3.6/dist-packages/escpos/magicencode.py", line 272, in write
self.write_with_encoding(encoding, to_write)
File "/usr/local/lib/python3.6/dist-packages/escpos/magicencode.py", line 293, in write_with_encoding
six.int2byte(self.encoder.get_sequence(encoding)))
File "/usr/local/lib/python3.6/dist-packages/escpos/printer.py", line 102, in _raw
self.device.write(self.out_ep, msg, self.timeout)
File "/usr/local/lib/python3.6/dist-packages/usb/core.py", line 940, in write
intf, ep = self._ctx.setup_request(self, endpoint)
File "/usr/local/lib/python3.6/dist-packages/usb/core.py", line 102, in wrapper
return f(self, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/usb/core.py", line 215, in setup_request
intf, ep = self.get_interface_and_endpoint(device, endpoint_address)
File "/usr/local/lib/python3.6/dist-packages/usb/core.py", line 102, in wrapper
return f(self, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/usb/core.py", line 231, in get_interface_and_endpoint
raise ValueError('Invalid endpoint address ' + hex(endpoint_address))
ValueError: Invalid endpoint address 0x1
Device info
Printer: Citizen ST-2000
python-escpos version: 3.0a6
python version: 3.6.9
operating system: Ubuntu 18.04.4 LTS
I have:
Bug description
I've got a sample python-escpos code that worked fine on my OrangePi microcomputer running Ubuntu. I didn't touch it for couple of months, and now it throws an error
Invalid endpoint address 0x1- which is weird since I have different endpoint addresses explicitly set in my code.Steps to reproduce
My OS version:
Python3:
# python3 --version Python 3.6.9python-escpos:
# python-escpos version 3.0a6My Citizen CT-S2000 printer is plugged in:
# lsusb Bus 006 Device 002: ID 2730:0fff CitizenI've determined the endpoints:
# lsusb -v -d 2730:0fff Bus 006 Device 002: ID 2730:0fff Citizen Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x2730 Citizen idProduct 0x0fff bcdDevice 0.02 iManufacturer 1 CITIZEN iProduct 2 Thermal Printer iSerial 3 00000000 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 32 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xc0 Self Powered MaxPower 0mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 255 Vendor Specific Class bInterfaceSubClass 255 Vendor Specific Subclass bInterfaceProtocol 255 Vendor Specific Protocol 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 0x0040 1x 64 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 0 Device Status: 0x0000 (Bus Powered)(as you can see, "in" endpoint is
0x81and "out" is0x02).I've se up
dialoutgroup:And added current user,
root, to it:# groups root dialout i2cMy test code is:
Yet I receive an error:
Device info
Printer: Citizen ST-2000
python-escpos version: 3.0a6
python version: 3.6.9
operating system: Ubuntu 18.04.4 LTS