Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 297
  • Last Modified:

input from parallel port

Hello! can anyone tell me what's wrong with my code?  It's supposed to get input from my parallel port.  I compiled it with turbo c++.  I'm using windows me.

#include <dos.h>
#include <iostream.h>

main()
{
for( unsigned int i = 0; i < 256; i++ )
  {
  int x = inportb( 0x379 );
  cout<<x<<" ****"<<'\n';
  sleep( 1 );
  }
}

the output i get is:

120 ****
120 ****
... and so on...

this happens even though I put one of the input pins into high logic( 5V ).  Can anyone tell me what's wrong?  thanks!
0
wirgeld23
Asked:
wirgeld23
1 Solution
 
MafaldaCommented:
LPT1 data is at 0x378 ....
0
 
wirgeld23Author Commented:
i thought 0x378(data port) was for output and 0x379(status port) was for input?...(0x37A for control port)
0
 
MafaldaCommented:
Yes, the status ports are designed for input...
Are you sure that you are accesing the active parallel port.
In some PCs 0x378 is LPT2, 0x278 is LPT3 ... and 0x3BC is LPT1
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
MafaldaCommented:
Also, a good book for you:
http://www.lvr.com/parprtib.htm
0
 
wirgeld23Author Commented:
i checked my parallel port address.  The i/o is in 378.  Does that mean I should use 378 even when inputting data?  By the way, what am I supposed to get when I use the inp function if I don't input anything?  and if I do input 5v in one of the input pins?
0
 
wirgeld23Author Commented:
ps.  my parallel port is set to EPP.  I read that you can input to pins 2-8( data pins ) in EPP.  I tried it but nothing happens.
0
 
Mayank SAssociate Director - Product EngineeringCommented:
I see that you've also posted the question under the 'Programming' section.

Please refer to:

http://www.experts-exchange.com/Programming/Q_20566532.html

where more comments have been posted for you.

Mayank.
0
 
tinchosCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

PAQ/Refund

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0
 
Computer101Commented:
PAQed, with points refunded (20)

Computer101
E-E Admin
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now