Skip to main content
gamedev.net
🔒 Locked

Controlling Parallel port(Windows)

Started by Sand_Hawk Jan 6, 2003 at 2:18 PM 6 replies 700+ views
Original Post
Sand_Hawk
Sand_Hawk
I want to control my parallel port under Windows 2000. I have a couple of LED''s connected to my parallel port. Is there some kind of DLL/header/lib which I can use to write data to my parallel port in Windows 2000? I don''t have time to write my own library so I was wondering if there are any ready to use. Sand Hawk ---------------- -Earth is 98% full. Please delete anybody you can.
My Site
----------------(Inspired by Pouya)
LessBread
LessBread
Check out WinIO.



"Beautiful maiden," answered Candide, "when a man is in love, is jealous, and has been flogged by the Inquisition, he becomes lost to all reflection."
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
DefCom
DefCom
This page covered enough stuff for me to attach a number of LEDs,

http://www.doc.ic.ac.uk/~ih/doc/par/

I can not remember if my first attempt was in Borland builder 5 or VC6, but it didn't work, so i went back to an ancient copy of turbo C++ and that worked fine.

PS. Sorry this was win98 not 2000, i havn't tried 2000.



[edited by - Defcom on January 7, 2003 3:37:01 AM]
DefCom
DefCom
While we are on this topic, does anyone know how to r/w pins of the parallel port using java?
Dwiel
Dwiel
I am working on a parrallel port project right now for my physics teacher. It's a lot more complex than lighting LEDS... it's for turning on/off and setting a cosmic ray detector, but anyway.. I think I have all of your answers!

direct access to the parrallell port does not exist in XP due to microsoft. I know that you can directly access the PP in 98 and not to sure about 2000, but if I had to guess I'd say that it doesn't.

try looking at this code... (MSVC 6.0)


          
#define BASE_ADDRESS 0x0378 // printer port base address


// the first bit of states correspondes to the new state of LED #1

// the second bit of states correspondes to the new state of LED #2

// the third bit of states correspondes to the new state of LED #3

//...

void ChangeLEDStates(char states)
{
_outp(BASE_ADDRESS, data); // change some states

}


If you want the pin #s you need to connect to for this to work, just let me know!

[edited by - tazzel3d on January 8, 2003 8:51:49 PM]
Sand_Hawk
Sand_Hawk
I already got it to work. I downloaded the WinIO module and it works excellent. Thanks to this module I can directly access the ports under Windows 9x or NT based kernels. Calling the init function of the DLL grants me access to the ports under Windows 2K using either the standard _outp functions or the functions belonging to the module. After doing a little searching over at www.hardwarebook.net I found which pins are used for what.

So, I am done with trying to access it. Now it''s time to write some software

Sand Hawk

----------------
-Earth is 98% full. Please delete anybody you can.


My Site
----------------(Inspired by Pouya)
Shannon Barber
Shannon Barber
quote:
Original post by DefCom
While we are on this topic, does anyone know how to r/w pins of the parallel port using java?


Very funny
The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
LessBread
LessBread
quote:
Original post by Sand_Hawk
I already got it to work. I downloaded the WinIO module and it works excellent. Thanks to this module I can directly access the ports under Windows 9x or NT based kernels. Calling the init function of the DLL grants me access to the ports under Windows 2K using either the standard _outp functions or the functions belonging to the module. After doing a little searching over at www.hardwarebook.net I found which pins are used for what.
So, I am done with trying to access it. Now it''s time to write some software



Cool, now get to it!

To recap for others. Direct hardware access requires ring0 access. User programs run at ring3. These "rings" are part of the cpu, not the os. Under Windows a program that runs at ring0 is said to be running in "kernel mode" and for ring3, "user mode". Under Win9x there are several methods of gaining ring0 access from ring3 code. These methods do not work on NT/2K/XP. This include using "_outp". Instead one must use a driver or a go between module such as WinIO.

Accessing hardware through Java isn''t impossible, but it''s not easy either. You''ll need to write a bridge between the WinIO dll and java using JINI, iirc.





"Beautiful maiden," answered Candide, "when a man is in love, is jealous, and has been flogged by the Inquisition, he becomes lost to all reflection."
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.