modbus-cli 0.0.8 → 0.0.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.
- data/.gitignore +0 -0
- data/.travis.yml +0 -0
- data/Gemfile +0 -0
- data/README.markdown +0 -0
- data/Rakefile +0 -0
- data/lib/modbus-cli.rb +0 -0
- data/lib/modbus-cli/commands_common.rb +6 -0
- data/lib/modbus-cli/dump_command.rb +0 -0
- data/lib/modbus-cli/read_command.rb +2 -0
- data/lib/modbus-cli/version.rb +1 -1
- data/lib/modbus-cli/write_command.rb +2 -0
- data/modbus-cli.gemspec +0 -0
- data/spec/dump_command_spec.rb +0 -0
- data/spec/modbus_cli_spec.rb +0 -0
- data/spec/read_command_spec.rb +7 -0
- data/spec/spec_helper.rb +0 -0
- data/spec/write_command_spec.rb +10 -2
- data/tust.yml +0 -0
- metadata +33 -17
data/.gitignore
CHANGED
File without changes
|
data/.travis.yml
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/README.markdown
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/lib/modbus-cli.rb
CHANGED
File without changes
|
@@ -47,6 +47,12 @@ module Modbus
|
|
47
47
|
def debug_option
|
48
48
|
option ["-D", "--debug"], :flag, "show debug messages"
|
49
49
|
end
|
50
|
+
|
51
|
+
def timeout_option
|
52
|
+
option ["-T", "--timeout"], 'TIMEOUT', "Specify the timeout in seconds when talking to the slave" do |t|
|
53
|
+
Integer(t)
|
54
|
+
end
|
55
|
+
end
|
50
56
|
end
|
51
57
|
|
52
58
|
|
File without changes
|
@@ -18,6 +18,7 @@ module Modbus
|
|
18
18
|
address_parameter
|
19
19
|
option ["-o", "--output"], 'FILE', "write results to file FILE"
|
20
20
|
debug_option
|
21
|
+
timeout_option
|
21
22
|
|
22
23
|
parameter 'COUNT', 'number of data to read', :attribute_name => :count do |c|
|
23
24
|
result = Integer(c)
|
@@ -75,6 +76,7 @@ module Modbus
|
|
75
76
|
ModBus::TCPClient.connect(host, port) do |cl|
|
76
77
|
cl.with_slave(slave) do |sl|
|
77
78
|
sl.debug = true if debug?
|
79
|
+
sl.read_retry_timeout = timeout if timeout
|
78
80
|
|
79
81
|
if output then
|
80
82
|
case addr_type
|
data/lib/modbus-cli/version.rb
CHANGED
@@ -14,6 +14,7 @@ module Modbus
|
|
14
14
|
host_option
|
15
15
|
address_parameter
|
16
16
|
debug_option
|
17
|
+
timeout_option
|
17
18
|
|
18
19
|
parameter 'VALUES ...', 'values to write, nonzero counts as true for discrete values', :attribute_name => :values do |vv|
|
19
20
|
case addr_type
|
@@ -37,6 +38,7 @@ module Modbus
|
|
37
38
|
ModBus::TCPClient.connect(host, port) do |cl|
|
38
39
|
cl.with_slave(slave) do |sl|
|
39
40
|
sl.debug = true if debug?
|
41
|
+
sl.read_retry_timeout = timeout if timeout
|
40
42
|
|
41
43
|
case addr_type
|
42
44
|
when :bit
|
data/modbus-cli.gemspec
CHANGED
File without changes
|
data/spec/dump_command_spec.rb
CHANGED
File without changes
|
data/spec/modbus_cli_spec.rb
CHANGED
File without changes
|
data/spec/read_command_spec.rb
CHANGED
@@ -163,6 +163,13 @@ describe Modbus::Cli::ReadCommand do
|
|
163
163
|
cmd.run %w(read --debug 1.2.3.4 %MW100 10)
|
164
164
|
end
|
165
165
|
|
166
|
+
it 'has a --timeout flag' do
|
167
|
+
client, slave = standard_connect_helper '1.2.3.4', 502
|
168
|
+
slave.should_receive(:read_retry_timeout=).with(99)
|
169
|
+
slave.should_receive(:read_holding_registers).with(100, 10).and_return((0..9).to_a)
|
170
|
+
cmd.run %w(read --timeout 99 1.2.3.4 %MW100 10)
|
171
|
+
end
|
172
|
+
|
166
173
|
|
167
174
|
end
|
168
175
|
|
data/spec/spec_helper.rb
CHANGED
File without changes
|
data/spec/write_command_spec.rb
CHANGED
@@ -53,8 +53,9 @@ describe Modbus::Cli::WriteCommand do
|
|
53
53
|
|
54
54
|
it 'should split large writes in chunks for coils' do
|
55
55
|
client, slave = standard_connect_helper 'HOST', 502
|
56
|
-
slave.should_receive(:write_multiple_coils).with(100, [0, 1] *
|
57
|
-
slave.should_receive(:write_multiple_coils).with(
|
56
|
+
slave.should_receive(:write_multiple_coils).with(100, [0, 1] * 400)
|
57
|
+
slave.should_receive(:write_multiple_coils).with(900, [0, 1] * 400)
|
58
|
+
slave.should_receive(:write_multiple_coils).with(1700, [0, 1] * 200)
|
58
59
|
cmd.run %w(write HOST %M100) + [0, 1] * 1000
|
59
60
|
end
|
60
61
|
|
@@ -108,6 +109,13 @@ describe Modbus::Cli::WriteCommand do
|
|
108
109
|
cmd.run %w(write --debug HOST 101 1)
|
109
110
|
end
|
110
111
|
|
112
|
+
it 'has a --timeout flag' do
|
113
|
+
client, slave = standard_connect_helper 'HOST', 502
|
114
|
+
slave.should_receive(:read_retry_timeout=).with(99)
|
115
|
+
slave.should_receive(:write_multiple_coils)
|
116
|
+
cmd.run %w(write --timeout 99 HOST 101 1)
|
117
|
+
end
|
118
|
+
|
111
119
|
end
|
112
120
|
|
113
121
|
|
data/tust.yml
CHANGED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rmodbus
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '1.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.1'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: clamp
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0.3'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0.3'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rspec
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ~>
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '2.7'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.7'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: rake
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ~>
|
@@ -54,7 +69,12 @@ dependencies:
|
|
54
69
|
version: '0.9'
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0.9'
|
58
78
|
description: Command line interface to communicate over Modbus TCP
|
59
79
|
email:
|
60
80
|
- tallak@tveide.net
|
@@ -102,13 +122,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
122
|
version: '0'
|
103
123
|
requirements: []
|
104
124
|
rubyforge_project: modbus-cli
|
105
|
-
rubygems_version: 1.8.
|
125
|
+
rubygems_version: 1.8.24
|
106
126
|
signing_key:
|
107
127
|
specification_version: 3
|
108
128
|
summary: Modbus command line
|
109
|
-
test_files:
|
110
|
-
|
111
|
-
- spec/modbus_cli_spec.rb
|
112
|
-
- spec/read_command_spec.rb
|
113
|
-
- spec/spec_helper.rb
|
114
|
-
- spec/write_command_spec.rb
|
129
|
+
test_files: []
|
130
|
+
has_rdoc:
|