.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" 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 .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . 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::Bus 3pm" .TH Device::USB::Bus 3pm 2024-03-07 "perl v5.38.2" "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::Bus \- Use libusb to access USB devices. .SH VERSION .IX Header "VERSION" Version 0.38 .SH SYNOPSIS .IX Header "SYNOPSIS" This class encapsulates the USB bus structure and provides methods for retrieving data from it. This class is not meant to be used alone, it is part of the Device::USB package. .PP Device:USB:LibUSB provides a Perl wrapper around the libusb library. This supports Perl code controlling and accessing USB devices. .PP .Vb 1 \& use Device::USB; \& \& my $usb = Device::USB\->new(); \& \& foreach my $bus ($usb\->list_busses()) \& { \& print $bus\->dirname(), ":\en"; \& foreach my $dev ($bus\->devices()) \& { \& print "\et", $dev\->filename(), "\en"; \& } \& } .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This module provides a Perl interface to the bus structures returned by the libusb library. This library supports a read-only interface to the data libusb returns about a USB bus. .SH FUNCTIONS .IX Header "FUNCTIONS" .IP dirname 4 .IX Item "dirname" Return the directory name associated with this bus. .IP location 4 .IX Item "location" Return the location value associated with this bus. .IP devices 4 .IX Item "devices" In array context, it returns a list of Device::USB::Device objects representing all of the devices on this bus. In scalar context, it returns a reference to that array. .IP find_device_if 4 .IX Item "find_device_if" Find a particular USB 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_if This method provides a 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." 4 .IX Item "list_devices_if This method provides a 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 .PD 0 .IP pred 4 .IX Item "pred" .PD coderef to test devices. .RE .RS 4 .Sp For example, .Sp .Vb 3 \& my @devices = $bus\->list_devices_if( \& sub { Device::USB::CLASS_HUB == $_\->bDeviceClass() } \& ); .Ve .Sp Returns all USB hubs found on this bus. The device to test is available to the coderef in the \f(CW$_\fR variable for simplicity. .RE .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 and Device::USB, 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 .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 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 also go to Josep Monés Teixidor, Mike McCauley, and Tony Awtrey for spotting, reporting, and (sometimes) fixing bugs. .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.