modbus-cli 0.0.13 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.travis.yml +1 -1
 - data/lib/modbus-cli/commands_common.rb +6 -0
 - data/lib/modbus-cli/read_command.rb +8 -1
 - data/lib/modbus-cli/version.rb +1 -1
 - data/lib/modbus-cli/write_command.rb +8 -1
 - data/modbus-cli.gemspec +1 -1
 - data/spec/dump_command_spec.rb +0 -7
 - data/spec/read_command_spec.rb +25 -26
 - data/spec/write_command_spec.rb +18 -14
 - metadata +5 -5
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 619dfae9c197b362c05c0b2e09f098505d0ddc3a
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: e6680b55e2b2acbddf157c6b7d10c3908f48b638
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 2079acde76a8b597ec68c24bed2734069d51d255ad7832ff68d51f07433de1fdc54c7fe864a051fc5eff6bf32d68f0bda0f9e93198fa2b76cd787b1368b3b591
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: '0198d380c09a329db158cdd5607101a7b69db672bfbbd5d5fe64b3510c27eeca1ee9e588cba5d6b3b6ca3b456326dc40b18dbc874ca8d05b053873a325d6b273'
         
     | 
    
        data/.travis.yml
    CHANGED
    
    
| 
         @@ -19,6 +19,7 @@ module Modbus 
     | 
|
| 
       19 
19 
     | 
    
         
             
                  option ["-o", "--output"], 'FILE', "write results to file FILE"
         
     | 
| 
       20 
20 
     | 
    
         
             
                  debug_option
         
     | 
| 
       21 
21 
     | 
    
         
             
                  timeout_option
         
     | 
| 
      
 22 
     | 
    
         
            +
                  connect_timeout_option
         
     | 
| 
       22 
23 
     | 
    
         | 
| 
       23 
24 
     | 
    
         
             
                  parameter 'COUNT', 'number of data to read', :attribute_name => :count do |c|
         
     | 
| 
       24 
25 
     | 
    
         
             
                    result = Integer(c)
         
     | 
| 
         @@ -73,7 +74,13 @@ module Modbus 
     | 
|
| 
       73 
74 
     | 
    
         
             
                  end
         
     | 
| 
       74 
75 
     | 
    
         | 
| 
       75 
76 
     | 
    
         
             
                  def execute
         
     | 
| 
       76 
     | 
    
         
            -
                     
     | 
| 
      
 77 
     | 
    
         
            +
                    connect_args =
         
     | 
| 
      
 78 
     | 
    
         
            +
                      if connect_timeout
         
     | 
| 
      
 79 
     | 
    
         
            +
                        [host, port, {connect_timeout: connect_timeout}]
         
     | 
| 
      
 80 
     | 
    
         
            +
                      else
         
     | 
| 
      
 81 
     | 
    
         
            +
                        [host, port]
         
     | 
| 
      
 82 
     | 
    
         
            +
                      end
         
     | 
| 
      
 83 
     | 
    
         
            +
                    ModBus::TCPClient.connect(*connect_args) do |cl|
         
     | 
| 
       77 
84 
     | 
    
         
             
                      cl.with_slave(slave) do |sl|
         
     | 
| 
       78 
85 
     | 
    
         
             
                        sl.debug = true if debug?
         
     | 
| 
       79 
86 
     | 
    
         
             
                        sl.read_retry_timeout = timeout if timeout
         
     | 
    
        data/lib/modbus-cli/version.rb
    CHANGED
    
    
| 
         @@ -15,6 +15,7 @@ module Modbus 
     | 
|
| 
       15 
15 
     | 
    
         
             
                  address_parameter
         
     | 
| 
       16 
16 
     | 
    
         
             
                  debug_option
         
     | 
| 
       17 
17 
     | 
    
         
             
                  timeout_option
         
     | 
| 
      
 18 
     | 
    
         
            +
                  connect_timeout_option
         
     | 
| 
       18 
19 
     | 
    
         | 
| 
       19 
20 
     | 
    
         
             
                  parameter 'VALUES ...', 'values to write, nonzero counts as true for discrete values' do |v|
         
     | 
| 
       20 
21 
     | 
    
         
             
                    case addr_type
         
     | 
| 
         @@ -35,7 +36,13 @@ module Modbus 
     | 
|
| 
       35 
36 
     | 
    
         | 
| 
       36 
37 
     | 
    
         | 
| 
       37 
38 
     | 
    
         
             
                  def execute
         
     | 
| 
       38 
     | 
    
         
            -
                     
     | 
| 
      
 39 
     | 
    
         
            +
                    connect_args =
         
     | 
| 
      
 40 
     | 
    
         
            +
                      if connect_timeout
         
     | 
| 
      
 41 
     | 
    
         
            +
                        [host, port, {connect_timeout: connect_timeout}]
         
     | 
| 
      
 42 
     | 
    
         
            +
                      else
         
     | 
| 
      
 43 
     | 
    
         
            +
                        [host, port]
         
     | 
| 
      
 44 
     | 
    
         
            +
                      end
         
     | 
| 
      
 45 
     | 
    
         
            +
                    ModBus::TCPClient.connect(*connect_args) do |cl|
         
     | 
| 
       39 
46 
     | 
    
         
             
                      cl.with_slave(slave) do |sl|
         
     | 
| 
       40 
47 
     | 
    
         
             
                        sl.debug = true if debug?
         
     | 
| 
       41 
48 
     | 
    
         
             
                        sl.read_retry_timeout = timeout if timeout
         
     | 
    
        data/modbus-cli.gemspec
    CHANGED
    
    | 
         @@ -25,5 +25,5 @@ Gem::Specification.new do |s| 
     | 
|
| 
       25 
25 
     | 
    
         
             
              s.add_runtime_dependency "gserver", '~> 0.0'
         
     | 
| 
       26 
26 
     | 
    
         
             
              s.add_development_dependency "rspec", '~> 3.5'
         
     | 
| 
       27 
27 
     | 
    
         
             
              s.add_development_dependency "rake", '~> 12.0'
         
     | 
| 
       28 
     | 
    
         
            -
              s.add_development_dependency "bundler", '~> 1. 
     | 
| 
      
 28 
     | 
    
         
            +
              s.add_development_dependency "bundler", '~> 1.16'
         
     | 
| 
       29 
29 
     | 
    
         
             
            end
         
     | 
    
        data/spec/dump_command_spec.rb
    CHANGED
    
    
    
        data/spec/read_command_spec.rb
    CHANGED
    
    | 
         @@ -4,49 +4,49 @@ require 'yaml' 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            describe Modbus::Cli::ReadCommand do
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
              include OutputCapture
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
              before(:each) do
         
     | 
| 
       10 
10 
     | 
    
         
             
                stub_tcpip
         
     | 
| 
       11 
11 
     | 
    
         
             
              end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
              it 'can read holding registers' do
         
     | 
| 
       14 
     | 
    
         
            -
                 
     | 
| 
      
 14 
     | 
    
         
            +
                _client, slave = standard_connect_helper '1.2.3.4', 502
         
     | 
| 
       15 
15 
     | 
    
         
             
                slave.should_receive(:read_holding_registers).with(100, 10).and_return((0..9).to_a)
         
     | 
| 
       16 
16 
     | 
    
         
             
                cmd.run %w(read 1.2.3.4 %MW100 10)
         
     | 
| 
       17 
17 
     | 
    
         
             
                stdout.should match(/^\s*%MW105\s*5$/)
         
     | 
| 
       18 
18 
     | 
    
         
             
              end
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
              it 'can read input registers' do
         
     | 
| 
       21 
     | 
    
         
            -
                 
     | 
| 
      
 21 
     | 
    
         
            +
                _client, slave = standard_connect_helper '1.2.3.4', 502
         
     | 
| 
       22 
22 
     | 
    
         
             
                slave.should_receive(:read_input_registers).with(100, 10).and_return((0..9).to_a)
         
     | 
| 
       23 
23 
     | 
    
         
             
                cmd.run %w(read 1.2.3.4 300101 10)
         
     | 
| 
       24 
24 
     | 
    
         
             
                stdout.should match(/^\s*300106\s*5$/)
         
     | 
| 
       25 
25 
     | 
    
         
             
              end
         
     | 
| 
       26 
26 
     | 
    
         | 
| 
       27 
27 
     | 
    
         
             
              it 'can read floating point numbers' do
         
     | 
| 
       28 
     | 
    
         
            -
                 
     | 
| 
      
 28 
     | 
    
         
            +
                _client, slave = standard_connect_helper '1.2.3.4', 502
         
     | 
| 
       29 
29 
     | 
    
         
             
                slave.should_receive(:read_holding_registers).with(100, 4).and_return([52429, 17095, 52429, 17095])
         
     | 
| 
       30 
30 
     | 
    
         
             
                cmd.run %w(read 1.2.3.4 %MF100 2)
         
     | 
| 
       31 
31 
     | 
    
         
             
                stdout.should match(/^\s*%MF102\s*99[.]9(00[0-9]*)?$/)
         
     | 
| 
       32 
32 
     | 
    
         
             
              end
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
              it 'should display numbers with good precision' do
         
     | 
| 
       35 
     | 
    
         
            -
                 
     | 
| 
      
 35 
     | 
    
         
            +
                _client, slave = standard_connect_helper '1.2.3.4', 502
         
     | 
| 
       36 
36 
     | 
    
         
             
                slave.should_receive(:read_holding_registers).and_return([1049, 16286])
         
     | 
| 
       37 
37 
     | 
    
         
             
                cmd.run %w(read 1.2.3.4 %MF100 1)
         
     | 
| 
       38 
38 
     | 
    
         
             
                stdout.should match(/^\s*%MF100\s*1[.]2345\d*$/)
         
     | 
| 
       39 
39 
     | 
    
         
             
              end
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         
             
              it 'can read double word numbers' do
         
     | 
| 
       42 
     | 
    
         
            -
                 
     | 
| 
      
 42 
     | 
    
         
            +
                _client, slave = standard_connect_helper '1.2.3.4', 502
         
     | 
| 
       43 
43 
     | 
    
         
             
                slave.should_receive(:read_holding_registers).with(100, 4).and_return([16959, 15, 16959, 15])
         
     | 
| 
       44 
44 
     | 
    
         
             
                cmd.run %w(read 1.2.3.4 %MD100 2)
         
     | 
| 
       45 
45 
     | 
    
         
             
                stdout.should match(/^\s*%MD102\s*999999$/)
         
     | 
| 
       46 
46 
     | 
    
         
             
              end
         
     | 
| 
       47 
47 
     | 
    
         | 
| 
       48 
48 
     | 
    
         
             
              it 'can read coils' do
         
     | 
| 
       49 
     | 
    
         
            -
                 
     | 
| 
      
 49 
     | 
    
         
            +
                _client, slave = standard_connect_helper '1.2.3.4', 502
         
     | 
| 
       50 
50 
     | 
    
         
             
                slave.should_receive(:read_coils).with(100, 10).and_return([1, 0] * 5)
         
     | 
| 
       51 
51 
     | 
    
         
             
                cmd.run %w(read 1.2.3.4 %M100 10)
         
     | 
| 
       52 
52 
     | 
    
         
             
                stdout.should match(/^\s*%M105\s*0$/)
         
     | 
| 
         @@ -66,14 +66,14 @@ describe Modbus::Cli::ReadCommand do 
     | 
|
| 
       66 
66 
     | 
    
         
             
              end
         
     | 
| 
       67 
67 
     | 
    
         | 
| 
       68 
68 
     | 
    
         
             
              it 'should split large reads into smaller chunks for words' do
         
     | 
| 
       69 
     | 
    
         
            -
                 
     | 
| 
      
 69 
     | 
    
         
            +
                _client, slave = standard_connect_helper '1.2.3.4', 502
         
     | 
| 
       70 
70 
     | 
    
         
             
                slave.should_receive(:read_holding_registers).with(100, 125).and_return([1, 0] * 1000)
         
     | 
| 
       71 
71 
     | 
    
         
             
                slave.should_receive(:read_holding_registers).with(225, 25).and_return([1, 0] * 1000)
         
     | 
| 
       72 
72 
     | 
    
         
             
                cmd.run %w(read 1.2.3.4 %MW100 150)
         
     | 
| 
       73 
73 
     | 
    
         
             
              end
         
     | 
| 
       74 
74 
     | 
    
         | 
| 
       75 
75 
     | 
    
         
             
              it 'should split large reads into smaller chunks for coils' do
         
     | 
| 
       76 
     | 
    
         
            -
                 
     | 
| 
      
 76 
     | 
    
         
            +
                _client, slave = standard_connect_helper '1.2.3.4', 502
         
     | 
| 
       77 
77 
     | 
    
         
             
                slave.should_receive(:read_coils).with(100, 1000).and_return([1, 0] * 500)
         
     | 
| 
       78 
78 
     | 
    
         
             
                slave.should_receive(:read_coils).with(1100, 1000).and_return([1, 0] * 500)
         
     | 
| 
       79 
79 
     | 
    
         
             
                slave.should_receive(:read_coils).with(2100, 1000).and_return([1, 0] * 500)
         
     | 
| 
         @@ -81,39 +81,39 @@ describe Modbus::Cli::ReadCommand do 
     | 
|
| 
       81 
81 
     | 
    
         
             
              end
         
     | 
| 
       82 
82 
     | 
    
         | 
| 
       83 
83 
     | 
    
         
             
              it 'can read registers as ints' do
         
     | 
| 
       84 
     | 
    
         
            -
                 
     | 
| 
      
 84 
     | 
    
         
            +
                _client, slave = standard_connect_helper '1.2.3.4', 502
         
     | 
| 
       85 
85 
     | 
    
         
             
                slave.should_receive(:read_holding_registers).with(100, 1).and_return([0xffff])
         
     | 
| 
       86 
86 
     | 
    
         
             
                cmd.run %w(read --int 1.2.3.4 %MW100 1)
         
     | 
| 
       87 
87 
     | 
    
         
             
                stdout.should match(/^\s*%MW100\s*-1$/)
         
     | 
| 
       88 
88 
     | 
    
         
             
              end
         
     | 
| 
       89 
89 
     | 
    
         | 
| 
       90 
90 
     | 
    
         
             
              it 'can read registers as floats' do
         
     | 
| 
       91 
     | 
    
         
            -
                 
     | 
| 
      
 91 
     | 
    
         
            +
                _client, slave = standard_connect_helper '1.2.3.4', 502
         
     | 
| 
       92 
92 
     | 
    
         
             
                slave.should_receive(:read_holding_registers).with(100, 2).and_return([0,0])
         
     | 
| 
       93 
93 
     | 
    
         
             
                cmd.run %w(read --float 1.2.3.4 %MW100 1)
         
     | 
| 
       94 
94 
     | 
    
         
             
              end
         
     | 
| 
       95 
95 
     | 
    
         | 
| 
       96 
96 
     | 
    
         
             
              it 'can read registers as dwords' do
         
     | 
| 
       97 
     | 
    
         
            -
                 
     | 
| 
      
 97 
     | 
    
         
            +
                _client, slave = standard_connect_helper '1.2.3.4', 502
         
     | 
| 
       98 
98 
     | 
    
         
             
                slave.should_receive(:read_holding_registers).with(100, 2).and_return([0,0])
         
     | 
| 
       99 
99 
     | 
    
         
             
                cmd.run %w(read --dword 1.2.3.4 %MW100 1)
         
     | 
| 
       100 
100 
     | 
    
         
             
              end
         
     | 
| 
       101 
101 
     | 
    
         | 
| 
       102 
102 
     | 
    
         
             
              it 'can read registers as words' do
         
     | 
| 
       103 
     | 
    
         
            -
                 
     | 
| 
      
 103 
     | 
    
         
            +
                _client, slave = standard_connect_helper '1.2.3.4', 502
         
     | 
| 
       104 
104 
     | 
    
         
             
                slave.should_receive(:read_holding_registers).with(100, 1).and_return([0])
         
     | 
| 
       105 
105 
     | 
    
         
             
                cmd.run %w(read --word 1.2.3.4 %MD100 1)
         
     | 
| 
       106 
106 
     | 
    
         
             
              end
         
     | 
| 
       107 
107 
     | 
    
         | 
| 
       108 
108 
     | 
    
         
             
              it 'accepts Modicon addresses for coils' do
         
     | 
| 
       109 
     | 
    
         
            -
                 
     | 
| 
      
 109 
     | 
    
         
            +
                _client, slave = standard_connect_helper '1.2.3.4', 502
         
     | 
| 
       110 
110 
     | 
    
         
             
                slave.should_receive(:read_coils).with(100, 10).and_return([1, 0] * 5)
         
     | 
| 
       111 
111 
     | 
    
         
             
                cmd.run %w(read 1.2.3.4 101 10)
         
     | 
| 
       112 
112 
     | 
    
         
             
                stdout.should match(/^\s*106\s*0$/)
         
     | 
| 
       113 
113 
     | 
    
         
             
              end
         
     | 
| 
       114 
114 
     | 
    
         | 
| 
       115 
115 
     | 
    
         
             
              it 'accepts Modicon addresses for registers' do
         
     | 
| 
       116 
     | 
    
         
            -
                 
     | 
| 
      
 116 
     | 
    
         
            +
                _client, slave = standard_connect_helper '1.2.3.4', 502
         
     | 
| 
       117 
117 
     | 
    
         
             
                slave.should_receive(:read_holding_registers).with(100, 10).and_return((0..9).to_a)
         
     | 
| 
       118 
118 
     | 
    
         
             
                cmd.run %w(read 1.2.3.4 400101 10)
         
     | 
| 
       119 
119 
     | 
    
         
             
                stdout.should match(/^\s*400106\s*5$/)
         
     | 
| 
         @@ -121,14 +121,14 @@ describe Modbus::Cli::ReadCommand do 
     | 
|
| 
       121 
121 
     | 
    
         | 
| 
       122 
122 
     | 
    
         | 
| 
       123 
123 
     | 
    
         
             
              it 'should accept the --modicon option to force modicon output' do
         
     | 
| 
       124 
     | 
    
         
            -
                 
     | 
| 
      
 124 
     | 
    
         
            +
                _client, slave = standard_connect_helper '1.2.3.4', 502
         
     | 
| 
       125 
125 
     | 
    
         
             
                slave.should_receive(:read_holding_registers).with(100, 10).and_return((0..9).to_a)
         
     | 
| 
       126 
126 
     | 
    
         
             
                cmd.run %w(read --modicon 1.2.3.4 %MW100 10)
         
     | 
| 
       127 
127 
     | 
    
         
             
                stdout.should match(/^\s*400106\s*5$/)
         
     | 
| 
       128 
128 
     | 
    
         
             
              end
         
     | 
| 
       129 
129 
     | 
    
         | 
| 
       130 
130 
     | 
    
         
             
              it 'should accept the --schneider option to force schneider output' do 
         
     | 
| 
       131 
     | 
    
         
            -
                 
     | 
| 
      
 131 
     | 
    
         
            +
                _client, slave = standard_connect_helper '1.2.3.4', 502
         
     | 
| 
       132 
132 
     | 
    
         
             
                slave.should_receive(:read_holding_registers).with(100, 10).and_return((0..9).to_a)
         
     | 
| 
       133 
133 
     | 
    
         
             
                cmd.run %w(read --schneider 1.2.3.4 400101 10)
         
     | 
| 
       134 
134 
     | 
    
         
             
                stdout.should match(/^\s*%MW105\s*5$/)
         
     | 
| 
         @@ -142,7 +142,7 @@ describe Modbus::Cli::ReadCommand do 
     | 
|
| 
       142 
142 
     | 
    
         
             
              end
         
     | 
| 
       143 
143 
     | 
    
         | 
| 
       144 
144 
     | 
    
         
             
              it 'can write the output from reading registers to a yaml file using the -o <filename> parameter' do
         
     | 
| 
       145 
     | 
    
         
            -
                 
     | 
| 
      
 145 
     | 
    
         
            +
                _client, slave = standard_connect_helper '1.2.3.4', 502
         
     | 
| 
       146 
146 
     | 
    
         
             
                slave.should_receive(:read_holding_registers).with(100, 1).and_return([1])
         
     | 
| 
       147 
147 
     | 
    
         
             
                file_double = double('file')
         
     | 
| 
       148 
148 
     | 
    
         
             
                File.should_receive(:open).and_yield(file_double)
         
     | 
| 
         @@ -152,7 +152,7 @@ describe Modbus::Cli::ReadCommand do 
     | 
|
| 
       152 
152 
     | 
    
         
             
              end
         
     | 
| 
       153 
153 
     | 
    
         | 
| 
       154 
154 
     | 
    
         
             
              it 'can write the output from reading coils to a yaml file using the -o <filename> parameter' do
         
     | 
| 
       155 
     | 
    
         
            -
                 
     | 
| 
      
 155 
     | 
    
         
            +
                _client, slave = standard_connect_helper '1.2.3.4', 502
         
     | 
| 
       156 
156 
     | 
    
         
             
                slave.should_receive(:read_coils).with(100, 1).and_return([1])
         
     | 
| 
       157 
157 
     | 
    
         
             
                file_double = double('file')
         
     | 
| 
       158 
158 
     | 
    
         
             
                File.should_receive(:open).and_yield(file_double)
         
     | 
| 
         @@ -162,23 +162,22 @@ describe Modbus::Cli::ReadCommand do 
     | 
|
| 
       162 
162 
     | 
    
         
             
              end
         
     | 
| 
       163 
163 
     | 
    
         | 
| 
       164 
164 
     | 
    
         
             
              it 'has a --debug flag' do
         
     | 
| 
       165 
     | 
    
         
            -
                 
     | 
| 
      
 165 
     | 
    
         
            +
                _client, slave = standard_connect_helper '1.2.3.4', 502
         
     | 
| 
       166 
166 
     | 
    
         
             
                slave.should_receive(:read_holding_registers).with(100, 10).and_return((0..9).to_a)
         
     | 
| 
       167 
167 
     | 
    
         
             
                slave.should_receive(:debug=).with(true)
         
     | 
| 
       168 
168 
     | 
    
         
             
                cmd.run %w(read --debug 1.2.3.4 %MW100 10)
         
     | 
| 
       169 
169 
     | 
    
         
             
              end
         
     | 
| 
       170 
170 
     | 
    
         | 
| 
       171 
171 
     | 
    
         
             
              it 'has a --timeout flag' do
         
     | 
| 
       172 
     | 
    
         
            -
                 
     | 
| 
      
 172 
     | 
    
         
            +
                _client, slave = standard_connect_helper '1.2.3.4', 502
         
     | 
| 
       173 
173 
     | 
    
         
             
                slave.should_receive(:read_retry_timeout=).with(99)
         
     | 
| 
       174 
174 
     | 
    
         
             
                slave.should_receive(:read_holding_registers).with(100, 10).and_return((0..9).to_a)
         
     | 
| 
       175 
175 
     | 
    
         
             
                cmd.run %w(read --timeout 99 1.2.3.4 %MW100 10)
         
     | 
| 
       176 
176 
     | 
    
         
             
              end
         
     | 
| 
       177 
177 
     | 
    
         | 
| 
       178 
     | 
    
         
            -
             
     | 
| 
      
 178 
     | 
    
         
            +
              it 'has a --connect-timeout flag' do
         
     | 
| 
      
 179 
     | 
    
         
            +
                ModBus::TCPClient.should_receive(:connect).with('X', 502, connect_timeout: 99)
         
     | 
| 
      
 180 
     | 
    
         
            +
                cmd.run %w(read --connect-timeout 99 X %MW100 10)
         
     | 
| 
      
 181 
     | 
    
         
            +
              end
         
     | 
| 
       179 
182 
     | 
    
         
             
            end
         
     | 
| 
       180 
183 
     | 
    
         | 
| 
       181 
     | 
    
         
            -
             
     | 
| 
       182 
     | 
    
         
            -
             
     | 
| 
       183 
     | 
    
         
            -
             
     | 
| 
       184 
     | 
    
         
            -
             
     | 
    
        data/spec/write_command_spec.rb
    CHANGED
    
    | 
         @@ -10,26 +10,26 @@ describe Modbus::Cli::WriteCommand do 
     | 
|
| 
       10 
10 
     | 
    
         
             
              end
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
              it 'can write to registers' do
         
     | 
| 
       13 
     | 
    
         
            -
                 
     | 
| 
      
 13 
     | 
    
         
            +
                _client, slave = standard_connect_helper 'HOST', 502
         
     | 
| 
       14 
14 
     | 
    
         
             
                slave.should_receive(:write_holding_registers).with(100, [1, 2, 3, 4])
         
     | 
| 
       15 
15 
     | 
    
         
             
                cmd.run %w(write HOST %MW100 1 2 3 4)
         
     | 
| 
       16 
16 
     | 
    
         
             
              end
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
              it 'can write floating point numbers' do
         
     | 
| 
       20 
     | 
    
         
            -
                 
     | 
| 
      
 20 
     | 
    
         
            +
                _client, slave = standard_connect_helper 'HOST', 502
         
     | 
| 
       21 
21 
     | 
    
         
             
                slave.should_receive(:write_holding_registers).with(100, [52429, 17095, 52429, 17095])
         
     | 
| 
       22 
22 
     | 
    
         
             
                cmd.run %w(write HOST %MF100 99.9 99.9)
         
     | 
| 
       23 
23 
     | 
    
         
             
              end
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
              it 'can write double word numbers' do
         
     | 
| 
       26 
     | 
    
         
            -
                 
     | 
| 
      
 26 
     | 
    
         
            +
                _client, slave = standard_connect_helper 'HOST', 502
         
     | 
| 
       27 
27 
     | 
    
         
             
                slave.should_receive(:write_holding_registers).with(100, [16959, 15, 16959, 15])
         
     | 
| 
       28 
28 
     | 
    
         
             
                cmd.run %w(write HOST %MD100 999999 999999)
         
     | 
| 
       29 
29 
     | 
    
         
             
              end
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
31 
     | 
    
         
             
              it 'can write to coils' do
         
     | 
| 
       32 
     | 
    
         
            -
                 
     | 
| 
      
 32 
     | 
    
         
            +
                _client, slave = standard_connect_helper 'HOST', 502
         
     | 
| 
       33 
33 
     | 
    
         
             
                slave.should_receive(:write_multiple_coils).with(100, [1, 0, 1, 0, 1, 0, 0, 1, 1])
         
     | 
| 
       34 
34 
     | 
    
         
             
                cmd.run %w(write HOST %M100 1 0 1 0 1 0 0 1 1)
         
     | 
| 
       35 
35 
     | 
    
         
             
              end
         
     | 
| 
         @@ -45,14 +45,14 @@ describe Modbus::Cli::WriteCommand do 
     | 
|
| 
       45 
45 
     | 
    
         | 
| 
       46 
46 
     | 
    
         | 
| 
       47 
47 
     | 
    
         
             
              it 'should split large writes in chunks for words' do
         
     | 
| 
       48 
     | 
    
         
            -
                 
     | 
| 
      
 48 
     | 
    
         
            +
                _client, slave = standard_connect_helper 'HOST', 502
         
     | 
| 
       49 
49 
     | 
    
         
             
                slave.should_receive(:write_holding_registers).with(100, (1..123).to_a)
         
     | 
| 
       50 
50 
     | 
    
         
             
                slave.should_receive(:write_holding_registers).with(223, (124..150).to_a)
         
     | 
| 
       51 
51 
     | 
    
         
             
                cmd.run %w(write HOST %MW100) + (1..150).to_a
         
     | 
| 
       52 
52 
     | 
    
         
             
              end
         
     | 
| 
       53 
53 
     | 
    
         | 
| 
       54 
54 
     | 
    
         
             
              it 'should split large writes in chunks for coils' do
         
     | 
| 
       55 
     | 
    
         
            -
                 
     | 
| 
      
 55 
     | 
    
         
            +
                _client, slave = standard_connect_helper 'HOST', 502
         
     | 
| 
       56 
56 
     | 
    
         
             
                slave.should_receive(:write_multiple_coils).with(100, [0, 1] * 400)
         
     | 
| 
       57 
57 
     | 
    
         
             
                slave.should_receive(:write_multiple_coils).with(900, [0, 1] * 400)
         
     | 
| 
       58 
58 
     | 
    
         
             
                slave.should_receive(:write_multiple_coils).with(1700, [0, 1] * 200)
         
     | 
| 
         @@ -60,37 +60,37 @@ describe Modbus::Cli::WriteCommand do 
     | 
|
| 
       60 
60 
     | 
    
         
             
              end
         
     | 
| 
       61 
61 
     | 
    
         | 
| 
       62 
62 
     | 
    
         
             
              it 'can write to registers as ints' do
         
     | 
| 
       63 
     | 
    
         
            -
                 
     | 
| 
      
 63 
     | 
    
         
            +
                _client, slave = standard_connect_helper 'HOST', 502
         
     | 
| 
       64 
64 
     | 
    
         
             
                slave.should_receive(:write_holding_registers).with(100, [0xffff])
         
     | 
| 
       65 
65 
     | 
    
         
             
                cmd.run %w(write --int HOST %MW100 -1)
         
     | 
| 
       66 
66 
     | 
    
         
             
              end
         
     | 
| 
       67 
67 
     | 
    
         | 
| 
       68 
68 
     | 
    
         
             
              it 'can write to registers as floats' do
         
     | 
| 
       69 
     | 
    
         
            -
                 
     | 
| 
      
 69 
     | 
    
         
            +
                _client, slave = standard_connect_helper 'HOST', 502
         
     | 
| 
       70 
70 
     | 
    
         
             
                slave.should_receive(:write_holding_registers).with(100, [52429, 17095])
         
     | 
| 
       71 
71 
     | 
    
         
             
                cmd.run %w(write --float HOST %MW100 99.9)
         
     | 
| 
       72 
72 
     | 
    
         
             
              end
         
     | 
| 
       73 
73 
     | 
    
         | 
| 
       74 
74 
     | 
    
         
             
              it 'can write to registers as double words' do
         
     | 
| 
       75 
     | 
    
         
            -
                 
     | 
| 
      
 75 
     | 
    
         
            +
                _client, slave = standard_connect_helper 'HOST', 502
         
     | 
| 
       76 
76 
     | 
    
         
             
                slave.should_receive(:write_holding_registers).with(100, [16959, 15])
         
     | 
| 
       77 
77 
     | 
    
         
             
                cmd.run %w(write --dword HOST %MW100 999999)
         
     | 
| 
       78 
78 
     | 
    
         
             
              end
         
     | 
| 
       79 
79 
     | 
    
         | 
| 
       80 
80 
     | 
    
         
             
              it 'can write to registers as words' do
         
     | 
| 
       81 
     | 
    
         
            -
                 
     | 
| 
      
 81 
     | 
    
         
            +
                _client, slave = standard_connect_helper 'HOST', 502
         
     | 
| 
       82 
82 
     | 
    
         
             
                slave.should_receive(:write_holding_registers).with(100, [99])
         
     | 
| 
       83 
83 
     | 
    
         
             
                cmd.run %w(write --word HOST %MF100 99)
         
     | 
| 
       84 
84 
     | 
    
         
             
              end
         
     | 
| 
       85 
85 
     | 
    
         | 
| 
       86 
86 
     | 
    
         
             
              it 'can write to registers using Modicon addressing' do
         
     | 
| 
       87 
     | 
    
         
            -
                 
     | 
| 
      
 87 
     | 
    
         
            +
                _client, slave = standard_connect_helper 'HOST', 502
         
     | 
| 
       88 
88 
     | 
    
         
             
                slave.should_receive(:write_holding_registers).with(100, [1, 2, 3, 4])
         
     | 
| 
       89 
89 
     | 
    
         
             
                cmd.run %w(write HOST 400101 1 2 3 4)
         
     | 
| 
       90 
90 
     | 
    
         
             
              end
         
     | 
| 
       91 
91 
     | 
    
         | 
| 
       92 
92 
     | 
    
         
             
              it 'can write to coils using Modicon addressing' do
         
     | 
| 
       93 
     | 
    
         
            -
                 
     | 
| 
      
 93 
     | 
    
         
            +
                _client, slave = standard_connect_helper 'HOST', 502
         
     | 
| 
       94 
94 
     | 
    
         
             
                slave.should_receive(:write_multiple_coils).with(100, [1, 0, 1, 0, 1, 0, 0, 1, 1])
         
     | 
| 
       95 
95 
     | 
    
         
             
                cmd.run %w(write HOST 101 1 0 1 0 1 0 0 1 1)
         
     | 
| 
       96 
96 
     | 
    
         
             
              end
         
     | 
| 
         @@ -103,19 +103,23 @@ describe Modbus::Cli::WriteCommand do 
     | 
|
| 
       103 
103 
     | 
    
         
             
              end
         
     | 
| 
       104 
104 
     | 
    
         | 
| 
       105 
105 
     | 
    
         
             
              it 'has a --debug flag' do
         
     | 
| 
       106 
     | 
    
         
            -
                 
     | 
| 
      
 106 
     | 
    
         
            +
                _client, slave = standard_connect_helper 'HOST', 502
         
     | 
| 
       107 
107 
     | 
    
         
             
                slave.should_receive(:debug=).with(true)
         
     | 
| 
       108 
108 
     | 
    
         
             
                slave.should_receive(:write_multiple_coils)
         
     | 
| 
       109 
109 
     | 
    
         
             
                cmd.run %w(write --debug HOST 101 1)
         
     | 
| 
       110 
110 
     | 
    
         
             
              end
         
     | 
| 
       111 
111 
     | 
    
         | 
| 
       112 
112 
     | 
    
         
             
              it 'has a --timeout flag' do
         
     | 
| 
       113 
     | 
    
         
            -
                 
     | 
| 
      
 113 
     | 
    
         
            +
                _client, slave = standard_connect_helper 'HOST', 502
         
     | 
| 
       114 
114 
     | 
    
         
             
                slave.should_receive(:read_retry_timeout=).with(99)
         
     | 
| 
       115 
115 
     | 
    
         
             
                slave.should_receive(:write_multiple_coils)
         
     | 
| 
       116 
116 
     | 
    
         
             
                cmd.run %w(write --timeout 99 HOST 101 1)
         
     | 
| 
       117 
117 
     | 
    
         
             
              end
         
     | 
| 
       118 
118 
     | 
    
         | 
| 
      
 119 
     | 
    
         
            +
              it 'has a --connect-timeout flag' do
         
     | 
| 
      
 120 
     | 
    
         
            +
                ModBus::TCPClient.should_receive(:connect).with('X', 502, connect_timeout: 99)
         
     | 
| 
      
 121 
     | 
    
         
            +
                cmd.run %w(write --connect-timeout 99 X %MW100 10)
         
     | 
| 
      
 122 
     | 
    
         
            +
              end
         
     | 
| 
       119 
123 
     | 
    
         
             
            end
         
     | 
| 
       120 
124 
     | 
    
         | 
| 
       121 
125 
     | 
    
         | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: modbus-cli
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.14
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Tallak Tveide
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2018-10-16 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rmodbus
         
     | 
| 
         @@ -86,14 +86,14 @@ dependencies: 
     | 
|
| 
       86 
86 
     | 
    
         
             
                requirements:
         
     | 
| 
       87 
87 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       88 
88 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       89 
     | 
    
         
            -
                    version: '1. 
     | 
| 
      
 89 
     | 
    
         
            +
                    version: '1.16'
         
     | 
| 
       90 
90 
     | 
    
         
             
              type: :development
         
     | 
| 
       91 
91 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       92 
92 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       93 
93 
     | 
    
         
             
                requirements:
         
     | 
| 
       94 
94 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       95 
95 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       96 
     | 
    
         
            -
                    version: '1. 
     | 
| 
      
 96 
     | 
    
         
            +
                    version: '1.16'
         
     | 
| 
       97 
97 
     | 
    
         
             
            description: Command line interface to communicate over Modbus TCP
         
     | 
| 
       98 
98 
     | 
    
         
             
            email:
         
     | 
| 
       99 
99 
     | 
    
         
             
            - tallak@tveide.net
         
     | 
| 
         @@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       139 
139 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       140 
140 
     | 
    
         
             
            requirements: []
         
     | 
| 
       141 
141 
     | 
    
         
             
            rubyforge_project: modbus-cli
         
     | 
| 
       142 
     | 
    
         
            -
            rubygems_version: 2. 
     | 
| 
      
 142 
     | 
    
         
            +
            rubygems_version: 2.5.2.3
         
     | 
| 
       143 
143 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       144 
144 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       145 
145 
     | 
    
         
             
            summary: Modbus command line
         
     |