Asynchronous Serial Communications Programmer's Reference Manual (32022-90052)
Chapter 6 129
Typeahead Mode
Programming for Typeahead Mode
Bypassing the Typeahead Buffer
Figure 6-3 is an example of using FDEVICECONTROL to bypass the
typeahead buffer. You could use this capability to send a status request
and obtain a reply directly from a terminal without affecting the data
already in the typeahead buffer. This FDEVICECONTROL is only valid
if typeahead is enabled. The default is not to bypass the typeahead
buffer.
This FDEVICECONTROL call will cause the typeahead buffer to be
bypassed for a single read only; normal typeahead mode processing will
resume for any following reads, and data will be taken from the
typeahead buffer if data is present.
When you use this request, you call FDEVICECONTROL with parm1
set to 61, bypass typeahead mode, and pass a value of 1 in the buffer
parameter (value :=1). As in the previous examples, Write access is
specified in parm2, and the Pascal/iX
ccode
function is used for error
checking.
NOTE
In cases where there is no read trigger (read trigger set to null)
bypassing the typeahead buffer may have unexpected results. If, for
example, your program is swapped out between the FWRITE and
FREAD of a terminal status request, the terminal may appear to
become “hung”, since there is no read trigger to synchronize terminal
response with the posting of the read.
To avoid this problem, instead of bypassing the typeahead buffer to
send a status request when no read trigger is present, the following
should be the sequence that occurs:
1. = Disable typeahead mode
2. = Post a 0 byte read
3. = Enable typeahead mode
4. = (Lock keyboard) (FWRITE) Send status request
5. = FREAD of status
6. = FWRITE (unlock keyboard)