Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

When trying to run python3 printertest.py I get a termios.error: (25, 'Inappropriate ioctl for device') error #57

Open
threalboss opened this issue Jan 22, 2022 · 1 comment

Comments

@threalboss
Copy link

threalboss commented Jan 22, 2022

When trying to run python3 printertest.py (on my pi zero w) I get the error:

File "/home/pi/.local/lib/python3.9/site-packages/serial/serialposix.py", line 398, in _reconfigure_port
    orig_attr = termios.tcgetattr(self.fd)
termios.error: (25, 'Inappropriate ioctl for device')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/Python-Thermal-Printer/printertest.py", line 5, in <module>
    printer = Adafruit_Thermal("/dev/usb/lp0", 9600, timeout=5)
  File "/home/pi/Python-Thermal-Printer/Adafruit_Thermal.py", line 84, in __init__
    Serial.__init__(self, *args, **kwargs)
  File "/home/pi/.local/lib/python3.9/site-packages/serial/serialutil.py", line 244, in __init__
    self.open()
  File "/home/pi/.local/lib/python3.9/site-packages/serial/serialposix.py", line 332, in open
    self._reconfigure_port(force_update=True)
  File "/home/pi/.local/lib/python3.9/site-packages/serial/serialposix.py", line 401, in _reconfigure_port
    raise SerialException("Could not configure port: {}".format(msg))
serial.serialutil.SerialException: Could not configure port: (25, 'Inappropriate ioctl for device')

In printertest.py I change the printer setup line to:
printer = Adafruit_Thermal("/dev/usb/lp0", 9600, timeout=5)

This is because I could only get the first test to work with /dev/usb/lp0 and my print test page said it is 9600.

@aidyk
Copy link

aidyk commented Apr 14, 2022

It seems that the library doesn't support a tiny thermal printer connected via USB.
I instead found a solution using python-escpos (https://github.com/python-escpos/python-escpos).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants