Listing 5 (sin.c)

/***    INPUT A CHARACTER FROM SERIAL PORT   ***/

#include "serial.h"
#include <time.h>

extern int portbase;

int SerialIn()
  {
   int Char_Value;
   clock_t start, timeout;
   
   start = clock();
   
   while((inp(portbase + LSR) & RCVRDY) == 0)
    {
     timeout = clock();
     
     if((timeout-start) > 1)
      {
       return(-1);
      }
   }
  
  Char_Value = inp(portbase + RXR);
  return (Char_Value);
}
/* End of File */