Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"parallel port"

Status
Not open for further replies.

macwill

Programmer
Dec 8, 2002
13
CA
Hello,
I am trying to write to the parallel port using perl but I am not sure what the syntax should be. please help...
advice, links, or any code would help
thanks
MAC
 
hi me again.
Please if anyone has any idea how...
I am thinking devices???
please help
 
This is probably platform dependent. In Win/DOS, I think you'd open a file thusly:
open(PARALLEL, ">LPT1") or die "$!";

In various Unices, you'd likely try something like the above, but instead of ">LPT1", you'd use ">/dev/(whatever)".

I want to think that I've tried this before, but if someone else has a better way, you'll want to listen to them.
 
I have one question if you don't mind...
would the syntax for sending a one (#1) be

open(PARALLEL, ">LPT1") or die "$!";
print PARALLEL 1;
close(PARALLEL);

???
thanks
 
Perl is very forgiving when it comes to using quotation marks around things. I try to err on the side of explicitness, so I would write

open(PARALLEL, ">LPT1") or die "$!";
print PARALLEL "1";
close(PARALLEL);

but if omitting the quotation marks does the job, go right ahead. If the question was how to direct output to a specific file, you are correct in the second line where you put the file handle after "print" without any commas or anything.

Something this method doesn't allow is reading back from the parallel port. If your parallel device returns any information, you'll want to open the port a different way.
 
Hi,
I have used the above code and it works. The only problem is once it sends the data the program frezes. basicaly its a button and when you click on it it sends a one to the parallel port but after that the program just frezes?? any ideas...

thanks
M.
By the way how would you read from the port???
Thnx
 
I'm not quite sure about that. It might be possible to open the parallel port twice - once for reading, and once for writing. I'll see if I can try that out today. If you have any success before I post, please post a reply.
 
Have a look at the Device::parallelPort module, it's available from
Mike
________________________________________________________________________________

"Experience is the comb that Nature gives us, after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top