-
February 11th, 2005, 10:35 PM
#1
Parallel Port Programming
Hello guys !
Alright, let's go straight to the point from here.
I am having trouble figuring out how to control the parallel port and whether c++ can do the job ? My purpose is pretty simple, that is just to have the ability to switch on and off for 8 LEDs through a PC's Parallel port with a form of buttons of my own designed in microsoft windows XP.
I hope to get a thorough understanding of how many volt each tiny pin can produce or all about the parallel port.. Please guide me on where to start. And of course, the most importantly how to go about it. Thankyou
-
February 12th, 2005, 03:47 AM
#2
Re: Parallel Port Programming
The file input and output (I/O) functions ('CreateFile()', 'CloseHandle()', 'ReadFile()', 'ReadFileEx()', 'WriteFile()' and 'WriteFileEx()') provide the basic interface for opening and closing a communications resource handle and for performing read and write operations. Depending of what you are trying to do take also a look at the following functions...
Code:
// Parallel Device Callback Routines
USHORT *DetermineIeeeModes(IN PDEVICE_EXTENSION Extension)
NTSTATUS *IeeeFwdToRevMode(IN PDEVICE_EXTENSION Extension)
NTSTATUS *IeeeRevToFwdMode(IN PDEVICE_EXTENSION Extension)
NTSTATUS *NegotiateIeeeMode(IN PDEVICE_EXTENSION Extension,
IN USHORT ModeMaskFwd,
IN USHORT ModeMaskRev,
IN PARALLEL_SAFETY ModeSafety,
IN BOOLEAN IsForward)
NTSTATUS *ParallelRead(IN PDEVICE_EXTENSION Extension,
IN PVOID Buffer,
IN ULONG NumBytesToRead,
OUT PULONG NumBytesRead,
IN UCHAR Channel)
NTSTATUS *ParallelWrite(IN PDEVICE_EXTENSION Extension,
OUT PVOID Buffer,
IN ULONG NumBytesToWrite,
OUT PULONG NumBytesWritten,
IN UCHAR Channel)
NTSTATUS *TerminateIeeeMode(IN PDEVICE_EXTENSION Extension)
// Parallel Port Callback Routines
NTSTATUS *ClearChipMode(IN PDEVICE_EXTENSION Extension, IN UCHAR ChipMode)
NTSTATUS *DeselectDevice(IN PVOID Context, IN PVOID DeselectCommand)
VOID *FreePort(IN PVOID Context)
VOID *FreePortFromInterruptLevel(IN PVOID Context)
ULONG *QueryNumWaiters(IN PVOID Extension)
BOOLEAN *TryAllocatePort(IN PVOID Context)
BOOLEAN *TryAllocatePortAtInterruptLevel(IN PVOID Context)
NTSTATUS *TrySelectDevice(IN PVOID Context, IN PVOID TrySelectCommand)
NTSTATUS *TrySetChipMode(IN PDEVICE_EXTENSION Extension, IN UCHAR ChipMode)
All functions are coming from the Windows DDK (Driver Development Kit). For further information look within the MSDN (http:// msdn.microsoft.com)...
-
February 18th, 2005, 06:29 AM
#3
Re: Parallel Port Programming
Hi, this is my first post here, so hello everybody.
I am having the same trouble, which I haven't been able to solve. I tried some drivers, but they only work if I have admin rights (Im using Win2k, and developing under Buidler C++). I can make the user to install my app with admin rights (just once), but then my app has to run without admin rigths. I dont know very much about Windows driver's programming, so I am looking for a easy solution (I think I can't write a driver by my own.) In fact, if I run my app as admin, then close session (not reboot) and run my app as user it works. It seems that the driver is loaded.
The functions CreateFile(), WriteFile(), etc.. works fine if I specify \\\\.\\LPTx, but they try to print data!, while I just want to write/read some data to port.
I would very very gratefull if someone can help me with a driver or something which can work both with or without admin rights.
Thanks in advance!
Greetings from Argentina...
P/D: sorry about my english!
-
March 17th, 2005, 12:50 PM
#4
Re: Parallel Port Programming
The code to output voltage to the parallel port in C is:
#include <conio.h>
main
{
outp(0x378, 255);
//or
outportb(0x378, 255);
}
the binary of 255 is 11111111, which means pins 2-9 will output.
you can turn them off with 0, or turn just pin 2 on with 1, or just pin 9 on with 128.
You can use a 470 ohm resistor and led from pin 2 to 9, grounded to all pins 18 to 25.
Search Parallel Port Programming in Google
-
March 18th, 2005, 08:54 AM
#5
Re: Parallel Port Programming
JRoger, your code only works under Win9X, but not any NT platform (NT, 2000, XP) as those Windows doesn't let you direct access to parallel ports (among other things).
Regards,
-
June 20th, 2005, 03:21 AM
#6
Re: Parallel Port Programming
-
April 1st, 2006, 02:25 AM
#7
Re: Parallel Port Programming
If you're still looking for a solution for Win2k \ WinXP I'm looking into it at the moment and hopefully will have a driver\dll\testapp.
-
April 2nd, 2006, 10:49 AM
#8
Re: Parallel Port Programming
If You have some basic knowleges of w2k driver development, I think the example "PPort" from w2kdriverbook will help You:
http://www.w2kdriverbook.com/downloads/Chap8/pport.zip
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|