Ok, I just played around with this a bit... (never had used the module before).

It seems you can ignore the "uninitialized value" warning. It originates from accessing $this->{DATA}{DEVICE} in Device::ParallelPort::drv::linux::init(), where the hash entry DEVICE is undefined — which isn't too surprising, as it isn't being set anywhere in the entire code (and AFAICT you can't set it by passing some value to the constructor, or some such). And when you dig a bit into the XS code, you'll find that it should be a device name (string). OTOH, that name is only ever being used in an error message you'd see in case the device initialisation should fail...

Anyhow, to get rid of the "uninitialized value", you could add

sub init { my ($this, $str, @params) = @_; $this->{DATA}{DEVICE} = "lp0"; # <--- $this->{DATA}{BASE} = linux_opendev($this->{DATA}{DEVICE}); ...

to the init() routine in Device/ParallelPort/drv/linux.pm  (the base address of lp0 (i.e. 0x378) is hardcoded anyway).

Other than that, the module seems to work here (I am using the USB parallel port device), i.e. with the following test code

#!/usr/bin/perl -w use Device::ParallelPort; my $port = Device::ParallelPort->new('linux'); if($port){ $port->set_data(chr(0)); $port->set_control(chr(0)); show("Data", $port->get_data()); show("Control", $port->get_control()); show("Status", $port->get_status()); print "set bit 0 to 0\n"; $port->set_bit(0, 0); printf "read bit 0: %d\n", $port->get_bit(0); print "set bit 0 to 1\n"; $port->set_bit(0, 1); printf "read bit 0: %d\n", $port->get_bit(0); print "set bit 0 to 0\n"; $port->set_bit(0, 0); printf "read bit 0: %d\n", $port->get_bit(0); print "set bit 2 to 1\n"; $port->set_bit(2, 1); printf "read bit 2: %d\n", $port->get_bit(2); show("Data", $port->get_data()); print "set data 'a' (0x61 01100001)\n"; $port->set_data('a'); show("Data", $port->get_data()); print "set control 4 (bit 2)\n"; $port->set_control(chr(4)); show("Control", $port->get_control()); show("Status", $port->get_status()); } else { die "Errore sul driver\n"; } sub show { my $portname = shift; my $val = ord shift; printf "%-13s %02x %08b\n", "$portname port:", $val, $val; }

I do get

Data port: 00 00000000 Control port: c0 11000000 Status port: 7f 01111111 set bit 0 to 0 read bit 0: 0 set bit 0 to 1 read bit 0: 1 set bit 0 to 0 read bit 0: 0 set bit 2 to 1 read bit 2: 1 Data port: 04 00000100 set data 'a' (0x61 01100001) Data port: 61 01100001 set control 4 (bit 2) Control port: c4 11000100 Status port: 7f 01111111

which kinda makes sense... (the upper two bits of the control port apparently are static — at least with my hardware)


In reply to Re: use Perl With usblp Parallel Adapter by almut
in thread use Perl With usblp Parallel Adapter by Morzilla

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.