Asynchronous Serial Communications Programmer's Reference Manual (32022-90052)

124 Chapter6
Typeahead Mode
Programming for Typeahead Mode
Programming for Typeahead Mode
To programmatically set and control typeahead mode you use the
FDEVICECONTROL intrinsic, specifying one of three control
directives in the parm1 value.
A control directive of 51 is used to specify whether or not typeahead
mode is on for the device. Use this call with the buffer parameter
set to 1 to enable typeahead mode, or with the buffer parameter set
to 0 to disable typeahead mode (parm2 set to 2 or 3).
A control directive of 60 allows you to discard any data in the
typeahead buffer and read directly from the device.
A control directive of 61 allows you to bypass the typeahead buffer
for the next read while saving the data already in the typeahead
buffer.
A control directive of 63 is used to enable or disable single echo
typeahead. Use this call with the buffer parameter set to 1 to enable
typeahead mode, or with the buffer parameter set to 0 to disable
single echo typeahead mode (parm2 set to 2 or 3).
The code fragments that follow illustrate how these calls might look in
your program.
NOTE
When typeahead is enabled it is enabled for the device and not
specifically for an application. It is a good practice to make sure that
any program that enables typeahead mode also restores the terminal’s
previous typeahead setting before it terminates. To do so, your program
should save the value of the device’s current typeahead setting. This is
obtained either through a separate call to FDEVICECONTROL with a
control directive of 51 and parm2 set to 1 (Read access), or through the
call which changes the setting, with parm2 set to 3 (Read/Write
access). When your program is ready to end execution, it will be able to
return the device to its original typeahead setting through another
FDEVICECONTROL call, using the value of the previous setting
obtained in the first call as the value of buffer.