Thursday, February 19, 2015

Learning C Functions :bioscom ( Dos Only )

C Programming :
Function :
bioscom

Syntax

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

Description

bioscom performs various RS-232 communications over the I/O port given in port.
A port value of 0 corresponds to COM1, 1 corresponds to COM2, and so forth.
The value of cmd can be one of the following:

Value    Meaning

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

0x02    7 data bits    0x00    110 baud
0x03    8 data bits    0x20    150 baud
        0x40    300 baud
0x00    1 stop bit    0x60    600 baud
0x04    2 stop bits    0x80     1200 baud
0x00    No parity    0xA0    2400 baud
0x08    Odd parity    0xC0     4800 baud
0x18    Even parity    0xE0     9600 baud

For example, a value of 0xEB (0xE0|0x08|0x00|0x03) 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 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



No comments:

Post a Comment