delorie.com/djgpp/doc/libc/libc_70.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

bioscom

Syntax

 
#include <bios.h>

int bioscom(int cmd, char data, int port);

Description

This function accesses the BIOS interrupt 0x14 function, serial communication services. port should be the COM port (0=COM1, 1=COM2, etc).

The valid values of cmd are:

0 - initialize com port (data is the settings)
1 - write byte to port
2 - read byte from port (data is ignored)
3 - get port status

For initialization, the byte is made up of the following bits:

 
0000 0000
7654 3210  Meaning

---- --10  7 bits/character
---- --11  8 bits/character
---- -0--  1 stop bit
---- -1--  2 stop bits
---X 0---  no parity
---0 1---  odd parity
---1 1---  even parity
000- ----  110 baud
001- ----  150 baud
010- ----  300 baud
011- ----  600 baud
100- ----  1200 baud
101- ----  2400 baud
110- ----  4800 baud
111- ----  9600 baud

For writing a character out to the port, the return value's lower 8 bits contain the same byte as passed as the data argument.

For reading a character from the port, the value of data is ignored, and the lower 8 bits of the return value contain the byte read. Also, the "timeout" bit in the upper 8 bits is used as an error indicator in this case (0=success, 1=error). If it indicates an error, you should call the "get port status" variant to get the detailed error bits.

Return Value

The return value is a sequence of bits that indicate the port status and, for cmd=0 and 3, the modem status. For read/write operations, the lower eight bits are the character read.

 
1111 1100 0000 0000
5432 1098 7654 3210  Meaning

---- ---- ---- ---1  CTS change
---- ---- ---- --1-  DSR change
---- ---- ---- -1--  ring change
---- ---- ---- 1---  carrier detect change
---- ---- ---1 ----  CTS present
---- ---- --1- ----  DSR present
---- ---- -1-- ----  ring present
---- ---- 1--- ----  carrier detect
---- ---1 ---- ----  data ready
---- --1- ---- ----  overrun error
---- -1-- ---- ----  parity error
---- 1--- ---- ----  framing error
---1 ---- ---- ----  break detected
--1- ---- ---- ----  transmit holding register empty
-1-- ---- ---- ----  transmit shift register empty
1--- ---- ---- ----  time out (=1 if error present for cmd=1,2)

Portability

ANSI/ISO C No
POSIX No

Example

 
bioscom(0, 0xe3, 0); /* 9600 baud, no parity, one stop, 8 bits */
for (i=0; buf[i]; i++)
  bioscom(1, buf[i], 0);


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004