Connecting Tiny Thermal Receipt Printer - TTL Serial / USB

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
fabianhijlkema
 
Posts: 7
Joined: Wed Feb 10, 2016 11:03 am

Connecting Tiny Thermal Receipt Printer - TTL Serial / USB

Post by fabianhijlkema »

Hi all,

I've ordered a Tiny Thermal Receipt Printer with USB connection in order to use it with the Python library. The printer can be installed on MacOS (12.2.1) and can be selected from the system, but does not seem to show up as a serial connection (/dev/serial0). So I can't connect the Python library to it.

Any suggestions? I've installed the drive from Prolific, no change. Using the

Code: Select all

ls /dev/*
command doesn't list anything that resembles 'serial0' or usb for that matter.

The command

Code: Select all

sudo lpoptions -d ZJ_58
results in the following:

Code: Select all

copies=1 device-uri=usb://Caysn/Thermal%20Printer?serial=4B39413148FFFF0C0002706E finishings=3 job-cancel-after=10800 job-hold-until=no-hold job-priority=50 job-sheets=none,none marker-change-time=0 number-up=1 printer-commands=AutoConfigure,Clean,PrintSelfTestPage printer-info=ZJ-58 printer-is-accepting-jobs=true printer-is-shared=false printer-is-temporary=false printer-location='Fabian’s MacBook Pro' printer-make-and-model='Generic PostScript Printer' printer-state=3 printer-state-change-time=1652805618 printer-state-reasons=none printer-type=10489924 printer-uri-supported=ipp://localhost/printers/ZJ_58
All help is appreciated. Thank you.

User avatar
mikeysklar
 
Posts: 14194
Joined: Mon Aug 01, 2016 8:10 pm

Re: Connecting Tiny Thermal Receipt Printer - TTL Serial / U

Post by mikeysklar »

Modern versions of Raspberry Pi use the /dev/serial0 or /dev/ttyUSB0 depending on how you are connecting.

On MacOS (even an older 12.x release) will use different device names.

While the printer is unlugged you can take a snaphsot of the /dev devices and then plug it in and take another to compare the two.

printer unplugged:

Code: Select all

ls /dev > /tmp/unplugged/code]

printer plugged in:
[code]ls /dev > /tmp/pluggedin
compare:

Code: Select all

diff /tmp/unplugged /tmp/pluggedin
The printer and device name are also likely to show up in the output of:

Code: Select all

sudo dmesg

User avatar
fabianhijlkema
 
Posts: 7
Joined: Wed Feb 10, 2016 11:03 am

Re: Connecting Tiny Thermal Receipt Printer - TTL Serial / U

Post by fabianhijlkema »

Hi @mikeysklar,

Thanks for your answer. Tried your first approach, resulting in exactly the same list, so no difference at all.

Also no mention of the printer with the latter command you provided.

Could this be related to the fact I'm using a USB-c hub to attach the USB-a cable of the printer? Maybe a stupid thought, but it crossed my mind.

Fabian

User avatar
mikeysklar
 
Posts: 14194
Joined: Mon Aug 01, 2016 8:10 pm

Re: Connecting Tiny Thermal Receipt Printer - TTL Serial / U

Post by mikeysklar »

I think you have the right idea that it could be a USB cable issue that is preventing you from seeing the device.

Do you know that the USB-C adapter you are using is data capable? If you plugin other devices through it do they mount or become visible?

Do you have a Raspberry Pi you can do the initial hookup with? While this printer can be made to work with MacOS it might reduce complexity to start with a Pi as the guides are all geared towards them in terms of device names and connectors.

User avatar
fabianhijlkema
 
Posts: 7
Joined: Wed Feb 10, 2016 11:03 am

Re: Connecting Tiny Thermal Receipt Printer - TTL Serial / U

Post by fabianhijlkema »

I’ve ruled out the USB-c hub as the culprit for now. Other devices do show up, and I’ve had similar results using a Mac with USB-a slots.

I had indeed already dug up a Rasberry Pi that I still had. I will try to make it work with that.

I’ll post the results in the coming days.

User avatar
fabianhijlkema
 
Posts: 7
Joined: Wed Feb 10, 2016 11:03 am

Re: Connecting Tiny Thermal Receipt Printer - TTL Serial / U

Post by fabianhijlkema »

Hi @mikeysklar,

Ok, some good news to share. I've managed to get things working on the Raspberry Pi instead, which in my case is a good solution.

It is however only working using the TTL connection (Serial0), and not with the USB connection I was trying earlier. To precise, the USB connection is working with a command like:

Code: Select all

sudo chmod 777 /dev/usb/lp0
echo -e "This is a test.\\n\\n\\n" > /dev/usb/lp0
But with the Python library (https://github.com/adafruit/Python-Thermal-Printer) I was intending to use, the usb connection (/dev/usb/lp0) results in an error. This question probably needs to be asked in another topic, but maybe who is reading this already know the answer to this. Connecting with usb would be great, because it would allow me to connect two printers (which was my plan).

Error running Python script:

Code: Select all

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 380, 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/Documents/Python-Thermal-Printer/test.py", line 2, in <module>
    printer = Adafruit_Thermal("/dev/usb/lp0", 9600, timeout=5)
  File "/home/pi/Documents/Python-Thermal-Printer/Adafruit_Thermal.py", line 84, in __init__
    Serial.__init__(self, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/serial/serialutil.py", line 244, in __init__
    self.open()
  File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 329, in open
    self._reconfigure_port(force_update=True)
  File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 383, in _reconfigure_port
    raise SerialException("Could not configure port: {}".format(msg))
serial.serialutil.SerialException: Could not configure port: (25, 'Inappropriate ioctl for device')

User avatar
mikeysklar
 
Posts: 14194
Joined: Mon Aug 01, 2016 8:10 pm

Re: Connecting Tiny Thermal Receipt Printer - TTL Serial / U

Post by mikeysklar »

Congrats on getting the Pi working with serial and some USB.

This open issue might provide some guidance for you since you have the Tiny thermal printer.

https://github.com/adafruit/Python-Ther ... /issues/57

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”