home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / microcrn / issue_36.arc / SIOTEST.PAS < prev    next >
Pascal/Delphi Source File  |  1979-12-31  |  2KB  |  59 lines

  1. { include the interrupt interface routines }
  2. {$IB:SIOLIB.INC}
  3.  
  4. Var
  5.    Ch:     Char;
  6.    B:      Byte;
  7.    NoData: Boolean;            { no data read from serial port flag }
  8.    I:      Integer;
  9.    BRate:  Integer;            { baud rate value (0 - 15) }
  10.  
  11. Begin
  12.      Repeat
  13.            ClrScr;
  14.  
  15.            Writeln('Baud Rates');
  16.            Writeln;
  17.            Writeln('0  = 50');        Writeln('1  = 75');
  18.            Writeln('2  = 110');       Writeln('3  = 134');
  19.            Writeln('4  = 150');       Writeln('5  = 300');
  20.            Writeln('6  = 600');       Writeln('7  = 1200');
  21.            Writeln('8  = 1800');      Writeln('9  = 2000');
  22.            Writeln('10 = 2400');      Writeln('11 = 3600');
  23.            Writeln('12 = 4800');      Writeln('13 = 7200');
  24.            Writeln('14 = 9600');      Writeln('15 = 19200');
  25.            Writeln;
  26.            Write('Which Baud Rate ? ');
  27.            Readln(BRate);
  28.      Until (BRate In [0..15]);
  29.  
  30.  
  31.      { Initialize the SIO to the desired baud rate, 8 data bits, odd parity }
  32.      { and 2 stop bits }
  33.  
  34.      Writeln('Initializing SIO');
  35.      InitSIO(BRate,8,3,3);
  36.      Writeln('sio initialized');
  37.  
  38.  
  39.      { Read a character from the keyboard and if any present send to serial }
  40.      { output 80 times, also read character from serial input fifo and echo }
  41.      { to screen. Pressing control-c terminates program }
  42.  
  43.      While (True) Do
  44.      Begin
  45.           If (KeyPressed) Then
  46.           Begin
  47.                Read(Kbd,Ch);
  48.                If (Ch = ^C) Then Halt;
  49.                B:=Ord(Ch);
  50.                For I:=1 to 80 Do WriteByte(B);
  51.           End;
  52.  
  53.           B:=ReadByte(NoData);
  54.           If (Not NoData) Then
  55.                Write(Chr(B));
  56.  
  57.      End;
  58. End.
  59.