line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Device::USB::DevEndpoint; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.006; |
4
|
19
|
|
|
19
|
|
119
|
use warnings; |
|
19
|
|
|
|
|
39
|
|
|
19
|
|
|
|
|
547
|
|
5
|
19
|
|
|
19
|
|
107
|
use strict; |
|
19
|
|
|
|
|
37
|
|
|
19
|
|
|
|
|
568
|
|
6
|
19
|
|
|
19
|
|
104
|
use Carp; |
|
19
|
|
|
|
|
33
|
|
|
19
|
|
|
|
|
4052
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 Device::USB::DevEndpoint |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This class encapsulates a USB Device endpoint and the methods that object |
11
|
|
|
|
|
|
|
would support. |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Device::USB::DevEndpoint - Access a device endpoint returned by libusb. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Version 0.36 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION=0.36; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Device::USB:DevEndpoint provides a Perl object for accessing an endpoint |
28
|
|
|
|
|
|
|
of 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
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
See USB specification for an explanation of the attributes of an |
45
|
|
|
|
|
|
|
endpoint. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 DESCRIPTION |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
This module defines a Perl object that represents the data associated with |
50
|
|
|
|
|
|
|
a USB interface endpoint. The object provides read-only access to the |
51
|
|
|
|
|
|
|
important data associated with the endpoint. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 METHODS |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
There are several accessor methods that return data from the interface. |
56
|
|
|
|
|
|
|
Each is named after the field that they return. These accessors include: |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# I need to build a lot of accessors |
61
|
|
|
|
|
|
|
sub _make_descr_accessor |
62
|
|
|
|
|
|
|
{ |
63
|
114
|
|
|
114
|
|
179
|
my $name = shift; |
64
|
|
|
|
|
|
|
## no critic (ProhibitStringyEval) |
65
|
|
|
|
|
|
|
|
66
|
114
|
|
|
0
|
1
|
6561
|
return eval <<"EOE"; |
|
0
|
|
|
0
|
1
|
|
|
|
0
|
|
|
0
|
1
|
|
|
|
0
|
|
|
0
|
1
|
|
|
|
0
|
|
|
0
|
1
|
|
|
|
0
|
|
|
0
|
1
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub $name |
68
|
|
|
|
|
|
|
{ |
69
|
|
|
|
|
|
|
my \$self = shift; |
70
|
|
|
|
|
|
|
return \$self->{$name}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
EOE |
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
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This is an explanation of the diagnostic and error messages this module |
103
|
|
|
|
|
|
|
can generate. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This module depends on the Carp, Inline and Inline::C modules, as well as |
108
|
|
|
|
|
|
|
the strict and warnings pragmas. Obviously, libusb must be available since |
109
|
|
|
|
|
|
|
that is the entire reason for the module's existence. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 AUTHOR |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
G. Wade Johnson (gwadej at cpan dot org) |
114
|
|
|
|
|
|
|
Paul Archer (paul at paularcher dot org) |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Houston Perl Mongers Group |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 BUGS |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
121
|
|
|
|
|
|
|
C, or through the web interface at |
122
|
|
|
|
|
|
|
L. |
123
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
124
|
|
|
|
|
|
|
your bug as I make changes. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Thanks go to various members of the Houston Perl Mongers group for input |
129
|
|
|
|
|
|
|
on the module. But thanks mostly go to Paul Archer who proposed the project |
130
|
|
|
|
|
|
|
and helped with the development. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Copyright 2006-2013 Houston Perl Mongers |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
137
|
|
|
|
|
|
|
under the same terms as Perl itself. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
1; |