Technical information

Serial Solutions Forterm
Figure 11-2. Function inpstr._________________________
C *******************************************************************
C * *
C * InpStr reads a character from the serial port, and writes it *
C * to ’c’. The return value indicates whether any characters *
C * were read. *
C * *
C *******************************************************************
logical function inpstr (c)
character c
integer io
read (1,iostat=io) c
inpstr = ( io .EQ. 0 )
C Rewind file
C (which flushes internal buffer) only when no more characters
if(.NOT. inpstr) rewind (1)
end
The read is performed by the read statement. It is at the
first access of the port for a read or write that the driver itself is
actually accessed. It sets up its internal buffers, which are
essential for interrupt driven I/O, and initialises the serial
hardware. If the driver can return no data then io takes a non-
zero value which inpstr checks. The rewind statement, which
initialises the file for either reading or writing, is only called if
no characters have been read from the port. This is to prevent
rewind flushing the input buffer that FORTRAN maintains.
Inpstr is called repeatedly until there are no more characters to
read, and only then does the program cycle to writing to the
serial port.
Writing To The File.__________________
Writes are performed by the subroutine outstr.
Figure 11-3. Subroutine outstr.___________________________
C *******************************************************************
C * *
C * Outstr sends count characters to the serial port. Any write *
C * errors are dealt with. *
C * *
C *******************************************************************
Page 166 Chapter 11