Advertisement

COM and LPT port

Started by December 26, 2000 08:42 AM
13 comments, last by SKSlayer 23 years, 10 months ago
how can I do it it with non windows libs
(you can find me on IRC : #opengl on undernet)
Hi. I don''t know anything about com port but I know about the parallel port. I''ve written a software which write to the lpt port for a school projects.

_outp works in win32 program written with visual c++.

Let''s suppose you want to write to the data byte of the parallel port, all you have to do is use this function:
_outp(adress of the byte in memory, value)

example
//usual adresses of lpt1 port
#define DATA 0x378
#define STATUS DATA+1
#define CONTROL DATA+2

...

_outp(DATA, y);

reading the port is similar. More information on the parallel port programming is easy to find on the net.
Advertisement
But, what the func to input ?
(you can find me on IRC : #opengl on undernet)
_outp(port, value); is for output
int _inp( unsigned short port ); is for input

you need to include

they are equivalent to inportb, outportb that brettporter talked about (at first I used DJGPP before switching to VC++).

You can''t input from all the wires I think. I think it''s only possible to input from the wires connected to the control byte of the parallel port (address 0x37A if I remember).

If i''m not mistaken, you can only use 5 wires for input so using the parallel port for input could be a problem if you have to send more than 5 bits of information to receive. (for my school projects, because of hardware constraints, I could only use 2 wires to communicate with the hardware, so I had to send the information in serial. Not funny)

So, for example. Let''s suppose you want to know if the third bit of the control byte is HIGH or LOW, you should do something like this I think (it might not be 100% correct):

int y;

y = _inp( 0x37A );

if (y &100)
MessageBox("third bit is High");
else
MessageBox("third bit is Low");

Links you might find interesting:
http://www.beyondlogic.org/spp/parallel.htm
http://www.lvr.com/parport.htm
http://www.lvr.com/jansfaq.htm
http://www.phanderson.com/PIC/PICC/pic_c_routines.html

Wow! This really looks like a lot of fun. I couldn''t only imagine what I can do with it.

---------------------------
"the only thing I ask, is that if my games get pirated, people must do a good job of it." - Erick

This topic is closed to new replies.

Advertisement