3

I'm having trouble hooking up my Raspberry Pi 3 Model B to my Adafruit Tiny Thermal Printer (nb: not the mini thermal printer - this is the one with a mini-USB port built in).

I've got it connected via mini-USB to USB in my rPi, it's connected to power using the supplied AC adapter. I can print a test page by holding the feed button while connected to power.

I noticed that it's currently on /dev/usb/lp0 and after chmod'ing this to 666 I was able to use the following command to get a test print:

echo -e "This is a test.\\n\\n\\n" > /dev/usb/lp0

However, I'm trying to use the following library:

https://github.com/adafruit/Python-Thermal-Printer/

But it's not playing ball...

By default it's set to look at /dev/serial0 - which if I run python printertest.py

I get the following error:

Traceback (most recent call last):
File "printertest.py", line 5, in <module>
printer = Adafruit_Thermal("/dev/serial0", 19200, timeout=5)
File "/home/pi/printer/Adafruit_Thermal.py", line 85, in __init__
Serial.__init__(self, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/serial/serialutil.py", line 261,     
in __init__
self.open()
File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 278, in open
raise SerialException("could not open port %s: %s" % (self._port, msg))
serial.serialutil.SerialException: could not open port /dev/serial0: [Errno 2] No such file or directory: '/dev/serial0'

Changing it to /dev/usb/lp0 gives me this error:

Traceback (most recent call last):
File "printertest.py", line 5, in <module>
printer = Adafruit_Thermal("/dev/usb/lp0", 19200, timeout=5)
File "/home/pi/printer/Adafruit_Thermal.py", line 85, in __init__
Serial.__init__(self, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/serial/serialutil.py", line 261, 
in __init__
self.open()
File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 282, in open
self._reconfigurePort()
File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 311, in _reconfigurePort
raise SerialException("Could not configure port: %s" % msg)
serial.serialutil.SerialException: Could not configure port: (25, 'Inappropriate ioctl for device')

Which I assume the problem to be with Could not configure port: (25, 'Inappropriate ioctl for device')

I've tried looking around for this but I can't see a relevant explanation to my situation. Am I missing something big here?

  • Is it possible that library doesn't support RP1 yet? github.com/adafruit/Python-Thermal-Printer/issues/23 – MartinMarty May 2 '17 at 1:19
  • The library you've linked to expects a serial device. By passing /dev/usb/lpX you're giving it something it can't work with. Try this: disconnect the printer, then do ls -l /dev then reconnect the printer and run the same command, then compare the results. You might (hopefully) find that you have a new /dev/ttyUSBX device (or /dev/serialX device which is linked to a /dev/ttyX device), if you do then this is the device you want to pass to the Adafruit_Thermal constructor. – Aaron F Aug 6 '18 at 11:04
  • scruss.com/blog/2015/07/12/… might help you get started. – Dougie Dec 9 '18 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.