rmodbus 1.2.5 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +4 -0
- data/lib/rmodbus/rtu.rb +2 -16
- data/lib/rmodbus/version.rb +1 -1
- data/spec/logging_spec.rb +1 -1
- data/spec/rtu_client_spec.rb +1 -10
- data/spec/rtu_via_tcp_client_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32a45f98ff103499e6446a926f9819928716602a
|
4
|
+
data.tar.gz: 0f883902d6eb8a80330769ca519e69915343d857
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e050abe8430ef0b8f58bc953c249b6b8143d90e673889c3ec91723deba0888d8ddf081ba7efcfbba7a3517a1287bce028386e203505156c5cb00a40005fa2ad2
|
7
|
+
data.tar.gz: 0badca7a5158d6ab27d094c27f3c1b030a14c70e50079fedf4533041d5f340e6fa871d8383ab3e3f5cfb53fa8dea413efca44bb217e8525b2bec602b01dd81d7
|
data/NEWS.md
CHANGED
data/lib/rmodbus/rtu.rb
CHANGED
@@ -17,8 +17,6 @@ module ModBus
|
|
17
17
|
module RTU
|
18
18
|
private
|
19
19
|
|
20
|
-
CHUNK_SIZE = 1500
|
21
|
-
|
22
20
|
# We have to read specific amounts of numbers of bytes from the network depending on the function code and content
|
23
21
|
def read_rtu_response(io)
|
24
22
|
# Read the slave_id and function code
|
@@ -47,20 +45,8 @@ module ModBus
|
|
47
45
|
end
|
48
46
|
|
49
47
|
def clean_input_buff
|
50
|
-
|
51
|
-
|
52
|
-
# Read up to CHUNK_SIZE bytes of trash.
|
53
|
-
if win_platform
|
54
|
-
# non-blocking reads are not supported by Windows
|
55
|
-
@io.readpartial(CHUNK_SIZE)
|
56
|
-
else
|
57
|
-
@io.read_nonblock(CHUNK_SIZE)
|
58
|
-
end
|
59
|
-
rescue Errno::EAGAIN
|
60
|
-
# Ignore the fact we couldn't read.
|
61
|
-
rescue Exception => e
|
62
|
-
raise e unless win_platform || e.is_a?(EOFError) # EOFError means we are done
|
63
|
-
end
|
48
|
+
# empty the input buffer
|
49
|
+
@io.flush_input
|
64
50
|
end
|
65
51
|
|
66
52
|
def send_rtu_pdu(pdu)
|
data/lib/rmodbus/version.rb
CHANGED
data/spec/logging_spec.rb
CHANGED
@@ -68,7 +68,7 @@ begin
|
|
68
68
|
it 'should log rec\send bytes' do
|
69
69
|
request = "\x3\x0\x1\x0\x1"
|
70
70
|
@sp.should_receive(:write).with("\1#{request}\xd5\xca")
|
71
|
-
@sp.should_receive(:
|
71
|
+
@sp.should_receive(:flush_input) # Clean a garbage
|
72
72
|
@sp.should_receive(:read).with(2).and_return("\x1\x3")
|
73
73
|
@sp.should_receive(:read).with(1).and_return("\x2")
|
74
74
|
@sp.should_receive(:read).with(4).and_return("\xff\xff\xb9\xf4")
|
data/spec/rtu_client_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe ModBus::RTUClient do
|
|
7
7
|
SerialPort.should_receive(:new).with("/dev/port1", 9600, 8, 1, 0).and_return(@sp)
|
8
8
|
@sp.stub!(:read_timeout=)
|
9
9
|
@sp.should_receive(:flow_control=).with(SerialPort::NONE)
|
10
|
-
@sp.stub!(:
|
10
|
+
@sp.stub!(:flush_input)
|
11
11
|
|
12
12
|
@cl = ModBus::RTUClient.new("/dev/port1", 9600, :data_bits => 8, :stop_bits => 1, :parity => SerialPort::NONE)
|
13
13
|
@slave = @cl.with_slave(1)
|
@@ -50,15 +50,6 @@ describe ModBus::RTUClient do
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
-
unless RUBY_PLATFORM.include? "mingw"
|
54
|
-
it 'should ignore EOFError during clearing the buffer' do
|
55
|
-
@sp.should_receive(:read_nonblock).and_raise(EOFError)
|
56
|
-
|
57
|
-
request = stab_valid_request
|
58
|
-
lambda { @slave.query(request)}.should_not raise_error(EOFError)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
53
|
it 'should have closed? method' do
|
63
54
|
@sp.should_receive(:closed?).and_return(false)
|
64
55
|
@cl.closed?.should == false
|
@@ -7,7 +7,7 @@ describe ModBus::RTUViaTCPClient do
|
|
7
7
|
@sock = mock('Socked')
|
8
8
|
TCPSocket.should_receive(:new).with("127.0.0.1", 10002).and_return(@sock)
|
9
9
|
@sock.stub!(:read_timeout=)
|
10
|
-
@sock.stub!(:
|
10
|
+
@sock.stub!(:flush_input)
|
11
11
|
|
12
12
|
@cl = ModBus::RTUViaTCPClient.new("127.0.0.1")
|
13
13
|
@slave = @cl.with_slave(1)
|
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: 1.2.
|
4
|
+
version: 1.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- A.Timin, J. Sanders, K. Reynolds
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|