Device::USB(3pm) | User Contributed Perl Documentation | Device::USB(3pm) |
Device::USB - Use libusb to access USB devices. (DEPRECATED)
Version 0.38
Device::USB has now been superceded by USB::LibUSB <https://metacpan.org/pod/USB::LibUSB>, which supports the v1.0 libusb API.
Device::USB provides a Perl wrapper around the libusb library. This supports Perl code controlling and accessing USB devices.
use Device::USB; my $usb = Device::USB->new(); my $dev = $usb->find_device( $VENDOR, $PRODUCT ); printf "Device: %04X:%04X\n", $dev->idVendor(), $dev->idProduct(); $dev->open(); print "Manufactured by ", $dev->manufacturer(), "\n", " Product: ", $dev->product(), "\n"; $dev->set_configuration( $CFG ); $dev->control_msg( @params ); ...
See the libusb manual for more information about most of the methods. The functionality is generally the same as the libusb function whose name is the method name prepended with "usb_".
This module is deprecated as of version 0.38. I have not had the time or need to update the module, and no one has been willing to take it over.
This module provides a Perl interface to the C library libusb. This library supports a relatively full set of functionality to access a USB device. In addition to the libusb functionality Device::USB provides a few convenience features that are intended to produce a more Perl-ish interface.
These features include:
This class provides an interface to the non-bus and non-device specific functions of the libusb library. In particular, it provides interfaces to find busses and devices. It also provides convenience methods that simplify some of the tasks above.
This class provides a set of constants for the defined device classes. The constants defined at this time are:
Any other values are forced to the nearest endpoint.
returns a device reference or undef if none was found.
returns a device reference or undef if none was found.
returns a list of devices matching the supplied criteria or a reference to that array in scalar context
For example,
my @devices = $usb->list_devices_if( sub { Device::USB::CLASS_HUB == $_->bDeviceClass() } );
Returns all USB hubs found. The device to test is available to the coderef in the $_ variable for simplicity.
By using this function, you do not need to do the find_* calls yourself.
returns a reference to an array of busses.
Before calling this function, remember to call find_busses and find_devices.
returns a reference to an array of busses.
The raw api of the libusb library is also :
Before calling this function, remember to call find_busses and find_devices.
returns a reference to an array of busses.
By using this function, you do not need to do the find_* calls yourself.
returns a reference to an array of busses.
vendor - the vendor id product - product id for that vendor
returns a pointer to the device if it is found, NULL otherwise.
This is an explanation of the diagnostic and error messages this module can generate.
This module depends on the Carp, Inline and Inline::C modules, as well as the strict and warnings pragmas. Obviously, libusb must be available since that is the entire reason for the module's existence.
G. Wade Johnson (gwadej at cpan dot org) Paul Archer (paul at paularcher dot org)
Houston Perl Mongers Group
Original author: David Davis
Please report any bugs or feature requests to "bug-device-usb@rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Device::USB>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
The project is hosted at github <https://github.com/gwadej/perl-device-usb/>. More information on the project, including installation help is available on the Wiki.
So far, this module has only been tested on Linux. It should work on any OS that supports the libusb library. Several people have reported problems compiling the module on Windows. In theory, it should be possible to make the library work with LibUsb-Win32 <http://libusb-win32.sourceforge.net/>. Without access to a Windows development system, I can't make those changes.
The Interfaces and Endpoints are not yet proper objects. The code to extract this information is not yet written.
Thanks go to various members of the Houston Perl Mongers group for input on the module. But thanks mostly go to Paul Archer who proposed the project and helped with the development.
Thanks to Josep Monés Teixidor for fixing the "bInterfaceClass" bug.
Thanks to Mike McCauley for support of "usb_get_driver_np" and "usb_detach_kernel_driver_np".
Thanks to Vadim Mikhailov for fixing a compile problem with VC6 on Windows and then chipping in again for VS 2005 on Windows, and yet again to fix warnings on C99-compliant compilers.
Thanks to John R. Hogheruis for information about modifying the Inline parameters for compiling with Strawberry Perl on Windows.
Thanks to Tony Shadwick for helping me resolve a problem with bulk_read and interrupt_read.
Copyright 2006-2013 Houston Perl Mongers
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
2020-11-08 | perl v5.32.0 |