in reply to Re: use Perl With usblp Parallel Adapter
in thread use Perl With usblp Parallel Adapter

Thanks. I modified the Device::ParallelPort::drv::linux module, and in the init() function I added the code:
$this->{DATA}{DEVICE} = "lp0";
before the "linux_opendev" call, but the result is the same: I can't set (and probably get) the data bits (this is the result of your script almut):
Data port: ff 11111111 Control port: ff 11111111 Status port: ff 11111111 set bit 0 to 0 read bit 0: 1 set bit 0 to 1 read bit 0: 1 set bit 0 to 0 read bit 0: 1 set bit 2 to 1 read bit 2: 1 Bit 0: 1 Data port: ff 11111111 set data 'a' (0x61 01100001) Data port: ff 11111111 set control 4 (bit 2) Control port: ff 11111111 Status port: ff 11111111
I tried to change "lp0" in this->{DATA}{DEVICE} to "/dev/usb/lp0", but nothing changed... I think that my usb adapter is not so compatible with Linux or maybe it's not a really usb to parallel port adapter...

Replies are listed 'Best First'.
Re^3: use Perl With usblp Parallel Adapter
by almut (Canon) on Oct 04, 2009 at 12:31 UTC
    I tried to change "lp0" in this->{DATA}{DEVICE} to "/dev/usb/lp0", but nothing changed...

    As I said, that value is only ever being used in an error message. The purpose behind setting it was just to silence the warning...

    I think that my usb adapter is not so compatible with Linux or maybe it's not a really usb to parallel port adapter...

    Either that, or it isn't mapped to the I/O address 0x378 (which is hardcoded in Device::ParallelPort::drv::linux::linux_opendev() ).  The code in question is:

    ... base = 0x378; if (ioperm(base, LPSIZE, 1) < 0) { fprintf(stderr, "%s: ioperm:%s ", devname, strerror(errno) +); RETVAL = -1; } else { RETVAL = base; }

    ioperm(2) can only fail with

    EINVAL Invalid address(-range). EPERM The calling process has insufficient privilege. ENOMEM Out of memory. EIO This call is not supported (on PowerPC).

    In particular, no checks are being made that the address actually maps to the intended hardware device.

    You might want to check your dmesg output — mine, for example, says:

    [ 61.718702] parport_pc 00:0b: reported by Plug and Play ACPI [ 61.718797] parport0: PC-style at 0x378, irq 7 [PCSPP,TRISTATE] [ 63.870838] lp0: using parport0 (interrupt-driven).