TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Steven Hendriks
from: David Muir
date: 1995-08-05 06:30:38
subject: Serial I/O {1 of 10}

-=> Quoting Steven Hendriks to All <=-

 SH> Hi All,

 SH> I am looking for some serial I/O routines for OS/2 in PASCAL. I'm
 SH> using Virtual Pascal to port some DOS programs to OS/2, but ran into
 SH> problems with the communications routines. I used to use fossil driver
 SH> routines in DOS (which is quite easy), but I don't have a clue of
 SH> what's needed to get serial I/O working under OS/2...

 SH> What I need:

 SH> - Init the comport (is it necessary? It is when using a fossil driver
 SH> under DOS...)
 SH> - Send a character to the comport
 SH> - Read a character from the comport

 SH> If you get me a solution, you'll get free keys for all my shareware
 SH> programs which will use it.

`You asked for it '

David Muir (Author THD ProScan )

Unit OS2_COMM;
{
 A communications unit for Virtual Pascal Version 1 (beta 3)
 which makes use of the OS2 API.

 Please note, that "I" am not an "experienced"
programmer and these
 routines could prove to be absolutely useless in the real world.
 They were created after much hair pulling based on how "I think"
 it was intended to be done. Most have been tested, others are
 "assumed" to work based on their similarity to other Functions.

 I assert no promises or guarantees in relation to these routines.
 Nor do I claim any "rights" to their use. If however you make
 improvements to them, please drop me a line at 1:259/423 (fido)
 so I can update my routines.

 All implementations below are the original work of David Muir

 Tech note..   If attempting to port this source to a Pascal compiler
 other than Virtual Pascal, You may need to change references of
 DOSDEVIOCTL to DosDevIOCtl2 and DOSOPEN to DosOpen2 depending on
 the compiler and the implementations of the API used by that compiler.

 Not all 'comm' Functions are implemented here (not by a longshot).
 I "did" it because I needed a few simple comm Functions. It seemed
 only logical to add some of the other Functions while I was doing it.

 I'm releasing it to spite all those people who didn't help me figure
 it out, so they can't do the same to you.

 Acknowledgement appreciated but not required...
}

INTERFACE

(*
July 20, 1995 - Original Release - David Muir
*)


Uses OS2BASE;

(***************************************************************************)
(* ----------------------------- CONSTANTS ------------------------------- *)
(***************************************************************************)

CONST

  Retries   : longint = 5;    { maximum number of times to attempt to send
                                each char before aborting }

  LocalEcho : Boolean = True; { Should the send routine allow the 'sent'
                                characters to be placed in the receive
                                buffer?
                                - TRUE is faster since the send routine
                                  won't try to locate and strip the sent
                                  character from the RX buffer.
                                - False will cause the send routine to
                                  attempt to strip the sent character
                                  from the RX buffer }

(***************************************************************************)
(* -------------------------- TYPE DECLARATIONS -------------------------- *)
(***************************************************************************)

TYPE

   RTS_DTR = Record      { Record for setting DTR and / or RTS }
      Onmask,
      Offmask:byte;
      end;

   EBREC = Record        { Record for storing the return of GetEbaud}
      C_baud  : longint; { Current BaudRate }
      C_frac  : byte;    { Current Fraction }
      Mn_baud : longint; { Minimum BaudRate }
      Mn_frac : byte;    { Minimum Fraction }
      Mx_baud : longint; { Maximum BaudRate }
      Mx_frac : byte;    { Maximum Fraction }
      end;

   BUFFREC = Record      { For storing TX or RX buffer records }
      Bytesin,           { Number of bytes in buffer }
      FullSize : word;   { Size of the buffer }
      end;

   DCBREC = Record       { Device Control Block Record }
      Read_tmo,          { Read timeout }
      Write_tmo : word;  { Write timeout }
      Flag1,             { bit flags }
      Flag2,             { bit flags }
      Flag3,             { bit flags }
      Err_Rep,           { Error replacement byte }
      Brk_Rep,           { Break replacement byte }
      XonChar,           { Xon Character - normally $11}
      XoffChar : byte;   { Xoff Character- normally $13}
      end;

(***************************************************************************)
___ Blue Wave/QWK v2.12
--- Renegade v10-05 Exp

* Origin: Scrawled From the Tomb..(416-255-2164) (1:250/346)
SEEN-BY: 105/42 620/243 711/401 409 410 413 430 807 808 809 934 955 712/407
SEEN-BY: 515 628 704 713/888 800/1 7877/2809
@PATH: 250/346 426 702 3615/50 396/1 270/101 105/103 42 712/515 711/808
@PATH: 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.