| 
 Q:  
How do I specify and control Open Transport Serial port I/O handshaking? 
The options seem a bit confusing. A: 
By using the the SRL_OPT_HANDSHAKEOption provided by the Open Transport native 
interfaces you can customize serial port handshaking in variety of ways. For instance, 
you can request that input handshake be controlled by the CTS line, or by theXON/OFF sequence. The handshaking behavior is specified by a 4-byte unsigned integer value that 
is passed in with theSRL_OPT_HANDSHAKEOption: 
	| 
+=====-========-========-========-========-========-========-========-========+
|  Bit|   7    |   6    |   5    |   4    |   3    |   2    |   1    |   0    |
|Byte |        |        |        |        |        |        |        |        |
|=====+========+========+=====================================================|
|  0  |        |        |        |        |        |        |        |        |
|-----+-----------------------------------------------------------------------|
|  1  |        |        |        |        | DTR    | CTS    | XON/OFF| XON/OFF|
|     |        |        |        |        | Output | Input  | Input  | Output |
|-----+-----------------------------------------------------------------------|
|  2  |                         XON character                                 |
|-----+-----------------------------------------------------------------------|
|  3  |                         XOff character                                |
+=============================================================================+
 |  The high word (16 bits) of the integer is a bitmap with 1 or more of the following bits set: 
	| 
        kOTSerialXOnOffInputHandshake   = 1
        kOTSerialXOnOffOutputHandshake  = 2
        kOTSerialCTSInputHandshake      = 4
        kOTSerialDTROutputHandshake     = 8
 |  The 2nd lowest byte is the XOncharacter value; the lowest byte is theXOffcharacter value. If these values are 0, and XOnOffhandshaking was requested, the default values of 
Control-S forXOffand Control-Q forXOnwill be used. There is an inline function (or #define for C users) 
SerialHandshakeData(type, onChar, offChar)defined in OpenTptSerial.h can be used to create this 4-byte value. The default value 
of this option is no handshaking. For instance, if you wish to enable XON/XOFFinput handshaking, but you wanted to specify 
that theXONchar be a ^T instead of an ^Q. You would create an option structure in this manner. 
	| 
    TOption     opt;
    opt.len     = kOTFourByteOptionSize;
    opt.level   = XTI_GENERIC;
    opt.name    = SERIAL_OPT_HANDSHAKE;
    opt.value   = OTSerialHandshakeData  (
kOTSerialXOnOffInputHandshake,
                              ('T' & ~0x40),
                // normally kOTSerialDefaultOnChar
kOTSerialDefaultOffChar);
 |  
                                            
You also have the ability to control the XOff state of the serial input port by using the                        the I_SetSerialXOffState Ioctlcommand. A value of 0 will unconditionally clear theXOFFstate, while a value of 1 will unconditionally set it. 
	| 
OTIoctl(theSerialEndpoint, I_SetSerialXOffState, 1);    // Set XOFF state to ON
 |  The I_SetSerialXOnIoctl causes the serial port to send anXONcharacter. A value of 
0 will only cause it to be sent if we're in theXOFFstate, while a value of 1 will 
unconditionally send the character. 
	| 
OTIoctl(theSerialEndpoint, I_SetSerialXOn, 1);          // Unconditionally send an XON
 |  Conversely, the I_SetSerialXOff Ioctlcauses the serial port to send anXOFFcharacter. A 
value of 0 will only cause it to be sent if we're in theXONstate, while a value 
of 1 will unconditionally send the character. 
	| 
OTIoctl(theSerialEndpoint, I_SetSerialXOff, 1);         // Unconditionally send an XOFF
 |  |