-
Notifications
You must be signed in to change notification settings - Fork 304
Description
During my test using a USB to serial adapter PL2303, i have a issue with the library in this scenario.
1 : the python process is running and the printer is on and connecté et visibilité using lsusb. i create a new printer.Usb that it's working fine and i can print using the printer api.
2 : i turn off the printer. in that case i got an exception in the python process as the device doesn't respond anymore and i call the method close of the printer object before clearing it in my class to don't use this instance of printer anymore.
In lsusb i can still see the PL2303 usb adaptater even if the device is no longer here.
3 : i turn on the printer and i try in the same python process to create a new printer.Usb instance to be able to use it again and in that case the escpos api raise an exception
Traceback (most recent call last): File "/opt/node/repo/cohorteiot/iotill/printer/printer_comm.py", line 173, in _init_connection self._printer = printer.Usb(w_usb_info[PRINT].get_vendor_id(),w_usb_info[PRINT].get_device_id(),None,0,w_usb_info[PRINT].get_endpoint_in_address(),w_usb_info[PRINT].get_endpoint_out_address()) File "/usr/local/lib/python3.6/dist-packages/python_escpos-3.0a9.dev26+g84a97e5-py3.6.egg/escpos/printer.py", line 53, in __init__ self.open(usb_args) File "/usr/local/lib/python3.6/dist-packages/python_escpos-3.0a9.dev26+g84a97e5-py3.6.egg/escpos/printer.py", line 62, in open raise USBNotFoundError("Device not found or cable not plugged in.") escpos.exceptions.USBNotFoundError: USB device not found (Device not found or cable not plugged in.)
4 : Finally, if i stop the python process, create a new one and create a new printer.Usb to use it. it works. So it seems when we close the printer, there is still something that is not properly clear that is a side effect of the fact that the lsusb of the PL2303 is still here even if the printer is down.
So my question is do you have a solution to ensure that every is cleared when we close the printer.Usb instance to ensure when we create a new one we don't have this behavior ?
Thanks in advance for your answser