Posted by Guadalupe E Ruiz/MATA1/MFG/KEMET/US on 2000-11-13
To read data or write data to a port, first you have to know the port number (ex. serial port com 1 = 0x3F8 & LPT1 0x378).
and program the baud rate, parity, stop bits only for the serial ports (com 1, 2...), for LPT you can send and read without
programing a value to the port.
Hope this Help!!!
In MsVisual C++ 6, you can use to send data to a port this function:
_outp, _outpw, _outpd
Output a byte(_outp), a word(_outpw), or a double word (_outpd) at a port.
int _outp( unsigned short port, int databyte );
unsigned short _outpw( unsigned short port, unsigned short dataword );
unsigned long _outpd( unsigned short port, unsigned long dataword );
Routine Required Header Compatibility
_outp <conio.h> Win 95
_outpw <conio.h> Win 95
_outpd <conio.h> Win 95
Return Value
The functions return the data output. There is no error return.
Parameters
port Port number
databyte, dataword Output values
Remarks
The _outp, _outpw, and _outpd functions write a byte, a word, and a double word, respectively, to the specified output port.
The port argument can be any unsigned integer in the range 0 ? 65,535; databyte can be any integer in the range 0 ? 255;
and dataword can be any value in the range of an integer, an unsigned short integer, and an unsigned long integer, respectively.
And to read data you can use this one:
_inp, _inpw, _inpd
Input a byte (_inp), a word (_inpw), or a double word (_inpd) from a port.
int _inp( unsigned short port );
unsigned short _inpw( unsigned short port );
unsigned long _inpd( unsigned short port );
Routine Required Header Compatibility
_inp <conio.h> Win 95
_inpw <conio.h> Win 95
_inpd <conio.h> Win 95
Return Value
The functions return the byte, word, or double word read from port. There is no error return.
Parameter
port Port number
Remarks
The _inp, _inpw, and _inpd functions read a byte, a word, and a double word, respectively, from the specified input port.
The input value can be any unsigned short integer in the range 0 ? 65,535.
Feel free to send me an e-mail if you have more questions on I/O using ports.
G. Ruiz
Equipment Enginner
Previous post | Next post | Timeline | Home