Firstly, I would like to know how to tell on which port my serial POS printer is connected? When I do dmesg | grep tty
I get:
[ 0.000000] console [tty0] enabled
[ 1.255791] 00:04: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
I guess, it is connected to /dev/ttyS0? After that I did chmod 777 /dev/ttyS0
crwxrwxrwx 1 root dialout 4, 64 May 25 09:49 /dev/ttyS0
Then I tried to write like this echo -ne '\033[2J' > /dev/ttyS0
from here
I know the hardware is fine because it works when connected to parallel port. What did I missed?
/dev/ttyS0
is the correct device, you probably forgot to set the baud rate, start and stop bits, and parity settings. You can do that withstty
...but first you need to know what the printer expects those settings to be (i.e. consult its manual). – cas May 25 '16 at 08:36statserial /dev/ttyS0
to see the hw line signals on that serial port. you can use that to find out which is the correct port. it's been a long time since i did much with serial ports, but IIRC you probably should have CTS=0 and DSR=1 if there's an active device on the port. – cas May 25 '16 at 08:39stty -F /dev/ttyS0 9600 cs8 -cstopb -parenb
) – cas May 25 '16 at 08:47/serial-port
tag in your question to see other questions with the same tag. – cas May 25 '16 at 08:53stty -F /dev/ttyS0 -a
saysspeed 9600 baud; rows 0; columns 0; line = 0;
I think this is it. How to send data now? Is it withecho -ne 'some_text' > /dev/ttyS0
. Still not working. I will try different speeds – Hrvoje T May 25 '16 at 08:58DTE
,Data Terminal Equipment
(your printer) must have femaleD-SUB
, whileDCE
,Data Control Equipment
(your PC) must have maleD-SUB
. Anyway, check with specs on PC and printer that they have correct pin-outs, check that the cable is wired correctly as well, and check that you have synchronized flow-control settings betweenDTE
andDCE
– Serge May 25 '16 at 11:31cat test.txt > /dev/ttyS0
. Can I read in other terminal what is sent to ttyS0? – Hrvoje T Oct 04 '16 at 08:40