Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using Parallel Port for Switch Input

Posted on 1998-08-02
2
Medium Priority
?
409 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 600 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Healthcare organizations in the United States must adhere to the guidance of both the HIPAA (Health Insurance Portability and Accountability Act) and HITECH (Health Information Technology for Economic and Clinical Health Act) for securing and protec…
This month, Experts Exchange’s free Course of the Month is focused on CompTIA IT Fundamentals.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

705 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