Posted on 2008-02-10 16:44:08-08 by berni
set- reset of direction bit in control register
Hello there, 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. Does somebody know, what i'm doing wrong ? Thanks in advance Bernd
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.