serial-port thermal printer communication

7,346

I have no idea about thermal printers, but this the way I used to test Arduino or cell phone modem.

As example, with an Android phone as modem:

  1. Reading serial port (need to be root):

    sudo su
    cat /dev/ttyACM0
    

    As you can read just few lines as needed:

    head -n2 /dev/ttyACM0
    
  2. Writing serial, Open other terminal tab or window:

    sudo su
    echo -e "AT" > /dev/ttyACM0
    

    It shows OK on reading port window, Also you can sent hexadecimal data (use -n option to avoid sending new line at the end)

    echo -e -n "\x41\x54\x0a" > /dev/ttyACM0
    

    same as:

    echo -e "\x41\x54" > /dev/ttyACM0
    

    Shell will show undisplayed hex as small square with its value written inside it. Try this.

    echo -e "\x13"
    
Share:
7,346

Related videos on Youtube

BVJ
Author by

BVJ

Updated on September 18, 2022

Comments

  • BVJ
    BVJ almost 2 years

    I am trying to establish low level communication with an Epson tm-t88iv thermal printer via shell but I can't figure it out. I'm working on ubuntu 13.10 64 bit with a Dell vostro 1510.

    I have it connected through a prolific serial-usb pl2303 cable. lsusb shows:

    ben@ben-Vostro1510:~$ lsusb
    Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 006 Device 003: ID 046d:c52b Logitech, Inc. Unifying Receiver
    Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 005 Device 005: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
    Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 001 Device 002: ID 0c45:63e0 Microdia Sonix Integrated Webcam
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    

    dmesg | grep tty shows:

    ben@ben-Vostro1510:~$ dmesg | grep tty
    [    0.000000] console [tty0] enabled
    [    1.488664] tty tty28: hash matches
    [  225.882444] cdc_acm 2-4:1.0: ttyACM0: USB ACM device
    [ 1478.741395] usb 5-1: pl2303 converter now attached to ttyUSB0
    [ 3672.537405] pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0
    [ 3679.219805] usb 5-1: pl2303 converter now attached to ttyUSB0
    [ 4657.704772] pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0
    [ 4699.905633] usb 5-1: pl2303 converter now attached to ttyUSB0
    [ 4798.952739] pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0
    [ 9930.266470] usb 5-1: pl2303 converter now attached to ttyUSB0
    

    I have tried using cutecom to send a specific hexadecimal code to it, but i get no answer. I also tried echoing to /dev/ttyUSB0 but i don't know where to read the response from. i also tried "sudo cat /dev/ttyUSB0" but get nothing.

    please help me solve this! thanks!

    Solution:

    I had to run

    sudo chmod 777 /dev/ttyUSB0
    

    and then run jpnevulator as root

    sudo jpnevulator --tty /dev/ttyUSB0 --read
    

    and then using another in write mode I wrote the status check sequence 02 AC 00 01 1C 00 00 03 30 30 43 45

    and got the printer's response on screen. I now have a different problem with the checksum, but that's for the next episode of my odyssey into low-level programming.

  • BVJ
    BVJ over 10 years
    thanks! I used your answer as guide. I finally had to chmod it to 777 for some reason (I am registered in dialup but it still didn't work) and i used jpnevulator but took the same approach you suggested.