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