rmodbus 2.1.2 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1aea47814577228ffdc9f2cb1bba67bf52b5cdb76d8e911c8a06125ceb80b7ad
4
- data.tar.gz: be1e6031671b722d4c96a510eeab66191d3c8a79e854c97d3e16cd7f242e38e3
3
+ metadata.gz: 025a947981907584989c025378c6ea0650afc8d102a05431fc084d1e9da84e4b
4
+ data.tar.gz: d7f722ccf020d283e0cc83ece81f640ce85b1c323391b7ab67e8cfa970504536
5
5
  SHA512:
6
- metadata.gz: 392b5ad4164e0675bbbba1d1c62e5374a432e2c2e4a83e79cfa1a68cd05a4e3a64d9a4438bd49e073b2f1437849a14c3fc2face1139765985a4c8247ee2c862e
7
- data.tar.gz: 95e198118db64019335403b4092f637b1e3cbe49f6a5303abb913bf3f3fbab2e2486b70f2a84d8fa6bb4fca47b0105f22ba5724d86d6ba162439de27ffac7032
6
+ metadata.gz: bf1c1cad9756deec4519ffb2f0a157d579a34c1f6a5189508e337432566997a6bfac5f1cd44ef58da8bf1805aa9b6d8dbe7d1efb5a64aa2c32a228191bfc4607
7
+ data.tar.gz: a2390510c7a066d7a5df9430dbc7d23706da4e5f0a8f3c9f5ccf7e410e53bdd6d1f88dc94bf1a7f9e301fd0aea323817e6a52879793595c1b6b091670998ffc4
@@ -30,9 +30,9 @@ module ModBus
30
30
  #
31
31
  # @example
32
32
  # coils[addr] => [1]
33
- # coils[addr1..addr2] => [1, 0, ..]
33
+ # coils[addr1..addr2] => [1, 0, ..-1]
34
34
  # coils[addr] = 0 => [0]
35
- # coils[addr1..addr2] = [1, 0, ..] => [1, 0, ..]
35
+ # coils[addr1..addr2] = [1, 0, ..-1] => [1, 0, ..-1]
36
36
  #
37
37
  # @return [ReadWriteProxy] proxy object
38
38
  def coils
@@ -42,7 +42,7 @@ module ModBus
42
42
  # Read coils
43
43
  #
44
44
  # @example
45
- # read_coils(addr, ncoils) => [1, 0, ..]
45
+ # read_coils(addr, ncoils) => [1, 0, ..-1]
46
46
  #
47
47
  # @param [Integer] addr address first coil
48
48
  # @param [Integer] ncoils number coils
@@ -103,7 +103,7 @@ module ModBus
103
103
  #
104
104
  # @example
105
105
  # discrete_inputs[addr] => [1]
106
- # discrete_inputs[addr1..addr2] => [1, 0, ..]
106
+ # discrete_inputs[addr1..addr2] => [1, 0, ..-1]
107
107
  #
108
108
  # @return [ReadOnlyProxy] proxy object
109
109
  def discrete_inputs
@@ -113,7 +113,7 @@ module ModBus
113
113
  # Read discrete inputs
114
114
  #
115
115
  # @example
116
- # read_discrete_inputs(addr, ninputs) => [1, 0, ..]
116
+ # read_discrete_inputs(addr, ninputs) => [1, 0, ..-1]
117
117
  #
118
118
  # @param [Integer] addr address first input
119
119
  # @param[Integer] ninputs number inputs
@@ -130,7 +130,7 @@ module ModBus
130
130
  #
131
131
  # @example
132
132
  # input_registers[addr] => [1]
133
- # input_registers[addr1..addr2] => [1, 0, ..]
133
+ # input_registers[addr1..addr2] => [1, 0, ..-1]
134
134
  #
135
135
  # @return [ReadOnlyProxy] proxy object
136
136
  def input_registers
@@ -140,7 +140,7 @@ module ModBus
140
140
  # Read input registers
141
141
  #
142
142
  # @example
143
- # read_input_registers(1, 5) => [1, 0, ..]
143
+ # read_input_registers(1, 5) => [1, 0, ..-1]
144
144
  #
145
145
  # @param [Integer] addr address first registers
146
146
  # @param [Integer] nregs number registers
@@ -157,9 +157,9 @@ module ModBus
157
157
  #
158
158
  # @example
159
159
  # holding_registers[addr] => [123]
160
- # holding_registers[addr1..addr2] => [123, 234, ..]
160
+ # holding_registers[addr1..addr2] => [123, 234, ..-1]
161
161
  # holding_registers[addr] = 123 => 123
162
- # holding_registers[addr1..addr2] = [234, 345, ..] => [234, 345, ..]
162
+ # holding_registers[addr1..addr2] = [234, 345, ..-1] => [234, 345, ..-1]
163
163
  #
164
164
  # @return [ReadWriteProxy] proxy object
165
165
  def holding_registers
@@ -169,7 +169,7 @@ module ModBus
169
169
  # Read holding registers
170
170
  #
171
171
  # @example
172
- # read_holding_registers(1, 5) => [1, 0, ..]
172
+ # read_holding_registers(1, 5) => [1, 0, ..-1]
173
173
  #
174
174
  # @param [Integer] addr address first registers
175
175
  # @param [Integer] nregs number registers
@@ -227,7 +227,7 @@ module ModBus
227
227
  # Read/write multiple holding registers
228
228
  #
229
229
  # @example
230
- # read_write_multiple_registers(1, 5, 1, [0xaa, 0]) => [1, 0, ..]
230
+ # read_write_multiple_registers(1, 5, 1, [0xaa, 0]) => [1, 0, ..-1]
231
231
  #
232
232
  # @param [Integer] addr_r address first registers to read
233
233
  # @param [Integer] nregs number registers to read
@@ -286,7 +286,7 @@ module ModBus
286
286
  end
287
287
 
288
288
  check_response_mismatch(request, response) if raise_exception_on_mismatch
289
- response[2..]
289
+ response[2..-1]
290
290
  end
291
291
  # rubocop:enable Layout/LineLength
292
292
 
@@ -294,7 +294,7 @@ module ModBus
294
294
 
295
295
  def check_response_mismatch(request, response)
296
296
  read_func = response.getbyte(0)
297
- data = response[2..]
297
+ data = response[2..-1]
298
298
  # Mismatch functional code
299
299
  send_func = request.getbyte(0)
300
300
  msg = "Function code is mismatch (expected #{send_func}, got #{read_func})" if read_func != send_func
data/lib/rmodbus/rtu.rb CHANGED
@@ -60,7 +60,7 @@ module ModBus
60
60
 
61
61
  loop do
62
62
  offset = 0
63
- crc = msg[-2..].unpack1("S<")
63
+ crc = msg[-2..-1].unpack1("S<")
64
64
 
65
65
  # scan the bytestream for a valid CRC
66
66
  loop do
@@ -88,7 +88,7 @@ module ModBus
88
88
  @last_req_timestamp = Time.now.to_f
89
89
  end
90
90
  log "Server RX discarding #{offset} bytes: #{logging_bytes(msg[0...offset])}" if offset != 0
91
- log "Server RX (#{msg.size - offset} bytes): #{logging_bytes(msg[offset..])}"
91
+ log "Server RX (#{msg.size - offset} bytes): #{logging_bytes(msg[offset..-1])}"
92
92
  return [msg.getbyte(offset), msg.getbyte(offset + 1), params, msg[offset + 1..-3], is_response]
93
93
  end
94
94
  end
@@ -98,7 +98,7 @@ module ModBus
98
98
  msg.concat(read(io, 1))
99
99
  # maximum message size is 256, so that's as far as we have to
100
100
  # be able to see at once
101
- msg = msg[1..] if msg.length > 256
101
+ msg = msg[1..-1] if msg.length > 256
102
102
  end
103
103
  end
104
104
 
@@ -98,11 +98,11 @@ module ModBus
98
98
  when 1, 2
99
99
  return nil unless res.length == res[1].ord + 2
100
100
 
101
- res[2..].unpack_bits
101
+ res[2..-1].unpack_bits
102
102
  when 3, 4, 23
103
103
  return nil unless res.length == res[1].ord + 2
104
104
 
105
- res[2..].unpack("n*")
105
+ res[2..-1].unpack("n*")
106
106
  when 5, 6, 15, 16
107
107
  return nil unless res.length == 5
108
108
 
@@ -254,7 +254,7 @@ module ModBus
254
254
  return nil if req.length < 12
255
255
 
256
256
  params = { read: parse_read_func(req, nil),
257
- write: parse_write_multiple_registers_func(req[4..]) }
257
+ write: parse_write_multiple_registers_func(req[4..-1]) }
258
258
  return nil if params[:write].nil?
259
259
 
260
260
  params
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ModBus
4
- VERSION = "2.1.2"
4
+ VERSION = "2.1.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rmodbus
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - A.Timin, J. Sanders, K. Reynolds, F. Luizão, C. Cutrer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-20 00:00:00.000000000 Z
11
+ date: 2024-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,48 +80,6 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.11'
83
- - !ruby/object:Gem::Dependency
84
- name: rubocop-inst
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '1.0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '1.0'
97
- - !ruby/object:Gem::Dependency
98
- name: rubocop-rake
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '0.6'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '0.6'
111
- - !ruby/object:Gem::Dependency
112
- name: rubocop-rspec
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '3.0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '3.0'
125
83
  - !ruby/object:Gem::Dependency
126
84
  name: digest-crc
127
85
  requirement: !ruby/object:Gem::Requirement
@@ -193,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
193
151
  requirements:
194
152
  - - ">="
195
153
  - !ruby/object:Gem::Version
196
- version: '2.7'
154
+ version: '2.5'
197
155
  required_rubygems_version: !ruby/object:Gem::Requirement
198
156
  requirements:
199
157
  - - ">="