xon
- Updated2024-03-18
- 2 minute(s) read
xon
Change Serial Port XON/XOFF Protocol
Type
Serial port function
Syntax
xon [booltx] [,boolrx]<CR>
Purpose
You can use xon at the beginning of your program to configure the GPIB-RS232/485/422 to communicate over the serial port using the same XON/XOFF protocol as your serial device.
Remarks
The argument booltx specifies whether to enable the XON/XOFF protocol when sending data out on the serial port. If the argument booltx is 1, the GPIB-RS232/485/422 monitors its serial receive buffer for XON/XOFF characters as it sends data over the serial port. If it receives the XOFF character (decimal 19 or <Ctrl-S>), it immediately stops sending data. When it receives the XON character (decimal 17 or <Ctrl-Q>), it begins sending data again. To send a data string that might contain a <Ctrl-S> or <Ctrl-Q>, you must disable booltx.
The argument boolrx specifies whether to enable the XON/XOFF protocol when receiving data over the serial port. If the argument boolrx is 1, and the GPIB-RS232/485/422 is receiving data over the serial port, it sends XOFF over the serial port when its serial receive buffer is almost full. This tells the sender to stop sending data. When the GPIB-232/485CT-A serial port receive buffer is ready to receive more bytes, the GPIB-RS232/485/422 sends XON over the serial port. This tells the sender to begin sending data again.
![]() |
Note Enabling either booltx or boolrx enables the XON/XOFF protocol for both sending and receiving the data to/from the serial port. This behavior is different from the GPIB-232-CT-A. Refer to Differences between the GPIB-232/485CT/CV-A and GPIB-RS232/485/422 for more information about this and other differences. |
You should use XON/XOFF if your serial device does not recognize the hardware handshake protocol and you are transferring large amounts of data at high speeds. Without handshaking, there is danger of overflowing the GPIB-RS232/485/422 and serial device serial port receive buffers.
The flow control setting selected using the NI GPIB-Serial Converter Wizard determines the power-on default of XON/XOFF for both sending and receiving. For more information, refer to Configuration of S Mode and Hardware Handshaking.
If you call xon without an argument, the GPIB-RS232/485/422 returns the current handshake setting: 1 if the protocol is enabled or 0 if protocol is disabled.
The assignment made by xon remains in effect until you call xon again, call onl, or turn off the GPIB-RS232/485/422.
Example 1
Enable the GPIB-RS232/485/422 XON/XOFF protocol for TX and RX.
char buffer [] = "xon 1,1\r";
viWrite(instr, buffer, strlen(buffer), &retCount);
Example 2
Disable the GPIB-RS232/485/422 XON/XOFF protocol for TX and RX.
char buffer [] = "xon 0,0\r";
viWrite(instr, buffer, strlen(buffer), &retCount);