home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / ISC365 / MAIN.CPP < prev    next >
C/C++ Source or Header  |  1992-10-14  |  978b  |  64 lines

  1. #include <conio.h> ; // kbhit.
  2. #include "serial.h";
  3.  
  4.  
  5. //#define TRANSMIT // now defined in Options|Compiler|Code generation|Defines
  6. //#define RECEIVE  // - DITTO -
  7.  
  8.  
  9. SERIAL_PORT com1;
  10.  
  11. char * text= "hello there!!!";
  12.  
  13.  
  14. #ifdef TRANSMIT
  15.  
  16. // simple transmit.
  17.  
  18. int main()
  19. {
  20.     com1.activate(1); // hooks to com1.
  21.     com1.set_up_port(9600,8,'N',1); // setup port.
  22.  
  23.     while (*text) {
  24.           com1<< *text++;
  25.     }
  26.  
  27.     while (com1.output_buff_len()); // normally, this is not neccessary.
  28.  
  29.     return 0;
  30. }
  31.  
  32. #endif /* TRANSMIT */
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. #ifdef RECEIVE
  40.  
  41. int main()
  42. {
  43.     int i= 0;
  44.     BYTE t;
  45.  
  46.     com1.activate(1); // hooks to com1.
  47.     com1.set_up_port(9600,8,'N',1); // setup port.
  48.  
  49.     while (text[i]&& (!kbhit())) {
  50.           if (com1>> t) {
  51.  
  52.              putch(t);
  53.              if (t== text[i])
  54.                 i++;
  55.              else
  56.                  i= 0;
  57.           }
  58.     }
  59.  
  60.     return 0;
  61. }
  62.  
  63. #endif /* RECEIVE */
  64.