rmodbus 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/NEWS.md +6 -2
- data/Rakefile +0 -8
- data/lib/rmodbus/server.rb +4 -4
- data/lib/rmodbus/version.rb +1 -1
- data/spec/tcp_server_spec.rb +16 -4
- metadata +65 -156
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA512:
|
3
|
+
metadata.gz: 7439565bc235bd2e35e610083325a8946e6f0ff1c46df6582bee852366555745ba7af9f1d7d50a5e4d6cdf45be288ff177588d74b09d97603e36338b18fec9ad
|
4
|
+
data.tar.gz: a81c7ce89ff654f5faf43be3b9cfda5c6130d0470e3e20f56a418049984ff3c9cb9215361877c928b648a1e1b80cdac533d3ef1e9d90a01a11f866aea4d33cf5
|
5
|
+
SHA1:
|
6
|
+
metadata.gz: 0e1df248725aa3e1f6c90f39096062e99511f9cb
|
7
|
+
data.tar.gz: 08414de5199b5bee7e053faa6fa57f2ad34ae4de
|
data/NEWS.md
CHANGED
@@ -1,12 +1,16 @@
|
|
1
|
+
###2013-10-28 Release 1.2.2
|
2
|
+
|
3
|
+
1. Fixed issue [#29](https://github.com/flipback/rmodbus/pull/29). The server part supports 2000 of coils/discrete inputs for reading instead of 125.
|
4
|
+
|
1
5
|
###2013-06-28 Release 1.2.1
|
2
6
|
|
3
|
-
1. Fixed issue [#27](https://github.com/flipback/rmodbus/issues/
|
7
|
+
1. Fixed issue [#27](https://github.com/flipback/rmodbus/issues/27) for read_nonblock error on Windows
|
4
8
|
|
5
9
|
###2013-03-12 Release 1.2.0
|
6
10
|
|
7
11
|
1. Transaction number mismatch doesn't throw exception in TCPSlave#query method.
|
8
12
|
Now this method will wait correct transaction until timeout breaks waiting.
|
9
|
-
2. Added ruby-2.0
|
13
|
+
2. Added ruby-2.0 experimental compatibility
|
10
14
|
|
11
15
|
###2012-07-17 Release 1.1.5
|
12
16
|
|
data/Rakefile
CHANGED
@@ -22,16 +22,8 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
26
|
-
spec.pattern = FileList['spec/**/*_spec.rb']
|
27
|
-
spec.rcov = true
|
28
|
-
end
|
29
|
-
|
30
25
|
task :default => :spec
|
31
26
|
|
32
|
-
require 'yard'
|
33
|
-
YARD::Rake::YardocTask.new
|
34
|
-
|
35
27
|
task :pry do
|
36
28
|
sh "bundle exec pry -r ./lib/rmodbus.rb"
|
37
29
|
end
|
data/lib/rmodbus/server.rb
CHANGED
@@ -35,13 +35,13 @@ module ModBus
|
|
35
35
|
|
36
36
|
case func
|
37
37
|
when 1
|
38
|
-
params = parse_read_func(req, coils)
|
38
|
+
params = parse_read_func(req, coils, 2000)
|
39
39
|
if params[:err] == 0
|
40
40
|
val = coils[params[:addr],params[:quant]].pack_to_word
|
41
41
|
pdu = func.chr + val.size.chr + val
|
42
42
|
end
|
43
43
|
when 2
|
44
|
-
params = parse_read_func(req, discrete_inputs)
|
44
|
+
params = parse_read_func(req, discrete_inputs, 2000)
|
45
45
|
if params[:err] == 0
|
46
46
|
val = discrete_inputs[params[:addr],params[:quant]].pack_to_word
|
47
47
|
pdu = func.chr + val.size.chr + val
|
@@ -89,10 +89,10 @@ module ModBus
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
def parse_read_func(req, field)
|
92
|
+
def parse_read_func(req, field, quant_max=0x7d)
|
93
93
|
quant = req[3,2].unpack('n')[0]
|
94
94
|
|
95
|
-
return { :err => 3} unless quant <=
|
95
|
+
return { :err => 3} unless quant <= quant_max
|
96
96
|
|
97
97
|
addr = req[1,2].unpack('n')[0]
|
98
98
|
return { :err => 2 } unless addr + quant <= field.size
|
data/lib/rmodbus/version.rb
CHANGED
data/spec/tcp_server_spec.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
require "rmodbus"
|
3
3
|
|
4
4
|
describe ModBus::TCPServer do
|
5
|
-
before do
|
5
|
+
before :all do
|
6
6
|
@server = ModBus::TCPServer.new(8502,1)
|
7
7
|
@server.coils = [1,0,1,1]
|
8
8
|
@server.discrete_inputs = [1,1,0,0]
|
@@ -29,8 +29,15 @@ describe ModBus::TCPServer do
|
|
29
29
|
)
|
30
30
|
end
|
31
31
|
|
32
|
-
it "should send exception if quanity of
|
33
|
-
lambda { @slave.
|
32
|
+
it "should send exception if quanity of registers are more than 0x7d" do
|
33
|
+
lambda { @slave.read_holding_registers(0, 0x7e) }.should raise_exception(
|
34
|
+
ModBus::Errors::IllegalDataValue,
|
35
|
+
"A value contained in the query data field is not an allowable value for server"
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "shouldn't send exception if quanity of coils are more than 0x7d0" do
|
40
|
+
lambda { @slave.read_coils(0, 0x7d1) }.should raise_exception(
|
34
41
|
ModBus::Errors::IllegalDataValue,
|
35
42
|
"A value contained in the query data field is not an allowable value for server"
|
36
43
|
)
|
@@ -53,6 +60,11 @@ describe ModBus::TCPServer do
|
|
53
60
|
@slave.read_coils(0,3).should == @server.coils[0,3]
|
54
61
|
end
|
55
62
|
|
63
|
+
it "should supported function 'read coils' with more than 125 in one request" do
|
64
|
+
@server.coils = Array.new( 1900, 1 )
|
65
|
+
@slave.read_coils(0,1900).should == @server.coils[0,1900]
|
66
|
+
end
|
67
|
+
|
56
68
|
it "should supported function 'read discrete inputs'" do
|
57
69
|
@slave.read_discrete_inputs(1,3).should == @server.discrete_inputs[1,3]
|
58
70
|
end
|
@@ -101,7 +113,7 @@ describe ModBus::TCPServer do
|
|
101
113
|
srv.maxConnections.should eql(max_conn)
|
102
114
|
end
|
103
115
|
|
104
|
-
after do
|
116
|
+
after :all do
|
105
117
|
@cl.close unless @cl.closed?
|
106
118
|
@server.stop unless @server.stopped?
|
107
119
|
while GServer.in_service?(8502)
|
metadata
CHANGED
@@ -1,168 +1,79 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rmodbus
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
5
|
-
prerelease:
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.2
|
6
5
|
platform: ruby
|
7
|
-
authors:
|
6
|
+
authors:
|
8
7
|
- A.Timin, J. Sanders, K. Reynolds
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
|
12
|
+
date: 2013-10-28 00:00:00 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :development
|
23
16
|
prerelease: false
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: bundler
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- &id002
|
20
|
+
- ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
38
23
|
type: :development
|
24
|
+
version_requirements: *id001
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: bundler
|
39
27
|
prerelease: false
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: rspec
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: 2.9.0
|
28
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- *id002
|
54
31
|
type: :development
|
32
|
+
version_requirements: *id003
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rspec
|
55
35
|
prerelease: false
|
56
|
-
|
57
|
-
|
58
|
-
requirements:
|
36
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
59
38
|
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
39
|
+
- !ruby/object:Gem::Version
|
61
40
|
version: 2.9.0
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: simplecov
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: yard
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ! '>='
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '0'
|
86
41
|
type: :development
|
87
|
-
|
88
|
-
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '0'
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: rdiscount
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
|
-
requirements:
|
99
|
-
- - ! '>='
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '0'
|
102
|
-
type: :development
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
110
|
-
- !ruby/object:Gem::Dependency
|
42
|
+
version_requirements: *id004
|
43
|
+
- !ruby/object:Gem::Dependency
|
111
44
|
name: guard-rspec
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
|
-
requirements:
|
115
|
-
- - ! '>='
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
45
|
prerelease: false
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
- - ! '>='
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: '0'
|
126
|
-
- !ruby/object:Gem::Dependency
|
127
|
-
name: pry
|
128
|
-
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
|
-
requirements:
|
131
|
-
- - ! '>='
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: '0'
|
46
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- *id002
|
134
49
|
type: :development
|
50
|
+
version_requirements: *id005
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: pry
|
135
53
|
prerelease: false
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
- - ! '>='
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: '0'
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: serialport
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
|
-
requirements:
|
147
|
-
- - ! '>='
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: '0'
|
54
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- *id002
|
150
57
|
type: :development
|
58
|
+
version_requirements: *id006
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: serialport
|
151
61
|
prerelease: false
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
version: '0'
|
62
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- *id002
|
65
|
+
type: :development
|
66
|
+
version_requirements: *id007
|
158
67
|
description:
|
159
68
|
email: atimin@gmail.com
|
160
69
|
executables: []
|
70
|
+
|
161
71
|
extensions: []
|
162
|
-
|
72
|
+
|
73
|
+
extra_rdoc_files:
|
163
74
|
- README.md
|
164
75
|
- NEWS.md
|
165
|
-
files:
|
76
|
+
files:
|
166
77
|
- lib/rmodbus/rtu_client.rb
|
167
78
|
- lib/rmodbus/rtu_via_tcp_slave.rb
|
168
79
|
- lib/rmodbus/rtu_server.rb
|
@@ -210,33 +121,31 @@ files:
|
|
210
121
|
- README.md
|
211
122
|
- NEWS.md
|
212
123
|
homepage: http://rmodbus.flipback.net
|
213
|
-
licenses:
|
124
|
+
licenses:
|
125
|
+
- GPL v2.0
|
126
|
+
metadata: {}
|
127
|
+
|
214
128
|
post_install_message:
|
215
|
-
rdoc_options:
|
129
|
+
rdoc_options:
|
216
130
|
- --title
|
217
131
|
- RModBus
|
218
132
|
- --inline-source
|
219
133
|
- --main
|
220
134
|
- README.md
|
221
|
-
require_paths:
|
135
|
+
require_paths:
|
222
136
|
- lib
|
223
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
230
|
-
none: false
|
231
|
-
requirements:
|
232
|
-
- - ! '>='
|
233
|
-
- !ruby/object:Gem::Version
|
234
|
-
version: '0'
|
137
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- *id002
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- *id002
|
235
143
|
requirements: []
|
144
|
+
|
236
145
|
rubyforge_project:
|
237
|
-
rubygems_version:
|
146
|
+
rubygems_version: 2.0.13
|
238
147
|
signing_key:
|
239
|
-
specification_version:
|
148
|
+
specification_version: 4
|
240
149
|
summary: RModBus - free implementation of protocol ModBus
|
241
150
|
test_files: []
|
242
|
-
|
151
|
+
|