I am trying read and write to/from a USB scanner to extend the functionality of sane a bit. I am able to view the device information and endpoints fairly easily with the following code:

my $usb = Device::USB->new(); my $dev = $usb->find_device( VENDOR, PRODUCT ); print Dumper $dev;

My problem is that I cannot quite figure out how to provide appropriate parameters for the interrupt_read, interrupt_write, bulk_read and bulk_write methods.

For example, the documentation for interrupt_write provides:

interrupt_write - Perform a interrupt write request to the specifi +ed endpoint. ep - The number of the endpoint to write bytes Buffer - Buffer from which to write the requested data. timeout - Maximum time to wait (in milliseconds)

Is 'ep' the full bEndpointAddress or just its lower 3 bits. How do I set up Buffer? Is that an array reference?

Could someone please provide some sample perl code that performs a read or write using Device::USB (or point me to a website)?

Thanks


In reply to Device::USB Read/Write by flbiggs

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.