1package Device::USB::DevEndpoint;
2
3require 5.006;
4use warnings;
5use strict;
6use Carp;
7
8=head1 Device::USB::DevEndpoint
9
10This class encapsulates a USB Device endpoint and the methods that object
11would support.
12
13=head1 NAME
14
15Device::USB::DevEndpoint - Access a device endpoint returned by libusb.
16
17=head1 VERSION
18
19Version 0.11
20
21=cut
22
23our $VERSION=0.11;
24
25=head1 SYNOPSIS
26
27Device::USB:DevEndpoint provides a Perl object for accessing an endpoint
28of an interface of a USB device using the libusb library.
29
30    use Device::USB;
31
32    my $usb = Device::USB->new();
33    my $dev = $usb->find_device( $VENDOR, $PRODUCT );
34
35    printf "Device: %04X:%04X\n", $dev->idVendor(), $dev->idProduct();
36    $dev->open();
37
38    my $cfg = $dev->config()->[0];
39    my $inter = $cfg->interfaces()->[0]->[0];
40    my $ep = $inter->endpoints()->[0];
41    print "Endpoint:", $inter->bEndpointAddress(),
42       " name: ", $dev->get_string_simple($iter->iInterface()), "\n";
43
44See USB specification for an explanation of the attributes of an
45endpoint.
46
47=head1 DESCRIPTION
48
49This module defines a Perl object that represents the data associated with
50a USB interface endpoint. The object provides read-only access to the
51important data associated with the endpoint.
52
53=head2 METHODS
54
55There are several accessor methods that return data from the interface.
56Each is named after the field that they return. These accessors include:
57
58=cut
59
60# I need to build a lot of accessors
61sub _make_descr_accessor
62{
63    my $name = shift;
64    ## no critic (ProhibitStringyEval)
65
66    return eval <<"EOE";
67sub $name
68        {
69            my \$self = shift;
70            return \$self->{$name};
71        }
72EOE
73}
74
75=over 4
76
77=item bEndpointAddress
78
79=item bmAttributes
80
81=item wMaxPacketSize
82
83=item bInterval
84
85=item bRefresh
86
87=item bSynchAddress
88
89=cut
90
91_make_descr_accessor( 'bEndpointAddress' );
92_make_descr_accessor( 'bmAttributes' );
93_make_descr_accessor( 'wMaxPacketSize' );
94_make_descr_accessor( 'bInterval' );
95_make_descr_accessor( 'bRefresh' );
96_make_descr_accessor( 'bSynchAddress' );
97
98=back
99
100=head1 DIAGNOSTICS
101
102This is an explanation of the diagnostic and error messages this module
103can generate.
104
105=head1 DEPENDENCIES
106
107This module depends on the Carp, Inline and Inline::C modules, as well as
108the strict and warnings pragmas. Obviously, libusb must be available since
109that is the entire reason for the module's existence.
110
111=head1 AUTHOR
112
113G. Wade Johnson (wade at anomaly dot org)
114Paul Archer (paul at paularcher dot org)
115
116Houston Perl Mongers Group
117
118=head1 BUGS
119
120Please report any bugs or feature requests to
121C<bug-device-usb@rt.cpan.org>, or through the web interface at
122L<http://rt.cpan.org/NoAuth/ReportBug.html?Device::USB>.
123I will be notified, and then you'll automatically be notified of progress on
124your bug as I make changes.
125
126=head1 ACKNOWLEDGEMENTS
127
128Thanks go to various members of the Houston Perl Mongers group for input
129on the module. But thanks mostly go to Paul Archer who proposed the project
130and helped with the development.
131
132=head1 COPYRIGHT & LICENSE
133
134Copyright 2006 Houston Perl Mongers
135
136This program is free software; you can redistribute it and/or modify it
137under the same terms as Perl itself.
138
139=cut
140
1411;
142