@node bioscom, bios @subheading Syntax @example #include int bioscom(int cmd, char data, int port); @end example @subheading Description This function accesses the BIOS interrupt 0x14 function, serial communication services. @code{port} should be the COM port (0=COM1, 1=COM2, etc). The valid values of cmd are: @table @asis @item 0 - initialize com port (@var{data} is the settings) @item 1 - write byte to port @item 2 - read byte from port (@var{data} is ignored) @item 3 - get port status @item @end table For initialization, the byte is made up of the following bits: @example 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 @end example For writing a character out to the port, the return value's lower 8 bits contain the same byte as passed as the @var{data} argument. For reading a character from the port, the value of @var{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. @subheading 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. @example 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) @end example @subheading Portability @portability !ansi, !posix @subheading Example @example bioscom(0, 0xe3, 0); /* 9600 baud, no parity, one stop, 8 bits */ for (i=0; buf[i]; i++) bioscom(1, buf[i], 0); @end example