svi 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/bin/dfu +176 -0
- data/bin/gettime +153 -0
- data/bin/led_set +158 -0
- data/bin/lun_format_ao +153 -0
- data/bin/lun_get_count +149 -0
- data/bin/lun_get_table +176 -0
- data/bin/lun_save_table +149 -0
- data/bin/lun_set_count +150 -0
- data/bin/lun_set_mode +161 -0
- data/bin/lun_set_table +154 -0
- data/bin/random +152 -0
- data/bin/settime +156 -0
- data/bin/svi +4 -0
- data/bin/svirb +21 -0
- data/bin/system_reset +149 -0
- data/bin/usb_reconnect +149 -0
- data/lib/svi/api.generated.rb +31 -0
- data/lib/svi/api.rb +111 -0
- data/lib/svi/svi.rb +135 -0
- metadata +98 -0
data/bin/lun_get_count
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
#!/usr/bin/ruby19
|
2
|
+
|
3
|
+
require 'svi/svi'
|
4
|
+
|
5
|
+
require 'optparse'
|
6
|
+
require 'optparse/time'
|
7
|
+
require 'ostruct'
|
8
|
+
|
9
|
+
USAGE = "Usage: lun_get_count [options]"
|
10
|
+
ARGS_NUM = 0
|
11
|
+
|
12
|
+
def parse_options(args)
|
13
|
+
options = OpenStruct.new
|
14
|
+
|
15
|
+
opt_parser = OptionParser.new do |opts|
|
16
|
+
opts.banner = USAGE
|
17
|
+
options.vid = 0x3241
|
18
|
+
options.pid = 0x9372
|
19
|
+
options.svi_if = 2
|
20
|
+
options.sbi_if = 3
|
21
|
+
options.sbi_if_ep_out = 0x3
|
22
|
+
options.sbi_if_ep_in = 0x3
|
23
|
+
options.svi_if_ep_out = 0x4
|
24
|
+
options.svi_if_ep_in = 0x4
|
25
|
+
options.timeout = 1000
|
26
|
+
options.devnum = 0
|
27
|
+
options.devnum_mod = nil
|
28
|
+
options.verbose = false
|
29
|
+
|
30
|
+
opts.separator ""
|
31
|
+
opts.separator "Common options:"
|
32
|
+
|
33
|
+
opts.on("-D", "--device vid:pid", String, "Use appropriate VID/PID") do |vidpid|
|
34
|
+
vidpid = vidpid.split ':'
|
35
|
+
options.vid = vidpid[0].hex
|
36
|
+
options.pid = vidpid[1].hex
|
37
|
+
end
|
38
|
+
|
39
|
+
opts.on("-N", "--device-number N", Integer, "Use device number N (see device list by --list option)") do |devnum|
|
40
|
+
options.devnum = devnum
|
41
|
+
options.devnum_mod = true
|
42
|
+
end
|
43
|
+
|
44
|
+
opts.on("-T", "--timeout milliseconds", Integer, "Timeout for transfers on both interfaces") do |timeout|
|
45
|
+
options.timeout = timeout
|
46
|
+
end
|
47
|
+
|
48
|
+
opts.on("--svi-if ifnum:epout:epin", String, "Define interface for SVI") do |args|
|
49
|
+
args = args.split ':'
|
50
|
+
options.svi_if = args[0].hex
|
51
|
+
options.svi_if_ep_out = args[1].hex
|
52
|
+
options.svi_if_ep_in = args[2].hex
|
53
|
+
end
|
54
|
+
|
55
|
+
opts.on("--verbose", "Print maximum information") do
|
56
|
+
options.verbose = true
|
57
|
+
end
|
58
|
+
|
59
|
+
opts.on("--sbi-if ifnum:epout:epin", String, "Define interface for SBI") do |args|
|
60
|
+
args = args.split ':'
|
61
|
+
options.sbi_if = args[0].hex
|
62
|
+
options.sbi_if_ep_out = args[1].hex
|
63
|
+
options.sbi_if_ep_in = args[2].hex
|
64
|
+
end
|
65
|
+
|
66
|
+
opts.on_tail("-l", "--list", "Show devices list only") do
|
67
|
+
USB.new(options.vid, options.pid).svi_devices.each_with_index { |dev, i|
|
68
|
+
puts "#%d %s %s" % [i, dev.manufacturer, dev.product]
|
69
|
+
}
|
70
|
+
exit
|
71
|
+
end
|
72
|
+
|
73
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
74
|
+
puts opts
|
75
|
+
exit
|
76
|
+
end
|
77
|
+
|
78
|
+
opts.on_tail("--version", "Show version") do
|
79
|
+
puts SVI_VERSION
|
80
|
+
exit
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
opt_parser.parse!(args)
|
85
|
+
[options, opt_parser]
|
86
|
+
end
|
87
|
+
|
88
|
+
res = parse_options(ARGV)
|
89
|
+
options = res[0]
|
90
|
+
opt_parser = res[1]
|
91
|
+
|
92
|
+
if ARGV.count != ARGS_NUM
|
93
|
+
p opt_parser
|
94
|
+
exit 1
|
95
|
+
end
|
96
|
+
|
97
|
+
devs = USB.new(options.vid, options.pid).svi_devices
|
98
|
+
|
99
|
+
if devs.count == 0
|
100
|
+
puts 'Device not found'
|
101
|
+
exit 1
|
102
|
+
end
|
103
|
+
|
104
|
+
if devs.count > 1 and options.devnum_mod.nil?
|
105
|
+
puts 'There are more than one devices, using device #%d.' % options.devnum
|
106
|
+
puts 'Use option -N to define necessary device.'
|
107
|
+
puts "To view list of devices use -l option.\n\n"
|
108
|
+
end
|
109
|
+
|
110
|
+
dev = devs[options.devnum]
|
111
|
+
|
112
|
+
dev.svi_if = options.svi_if
|
113
|
+
dev.svi_if_ep_out = options.svi_if_ep_out
|
114
|
+
dev.svi_if_ep_in = options.svi_if_ep_in
|
115
|
+
|
116
|
+
dev.sbi_if = options.sbi_if
|
117
|
+
dev.sbi_if_ep_out = options.sbi_if_ep_out
|
118
|
+
dev.sbi_if_ep_in = options.sbi_if_ep_in
|
119
|
+
|
120
|
+
dev.svi_timeout = options.timeout
|
121
|
+
dev.sbi_timeout = options.timeout
|
122
|
+
|
123
|
+
if options.verbose
|
124
|
+
puts "Configuration:"
|
125
|
+
puts "Device # = %d" % options.devnum
|
126
|
+
puts "idVendor = 0x%04x" % options.vid
|
127
|
+
puts "idProduct = 0x%04x" % options.pid
|
128
|
+
puts "Interface number SVI = %d" % options.svi_if
|
129
|
+
puts "OUT endpoint for SVI = 0x%02x" % options.svi_if_ep_out
|
130
|
+
puts "IN endpoint for SVI = 0x%02x" % (options.svi_if_ep_in | 0x80)
|
131
|
+
puts "Interface number SBI = %d" % options.sbi_if
|
132
|
+
puts "OUT endpoint for SBI = 0x%02x" % options.sbi_if_ep_out
|
133
|
+
puts "IN endpoint for SBI = 0x%02x" % (options.sbi_if_ep_in | 0x80)
|
134
|
+
puts "Timeout for IN operations = %d msec" % options.timeout
|
135
|
+
puts "\n\n"
|
136
|
+
end
|
137
|
+
|
138
|
+
if options.verbose
|
139
|
+
end
|
140
|
+
|
141
|
+
res = dev.lun_get_count
|
142
|
+
|
143
|
+
if options.verbose
|
144
|
+
end
|
145
|
+
|
146
|
+
p res[0].to_i
|
147
|
+
|
148
|
+
# vim: sw=2 sts=2 ts=8:
|
149
|
+
|
data/bin/lun_get_table
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
#!/usr/bin/ruby19
|
2
|
+
|
3
|
+
require 'svi/svi'
|
4
|
+
|
5
|
+
require 'optparse'
|
6
|
+
require 'optparse/time'
|
7
|
+
require 'ostruct'
|
8
|
+
|
9
|
+
USAGE = "Usage: lun_get_table [options]"
|
10
|
+
ARGS_NUM = 1
|
11
|
+
|
12
|
+
def parse_options(args)
|
13
|
+
options = OpenStruct.new
|
14
|
+
|
15
|
+
opt_parser = OptionParser.new do |opts|
|
16
|
+
opts.banner = USAGE
|
17
|
+
options.vid = 0x3241
|
18
|
+
options.pid = 0x9372
|
19
|
+
options.svi_if = 2
|
20
|
+
options.sbi_if = 3
|
21
|
+
options.sbi_if_ep_out = 0x3
|
22
|
+
options.sbi_if_ep_in = 0x3
|
23
|
+
options.svi_if_ep_out = 0x4
|
24
|
+
options.svi_if_ep_in = 0x4
|
25
|
+
options.timeout = 1000
|
26
|
+
options.devnum = 0
|
27
|
+
options.devnum_mod = nil
|
28
|
+
options.verbose = false
|
29
|
+
options.all = false
|
30
|
+
|
31
|
+
opts.separator ""
|
32
|
+
opts.separator "Specific options:"
|
33
|
+
|
34
|
+
opts.on("-a", "--all", "Display full table (with unused LUN's)") do
|
35
|
+
options.all = true
|
36
|
+
end
|
37
|
+
|
38
|
+
opts.separator ""
|
39
|
+
opts.separator "Common options:"
|
40
|
+
|
41
|
+
opts.on("-D", "--device vid:pid", String, "Use appropriate VID/PID") do |vidpid|
|
42
|
+
vidpid = vidpid.split ':'
|
43
|
+
options.vid = vidpid[0].hex
|
44
|
+
options.pid = vidpid[1].hex
|
45
|
+
end
|
46
|
+
|
47
|
+
opts.on("-N", "--device-number N", Integer, "Use device number N (see device list by --list option)") do |devnum|
|
48
|
+
options.devnum = devnum
|
49
|
+
options.devnum_mod = true
|
50
|
+
end
|
51
|
+
|
52
|
+
opts.on("-T", "--timeout milliseconds", Integer, "Timeout for transfers on both interfaces") do |timeout|
|
53
|
+
options.timeout = timeout
|
54
|
+
end
|
55
|
+
|
56
|
+
opts.on("--svi-if ifnum:epout:epin", String, "Define interface for SVI") do |args|
|
57
|
+
args = args.split ':'
|
58
|
+
options.svi_if = args[0].hex
|
59
|
+
options.svi_if_ep_out = args[1].hex
|
60
|
+
options.svi_if_ep_in = args[2].hex
|
61
|
+
end
|
62
|
+
|
63
|
+
opts.on("--verbose", "Print maximum information") do
|
64
|
+
options.verbose = true
|
65
|
+
end
|
66
|
+
|
67
|
+
opts.on("--sbi-if ifnum:epout:epin", String, "Define interface for SBI") do |args|
|
68
|
+
args = args.split ':'
|
69
|
+
options.sbi_if = args[0].hex
|
70
|
+
options.sbi_if_ep_out = args[1].hex
|
71
|
+
options.sbi_if_ep_in = args[2].hex
|
72
|
+
end
|
73
|
+
|
74
|
+
opts.on_tail("-l", "--list", "Show devices list only") do
|
75
|
+
USB.new(options.vid, options.pid).svi_devices.each_with_index { |dev, i|
|
76
|
+
puts "#%d %s %s" % [i, dev.manufacturer, dev.product]
|
77
|
+
}
|
78
|
+
exit
|
79
|
+
end
|
80
|
+
|
81
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
82
|
+
puts opts
|
83
|
+
exit
|
84
|
+
end
|
85
|
+
|
86
|
+
opts.on_tail("--version", "Show version") do
|
87
|
+
puts SVI_VERSION
|
88
|
+
exit
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
opt_parser.parse!(args)
|
93
|
+
[options, opt_parser]
|
94
|
+
end
|
95
|
+
|
96
|
+
res = parse_options(ARGV)
|
97
|
+
options = res[0]
|
98
|
+
opt_parser = res[1]
|
99
|
+
|
100
|
+
argv = ARGV.reverse
|
101
|
+
|
102
|
+
if argv.count > ARGS_NUM
|
103
|
+
p opt_parser
|
104
|
+
exit 1
|
105
|
+
end
|
106
|
+
|
107
|
+
devs = USB.new(options.vid, options.pid).svi_devices
|
108
|
+
|
109
|
+
if devs.count == 0
|
110
|
+
puts 'Device not found'
|
111
|
+
exit 1
|
112
|
+
end
|
113
|
+
|
114
|
+
if devs.count > 1 and options.devnum_mod.nil?
|
115
|
+
puts 'There are more than one devices, using device #%d.' % options.devnum
|
116
|
+
puts 'Use option -N to define necessary device.'
|
117
|
+
puts "To view list of devices use -l option.\n\n"
|
118
|
+
end
|
119
|
+
|
120
|
+
dev = devs[options.devnum]
|
121
|
+
|
122
|
+
dev.svi_if = options.svi_if
|
123
|
+
dev.svi_if_ep_out = options.svi_if_ep_out
|
124
|
+
dev.svi_if_ep_in = options.svi_if_ep_in
|
125
|
+
|
126
|
+
dev.sbi_if = options.sbi_if
|
127
|
+
dev.sbi_if_ep_out = options.sbi_if_ep_out
|
128
|
+
dev.sbi_if_ep_in = options.sbi_if_ep_in
|
129
|
+
|
130
|
+
dev.svi_timeout = options.timeout
|
131
|
+
dev.sbi_timeout = options.timeout
|
132
|
+
|
133
|
+
if options.verbose
|
134
|
+
puts "Configuration:"
|
135
|
+
puts "Device # = %d" % options.devnum
|
136
|
+
puts "idVendor = 0x%04x" % options.vid
|
137
|
+
puts "idProduct = 0x%04x" % options.pid
|
138
|
+
puts "Interface number SVI = %d" % options.svi_if
|
139
|
+
puts "OUT endpoint for SVI = 0x%02x" % options.svi_if_ep_out
|
140
|
+
puts "IN endpoint for SVI = 0x%02x" % (options.svi_if_ep_in | 0x80)
|
141
|
+
puts "Interface number SBI = %d" % options.sbi_if
|
142
|
+
puts "OUT endpoint for SBI = 0x%02x" % options.sbi_if_ep_out
|
143
|
+
puts "IN endpoint for SBI = 0x%02x" % (options.sbi_if_ep_in | 0x80)
|
144
|
+
puts "Timeout for IN operations = %d msec" % options.timeout
|
145
|
+
puts "\n\n"
|
146
|
+
end
|
147
|
+
|
148
|
+
count = argv.pop
|
149
|
+
|
150
|
+
if count.nil?
|
151
|
+
if options.all
|
152
|
+
count = dev.lun_get_maxcount[0]
|
153
|
+
else
|
154
|
+
count = dev.lun_get_count[0]
|
155
|
+
end
|
156
|
+
else
|
157
|
+
count = count.to_i
|
158
|
+
end
|
159
|
+
|
160
|
+
if options.verbose
|
161
|
+
puts "lun_get_table() for %d LUN's" % count
|
162
|
+
end
|
163
|
+
|
164
|
+
if count > 0
|
165
|
+
res = dev.lun_get_table count
|
166
|
+
|
167
|
+
if options.verbose
|
168
|
+
end
|
169
|
+
|
170
|
+
p [res[0]] + res[1..-1].each_slice(4).to_a
|
171
|
+
else
|
172
|
+
p []
|
173
|
+
end
|
174
|
+
|
175
|
+
# vim: sw=2 sts=2 ts=8:
|
176
|
+
|
data/bin/lun_save_table
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
#!/usr/bin/ruby19
|
2
|
+
|
3
|
+
require 'svi/svi'
|
4
|
+
|
5
|
+
require 'optparse'
|
6
|
+
require 'optparse/time'
|
7
|
+
require 'ostruct'
|
8
|
+
|
9
|
+
USAGE = "Usage: lun_save_table [options]"
|
10
|
+
ARGS_NUM = 0
|
11
|
+
|
12
|
+
def parse_options(args)
|
13
|
+
options = OpenStruct.new
|
14
|
+
|
15
|
+
opt_parser = OptionParser.new do |opts|
|
16
|
+
opts.banner = USAGE
|
17
|
+
options.vid = 0x3241
|
18
|
+
options.pid = 0x9372
|
19
|
+
options.svi_if = 2
|
20
|
+
options.sbi_if = 3
|
21
|
+
options.sbi_if_ep_out = 0x3
|
22
|
+
options.sbi_if_ep_in = 0x3
|
23
|
+
options.svi_if_ep_out = 0x4
|
24
|
+
options.svi_if_ep_in = 0x4
|
25
|
+
options.timeout = 1000
|
26
|
+
options.devnum = 0
|
27
|
+
options.devnum_mod = nil
|
28
|
+
options.verbose = false
|
29
|
+
|
30
|
+
opts.separator ""
|
31
|
+
opts.separator "Common options:"
|
32
|
+
|
33
|
+
opts.on("-D", "--device vid:pid", String, "Use appropriate VID/PID") do |vidpid|
|
34
|
+
vidpid = vidpid.split ':'
|
35
|
+
options.vid = vidpid[0].hex
|
36
|
+
options.pid = vidpid[1].hex
|
37
|
+
end
|
38
|
+
|
39
|
+
opts.on("-N", "--device-number N", Integer, "Use device number N (see device list by --list option)") do |devnum|
|
40
|
+
options.devnum = devnum
|
41
|
+
options.devnum_mod = true
|
42
|
+
end
|
43
|
+
|
44
|
+
opts.on("-T", "--timeout milliseconds", Integer, "Timeout for transfers on both interfaces") do |timeout|
|
45
|
+
options.timeout = timeout
|
46
|
+
end
|
47
|
+
|
48
|
+
opts.on("--svi-if ifnum:epout:epin", String, "Define interface for SVI") do |args|
|
49
|
+
args = args.split ':'
|
50
|
+
options.svi_if = args[0].hex
|
51
|
+
options.svi_if_ep_out = args[1].hex
|
52
|
+
options.svi_if_ep_in = args[2].hex
|
53
|
+
end
|
54
|
+
|
55
|
+
opts.on("--verbose", "Print maximum information") do
|
56
|
+
options.verbose = true
|
57
|
+
end
|
58
|
+
|
59
|
+
opts.on("--sbi-if ifnum:epout:epin", String, "Define interface for SBI") do |args|
|
60
|
+
args = args.split ':'
|
61
|
+
options.sbi_if = args[0].hex
|
62
|
+
options.sbi_if_ep_out = args[1].hex
|
63
|
+
options.sbi_if_ep_in = args[2].hex
|
64
|
+
end
|
65
|
+
|
66
|
+
opts.on_tail("-l", "--list", "Show devices list only") do
|
67
|
+
USB.new(options.vid, options.pid).svi_devices.each_with_index { |dev, i|
|
68
|
+
puts "#%d %s %s" % [i, dev.manufacturer, dev.product]
|
69
|
+
}
|
70
|
+
exit
|
71
|
+
end
|
72
|
+
|
73
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
74
|
+
puts opts
|
75
|
+
exit
|
76
|
+
end
|
77
|
+
|
78
|
+
opts.on_tail("--version", "Show version") do
|
79
|
+
puts SVI_VERSION
|
80
|
+
exit
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
opt_parser.parse!(args)
|
85
|
+
[options, opt_parser]
|
86
|
+
end
|
87
|
+
|
88
|
+
res = parse_options(ARGV)
|
89
|
+
options = res[0]
|
90
|
+
opt_parser = res[1]
|
91
|
+
|
92
|
+
if ARGV.count != ARGS_NUM
|
93
|
+
p opt_parser
|
94
|
+
exit 1
|
95
|
+
end
|
96
|
+
|
97
|
+
devs = USB.new(options.vid, options.pid).svi_devices
|
98
|
+
|
99
|
+
if devs.count == 0
|
100
|
+
puts 'Device not found'
|
101
|
+
exit 1
|
102
|
+
end
|
103
|
+
|
104
|
+
if devs.count > 1 and options.devnum_mod.nil?
|
105
|
+
puts 'There are more than one devices, using device #%d.' % options.devnum
|
106
|
+
puts 'Use option -N to define necessary device.'
|
107
|
+
puts "To view list of devices use -l option.\n\n"
|
108
|
+
end
|
109
|
+
|
110
|
+
dev = devs[options.devnum]
|
111
|
+
|
112
|
+
dev.svi_if = options.svi_if
|
113
|
+
dev.svi_if_ep_out = options.svi_if_ep_out
|
114
|
+
dev.svi_if_ep_in = options.svi_if_ep_in
|
115
|
+
|
116
|
+
dev.sbi_if = options.sbi_if
|
117
|
+
dev.sbi_if_ep_out = options.sbi_if_ep_out
|
118
|
+
dev.sbi_if_ep_in = options.sbi_if_ep_in
|
119
|
+
|
120
|
+
dev.svi_timeout = options.timeout
|
121
|
+
dev.sbi_timeout = options.timeout
|
122
|
+
|
123
|
+
if options.verbose
|
124
|
+
puts "Configuration:"
|
125
|
+
puts "Device # = %d" % options.devnum
|
126
|
+
puts "idVendor = 0x%04x" % options.vid
|
127
|
+
puts "idProduct = 0x%04x" % options.pid
|
128
|
+
puts "Interface number SVI = %d" % options.svi_if
|
129
|
+
puts "OUT endpoint for SVI = 0x%02x" % options.svi_if_ep_out
|
130
|
+
puts "IN endpoint for SVI = 0x%02x" % (options.svi_if_ep_in | 0x80)
|
131
|
+
puts "Interface number SBI = %d" % options.sbi_if
|
132
|
+
puts "OUT endpoint for SBI = 0x%02x" % options.sbi_if_ep_out
|
133
|
+
puts "IN endpoint for SBI = 0x%02x" % (options.sbi_if_ep_in | 0x80)
|
134
|
+
puts "Timeout for IN operations = %d msec" % options.timeout
|
135
|
+
puts "\n\n"
|
136
|
+
end
|
137
|
+
|
138
|
+
if options.verbose
|
139
|
+
end
|
140
|
+
|
141
|
+
res = dev.lun_save_table
|
142
|
+
|
143
|
+
if options.verbose
|
144
|
+
end
|
145
|
+
|
146
|
+
p res[0].to_i
|
147
|
+
|
148
|
+
# vim: sw=2 sts=2 ts=8:
|
149
|
+
|
data/bin/lun_set_count
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
#!/usr/bin/ruby19
|
2
|
+
|
3
|
+
require 'svi/svi'
|
4
|
+
|
5
|
+
require 'optparse'
|
6
|
+
require 'optparse/time'
|
7
|
+
require 'ostruct'
|
8
|
+
|
9
|
+
USAGE = "Usage: lun_set_count [options] count"
|
10
|
+
ARGS_NUM = 1
|
11
|
+
|
12
|
+
def parse_options(args)
|
13
|
+
options = OpenStruct.new
|
14
|
+
|
15
|
+
opt_parser = OptionParser.new do |opts|
|
16
|
+
opts.banner = USAGE
|
17
|
+
options.vid = 0x3241
|
18
|
+
options.pid = 0x9372
|
19
|
+
options.svi_if = 2
|
20
|
+
options.sbi_if = 3
|
21
|
+
options.sbi_if_ep_out = 0x3
|
22
|
+
options.sbi_if_ep_in = 0x3
|
23
|
+
options.svi_if_ep_out = 0x4
|
24
|
+
options.svi_if_ep_in = 0x4
|
25
|
+
options.timeout = 1000
|
26
|
+
options.devnum = 0
|
27
|
+
options.devnum_mod = nil
|
28
|
+
options.verbose = false
|
29
|
+
|
30
|
+
opts.separator ""
|
31
|
+
opts.separator "Common options:"
|
32
|
+
|
33
|
+
opts.on("-D", "--device vid:pid", String, "Use appropriate VID/PID") do |vidpid|
|
34
|
+
vidpid = vidpid.split ':'
|
35
|
+
options.vid = vidpid[0].hex
|
36
|
+
options.pid = vidpid[1].hex
|
37
|
+
end
|
38
|
+
|
39
|
+
opts.on("-N", "--device-number N", Integer, "Use device number N (see device list by --list option)") do |devnum|
|
40
|
+
options.devnum = devnum
|
41
|
+
options.devnum_mod = true
|
42
|
+
end
|
43
|
+
|
44
|
+
opts.on("-T", "--timeout milliseconds", Integer, "Timeout for transfers on both interfaces") do |timeout|
|
45
|
+
options.timeout = timeout
|
46
|
+
end
|
47
|
+
|
48
|
+
opts.on("--svi-if ifnum:epout:epin", String, "Define interface for SVI") do |args|
|
49
|
+
args = args.split ':'
|
50
|
+
options.svi_if = args[0].hex
|
51
|
+
options.svi_if_ep_out = args[1].hex
|
52
|
+
options.svi_if_ep_in = args[2].hex
|
53
|
+
end
|
54
|
+
|
55
|
+
opts.on("--verbose", "Print maximum information") do
|
56
|
+
options.verbose = true
|
57
|
+
end
|
58
|
+
|
59
|
+
opts.on("--sbi-if ifnum:epout:epin", String, "Define interface for SBI") do |args|
|
60
|
+
args = args.split ':'
|
61
|
+
options.sbi_if = args[0].hex
|
62
|
+
options.sbi_if_ep_out = args[1].hex
|
63
|
+
options.sbi_if_ep_in = args[2].hex
|
64
|
+
end
|
65
|
+
|
66
|
+
opts.on_tail("-l", "--list", "Show devices list only") do
|
67
|
+
USB.new(options.vid, options.pid).svi_devices.each_with_index { |dev, i|
|
68
|
+
puts "#%d %s %s" % [i, dev.manufacturer, dev.product]
|
69
|
+
}
|
70
|
+
exit
|
71
|
+
end
|
72
|
+
|
73
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
74
|
+
puts opts
|
75
|
+
exit
|
76
|
+
end
|
77
|
+
|
78
|
+
opts.on_tail("--version", "Show version") do
|
79
|
+
puts SVI_VERSION
|
80
|
+
exit
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
opt_parser.parse!(args)
|
85
|
+
[options, opt_parser]
|
86
|
+
end
|
87
|
+
|
88
|
+
res = parse_options(ARGV)
|
89
|
+
options = res[0]
|
90
|
+
opt_parser = res[1]
|
91
|
+
|
92
|
+
if ARGV.count != ARGS_NUM
|
93
|
+
p opt_parser
|
94
|
+
exit 1
|
95
|
+
end
|
96
|
+
|
97
|
+
devs = USB.new(options.vid, options.pid).svi_devices
|
98
|
+
|
99
|
+
if devs.count == 0
|
100
|
+
puts 'Device not found'
|
101
|
+
exit 1
|
102
|
+
end
|
103
|
+
|
104
|
+
if devs.count > 1 and options.devnum_mod.nil?
|
105
|
+
puts 'There are more than one devices, using device #%d.' % options.devnum
|
106
|
+
puts 'Use option -N to define necessary device.'
|
107
|
+
puts "To view list of devices use -l option.\n\n"
|
108
|
+
end
|
109
|
+
|
110
|
+
dev = devs[options.devnum]
|
111
|
+
|
112
|
+
dev.svi_if = options.svi_if
|
113
|
+
dev.svi_if_ep_out = options.svi_if_ep_out
|
114
|
+
dev.svi_if_ep_in = options.svi_if_ep_in
|
115
|
+
|
116
|
+
dev.sbi_if = options.sbi_if
|
117
|
+
dev.sbi_if_ep_out = options.sbi_if_ep_out
|
118
|
+
dev.sbi_if_ep_in = options.sbi_if_ep_in
|
119
|
+
|
120
|
+
dev.svi_timeout = options.timeout
|
121
|
+
dev.sbi_timeout = options.timeout
|
122
|
+
|
123
|
+
if options.verbose
|
124
|
+
puts "Configuration:"
|
125
|
+
puts "Device # = %d" % options.devnum
|
126
|
+
puts "idVendor = 0x%04x" % options.vid
|
127
|
+
puts "idProduct = 0x%04x" % options.pid
|
128
|
+
puts "Interface number SVI = %d" % options.svi_if
|
129
|
+
puts "OUT endpoint for SVI = 0x%02x" % options.svi_if_ep_out
|
130
|
+
puts "IN endpoint for SVI = 0x%02x" % (options.svi_if_ep_in | 0x80)
|
131
|
+
puts "Interface number SBI = %d" % options.sbi_if
|
132
|
+
puts "OUT endpoint for SBI = 0x%02x" % options.sbi_if_ep_out
|
133
|
+
puts "IN endpoint for SBI = 0x%02x" % (options.sbi_if_ep_in | 0x80)
|
134
|
+
puts "Timeout for IN operations = %d msec" % options.timeout
|
135
|
+
puts "\n\n"
|
136
|
+
end
|
137
|
+
|
138
|
+
if options.verbose
|
139
|
+
puts "lun_set_count(%d)" % ARGV[0].to_i
|
140
|
+
end
|
141
|
+
|
142
|
+
res = dev.lun_set_count ARGV[0].to_i
|
143
|
+
|
144
|
+
if options.verbose
|
145
|
+
end
|
146
|
+
|
147
|
+
p res[0].to_i
|
148
|
+
|
149
|
+
# vim: sw=2 sts=2 ts=8:
|
150
|
+
|