Subject: | possible bug: set / reset direction bit in control register |
Date: | Wed, 13 Feb 2008 18:01:04 +0100 |
To: | bug-Device-ParallelPort [...] rt.cpan.org |
From: | Bernd Abele <babele [...] t-online.de> |
Hello Scott,
when i'm executing following script
use Device::ParallelPort;
my $port = Device::ParallelPort->new('auto:1');
print ord($port->get_byte(0))."\n";
$port->set_byte(0,chr(0));
print ord($port->get_byte(0))."\n";
&set_DIR('r');
print ord($port->get_byte(0))."\n";
&set_DIR('w');
$port->set_byte(0,chr(0));
print ord($port->get_byte(0))."\n";
$port->set_byte(0,chr(0));
print ord($port->get_byte(0))."\n";
sub set_DIR{
if ($_[0] eq 'r'){
print "r\n";
$port->set_bit(21,1); #read
print ord($port->get_byte(2))."\n";
}elsif ($_[0] eq 'w'){
print "w\n";
$port->set_bit(21,0); #write
print ord($port->get_byte(2))."\n";
}
}
i'm getting following result:
0
0
r
12
255
w
12
255
255
but i'm expecting that, when i'm writing a "0" to the data register in write
mode, that i will also get back a "0" after reading the data register. But
this result looks like that, if the parallel port once is set in read mode,
it's not possible to switch back to the write mode.
if tested this script with an PCI parallelport controller from moschip with
the MCS9815 on it, i've also tested the script with my controller on my
mainboard (ASRock) and i've achieved the same result.
Checking the datasheet of the MCS9815 shows the direction of the parallel port
can only be switched by setting or resetting the bit 5 of the control
register.
I'm running Debian etch on my calculator as an addit. information of my HW/SW
configuration.
Might be i'm only a little bit stupid and not able to see the failure
Thanks in advance
Bernd