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

x
?
Solved

Interfacing the LPT-port using C++ under WinNT

Posted on 2003-03-21
5
Medium Priority
?
896 Views
Last Modified: 2008-01-16
Hi,
I have made a digital circuit which I want to test using the parallel port (instead of a microcontroller). I thought this was very simple, bus I discovered "_outp" does not work under WinNT. Then I found some alternatives:
- use a VxD (???)
- use a device driver (where do I get such a driver and how to use it?)
- use CreateFile("LPT1", .....) en WriteFile() (how?)
What is the best way to send some bits to the 8 datapins on the LPT-port in Visual C++ (Win32 Console App)?
I am just a beginner in C-programming, so keep it easy ;-)

Hope you can help me.
Svens.
0
Comment
Question by:Svens
[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
5 Comments
 

Expert Comment

by:Leo71
ID: 8180508
I think CreateFile is the best, because it works from Win95 till WinXP and you don't need extra drivers (which is always a problem if you give the programm out of your hands).
Also with Createfile you can just use another device (eg. serial port or even TCP) with very little codechanges but i guess that's irrelevant for you :).

Regards
Leo
0
 

Expert Comment

by:johanhz
ID: 8180595
It is not possible in NT (and XP,2000) to access hardware directly on the user level. You can write a device driver to access the hardware, but for the parallel port others did allready do the job.

Have a look at http://www.lvr.com/parport.htm

You will also find a link to freeware drivers to access the parallel port directly ...

JOHan.
0
 
LVL 1

Accepted Solution

by:
ivec earned 600 total points
ID: 8181375
You need a 3rd-party driver on WinNT.
For parallel port access, the free DriverLINX port I/O driver is very easy to install and use.
You can find it at:

  http://www.driverlinx.com/DownLoad/dnload.htm#Windows 95/NT Port I/O Driver

I used it for several projects, under NT/Win2000/XP/etc, without encountering any problem.

You just need to use a provided function call instead of directly reading/writing to an address.
0
 

Expert Comment

by:Leo71
ID: 8183018
Yes, that's what I forgot to say: Using the driver is easier than struggling with the functions yourself.
Probably the driver is only a wrapper that translates an easy to use interface to the windows functions. Alone the fact that such drivers exist proofs, that it's not so much fun doing it yourself. Nevertheless you learn a lot and have the highest level of control, if you use CreateFile ;-).
If you don't need full control (asynchronous acess, change standard timings/timeouts our some other crazy stuff) using a driver is the quickest way to implement something.

@johanhz:
That's really a nice link! :)

Regards
Leo
0
 

Author Comment

by:Svens
ID: 8244596
This is really the link I needed: It was very simple to me to install and use the software.

Thanx!
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little 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 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.

704 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