rmodbus 1.2.0 → 1.2.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/NEWS.md CHANGED
@@ -1,3 +1,7 @@
1
+ ###2013-06-28 Release 1.2.1
2
+
3
+ 1. Fixed issue [#27](https://github.com/flipback/rmodbus/issues/24) for read_nonblock error on Windows
4
+
1
5
  ###2013-03-12 Release 1.2.0
2
6
 
3
7
  1. Transaction number mismatch doesn't throw exception in TCPSlave#query method.
data/lib/rmodbus/rtu.rb CHANGED
@@ -17,6 +17,8 @@ module ModBus
17
17
  module RTU
18
18
  private
19
19
 
20
+ CHUNK_SIZE = 1500
21
+
20
22
  # We have to read specific amounts of numbers of bytes from the network depending on the function code and content
21
23
  def read_rtu_response(io)
22
24
  # Read the slave_id and function code
@@ -45,13 +47,19 @@ module ModBus
45
47
  end
46
48
 
47
49
  def clean_input_buff
50
+ win_platform = RUBY_PLATFORM.include? "mingw"
48
51
  begin
49
- # Read up to 1500 bytes of trash.
50
- @io.read_nonblock(1500)
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
51
59
  rescue Errno::EAGAIN
52
60
  # Ignore the fact we couldn't read.
53
61
  rescue Exception => e
54
- raise e
62
+ raise e unless win_platform && e.is_a?(EOFError) # EOFError means we are done
55
63
  end
56
64
  end
57
65
 
@@ -13,5 +13,5 @@
13
13
  # GNU General Public License for more details.
14
14
  module ModBus
15
15
  # Package version
16
- VERSION = '1.2.0'
16
+ VERSION = '1.2.1'
17
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: 1.2.0
4
+ version: 1.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-12 00:00:00.000000000 Z
12
+ date: 2013-06-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -234,7 +234,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
234
  version: '0'
235
235
  requirements: []
236
236
  rubyforge_project:
237
- rubygems_version: 1.8.24
237
+ rubygems_version: 1.8.25
238
238
  signing_key:
239
239
  specification_version: 3
240
240
  summary: RModBus - free implementation of protocol ModBus