Serial Communications

This section introduces telecommunications.  For many programmers, writing a communications program is difficult.  It is not that the programs themselves are especially long; it is that the procedures and terminology are unfamiliar.  That means programs take longer to write and debug, making writing such programs frustrating.  To compound the problem, performing serial communications using the Windows API can be a daunting task.

In this section, we define common communications terms and discuss some of the more regular ways of transmitting and receiving data, using the native COMM statements and related features of PowerBASIC.  There are plenty of examples and some working PowerBASIC program code (included on your distribution disks) for you to try out.  Feel free to use this code as a starting point for your own communications programs.

Before presenting any sample code or delving further into the mysteries of communications, let's define a few terms:

ACK

An acknowledgment signal sent by the receiver of a message.

Asynch

Asynchronous; not synchronous.  The receiver and transmitter are free to send signals without matching clocks.

Baud Rate

Baud (from J. M. E. Baudot, a communications pioneer) refers to the total number of signal changes that could possibly be sent between transmitter and receiver per second.  Signal changes do not necessarily mean bits, and not all bits are necessarily data, so baud rate isn't equivalent to a fixed number of characters (or even a fixed number of bits) per second.

Buffer

An area of memory used to hold transmitted or received signals before processing them.

CD

Carrier Detect.  A signal used to tell that a carrier has been detected; the DCE (modem) has connected with another computer and is ready for use.

CRC

Cyclic Redundancy Check.  A way of summing the data bits sent between transmitter and receiver so as to detect transmission errors.

CTS

Clear To Send.  A handshaking signal that indicates the receiver is ready to receive data.  Typically, a modem uses this signal for to control data flow from the computer.  CTS (and sometimes DSR) are often used in response to an RTS signal.

DCE

Data Circuit-terminating Equipment.  Typically, a DCE is a modem.  A DCE is often inaccurately referred to as the "Data Communications Equipment".

DSR

Data Set Ready.  A handshaking signal that serves to indicate that an RS-232C non-terminal device (usually a modem) is ready to receive data.  Often used with CTS.

DTE

Data Terminal Equipment.  Typically the computer.

DTR

Data Terminal Ready.  A handshaking signal that indicates that an RS-232C serial terminal device (the computer) is ready to receive data.

Handshaking

A process whereby the receiver and transmitter match signals and correctly determine each other's status.  See CTS, DSR, and RTS.

Modem

Modulator/Demodulator.  A device used to convert digital signals to sounds that can be carried over standard telephone lines, and to convert such sounds back to digital signals.

NAK

Negative Acknowledgment.  A signal sent from receiver to transmitter, indicating that an error was detected in the last message.

Null Modem

A way of connecting receive and transmit lines, so that one computer can send or receive signals directly from another without having to go through a modem.  This typically requires a "null-modem" or "cross-over" cable to ensure the signals are correctly interconnected between devices.

Parity

One bit (the high-order bit) per byte sent or received, used to detect some of the possible transmission errors.  Parity may be even, odd, none, mark (always on), or space (always off).

Port

A term used to refer to any one of the possibly several communications devices available to the operating system.  Usually COM1, COM2, etc.

Protocol

A way of controlling transmissions or receptions.  A protocol consists of a set of rules describing the form of a valid transmission, the proper response when a transmission is received, and ways of detecting and correcting errors.

RS-232

A standard for wiring on serial communications ports, that describes which wires should carry which signals at what voltage.  There are two basic standards: one for transmitting equipment (DTE) and one for receiving equipment (DCE).

RTS

Request To Send.  A signal raised by the transmitter, to which the receiver should reply with CTS and/or DSR.

Serial

Refers to signals sent one bit after the other, as opposed to parallel.  Parallel signals are sent more than one bit at a time.

Stop Bits

The number of bits added to each byte of data transmitted, to allow the receiver to get in step with the transmitter.

Synch

Synchronous.  The receiver and transmitter match their clocks so that each will send and receive only at specific times.

 

See Also

Communications Basics

Communication Buffers

Parity and general error checking

Start and Stop bits

Opening a communications port

Reading and writing data

A simple communications program