usbutils 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/usbutils/version.rb +1 -1
- metadata +2 -4
- data/bin/usb-devices +0 -173
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 681938447947a87f3510d70f1843ced9e3a6bf03
|
4
|
+
data.tar.gz: bd5429e951be37350d1b96c884b15547e0bc421d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc1f8ecf28cb2ecee1a9505d49f807dd50473217f7df1e9d4bfa096c7c0ffd181542493df7abf0ed5664b2d8a322a3bf8d0c7cabcbc7456f5074227aca1ae5bc
|
7
|
+
data.tar.gz: 61e586ed8b37d1c668a3ca7fdb7244912ea60fcd47f2b5ab7fd3082ef6e7dff7f225872793c640fc09dc2249869fc636fa0ce53a22432c9164828d7a3b1b110e
|
data/lib/usbutils/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: usbutils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k-yamada
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,7 +70,6 @@ description: ''
|
|
70
70
|
email:
|
71
71
|
- yamadakazu45@gmail.com
|
72
72
|
executables:
|
73
|
-
- usb-devices
|
74
73
|
- usbutils
|
75
74
|
extensions: []
|
76
75
|
extra_rdoc_files: []
|
@@ -83,7 +82,6 @@ files:
|
|
83
82
|
- README.md
|
84
83
|
- Rakefile
|
85
84
|
- Vagrantfile
|
86
|
-
- bin/usb-devices
|
87
85
|
- bin/usbutils
|
88
86
|
- lib/usbutils.rb
|
89
87
|
- lib/usbutils/cli.rb
|
data/bin/usb-devices
DELETED
@@ -1,173 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# Copyright: 2009 Greg Kroah-Hartman <greg@kroah.com>
|
4
|
-
# 2009 Randy Dunlap <rdunlap@xenotime.net>
|
5
|
-
# 2009 Frans Pop <elendil@planet.nl>
|
6
|
-
#
|
7
|
-
# This software may be used and distributed according to the terms of
|
8
|
-
# the GNU General Public License (GPL), version 2, or at your option
|
9
|
-
# any later version.
|
10
|
-
|
11
|
-
print_string() {
|
12
|
-
file=$1
|
13
|
-
name=$2
|
14
|
-
if [ -f $file ]; then
|
15
|
-
echo "S: $name=`cat $file`"
|
16
|
-
fi
|
17
|
-
}
|
18
|
-
|
19
|
-
class_decode() {
|
20
|
-
local class=$1 # v4: in hex
|
21
|
-
|
22
|
-
case $class in
|
23
|
-
"00") echo ">ifc " ;;
|
24
|
-
"01") echo "audio" ;;
|
25
|
-
"02") echo "commc" ;;
|
26
|
-
"03") echo "HID " ;;
|
27
|
-
"05") echo "PID " ;;
|
28
|
-
"06") echo "still" ;;
|
29
|
-
"07") echo "print" ;;
|
30
|
-
"08") echo "stor." ;;
|
31
|
-
"09") echo "hub " ;;
|
32
|
-
"0a") echo "data " ;;
|
33
|
-
"0b") echo "scard" ;;
|
34
|
-
"0d") echo "c-sec" ;;
|
35
|
-
"0e") echo "video" ;;
|
36
|
-
"0f") echo "perhc" ;;
|
37
|
-
"dc") echo "diagd" ;;
|
38
|
-
"e0") echo "wlcon" ;;
|
39
|
-
"ef") echo "misc " ;;
|
40
|
-
"fe") echo "app. " ;;
|
41
|
-
"ff") echo "vend." ;;
|
42
|
-
"*") echo "unk. " ;;
|
43
|
-
esac
|
44
|
-
}
|
45
|
-
|
46
|
-
print_endpoint() {
|
47
|
-
local eppath=$1
|
48
|
-
|
49
|
-
addr=`cat $eppath/bEndpointAddress`
|
50
|
-
attr=`cat $eppath/bmAttributes`
|
51
|
-
dir=`cat $eppath/direction`
|
52
|
-
eptype=`cat $eppath/type`
|
53
|
-
maxps_hex="0x`cat $eppath/wMaxPacketSize`"
|
54
|
-
# Extract MaxPS size (bits 0-10) and multiplicity values (bits 11-12)
|
55
|
-
maxps=`printf "%4i*%s\n" $(($maxps_hex & 0x7ff)) \
|
56
|
-
$((1 + (($maxps_hex >> 11) & 0x3)))`
|
57
|
-
interval=`cat $eppath/interval`
|
58
|
-
|
59
|
-
printf "E: Ad=%s(%s) Atr=%s(%s) MxPS=%s Ivl=%s\n" \
|
60
|
-
$addr $dir $attr $eptype "$maxps" $interval
|
61
|
-
}
|
62
|
-
|
63
|
-
print_interface() {
|
64
|
-
local ifpath=$1
|
65
|
-
|
66
|
-
ifnum=`cat $ifpath/bInterfaceNumber`
|
67
|
-
altset=`cat $ifpath/bAlternateSetting`
|
68
|
-
numeps=`cat $ifpath/bNumEndpoints`
|
69
|
-
class=`cat $ifpath/bInterfaceClass`
|
70
|
-
subclass=`cat $ifpath/bInterfaceSubClass`
|
71
|
-
protocol=`cat $ifpath/bInterfaceProtocol`
|
72
|
-
if [ -L $ifpath/driver ]; then # v4: allow for no driver
|
73
|
-
driver=`readlink $ifpath/driver`
|
74
|
-
driver=`basename $driver`
|
75
|
-
else
|
76
|
-
driver="(none)"
|
77
|
-
fi
|
78
|
-
classname=`class_decode $class`
|
79
|
-
printf "I: If#=%2i Alt=%2i #EPs=%2i Cls=%s(%s) Sub=%s Prot=%s Driver=%s\n" \
|
80
|
-
$ifnum $altset $numeps $class "$classname" $subclass \
|
81
|
-
$protocol $driver
|
82
|
-
|
83
|
-
for endpoint in $ifpath/ep_??
|
84
|
-
do
|
85
|
-
if [ -L $endpoint ]; then # v4: verify endpoint exists
|
86
|
-
print_endpoint $endpoint
|
87
|
-
fi
|
88
|
-
done
|
89
|
-
}
|
90
|
-
|
91
|
-
print_device() {
|
92
|
-
local devpath=$1
|
93
|
-
local parent=$2
|
94
|
-
local level=$3
|
95
|
-
local count=$4
|
96
|
-
|
97
|
-
[ -d $devpath ] || return
|
98
|
-
cd $devpath
|
99
|
-
|
100
|
-
local busnum=`cat busnum`
|
101
|
-
local devnum=`cat devnum`
|
102
|
-
|
103
|
-
if [ $level -gt 0 ]; then
|
104
|
-
port=$((${devpath##*[-.]} - 1))
|
105
|
-
else
|
106
|
-
port=0
|
107
|
-
fi
|
108
|
-
speed=`cat speed`
|
109
|
-
maxchild=`cat maxchild`
|
110
|
-
printf "\nPATH: $devpath"
|
111
|
-
printf "\nT: Bus=%02i Lev=%02i Prnt=%02i Port=%02i Cnt=%02i Dev#=%3i Spd=%-3s MxCh=%2i\n" \
|
112
|
-
$busnum $level $parent $port $count $devnum $speed $maxchild
|
113
|
-
|
114
|
-
ver=`cat version`
|
115
|
-
devclass=`cat bDeviceClass`
|
116
|
-
devsubclass=`cat bDeviceSubClass`
|
117
|
-
devprotocol=`cat bDeviceProtocol`
|
118
|
-
maxps0=`cat bMaxPacketSize0`
|
119
|
-
numconfigs=`cat bNumConfigurations`
|
120
|
-
classname=`class_decode $devclass`
|
121
|
-
printf "D: Ver=%5s Cls=%s(%s) Sub=%s Prot=%s MxPS=%2i #Cfgs=%3i\n" \
|
122
|
-
$ver $devclass "$classname" $devsubclass $devprotocol \
|
123
|
-
$maxps0 $numconfigs
|
124
|
-
|
125
|
-
vendid=`cat idVendor`
|
126
|
-
prodid=`cat idProduct`
|
127
|
-
revmajor=`cat bcdDevice | cut -c 1-2`
|
128
|
-
revminor=`cat bcdDevice | cut -c 3-4`
|
129
|
-
printf "P: Vendor=%s ProdID=%s Rev=%s.%s\n" \
|
130
|
-
$vendid $prodid $revmajor $revminor
|
131
|
-
|
132
|
-
print_string manufacturer "Manufacturer"
|
133
|
-
print_string product Product
|
134
|
-
print_string serial SerialNumber
|
135
|
-
|
136
|
-
numifs=`cat bNumInterfaces`
|
137
|
-
cfgnum=`cat bConfigurationValue`
|
138
|
-
attr=`cat bmAttributes`
|
139
|
-
maxpower=`cat bMaxPower`
|
140
|
-
printf "C: #Ifs=%2i Cfg#=%2i Atr=%s MxPwr=%s\n" \
|
141
|
-
$numifs $cfgnum $attr $maxpower
|
142
|
-
|
143
|
-
# There's not really any useful info in endpoint 00
|
144
|
-
#print_endpoint $devpath/ep_00
|
145
|
-
|
146
|
-
for interface in $busnum-*:?.*
|
147
|
-
do
|
148
|
-
print_interface $devpath/$interface
|
149
|
-
done
|
150
|
-
|
151
|
-
local devcount=0
|
152
|
-
for subdev in $busnum-*
|
153
|
-
do
|
154
|
-
echo "$subdev" | grep -Eq "^$busnum-[0-9]+(\.[0-9]+)*$" \
|
155
|
-
|| continue
|
156
|
-
|
157
|
-
devcount=$(($devcount + 1))
|
158
|
-
if [ -d $devpath/$subdev ]; then
|
159
|
-
print_device $devpath/$subdev \
|
160
|
-
$devnum $(($level +1)) $devcount
|
161
|
-
fi
|
162
|
-
done
|
163
|
-
}
|
164
|
-
|
165
|
-
if [ ! -d /sys/bus ]; then
|
166
|
-
echo "Error: directory /sys/bus does not exist; is sysfs mounted?" >&2
|
167
|
-
exit 1
|
168
|
-
fi
|
169
|
-
|
170
|
-
for device in /sys/bus/usb/devices/usb*
|
171
|
-
do
|
172
|
-
print_device $device 0 0 0
|
173
|
-
done
|