|
Posted by zentara on May 12, 2008, 2:17 pm
Please log in for more thread options
wrote:
>Hi, I've currently got a laptop running Ubuntu Server and Perl 5.8.8.
>I've installed the Device::ParallelPort module and I have it working
>fairly reliably with ouput. I can make it turn on an LED on some
>breadboard, etc.
>
>I am having problems with receiving input through the parallel port
>though. I really need to react to something happening. I currently
>have pin 12 (Paper-Out/Paper-End) connected to +5V through a switch.
>When I press the switch the bit should be set.
>
>Unfortunately I don't actually seem to get what I'm looking for at
>all. I'm having no end of trouble finding any example code using this
>module for anything but regular 8-pin output.
>
>Has anyone got any tips, bookmarks, or information at all about using
>this module for receiving input on the status pins?
>
>Any help would be greatly appreciated.
>
>Regards,
>Stuart.
Googling for "parallel port reading" will give some circuits and code
too. Remember to use optoisolators ...... one mistake with your
external circuits can blow out your port and/or motherboard.
Of course, you know that you must have your bios settings for the
parallel port serup for bi-directional transfer? There is ECP and EPP
settings, etc.
The perldoc states that you get status pins with get_status
and the pin looks like number 2 in the second row
1 - 2 Paper-Out - In - Status-5 - No
#untested
use Device::ParallelPort;
my $port = Device::ParallelPort->new();
while (1){
my $val = $port->get_status(5);
if ($val == 1){ print "PaperOut is on\n"; }
select( undef, undef, undef, 0.05); #delay
};
}
You might want to try different bios settings, to get input. You may
also try different numbers for the status.
If you havn't been usuing an optoisolater, you may have blown out
the circuits for that pin. Ouch!! All it takes is a tiny spark of
static.
zentara
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
|