rmodbus 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +2 -0
- data/lib/rmodbus/rtu_client.rb +7 -1
- data/lib/rmodbus/tcp_client.rb +1 -0
- data/spec/rtu_client_spec.rb +1 -0
- metadata +13 -4
data/ChangeLog
CHANGED
data/lib/rmodbus/rtu_client.rb
CHANGED
@@ -10,7 +10,9 @@ module ModBus
|
|
10
10
|
|
11
11
|
def initialize(port, rate=9600, slaveaddr=1)
|
12
12
|
@port = SerialPort.new(port, rate)
|
13
|
+
@port.read_timeout = 5
|
13
14
|
@slave = slaveaddr
|
15
|
+
super()
|
14
16
|
end
|
15
17
|
|
16
18
|
protected
|
@@ -21,7 +23,11 @@ module ModBus
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def read_pdu
|
24
|
-
msg =
|
26
|
+
msg = ''
|
27
|
+
while msg.size == 0 do
|
28
|
+
msg = @port.read
|
29
|
+
end
|
30
|
+
|
25
31
|
if msg.getbyte(0) == @slave
|
26
32
|
return msg[1..-3] if msg[-2,2] == crc16(msg[0..-3]).to_word
|
27
33
|
end
|
data/lib/rmodbus/tcp_client.rb
CHANGED
data/spec/rtu_client_spec.rb
CHANGED
@@ -11,6 +11,7 @@ describe RTUClient do
|
|
11
11
|
before do
|
12
12
|
@port = mock('Serial port')
|
13
13
|
SerialPort.should_receive(:new).with("/dev/port1", 9600).and_return(@port)
|
14
|
+
@port.stub!(:read_timeout=)
|
14
15
|
@mb_client = RTUClient.new("/dev/port1", 9600, 1)
|
15
16
|
@mb_client.read_retries = 0
|
16
17
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rmodbus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- A.Timin, J. Sanders
|
@@ -9,10 +9,19 @@ autorequire: rmodbus
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-12 00:00:00 +05:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: serialport
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.8.0
|
24
|
+
version:
|
16
25
|
description:
|
17
26
|
email:
|
18
27
|
executables: []
|