Technical information

Cterm Serial Solutions
Closing The File._______________
The C function fclose() is used to close the file. It does
not access the device driver, but merely informs DOS and C that
the program no longer wishes to use the file. The files are
closed by:
fclose(com_inp);
fclose(com_out);
performed just before the program ends or during a change of
port on the ’C’ command in CTERM.
Serial Port Parameters._____________________
The serial port has several settings, the Baud rate, parity
etc., which must be set to the values that the remote device
requires. The commands in CTERM which do this all call one
function, called bios_x_init(), which can set all these parameters.
Figure 7-5. Function bios_x_init().______________________________
/* Use BIOS services to set port parameters. */
/* Assumes presence of NewBIOS. */
/* Returns a flag to indicate whether it has succeeded. */
int bios_x_init(int port, int brk, char par,
int stop, int data, long baud)
{
union REGS inregs, outregs;
if( port < 1 || port > 16 )
return FALSE; /* Bad port specification. */
else
inregs.x.dx = port - 1; /* port number. */
inregs.h.al = (char)(brk ? 1 : 0); /* Break parameter. */
switch( tolower(par) )
{
case ’n’: inregs.h.bh = 0; /* Parity none */
break;
case ’o’: inregs.h.bh = 1; /* Parity odd */
break;
case ’e’: inregs.h.bh = 2; /* Parity even */
break;
case ’m’: inregs.h.bh = 3; /* Parity mark */
break;
Chapter 7 Page 123