rmodbus 0.3.0 → 0.3.1

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/ChangeLog CHANGED
@@ -17,4 +17,6 @@
17
17
  2010-01-7 Timin Aleksey <atimin@gmail.com>
18
18
  * lib/rmodbus/tcp_client.rb: Fixed bug of overflow transaction counter (thanks
19
19
  Tallak Tveide)
20
+ 2010-01-12 Timin Aleksey <atimin@gmail.com>
21
+ * lib/rmodbus/rtu_client.rb: RTUClient is live!!!
20
22
 
@@ -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 = @port.read
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
@@ -28,6 +28,7 @@ module ModBus
28
28
  # Connect with a ModBus server
29
29
  def initialize(ipaddr, port = 502, slaveaddr = 1)
30
30
  @ipaddr, @port = ipaddr, port
31
+ super()
31
32
  tried = 0
32
33
  begin
33
34
  timeout(1, ModBusTimeout) do
@@ -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.0
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-07 00:00:00 +05:00
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: []