Technical information

Cterm Serial Solutions
Menuout() deals with the function keys and the ALT-C
key. It reads the second byte of the extended key code and
interprets it as a request to perform a certain action, and calls
cmdout() for help, quit and commands, and setup() for the setup
option. Cmdout() decodes a character string as a command
(whether the string is from the keyboard, a file or a literal in the
program does not matter), calling one of the command execution
routines to do the actual work. Setup() present the user with a
group of menus to allow set up the serial port. It gets options
from the user and calls the command execution routines to
perform them.
Note the use of the function screen() throughout for output
to the screen. This function at this time simply calls printf(), but
is used so that future versions of CTERM can easily use
separate windows or a marking scheme to separate the three type
of text that appear on the screen- characters from the serial port
(’fromport’), echoed characters from the keyboard (’fromecho’),
and control information from the program (’fromctrl’). The
second parameter of screen() flags this. Figure 7-7 contains
examples of this.
Figure 7-7. Screen Output Examples.________________________________
if( echo & echos ) /* May need to echo character to screen. */
screen(c,fromecho);
inxlat(bf); /* Read in some characters. */
if(*bf != ’\0’ ) /* If some read in ok. */
screen(bf,fromport);
screen("Command not recognised\n",fromctrl);
screen("Command not recognised\n",fromctrl);
The actual commands which access the serial port are
comparatively simple to use, and are almost hidden by the
remainder of Cterm. The user should not find any great
difficulty in using serial port from C.
Chapter 7 Page 127