Dec 212017
The source to some good async routines in TP4.0+.
File TPASYNC.ZIP from The Programmer’s Corner in
Category Pascal Source Code
The source to some good async routines in TP4.0+.
File Name File Size Zip Size Zip Type
TPASYNC.DOC 5373 2031 deflated
TPASYNC.PAS 10585 2448 deflated

Download File TPASYNC.ZIP Here

Contents of the TPASYNC.DOC file

Turbo PASCAL Async Manager version 2.01

Copyright 1986-1990 by Kaleb Axon. All Rights Reserved.

For use with Turbo PASCAL 4.0

(Originally written in Turbo PASCAL 3.01)

The only requirement for freely incorporating this code into your own
programs is that the author of this code be given due credit wherever is
most appropriate (program's opening screen, copyright page or introduction
of manual, etc).

Information on updates and new releases to add to your library of Turbo
PASCAL source will be released from time to time via the PASCAL net-mail
echo, or you may drop me a note with your name and address (sent to the
address below).

If you have any questions or comments, please direct them to:

Kaleb Axon
1841 W. Katella St.
Springfield, MO 65807

The purpose of this unit is to provide access to the serial ports from Turbo


The Turbo PASCAL Async Manager may access either COM1 or COM2, or both
simultaneously. It is capable of up to 56,000 baud, and supports any normally
combination of data bits, stop bits and parity.

The TPAsync unit must NEVER be overlaid under any circumstances. When running
in a multi-tasking environment, any program using the TPAsync unit must be
defined as non-swappable; that is to say, it must be present and in the exact
same location in memory at all times.


These are the functions that are most often used. In fact, these are the only
functions I originally used in my own programming. A reasonably decent program
could be developed using these functions. Once these primary functions are
covered, we will go on to discuss the extended functions.

The AsyncOpen function opens an async port for access by your program, and
sets up an input buffer. The handle may be 1 or 2. The handle is used in
future calls to indicate which serial port to access. Note that the handle
need not be the same as the com port. For example, COM1 could be opened using
handle #2, and COM2 could be opened using handle #1. This may seem odd, but
for my purposes, it was originally a good idea, and I never saw any need to
change it. The function returns true if the operation was successful, or false
if it failed.

function AsyncOpen(Handle : byte;
ComPort : integer;
BaudRate : word;
Parity : char;
DataBits : integer;
StopBits : integer)
: boolean;

The AsyncSend procedure sends one character to the specified serial port.
Output is not buffered.

procedure AsyncSend(Handle : byte;
Ch : char);

The AsyncBufferRead function reads one character from the specified serial
port if one is available. If a character was successfully read, the function
returns true; otherwise, it returns false.

function AsyncBufferRead( Handle : byte;
var C : char)
: boolean;

The AsyncBufferClose procedure closes the specified serial port.

procedure AsyncClose(Handle : byte);


The AsyncSendString procedure sends a string to the specified serial port.
Output is not buffered.

procedure AsyncSendString(Handle : byte;
S : string);

The AsyncBufferCheck function returns true if a character is currently
available from the specified serial port for input via the AsyncBufferRead

function AsyncBufferCheck(Handle : byte) : boolean;

The Carrier function returns true if the CD (Carrier Detect) pin on the
specified serial port is hot.

function Carrier(Handle : byte) : boolean;

The AsyncChange procedure changes the baud rate, data bits, parity and stop
bits for the specified serial port without actually closing the port or
clearing the input buffer.

procedure AsyncChange(Handle : byte;
BaudRate : word;
Parity : char;
DataBits : integer;
StopBits : integer);

The AsyncCloseKeepDTR procedure closes the specified serial port, but does not
drop the DTR line. AsyncClose causes the carrier to be dropped on most
machines, and AsyncCloseKeepDTR will avoid dropping the carrier.

procedure AsyncCloseKeepDTR(Handle : byte);


{ This program does not implement all the features of the Turbo PASCAL Async }
{ Manager, but should give a general idea as to how it is used. }

program Sample;

Ch : char;
OldCarrier : boolean;

if AsyncOpen(1,1,2400,'N',8,1) then
WriteLn('COM1 opened successfully; press Ctrl-6 to exit.');
if AsyncBufferRead(1,Ch) then
if KeyPressed then
Ch := ReadKey;
if Ch <> ^^ then
end else
Ch := ^@;
until Ch = ^^;
end else
WriteLn('Couldn''t open COM1!');

 December 21, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>