Solved

Using Parallel Port for Switch Input

Posted on 1998-08-02
2
400 Views
Last Modified: 2013-11-15
Hi,
I'm trying to read switch input from the parallel port and am having trouble getting the input.  I've opened the port using FILE streams on "PRN", and also tried to read from the port with _inp(), but I don't seem to be able to read any changes on the port when I activate the switch.  I also havn't been able to verify that I've actually read the port since the uninitialized data in the buffer was not overwritten by the call to the read functions.  This also might not be a programming problem, but a hardware problem.  Right now, I'm just making connection between pins 2-9 and pin 25 trying to see a change on the port, but I'm not seeing it.  Any suggestions on how to do this.  Thanks.
Mark
0
Comment
Question by:mustang070597
2 Comments
 

Author Comment

by:mustang070597
ID: 1169222
P.S. I forgot to mention that I'm working in Windows 95/98, and using Visual C++ 4.2.
0
 
LVL 2

Accepted Solution

by:
warmcat earned 150 total points
ID: 1169223
musty -

Parallel ports come in ''standard'', ''bidirectional'', and ''EPP/ECP'' flavours.  You can only count on any particular PC meeting the ''standard''.. uh.. standard.

This has the data lines on p2..p9 as *output only*, so that's why you're not getting any joy there.

Opening a FILE * to PRN is a loser too.... think about it... what consititutes a ''character'' if you are hoping to detect one bit changing at a time?

Instead, you should wire your switch to pin10, pin11, pin12, pin13 or pin15.  You can pick up the states of these lines on _inp(wBaseAds+1), where wBaseAds is 0x378 or 0x278 for LPT1 or 2 (see http://warmcat.com/parallel for a better way to get base addresses and more detail).

The readback information:

b7 is ~pin11  (~ indicates inverted logic)
b6 is pin10
b5 is pin12
b4 is pin13
b3 is pin15

-Andy
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In our personal lives, we have well-designed consumer apps to delight us and make even the most complex transactions simple. Many enterprise applications, however, are a bit behind the times. For an enterprise app to be successful in today's tech wo…
Skype is a P2P (Peer to Peer) instant messaging and VOIP (Voice over IP) service – as well as a whole lot more.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now