Borland C++ reference

_bios_serialcom

raw OCR

Performs serial I/O.

Defined in header <bios.h>

Syntax

#include <bios.h>
unsigned  _bios_serialcom(int cmd, int port, char ahyte);

Portability

DOSUNIXWindowsANSI CC++ only
■■

Remarks

_bios_serialcom performs various RS-232 communications over the I/O port given in port.

A port value of 0 corresponds to COMl, 1 corresponds to COM2, and so forth.

The value of cmd can be one of the following values (defined in bios.h):

COM INITSets the communications parameters to the value in abyte.
COM SENDSends the character in abyte out over the communications line.
COM RECEIVEReceives a character from the communications line. The abyte argument is ignored.
_COM _STATUSReturns the current status of the communications port. The abyte argument is ignored.

When cmd is _COM_INIT, abyte is a OR combination of the following bits:

Select only one of these:

_COM_CHR77 data bits
_COM_CHR88 data bits

Select only one of these:

_COM_STOPl1 stop bit
_COM_STOP22 stop bits

Select only one of these:

_COM_NOPARITYNo parity
_COM_ODDPARITYOdd parity
_COM_EVENPARITYEven parity

Select only one of these:

COM 110110 baud
COM_150150 baud
COM.300300 baud
COM600600 baud
COM12001200 baud
COM_24002400 baud
COM_48004800 baud
COM96009600 baud
For example, a value of (_COM_9600I _COM_ODDPARITYI
_COM_STOPlI _COM_CHR8) for abijte sets the communications port to

9600 baud, odd parity, 1 stop bit, and 8 data bits. _bios_serialcom uses the BIOS 0x14 interrupt.

Return value

For all values of cmd, _bios_serialcom returns a 16-bit integer of which the upper 8 bits are status bits and the lower 8 bits vary, depending on the value of cmd. The upper bits of the return value are defined as follows:

Bit 15 Time out Bit 14 Transmit shift register empty Bit 13 Transmit holding register empty Bit 12 Break detect Bit 11 Framing error Bit 10 Parity error Bit 9 Overrun error Bit 8 Data ready

If the abyte value could not be sent, bit 15 is set to 1. Otherwise, the remaining upper and lower bits are appropriately set. For example, if a framing error has occurred, bit 11 is set to 1.

With a cmd value of _COM_RECElVE,the byte read is in the lower bits of

the return value if there is no error. If an error occurs, at least one of the upper bits is set to 1. If no upper bits are set to 1, the byte was received without error.

With a cmd value of _COM_INITor _COM_STATUS, the return value has

the upper bits set as defined, and the lower bits are defined as follows:

Bit 7 Received line signal detect Bit 6 Ring indicator Bit 5 Data set ready Bit 4 Clear to send Bit 3 Change in receive line signal detector Bit 2 Trailing edge ring detector Bit 1 Change in data set ready Bit 0 Change in clear to send

Example

#include <bios.h>
#include <conio.h>
#define COMl        0
Mefine  DATA_READY  0x100
#define TRUE        1
#define FALSE       0
tdefine SETTINGS  (_COM_1200  I _C0M_CHR7 I _C0M_ST0P1  I _COM_NOPARITY)

int main (void)
{
   unsigned  in, out, status;
   _bios_serialcom(_COM_INIT,  COMl,  SETTINGS);
   cprintfC...   _BIOS_SERIALCOM  [ESC] to exit ...\r\n");
   for  (;;) {
      status  = _bios_serialcom(_COM_STATUS,  COMl, 0);
      if  (status & DATA_READY)
         if  ((out = _bios_serialcoin(_COM_RECEIVE, COMl,  0) & 0x7F) !=
            putch(out) ;
      if  (kbhitO)  {
         if  ((in = getchO)  ==  '\xlB')
            break;
         _bios_serialcom(_COM_SEND,   COMl, in);

   return

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.

Extraction notes

  • heading `bios serialcom` read as `_bios_serialcom`