.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Device::USB 3pm" .TH Device::USB 3pm "2018-11-01" "perl v5.28.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Device::USB \- Use libusb to access USB devices. (DEPRECATED) .SH "VERSION" .IX Header "VERSION" Version 0.37 .SH "SYNOPSIS" .IX Header "SYNOPSIS" Device::USB provides a Perl wrapper around the libusb library. This supports Perl code controlling and accessing \s-1USB\s0 devices. .PP .Vb 1 \& use Device::USB; \& \& my $usb = Device::USB\->new(); \& my $dev = $usb\->find_device( $VENDOR, $PRODUCT ); \& \& printf "Device: %04X:%04X\en", $dev\->idVendor(), $dev\->idProduct(); \& $dev\->open(); \& print "Manufactured by ", $dev\->manufacturer(), "\en", \& " Product: ", $dev\->product(), "\en"; \& \& $dev\->set_configuration( $CFG ); \& $dev\->control_msg( @params ); \& ... .Ve .PP 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 \*(L"usb_\*(R". .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module is deprecated as of version 0.37. I have not had the time or need to update the module, and no one has been willing to take it over. .PP This module provides a Perl interface to the C library libusb. This library supports a relatively full set of functionality to access a \s-1USB\s0 device. In addition to the libusb, functioality, Device::USB provides a few convenience features that are intended to produce a more Perl-ish interface. .PP These features include: .IP "\(bu" 4 Using the library initializes it, no need to call the underlying usb_init function. .IP "\(bu" 4 Object interface reduces namespace pollution and provides a better interface to the library. .IP "\(bu" 4 The find_device method finds the device associated with a vendor id and product id and creates an appropriate Device::USB::Device object to manipulate the \s-1USB\s0 device. .IP "\(bu" 4 Object interfaces to the bus and device data structures allowing read access to information about each. .SH "Device::USB" .IX Header "Device::USB" 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. .SS "\s-1CONSTANTS\s0" .IX Subsection "CONSTANTS" This class provides a set of constants for the defined device classes. The constants defined at this time are: .IP "\(bu" 4 \&\s-1CLASS_PER_INSTANCE\s0 .IP "\(bu" 4 \&\s-1CLASS_AUDIO\s0 .IP "\(bu" 4 \&\s-1CLASS_COMM\s0 .IP "\(bu" 4 \&\s-1CLASS_HID\s0 .IP "\(bu" 4 \&\s-1CLASS_PRINTER\s0 .IP "\(bu" 4 \&\s-1CLASS_MASS_STORAGE\s0 .IP "\(bu" 4 \&\s-1CLASS_HUB\s0 .IP "\(bu" 4 \&\s-1CLASS_DATA\s0 .IP "\(bu" 4 \&\s-1CLASS_VENDOR_SPEC\s0 .SS "\s-1FUNCTIONS\s0" .IX Subsection "FUNCTIONS" .IP "new" 4 .IX Item "new" Create a new Device::USB object for accessing the library. .IP "debug_mode" 4 .IX Item "debug_mode" This class method enables low-level debugging messages from the library interface code. .RS 4 .IP "level" 4 .IX Item "level" 0 disables debugging, 1 enables some debug messages, and 2 enables verbose debug messages .Sp Any other values are forced to the nearest endpoint. .RE .RS 4 .RE .IP "find_busses" 4 .IX Item "find_busses" Returns the number of changes since previous call to the function: the number of busses added or removed. .IP "find_devices" 4 .IX Item "find_devices" Returns the number of changes since previous call to the function: the number of devices added or removed. Should be called after find_busses. .IP "find_device" 4 .IX Item "find_device" Find a particular \s-1USB\s0 device based on the vendor and product ids. If more than one device has the same product id from the same vendor, the first one found is returned. .RS 4 .IP "vendor" 4 .IX Item "vendor" the vendor id .IP "product" 4 .IX Item "product" product id for that vendor .RE .RS 4 .Sp returns a device reference or undef if none was found. .RE .IP "find_device_if" 4 .IX Item "find_device_if" Find a particular \s-1USB\s0 device based on the supplied predicate coderef. If more than one device would satisfy the predicate, the first one found is returned. .RS 4 .IP "pred" 4 .IX Item "pred" the predicate used to select a device .RE .RS 4 .Sp returns a device reference or undef if none was found. .RE .IP "list_devices" 4 .IX Item "list_devices" Find all devices matching a vendor id and optional product id. If called with no parameters, returns a list of all devices. If no product id is given, returns all devices found with the supplied vendor id. If a product id is given, returns all devices matching both the vendor id and product id. .RS 4 .IP "vendor" 4 .IX Item "vendor" the optional vendor id .IP "product" 4 .IX Item "product" optional product id for that vendor .RE .RS 4 .Sp returns a list of devices matching the supplied criteria or a reference to that array in scalar context .RE .IP "list_devices_if" 4 .IX Item "list_devices_if" This method provides a more flexible interface for finding devices. It takes a single coderef parameter that is used to test each discovered device. If the coderef returns a true value, the device is returned in the list of matching devices, otherwise it is not. .RS 4 .IP "pred" 4 .IX Item "pred" coderef to test devices. .RE .RS 4 .Sp For example, .Sp .Vb 3 \& my @devices = $usb\->list_devices_if( \& sub { Device::USB::CLASS_HUB == $_\->bDeviceClass() } \& ); .Ve .Sp Returns all \s-1USB\s0 hubs found. The device to test is available to the coderef in the \f(CW$_\fR variable for simplicity. .RE .IP "list_busses" 4 .IX Item "list_busses" Return the complete list of information after finding busses and devices. .Sp By using this function, you do not need to do the find_* calls yourself. .Sp returns a reference to an array of busses. .IP "get_busses" 4 .IX Item "get_busses" Return the complete list of information after finding busses and devices. .Sp Before calling this function, remember to call find_busses and find_devices. .Sp returns a reference to an array of busses. .SH "LIBRARY INTERFACE" .IX Header "LIBRARY INTERFACE" The raw api of the libusb library is also : .IP "\fBDeviceUSBDebugLevel()\fR" 4 .IX Item "DeviceUSBDebugLevel()" .PD 0 .IP "\fBlibusb_init()\fR" 4 .IX Item "libusb_init()" .IP "\fBlibusb_find_busses()\fR" 4 .IX Item "libusb_find_busses()" .IP "\fBlibusb_find_devices()\fR" 4 .IX Item "libusb_find_devices()" .IP "\fBlibusb_get_busses()\fR" 4 .IX Item "libusb_get_busses()" .IP "libusb_open(void *dev)" 4 .IX Item "libusb_open(void *dev)" .IP "libusb_close(void *dev)" 4 .IX Item "libusb_close(void *dev)" .IP "libusb_set_configuration(void *dev, int configuration)" 4 .IX Item "libusb_set_configuration(void *dev, int configuration)" .IP "libusb_set_altinterface(void *dev, int alternate)" 4 .IX Item "libusb_set_altinterface(void *dev, int alternate)" .IP "libusb_clear_halt(void *dev, unsigned int ep)" 4 .IX Item "libusb_clear_halt(void *dev, unsigned int ep)" .IP "libusb_reset(void *dev)" 4 .IX Item "libusb_reset(void *dev)" .IP "libusb_get_driver_np(void *dev, int interface, char *name, unsigned int namelen)" 4 .IX Item "libusb_get_driver_np(void *dev, int interface, char *name, unsigned int namelen)" .IP "libusb_detach_kernel_driver_np(void *dev, int interface)" 4 .IX Item "libusb_detach_kernel_driver_np(void *dev, int interface)" .IP "libusb_claim_interface(void *dev, int interface)" 4 .IX Item "libusb_claim_interface(void *dev, int interface)" .IP "libusb_release_interface(void *dev, int interface)" 4 .IX Item "libusb_release_interface(void *dev, int interface)" .IP "libusb_control_msg(void *dev, int requesttype, int request, int value, int index, char *bytes, int size, int timeout)" 4 .IX Item "libusb_control_msg(void *dev, int requesttype, int request, int value, int index, char *bytes, int size, int timeout)" .IP "libusb_get_string(void *dev, int index, int langid, char *buf, size_t buflen)" 4 .IX Item "libusb_get_string(void *dev, int index, int langid, char *buf, size_t buflen)" .IP "libusb_get_string_simple(void *dev, int index, char *buf, size_t buflen)" 4 .IX Item "libusb_get_string_simple(void *dev, int index, char *buf, size_t buflen)" .IP "libusb_get_descriptor(void *dev, unsigned char type, unsigned char index, char *buf, int size)" 4 .IX Item "libusb_get_descriptor(void *dev, unsigned char type, unsigned char index, char *buf, int size)" .IP "libusb_get_descriptor_by_endpoint(void *dev, int ep, unsigned char type, unsigned char index, char *buf, int size)" 4 .IX Item "libusb_get_descriptor_by_endpoint(void *dev, int ep, unsigned char type, unsigned char index, char *buf, int size)" .IP "libusb_bulk_write(void *dev, int ep, char *bytes, int size, int timeout)" 4 .IX Item "libusb_bulk_write(void *dev, int ep, char *bytes, int size, int timeout)" .IP "libusb_bulk_read(void *dev, int ep, char *bytes, int size, int timeout)" 4 .IX Item "libusb_bulk_read(void *dev, int ep, char *bytes, int size, int timeout)" .IP "libusb_interrupt_write(void *dev, int ep, char *bytes, int size, int timeout)" 4 .IX Item "libusb_interrupt_write(void *dev, int ep, char *bytes, int size, int timeout)" .IP "libusb_interrupt_read(void *dev, int ep, char *bytes, int size, int timeout)" 4 .IX Item "libusb_interrupt_read(void *dev, int ep, char *bytes, int size, int timeout)" .IP "\fBlib_get_usb_busses()\fR" 4 .IX Item "lib_get_usb_busses()" .PD Return the complete list of information after finding busses and devices. .Sp Before calling this function, remember to call find_busses and find_devices. .Sp returns a reference to an array of busses. .IP "\fBlib_list_busses()\fR" 4 .IX Item "lib_list_busses()" Return the complete list of information after finding busses and devices. .Sp By using this function, you do not need to do the find_* calls yourself. .Sp returns a reference to an array of busses. .IP "lib_find_usb_device( int vendor, int product )" 4 .IX Item "lib_find_usb_device( int vendor, int product )" Find a particular device .Sp .Vb 2 \& vendor \- the vendor id \& product \- product id for that vendor .Ve .Sp returns a pointer to the device if it is found, \s-1NULL\s0 otherwise. .IP "lib_debug_mode( int unsafe_level )" 4 .IX Item "lib_debug_mode( int unsafe_level )" Set debugging level: 0: off, 1: some messages, 2: verbose Values outside range are forced into range. .SH "DIAGNOSTICS" .IX Header "DIAGNOSTICS" This is an explanation of the diagnostic and error messages this module can generate. .SH "DEPENDENCIES" .IX Header "DEPENDENCIES" 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. .SH "AUTHOR" .IX Header "AUTHOR" G. Wade Johnson (gwadej at cpan dot org) Paul Archer (paul at paularcher dot org) .PP Houston Perl Mongers Group .PP Original author: David Davis .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests to \&\f(CW\*(C`bug\-device\-usb@rt.cpan.org\*(C'\fR, or through the web interface at . I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. .SH "FOR MORE INFORMATION" .IX Header "FOR MORE INFORMATION" The project is hosted at github . More information on the project, including installation help is available on the Wiki. .SH "LIMITATIONS" .IX Header "LIMITATIONS" So far, this module has only been tested on Linux. It should work on any \&\s-1OS\s0 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 . Without access to a Windows development system, I can't make those changes. .PP The Interfaces and Endpoints are not yet proper objects. The code to extract this information is not yet written. .SH "ACKNOWLEDGEMENTS" .IX Header "ACKNOWLEDGEMENTS" 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. .PP Thanks to Josep Monés Teixidor for fixing the \f(CW\*(C`bInterfaceClass\*(C'\fR bug. .PP Thanks to Mike McCauley for support of \f(CW\*(C`usb_get_driver_np\*(C'\fR and \&\f(CW\*(C`usb_detach_kernel_driver_np\*(C'\fR. .PP Thanks to Vadim Mikhailov for fixing a compile problem with \s-1VC6\s0 on Windows and then chipping in again for \s-1VS 2005\s0 on Windows, and yet again to fix warnings on C99\-compliant compilers. .PP Thanks to John R. Hogheruis for information about modifying the Inline parameters for compiling with Strawberry Perl on Windows. .PP Thanks to Tony Shadwick for helping me resolve a problem with bulk_read and interrupt_read. .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright 2006\-2013 Houston Perl Mongers .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.