It's possible to setup a serial port communication using hardware flow control with the RTS/CTS pins (CRTSCTS flag for tcsetattr), but there is no way to use the DTR/DSR pins for flow control in a reliable and efficient way.

One can use the TIOCMGET ioctl() to check the pin state, but then we need to send one byte at a time, which makes it VERY SLOW!

Isn't there a better way? Making our own cables doesn't scale and there are many POS serial printers on the market that only use DTR/DSR flow control.

P.S.- Forget XON/XOFF, I need reliable 8-bit communication.

  • Voted to delete my answer to increase the chances of getting better answers. This really seems to be an interesting problem other people have faced, too. Interestingly there were at least 3 kernel patches (2001, 2008 and 2010) to address this issue, but none of them seem to be implemented in current ditribution kernels. Looks like only solution (if not taking the custom cable option) would be to patch the kernel on your own. If it's for POS terminals where you have control over all installes software, a BSD UNIX could also worth a try. – ktf Oct 10 '11 at 21:23
  • This comment actually helped me. I found that Red Hat Enterprise Linux 5.3 included a patch to fix this problem [1] on a 2.6.18 kernel. Since RHEL is pretty much a kind of industry standard I believe it's pretty safe to use their patch [2]. [1] rhn.redhat.com/errata/RHSA-2009-0225.html [2] bugzilla.redhat.com/show_bug.cgi?id=445211 – nlucas Oct 12 '11 at 12:35

Answering my own question, thanks to an hint from @ktf, I found out that at least since 2.6.28 [1] there are IOCTLs (TCGETX, TCSETX, TCSETXF & TCSETXW) to setup extended attributes.

They seem to have been added to the upstream kernel on 13 Oct 2008 [2].

These extra IOCTLs (compatible with SYS5) allow to configure each of the extra pins handling individually.

See the link for the original RHEL patch [3] and look on the attached test case for an example of how to use it.

The IOCTL definitions are on the "asm-generic/ioctls.h" file and the structure and flag constants are defined on "linux/termios.h" (in "/usr/include", off course).


Further research shows that the generic serial support for this IOCTL wasn't merged into the upstream kernel source. RHEL 5.3 has it, but not the upstream 3.0.6 kernel.
That means the ioctl() call will fail for any other kernel that didn't port the RHEL patch [4].

[1] http://lxr.free-electrons.com/ident?v=2.6.28;i=TCGETX
[2] https://lkml.org/lkml/2008/10/13/120
[3] https://bugzilla.redhat.com/show_bug.cgi?id=445211
[4] https://bugzilla.redhat.com/attachment.cgi?id=315300&action=diff

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.