Subroutines > Detailed Descriptions > GET

Inputting from a serial device

To input from a serial device under UNIX or Linux, open it as an input file, e.g.:

OPEN #9, "/dev/cua0", INPUT

Then pass the file channel to XCALL GET just like any other input file channel. Beware, however, that under UNIX, such serial ports will be by default set to “line input” mode. Thus, while you may be asking for only 2 characters, you would not actually “see” them until a line terminator (usually LF) had been received. To avoid this annoyance and get the characters immediately as they are transmitted from the other end, you need to take the port out of “line input” mode. One way to accomplish this is to use XCALL HOSTEX with the UNIX stty command to turn off “icanon” mode, for example:

xcall HOSTEX, "stty –icanon < /dev/cua0"