Discussion:
Setting TTY tu use XON/XOFF protocol under Linux
(too old to reply)
Rafal Krypa
2005-06-01 15:58:53 UTC
Permalink
Hi.
I'm new to programming tty's under Linux.
I am writing software communicating with fiscal printer over serial port and I
want to use XON/XOFF protocol described in the printer's manual as follows:
- while waiting for command printer sends XON byte every 3 seconds
- after receiving complete command printer sends XOFF byte to signal that it
will now be busy
- after processing command printer checks if it received XON byte. If yes, it
sends XON as a sign of readiness for another command, otherwise the printer
waits for XON from host and then sends XON by itself

Printer can be put in mode described above by sending particular command to it.
The question is: how do I deal with this from the side of my program? Can I
somehow tell Linux (by ioctl() for example) that the device is sending and
expecting particular XON/XOFF bytes?
--
/"\ RafaƂ Krypa
\ / ===========
X ASCII Ribbon Campaign
/ \ against HTML mail
Lew Pitcher
2005-06-01 16:13:34 UTC
Permalink
Post by Rafal Krypa
Hi.
I'm new to programming tty's under Linux.
I am writing software communicating with fiscal printer over serial port and I
- while waiting for command printer sends XON byte every 3 seconds
- after receiving complete command printer sends XOFF byte to signal that it
will now be busy
- after processing command printer checks if it received XON byte. If yes, it
sends XON as a sign of readiness for another command, otherwise the printer
waits for XON from host and then sends XON by itself
Printer can be put in mode described above by sending particular command to it.
The question is: how do I deal with this from the side of my program? Can I
somehow tell Linux (by ioctl() for example) that the device is sending and
expecting particular XON/XOFF bytes?
Both the builtin COOKED and CBREAK modes handle XON/XOFF controls
(that's ^S and ^Q in a serial terminal). You shouldn't have to do
anything special with the serial line to handle XON/XOFF unless you
absolutely /want/ to handle them in userland software.

If you /must/ handle them in software, put the serial line into RAW mode
(see the Linux Documentation Project's "SERIAL HOWTO", at
http://tldp.org/) and then take the appropriate action as you read the
serial control data from the printer.


- --

Lew Pitcher, IT Specialist, Enterprise Data Systems
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)
Villy Kruse
2005-06-02 07:29:09 UTC
Permalink
On Wed, 01 Jun 2005 12:13:34 -0400,
Post by Lew Pitcher
Post by Rafal Krypa
Hi.
I'm new to programming tty's under Linux.
I am writing software communicating with fiscal printer over serial port and I
- while waiting for command printer sends XON byte every 3 seconds
- after receiving complete command printer sends XOFF byte to signal that it
will now be busy
- after processing command printer checks if it received XON byte. If yes, it
sends XON as a sign of readiness for another command, otherwise the printer
waits for XON from host and then sends XON by itself
That is not the xon/xoff protocol in the normal sense of the word. It is
a special protocol which just happens to use xon and xoff in a special way.
Post by Lew Pitcher
Post by Rafal Krypa
The question is: how do I deal with this from the side of my program? Can I
somehow tell Linux (by ioctl() for example) that the device is sending and
expecting particular XON/XOFF bytes?
Both the builtin COOKED and CBREAK modes handle XON/XOFF controls
(that's ^S and ^Q in a serial terminal). You shouldn't have to do
anything special with the serial line to handle XON/XOFF unless you
absolutely /want/ to handle them in userland software.
If the printer were using xon/xoff in the normal way that would be true.
From the description above it would be clear that isn't the case.
Post by Lew Pitcher
If you /must/ handle them in software, put the serial line into RAW mode
(see the Linux Documentation Project's "SERIAL HOWTO", at
http://tldp.org/) and then take the appropriate action as you read the
serial control data from the printer.
Therefore the whole thing should be done in user level program with
the tty device in raw mode and no flow control.


Villy

Loading...