Solved

Using Parallel Port for Switch Input

Posted on 1998-08-02
2
407 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HTTPSendRequest with WinINet delays on first call 11 119
Outlook 13 100
Need help with software deployments 3 89
JQuery on multiple lines 3 47
This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

734 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