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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZWM4YjFlMjg0MDc3N2RkMTcwNDE1ZGY0MDA3MTdmM2VhZTkzNTBmOQ==
4
+ MjYyOTA2MTUzMWFjMzAxMjBiMWE1MzdmODg4OWUwMjhiZjdhNmRlNg==
5
5
  data.tar.gz: !binary |-
6
- NjkwZGMxMGVhYTRhN2I4Nzk1YzYzNTMxMzhmNjc3YTI5YWE5NTQ2NQ==
6
+ OTE4MDYxYzQ4ZWIzMTgzOWZjYjc1NGJmZDliNDM5NTVhM2EwNmMxNg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YjczODI1YTFmODY1Y2RiOTc3NjBiYWNhOWJiNzJkZTliMTFjYjgzODczZTFi
10
- ODMzOWZjODE5ZWM1NmY4MTBiYTY3N2QxNWFjMDYyZDQ5M2RiM2Y3YWNiNDc2
11
- YjBmNTBhYTJhNzQ0MzQxOWI3YWI4YjFiMDA0MjRhMTczN2M0ZGU=
9
+ MmJmYmNiMWI0ZDhiNDYwNTk5OWZkODkyYTQxMjVjY2QwMWVmYmY0MzE2YjE3
10
+ YzBjYjhhMmZkMmQ1M2U0MmEzN2U0YTY5NDIyOTRhMzNjZDYxNGQ5Y2Y1NmMx
11
+ MmJlMzZlZWE2ODNjOGZmNmMxOWIyYjljMzkxZWY5Y2U1ZWFiMTg=
12
12
  data.tar.gz: !binary |-
13
- ZjI5ZjkwMGQ0MmRiZTQ5MGE0NWU3MWVkZTVkMzAwMmY2NGNiZGZjODg1M2Q2
14
- OWRiYzlkNDFhN2Y3MGY2ZjUzNGYxMTNiYzM2MGMzNWM4OGUyNWYyN2RmZTgw
15
- ZmZiYmRkZDdkYmUxYWNjMmJhMzBiNjViY2EzMmIyY2IzMjhhMjg=
13
+ NDQ5NDBlYTU0NWZlMWMyYmUyMjIzMWI5ZGRlMjA1MWE0OGRlZmI1YWQ4YmYy
14
+ YTZkNThhN2Q4ZWJkYzYxMmRhOGY1NjA3Y2M0NWY5OWYxYWJmZDc1ZmZiMDgz
15
+ NDc0YjVkNzg3M2ViNDI4ZjRmMDgxY2NiYzBlOWVhMGEzNmU0N2E=
data/bin/svi CHANGED
@@ -84,6 +84,7 @@ require 'svi/cmd/random'
84
84
  require 'svi/cmd/usb'
85
85
  require 'svi/cmd/sys'
86
86
  require 'svi/cmd/dfu'
87
+ require 'svi/cmd/time'
87
88
 
88
89
  exit run(ARGV)
89
90
 
@@ -7,18 +7,18 @@ $svi_api_desc = {
7
7
  :lun_set_mode => { :response => [Integer], :args => [Integer, Integer] },
8
8
  :lun_format_ao => { :response => [Integer], :args => [Integer, Integer] },
9
9
  :lun_save_table => { :response => [Integer], :args => [] },
10
- :firmware_program => { :response => [Integer], :args => [Integer, Integer] },
11
- :nvm_write => { :response => [Integer], :args => [Integer, Integer, String] },
12
- :nvm_read => { :response => [String, Integer], :args => [Integer, Integer, Integer] },
13
- :nvm_open => { :response => [Integer], :args => [Integer] },
14
- :nvm_close => { :response => [Integer], :args => [Integer] },
10
+ # :firmware_program => { :response => [Integer], :args => [Integer, Integer] },
11
+ # :nvm_write => { :response => [Integer], :args => [Integer, Integer, String] },
12
+ # :nvm_read => { :response => [String, Integer], :args => [Integer, Integer, Integer] },
13
+ # :nvm_open => { :response => [Integer], :args => [Integer] },
14
+ # :nvm_close => { :response => [Integer], :args => [Integer] },
15
15
  :led_set => { :response => [], :args => [Integer, Integer] },
16
16
  :usb_reconnect => { :response => [], :args => [] },
17
17
  :system_reset => { :response => [], :args => [] },
18
- :system_get_serial => { :response => [String], :args => [String] },
19
- :system_get_sysver => { :response => [String], :args => [String] },
20
- :firmware_get_ver => { :response => [String, String, String, String, String], :args => [] },
21
- :system_get_appver => { :response => [String], :args => [String] },
18
+ # :system_get_serial => { :response => [String], :args => [String] },
19
+ # :system_get_sysver => { :response => [String], :args => [String] },
20
+ # :firmware_get_ver => { :response => [String, String, String, String, String], :args => [] },
21
+ # :system_get_appver => { :response => [String], :args => [String] },
22
22
  :random => { :response => [Integer], :args => [] },
23
23
  :gettime => { :response => [Integer], :args => [] },
24
24
  :settime => { :response => [Integer], :args => [Integer] },
data/lib/svi/cmd/dfu.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  desc 'Device firmwares update'
2
2
  command :dfu do |c|
3
3
  c.desc 'Update kernel'
4
- arg_name 'firmware.bin'
4
+ c.arg_name 'firmware.bin'
5
5
  c.command :kernel do |kernel|
6
6
  kernel.action do |global_opts, opts, args|
7
7
  exit_now! 'Invalid arguments' if args.count != 1
@@ -26,7 +26,7 @@ command :dfu do |c|
26
26
  end
27
27
 
28
28
  c.desc 'Update app'
29
- arg_name 'firmware.bin'
29
+ c.arg_name 'firmware.bin'
30
30
  c.command :app do |app|
31
31
  app.action do |global_opts, opts, args|
32
32
  exit_now! 'Invalid arguments' if args.count != 1
data/lib/svi/cmd/lun.rb CHANGED
@@ -8,10 +8,75 @@ command :lun do |c|
8
8
  end
9
9
  end
10
10
 
11
- c.desc 'Get count of active luns'
11
+ c.desc 'Get or set count of active LUNs'
12
+ c.arg_name '[count]'
12
13
  c.command :count do |count|
13
- count.action do
14
- puts "Count of active LUNs = #{$dev.lun_get_count[0]}"
14
+ count.action do |global_opts, opts, args|
15
+ if args.count == 1
16
+ res = $dev.lun_set_count args[0].to_i
17
+
18
+ puts res[0] == 0 ? 'OK'.light_green : 'Fail'.light_red
19
+ else
20
+ puts "Count of active LUNs = #{$dev.lun_get_count[0]}"
21
+ end
22
+ end
23
+ end
24
+
25
+ c.desc 'Set LUN mode'
26
+ c.arg_name 'lun-number mode'
27
+ c.command :mode do |mode|
28
+ mode.action do |global_opts, opts, args|
29
+ res = $dev.lun_set_mode args[0].to_i, args[1].to_i
30
+
31
+ puts res[0] == 0 ? 'OK'.light_green : 'Fail'.light_red
32
+ end
33
+ end
34
+
35
+ c.desc 'LUN journal commands'
36
+ c.command :journal do |journal|
37
+ journal.desc 'LUN journal init'
38
+ journal.arg_name 'lun-number rec-size'
39
+ journal.command :init do |init|
40
+ init.action do |global_opts, opts, args|
41
+ res = $dev.lun_format_ao args[0].to_i, args[1].to_i
42
+
43
+ puts res[0] == 0 ? 'OK'.light_green : 'Fail'.light_red
44
+ end
45
+ end
46
+ end
47
+
48
+ c.desc 'LUN save table to NVM'
49
+ c.command :save do |save|
50
+ save.action do |global_opts, opts, args|
51
+ res = $dev.lun_save_table
52
+
53
+ puts res[0] == 0 ? 'OK'.light_green : 'Fail'.light_red
54
+ end
55
+ end
56
+
57
+ c.desc 'Get or set table of LUNs'
58
+ c.arg_name '(lun-number| start size mode flags start size ...)'
59
+ c.command :table do |table|
60
+ table.action do |global_opts, opts, args|
61
+ if args.count == 1
62
+ res = $dev.lun_get_table args[0].to_i
63
+
64
+ if res[0] == 0
65
+ puts res[1].inspect
66
+ else
67
+ puts 'Fail'.light_red
68
+ end
69
+ elsif args.count%4 == 0
70
+ iargs = args.map do |elem|
71
+ elem.to_i
72
+ end
73
+
74
+ res = $dev.lun_set_table iargs
75
+
76
+ puts res[0] == 0 ? 'OK'.light_green : 'Fail'.light_red
77
+ else
78
+ puts 'Bad table description'.light_red
79
+ end
15
80
  end
16
81
  end
17
82
  end
@@ -0,0 +1,24 @@
1
+ desc 'RTC'
2
+ command :time do |c|
3
+ c.desc 'Synchronize time to host'
4
+ c.command :sync do |sync|
5
+ sync.action do |global_opts, opts, args|
6
+ res = $dev.settime(Time.now.to_i)[0]
7
+
8
+ puts res[0] == 0 ? 'OK'.light_green : 'Fail'.light_red
9
+ end
10
+ end
11
+
12
+ c.action do |global_opts, opts, args|
13
+ res = $dev.gettime[0]
14
+
15
+ if res < 200
16
+ puts "Fail with code #{res}".light_red
17
+ else
18
+ puts "#{Time.at res}".light_yellow
19
+ end
20
+ end
21
+ end
22
+
23
+ # vim: sw=2 sts=2 ts=8:
24
+
data/lib/svi/version.rb CHANGED
@@ -1 +1 @@
1
- VERSION='0.3.14'
1
+ VERSION='0.3.15'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.14
4
+ version: 0.3.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Levenkov Artem
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-28 00:00:00.000000000 Z
11
+ date: 2015-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libusb
@@ -33,41 +33,13 @@ dependencies:
33
33
  description: Service Interface
34
34
  email: alev@mcs51.ru
35
35
  executables:
36
- - usb_reconnect
37
- - lun_set_mode
38
- - random
39
- - system_reset
40
- - lun_get_count
41
- - lun_set_count
42
- - lun_set_table
43
36
  - svi
44
37
  - svirb
45
- - lun_save_table
46
- - settime
47
- - dfu
48
- - lun_format_ao
49
- - gettime
50
- - led_set
51
- - lun_get_table
52
38
  extensions: []
53
39
  extra_rdoc_files: []
54
40
  files:
55
- - bin/dfu
56
- - bin/gettime
57
- - bin/led_set
58
- - bin/lun_format_ao
59
- - bin/lun_get_count
60
- - bin/lun_get_table
61
- - bin/lun_save_table
62
- - bin/lun_set_count
63
- - bin/lun_set_mode
64
- - bin/lun_set_table
65
- - bin/random
66
- - bin/settime
67
41
  - bin/svi
68
42
  - bin/svirb
69
- - bin/system_reset
70
- - bin/usb_reconnect
71
43
  - lib/svi/api.generated.rb
72
44
  - lib/svi/api.rb
73
45
  - lib/svi/cmd/app.rb
@@ -77,6 +49,7 @@ files:
77
49
  - lib/svi/cmd/lun.rb
78
50
  - lib/svi/cmd/random.rb
79
51
  - lib/svi/cmd/sys.rb
52
+ - lib/svi/cmd/time.rb
80
53
  - lib/svi/cmd/usb.rb
81
54
  - lib/svi/sbiif.rb
82
55
  - lib/svi/svi.rb
data/bin/dfu 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: dfu [options] filepath"
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 = 10000
26
- options.devnum = 0
27
- options.devnum_mod = nil
28
- options.rescue = false
29
- options.verbose = false
30
- options.target = :kernel
31
-
32
- opts.on("--app", "Update application") do
33
- options.target = :app
34
- end
35
-
36
- opts.separator ""
37
- opts.separator "Common options:"
38
-
39
- opts.on('--rescue', 'Set when device in rescue mode') do
40
- options.svi_if = 0
41
- options.rescue = true
42
- end
43
-
44
- opts.on("-D", "--device vid:pid", String, "Use appropriate VID/PID") do |vidpid|
45
- vidpid = vidpid.split ':'
46
- options.vid = vidpid[0].hex
47
- options.pid = vidpid[1].hex
48
- end
49
-
50
- opts.on("-N", "--device-number N", Integer, "Use device number N (see device list by --list option)") do |devnum|
51
- options.devnum = devnum
52
- options.devnum_mod = true
53
- end
54
-
55
- opts.on("-T", "--timeout milliseconds", Integer, "Timeout for transfers on both interfaces") do |timeout|
56
- options.timeout = timeout
57
- end
58
-
59
- opts.on("--svi-if ifnum:epout:epin", String, "Define interface for SVI") do |args|
60
- args = args.split ':'
61
- options.svi_if = args[0].hex
62
- options.svi_if_ep_out = args[1].hex
63
- options.svi_if_ep_in = args[2].hex
64
- end
65
-
66
- opts.on("--sbi-if ifnum:epout:epin", String, "Define interface for SBI") do |args|
67
- args = args.split ':'
68
- options.sbi_if = args[0].hex
69
- options.sbi_if_ep_out = args[1].hex
70
- options.sbi_if_ep_in = args[2].hex
71
- end
72
-
73
- opts.on_tail("-l", "--list", "Show devices list only") do
74
- USB.new(options.vid, options.pid).svi_devices.each_with_index { |dev, i|
75
- puts "#%d %s %s" % [i, dev.manufacturer, dev.product]
76
- }
77
- exit
78
- end
79
-
80
- opts.on("--verbose", "Print maximum information") do
81
- options.verbose = true
82
- end
83
-
84
- opts.on_tail("-h", "--help", "Show this message") do
85
- puts opts
86
- exit
87
- end
88
-
89
- opts.on_tail("--version", "Show version") do
90
- puts SVI_VERSION
91
- exit
92
- end
93
- end
94
-
95
- opt_parser.parse!(args)
96
- [options, opt_parser]
97
- end
98
-
99
- res = parse_options(ARGV)
100
- options = res[0]
101
- opt_parser = res[1]
102
-
103
- if ARGV.count != ARGS_NUM
104
- p opt_parser
105
- exit 1
106
- end
107
-
108
- argv = ARGV.reverse
109
-
110
- firmware_path = Pathname.new(argv.pop).expand_path
111
-
112
- devs = USB.new(options.vid, options.pid).svi_devices
113
-
114
- if devs.count == 0
115
- puts 'Device not found'
116
- exit 1
117
- end
118
-
119
- if devs.count > 1 and options.devnum_mod.nil?
120
- puts 'There are more than one devices, using device #%d.' % options.devnum
121
- puts 'Use option -N to define necessary device.'
122
- puts "To view list of devices use -l option.\n\n"
123
- end
124
-
125
- dev = devs[options.devnum]
126
-
127
- dev.svi_if = options.svi_if
128
- dev.svi_if_ep_out = options.svi_if_ep_out
129
- dev.svi_if_ep_in = options.svi_if_ep_in
130
-
131
- dev.sbi_if = options.sbi_if
132
- dev.sbi_if_ep_out = options.sbi_if_ep_out
133
- dev.sbi_if_ep_in = options.sbi_if_ep_in
134
-
135
- dev.svi_timeout = options.timeout
136
- dev.sbi_timeout = options.timeout
137
-
138
- if options.verbose
139
- puts "Configuration:"
140
- puts "Device # = %d" % options.devnum
141
- puts "idVendor = 0x%04x" % options.vid
142
- puts "idProduct = 0x%04x" % options.pid
143
- puts "Interface number SVI = %d" % options.svi_if
144
- puts "OUT endpoint for SVI = 0x%02x" % options.svi_if_ep_out
145
- puts "IN endpoint for SVI = 0x%02x" % (options.svi_if_ep_in | 0x80)
146
- puts "Interface number SBI = %d" % options.sbi_if
147
- puts "OUT endpoint for SBI = 0x%02x" % options.sbi_if_ep_out
148
- puts "IN endpoint for SBI = 0x%02x" % (options.sbi_if_ep_in | 0x80)
149
- puts "Timeout for IN operations = %d msec" % options.timeout
150
- puts "\n\n"
151
- end
152
-
153
- if options.verbose
154
- puts "dfu(%s)" % [firmware_path.to_s]
155
- end
156
-
157
- res = dev.nvm_load_file(1, 0, firmware_path.to_s)
158
-
159
- raise "Can't load firmware into buffer" if res != [0]
160
-
161
- res = dev.nvm_verify_file(1, 0, firmware_path.to_s)
162
-
163
- raise "Can't verify firmware into buffer" if res != [0]
164
-
165
- addr = 0x10000 if options.target == :kernel
166
- addr = 0x20000 if options.target == :app
167
-
168
- res = dev.firmware_program addr, firmware_path.size()/512+1, !options.rescue
169
-
170
- if options.verbose
171
- end
172
-
173
- p res
174
-
175
- # vim: sw=2 sts=2 ts=8:
176
-
data/bin/gettime 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 = 'gettime'
10
- USAGE = "Usage: #{PROG_NAME} [options] [time]"
11
- ARGS_NUM = (0..0)
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 = 10000
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
- 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
- end
143
-
144
- res = dev.gettime
145
-
146
- if options.verbose
147
- end
148
-
149
- p res
150
- p Time.at res
151
-
152
- # vim: sw=2 sts=2 ts=8:
153
-