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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controlling Computers LPT port with Perl

Status
Not open for further replies.

Saeeka

Programmer
Joined
Jun 1, 2001
Messages
3
Location
CA
I am looking for a way to control the computers LPT(Printer) port witha Perl program. I have successfully done this with Pascal and C++ But cannot find how to do it with Perl.
 
(Standard answer) Check out the Comprehensive Perl Archive Network at They have modules there to do almost anything you might need.
Tracy Dryden
tracy@bydisn.com

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
My knowledge on Perl is somewhat limited. I am still learning. I looked through that site but did not find anything I could use. I am looking more of a sample perl script I can learn from. I want to be able to control all of the parallel ports inputs and outputs.
 
i don't actually know how to do this myself, but it's likely part of the cpan modules for your OS (or maybe in the POSIX module?).
or, if you post some of the C++ code to do this, we could maybe be able to give you the perl equivelant). "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
 
I am not actually too good with C++ so this is code I have gotten out of a book to control one output from the LPT port.

/* Program ssr_demo */

#include <dos.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#include <bios.h>
#include &quot;My_TPU.h&quot;

void main() //SSR_DEMO
{
int A;

fprintf(stdprn,&quot;\x00&quot;); // set all parrallel port bites low
for(A = 1;A <=150;A++)
{
// turn solid state relay off
fprint(stdprn,&quot;\x01&quot;); delay(500);
// turn bit 3, OFF, binary=00000000
fprintf(stdprn,&quot;\x00); delay(500);
// turn bit 3, ON, binary=00000100
}
}

thank you for your help
 
hmm, well, that helped me less than i thought it would. i know how to do this in *nix - basically you can just open up a pipe/filehandle to the actual printer (located somewhere in the /dev hirearchy), and 'print' to that filehandle.
however, looking at your code, i notice you're not working in *nix, you're working in dos/windows. i would suggest looking through the documentation for the various perl modules for windows (Win32 and Win32API) that are likely already on your system (assuming you're using a windows distribution of perl(activestate)). one of them is bound to have the information you need.

sorry i can't be of any more help... &quot;If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top