Borland C++ reference

bioscom

raw OCR

Performs serial I/O.

Defined in header <bios.h>

Syntax

#include <bios.h>
int bioscom(int cmd, char abi/te, int port);

Portability

DOSUNIXWindowsANSI CC++ only
■

Remarks

bioscom 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:

0 Sets the communications parameters to the value in abyte. 1 Sends the character in abyte out over the communications line. 2 Receives a character from the communications line.

3 Returns the current status of the communications port.

abyte is a combination of the following bits (one value is selected from each of the groups):

0x027 data bits0x00110 baud
0x038 data bits0x20150 baud
0x40300 baud
0x001 stop bit0x60600 baud
0x042 stop bits0x801200 baud
0x00No parityOxAO2400 baud
0x08Odd parityOxCO4800 baud
0x18Even parityOxEO9600 baud

For example, a value of 0xEB (OxEO 10x08 10x00 10x03) for abyte sets the communications port to 9600 baud, odd parity, 1 stop bit, and 8 data bits. bioscom uses the BIOS 0x14 interrupt.

Return value

For all values of cmd, bioscom 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 2, 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 0 or 3, the return value has the upper bits set as defined, and the lower bits are defined as follows:

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

Example

#include <bios.h>
#include <conio.h>

ttdefine COMl      0
#define DATA_READY 0x100
ttdefine TRUE      1
#define FALSE      0
#define SETTINGS  (0x80 I 0x02   0x00 I 0x00)

int main(void)
{
   int in, out, status, DONE  = FALSE;
   bioscom(0, SETTINGS, COMl);
   cprintfC...  BIOSCOM  [ESC] to exit ...\n");
   while (!DONE) {
      status = bioscom (3, 0, COMl);
      if (status & DATA_READY)
         if ((out = bioscom(2,  0, COMl) & 0x7F)
            putch (out);
         if (kbhitO)   {
            if  ((in = getchO)  == '\xlB')
                    DONE = TRUE;
            bioscomd,  in, COMl);
         }
   }
   return 0;
}

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.