🇺🇸Adafruit will not be shipping orders on Independence Day Monday 7/4/2022. Please allow extra time for your order to ship and plan accordingly.🇺🇸
0

Connecting Tiny Thermal Receipt Printer - TTL Serial / USB
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Connecting Tiny Thermal Receipt Printer - TTL Serial / USB

by fabianhijlkema on Tue May 17, 2022 12:52 pm

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 | TOGGLE FULL SIZE
ls /dev/*
command doesn't list anything that resembles 'serial0' or usb for that matter.

The command
Code: Select all | TOGGLE FULL SIZE
sudo lpoptions -d ZJ_58
results in the following:
Code: Select all | TOGGLE FULL SIZE
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.

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

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

by mikeysklar on Tue May 17, 2022 1:48 pm

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 | TOGGLE FULL SIZE
ls /dev > /tmp/unplugged/code]

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

compare:
[code]diff /tmp/unplugged /tmp/pluggedin[/code]

The printer and device name are also likely to show up in the output of:

[code]sudo dmesg

mikeysklar
 
Posts: 7805
Joined: Mon Aug 01, 2016 8:10 pm

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

by fabianhijlkema on Tue May 17, 2022 4:19 pm

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

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

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

by mikeysklar on Wed May 18, 2022 7:57 pm

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.

mikeysklar
 
Posts: 7805
Joined: Mon Aug 01, 2016 8:10 pm

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

by fabianhijlkema on Thu May 19, 2022 1:11 am

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.

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

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

by fabianhijlkema on Fri May 20, 2022 3:11 am

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 | TOGGLE FULL SIZE
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 | TOGGLE FULL SIZE
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')

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

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

by mikeysklar on Fri May 20, 2022 4:20 pm

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

mikeysklar
 
Posts: 7805
Joined: Mon Aug 01, 2016 8:10 pm

Please be positive and constructive with your questions and comments.