svi 0.2.9
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 +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
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            !binary "U0hBMQ==":
         | 
| 3 | 
            +
              metadata.gz: !binary |-
         | 
| 4 | 
            +
                NWVjYWE1YWM1NzM3N2YwZjk1YThiMzc1Y2MzZmM3M2JmZjczOGZiNQ==
         | 
| 5 | 
            +
              data.tar.gz: !binary |-
         | 
| 6 | 
            +
                MWExMTI5YzYzMWNmMTc5YjgwMmQ5MjE4Mjc0MGVmZWQzYWY1MTU5Ng==
         | 
| 7 | 
            +
            SHA512:
         | 
| 8 | 
            +
              metadata.gz: !binary |-
         | 
| 9 | 
            +
                ODE3Njg4Y2M3ZjBjZmUzYTMxZTRlYmU4YmJhZDI0ZTg0Yjg3ZWI0NzAxMDE0
         | 
| 10 | 
            +
                NTcyNjIyMjI4NmU4NjkwODM4NGFlYjJlYTg1MTljNDk0MDExZmFlMmU0ZDIw
         | 
| 11 | 
            +
                NjEyNzMxNjBiMGVjMjRhZjM0ZDgyZTc3YzYzNjlhOTg5YTljMjM=
         | 
| 12 | 
            +
              data.tar.gz: !binary |-
         | 
| 13 | 
            +
                NjM3MTRiMDY3ZDM1ZjRhNWNmM2MyNGVmYTgzZTM5M2E0NDU0YTliMDUzMjBl
         | 
| 14 | 
            +
                YWE2MTY5ODI4YjlmZDNhZjIxYWI0YTFkNWY4Y2VlNDFiMTlkZWZjMDYyMmY3
         | 
| 15 | 
            +
                YTAwMDUzZGI0YzQ4ZmNhODAzNjNlZDEyZDQxYzg5NDA1NzU2OGI=
         | 
    
        data/bin/dfu
    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: 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
    ADDED
    
    | @@ -0,0 +1,153 @@ | |
| 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 | 
            +
             | 
    
        data/bin/led_set
    ADDED
    
    | @@ -0,0 +1,158 @@ | |
| 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
    ADDED
    
    | @@ -0,0 +1,153 @@ | |
| 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 | 
            +
             |