0

I've a cash drawer attached to my system via RJ11 cable in /dev/ttyS4. I'm trying to send an echo command to trigger the cash drawer using:

echo -e "\x07" > /dev/ttyS4

I observed that the terminal hangs for around ~ 10-15 seconds and eventually the echo command comes out.
I remember seeing this command worked earlier on the same system.

The following is the serial port settings from dmesg:

[    1.424083] 00:03: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
[    1.445149] 00:04: ttyS1 at I/O 0x2f8 (irq = 3, base_baud = 115200) is a 16550A
[    1.466208] 00:05: ttyS2 at I/O 0x3e8 (irq = 5, base_baud = 115200) is a 16550A
[    1.487268] 00:06: ttyS3 at I/O 0x2e8 (irq = 10, base_baud = 115200) is a 16550A
[    1.508361] 00:07: ttyS4 at I/O 0x2f0 (irq = 5, base_baud = 115200) is a 16550A
[    1.529427] 00:08: ttyS5 at I/O 0x2e0 (irq = 10, base_baud = 115200) is a 16550A

$ sudo stty -F /dev/ttyS4 -a

speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O;
min = 1; time = 5;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread clocal -crtscts
ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl ixon ixoff -iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke -flusho -extproc

Has any one faced similar issue ?

Since it worked earlier, could it be due to any changes in the serial port configuration ?

As another test, I wrote a simple serial port C program to send a command to /dev/ttyS4, but even in that case, I found that similar hang happens even in this case.

Could someone please help me to understand what could be the issue behind this ?

  • Can you find out on which call the C program takes so much time? open, write, something else? – Eelke Feb 5 at 19:17
  • When I ran strace on the c program, it was getting delayed on close(). So, when I commented close(), the delay was noticed on exit_group(0) of strace during program exit. – Narayanan krishnamurthy Feb 6 at 5:43
  • Does it actually take long for the drawer to open or does it open directly? If it opens quickly it might be a problem with the cashdrawer controller not detecting the drawer opened. – Eelke Feb 6 at 6:59
  • As a surprise, the echo command works when the cash drawer cable connected to the port is tightly held. Could this be an issue with the cable ? But, I would like to understand if the issue is due to the cable, then why should the echo command hang for sometime ? – Narayanan krishnamurthy Feb 7 at 5:11
  • Difficult to say it is not behaviour I would expect from a real serialport. Maybe virtual serial ports can do weird things. Does it use a standard driver or a driver specific for this system? POS manufacturers nowadays often emulate serial because most POS software already supports serial. BTW the RJ11 port on the back is very likely not a serial port but a cash drawer port. Within the system there is a cashdrawer controller which is internally connected to a serial port (or maybe usb to serial). – Eelke Feb 7 at 8:53

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.