home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c222 / 1.ddi / DEMOS / SI_TEST.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-01-23  |  1.7 KB  |  59 lines

  1. /*********************
  2.  *
  3.  *  si_test.c - serial port test program.
  4.  *
  5.  *  Purpose: This file contains functions to test the serial interface
  6.  *           functions. It will communicate with a 300 baud device
  7.  *           through the keyboard. (Can be connected directly to a Hayes
  8.  *           modem via com1 port).
  9.  *
  10.  *  Blackstar C Function Library
  11.  *  (c) Copyright 1985 Sterling Castle Software
  12.  *
  13.  *******/
  14.  
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include "blackstr.h"
  18. #include "sc_head.h"
  19. #include "si_head.h"
  20.  
  21.  
  22. void main()
  23. {
  24.     struct SI_PARMS sparm;
  25.     int status;
  26.     char c,d;
  27.  
  28.     //sc_init(3,7,0);     /* init screen */
  29.  
  30.     /*************************************************************
  31.      SET UP SERIAL PORT CHARACTERISTICS IN STRUCTURE
  32.     **************************************************************/
  33.     sparm.type = 0;             /* line type */
  34.     sparm.wbits = 8;            /* 8 bits per word */
  35.     sparm.parity = FALSE;
  36.     sparm.baud = 2;             /* 300 baud */
  37.     sparm.stop = 2;             /* 2 stop bit */
  38.  
  39.     status = si_init(0,&sparm); /* do initialization */
  40.     if(status& 0x6000) {
  41.       printf("\n\r Error - COM port initialization status is %x (hex) ",status);
  42.       exit(0);
  43.     }
  44.     sc_puts("\n\rSimple terminal program (COM1 @300bps)...[ESC] to Exit\n\n\r");
  45.  
  46.     /******************************************************************
  47.      NOW JUST SEND/RECEIVE BYTES BETWEEN THE SERIAL PORT AND CONSOLE
  48.     *******************************************************************/
  49.     while(1) {
  50.     while((d = (char)si_getc(0)) != 0)
  51.         sc_putc(d);
  52.        if(kb_hit())
  53.         si_putc(0,c=kb_getc()); /* half duplex mode */
  54.     if(c==0x1b)
  55.         exit(0);
  56.     }
  57. }
  58.  
  59.