Calls BIOS communications services, using INT 0x14.
#include <bios.h>
unsigned _bios_serialcom( unsigned service, unsigned serial_port,
unsigned data );
service | Communications service | |
serial_port | Serial port to use | |
data | Port configuration bits |
The _bios_serialcom routine uses INT 0x14 to provide serial communications services. The serial_port argument is set to 0 for COM1, to 1 for COM2, and so on.
The _bios_serialcom routine may not be able to establish reliable communications at baud rates in excess of 1,200 baud (_COM_1200) due to the overhead associated with servicing computer interrupts. Faster data communication rates are possible with more direct programming of serial-port controllers. See C Programmer's Guide to Serial Communications for more details on serial-communications programming in C.
The service argument can be set to one of the following manifest constants:
Constant | Service |
_COM_INIT | Sets the port to the parameters specified in the data argument |
_COM_SEND | Transmits the data characters over the selected serial port |
_COM_RECEIVE | Accepts an input character from the selected serial port |
_COM_STATUS | Returns the current status of the selected serial port |
The data argument is ignored if service is set to _COM_RECEIVE or _COM_STATUS. The data argument for _COM_INIT is created by combining (with the OR operator) one or more of the following constants:
Constant | Meaning |
_COM_CHR7 | 7 data bits |
_COM_CHR8 | 8 data bits |
_COM_STOP1 | 1 stop bit |
_COM_STOP2 | 2 stop bits |
_COM_NOPARITY | No parity |
_COM_EVENPARITY | Even parity |
_COM_ODDPARITY | Odd parity |
_COM_110 | 110 baud |
_COM_150 | 150 baud |
_COM_300 | 300 baud |
_COM_600 | 600 baud |
_COM_1200 | 1,200 baud |
_COM_2400 | 2,400 baud |
_COM_4800 | 4,800 baud |
_COM_9600 | 9,600 baud |
The default value of data is 1 stop bit, no parity, and 110 baud.
The function returns a 16-bit integer whose high-order byte contains status bits. The meaning of the low-order byte varies, depending on the service value. The high-order bits have the following meanings:
Bit | Meaning if Set |
15 | Timed out |
14 | Transmission-shift register empty |
13 | Transmission-hold register empty |
12 | Break detected |
11 | Framing error |
10 | Parity error |
9 | Overrun error |
8 | Data ready |
When service is _COM_SEND, bit 15 will be set if data could not be sent.
When service is _COM_RECEIVE, the byte read will be returned in the low-order bits if the call is successful. If an error occurs, any of the bits 9, 10, 11, or 15 will be set.
When service is _COM_INIT or _COM_STATUS, the low-order bits are defined as follows:
Bit | Meaning if Set |
7 | Receive-line signal detected |
6 | Ring indicator |
5 | Data set ready |
4 | Clear to send |
3 | Change in receive-line signal detected |
2 | Trailing-edge ring indicator |
1 | Change in data-set-ready status |
0 | Change in clear-to-send status |
Note that this function works only with IBM personal computers and true compatibles.
Standards:None
16-Bit:DOS, QWIN, WIN, WIN DLL
32-Bit:None
/* BSERIALC.C: This program checks the status of serial port COM1. */
#include <bios.h>
#include <stdio.h>
void main( void )
{
unsigned com1_status;
com1_status = _bios_serialcom( _COM_STATUS, 0, 0 );
printf ( "COM1 status: 0x%.4x\n", com1_status );
}
COM1 status: 0x6000