Technical information
Serial Solutions Cterm
com = fopen("COM1","rb"); /* Open file for input, or */
com = fopen("COM1","wb"); /* open for output, or */
com = fopen("COM1","rb+"); /* open for both. */
.
c = getc( com ); /* read from file */
fputc( com ); /* Write to file */
.
fseek( com, 0l, SEEK_SET); /* Flush C output buffer */
i = ferror( com ); /* Check for errors on transmission */
.
fclose( com ); /* Close file to tidy up */
Cterm accesses the BIOS services provided by NewCOM
with the C function int86(), in the Cterm function Bios_x_init().
This allows Cterm to set serial port parameters such as Baud
rate and parity.
Cterm also uses a DOS function to change the way that
DOS handles files, from cooked mode to raw data mode, which
prevents DOS from interfering with control characters. This is
encapsulated in the function Uncook().
The low-level i/o functions of Microsoft C, open, close,
read and write, could be used instead of the stream i/o functions
above.
Opening The File.________________
In CTERM the function ’open_com()’, Figure 7-1, opens
the file associated with the serial port.
Page 118 Chapter 7