rmodbus 1.0.3-java → 1.0.4-java

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,16 @@
1
+ 2011-08-10 Release 1.0.4
2
+ ====================================
3
+ 1. Fixed issue [#11](https://github.com/flipback/rmodbus/issues/11)
4
+
5
+
6
+ 2011-07-17 Release 1.0.3
7
+ ====================================
8
+
9
+ 1. Fixed issue #10
10
+ 2. Added new options for TCPServer#new and RTUViaTCPServer#new
11
+ :host - ip of host server (default 127.0.0.1)
12
+ :max_connection - maximum (client default 4)
13
+
1
14
  2011-07-1 Release 1.0.2
2
15
  ====================================
3
16
 
data/lib/rmodbus.rb CHANGED
@@ -33,3 +33,4 @@ require 'rmodbus/rtu_via_tcp_slave'
33
33
  require 'rmodbus/rtu_via_tcp_client'
34
34
  require 'rmodbus/rtu_via_tcp_server'
35
35
  require 'rmodbus/proxy'
36
+ require 'rmodbus/version'
data/lib/rmodbus/rtu.rb CHANGED
@@ -38,7 +38,7 @@ module ModBus
38
38
  when 22 then
39
39
  msg += io.read(8)
40
40
  when 0x80..0xff then
41
- msg += io.read(4)
41
+ msg += io.read(3)
42
42
  else
43
43
  raise ModBus::Errors::IllegalFunction, "Illegal function: #{function_code}"
44
44
  end
@@ -13,5 +13,5 @@
13
13
  # GNU General Public License for more details.
14
14
  module ModBus
15
15
  # Package version
16
- VERSION = '1.0.3'
16
+ VERSION = '1.0.4'
17
17
  end
@@ -0,0 +1,14 @@
1
+ require "rmodbus"
2
+ describe ModBus::RTUViaTCPServer do
3
+ it "should have options :host" do
4
+ host = '192.168.0.1'
5
+ srv = ModBus::RTUViaTCPServer.new(1010, 1, :host => '192.168.0.1')
6
+ srv.host.should eql(host)
7
+ end
8
+
9
+ it "should have options :max_connection" do
10
+ max_conn = 5
11
+ srv = ModBus::RTUViaTCPServer.new(1010, 1, :max_connection => 5)
12
+ srv.maxConnections.should eql(max_conn)
13
+ end
14
+ end
@@ -17,7 +17,7 @@ describe TCPServer do
17
17
  @cl.close
18
18
  ModBus::TCPClient.connect('127.0.0.1', 8502) do |cl|
19
19
  lambda { cl.with_slave(2).read_coils(1,3) }.should raise_exception(
20
- ModBus::Errors::ModBusException,
20
+ ModBus::Errors::ModBusException,
21
21
  "Server did not respond"
22
22
  )
23
23
  end
@@ -26,20 +26,20 @@ describe TCPServer do
26
26
  it "should send exception if function not supported" do
27
27
  lambda { @slave.query('0x43') }.should raise_exception(
28
28
  ModBus::Errors::IllegalFunction,
29
- "The function code received in the query is not an allowable action for the server"
29
+ "The function code received in the query is not an allowable action for the server"
30
30
  )
31
31
  end
32
32
 
33
33
  it "should send exception if quanity of out more 0x7d" do
34
34
  lambda { @slave.read_coils(0, 0x7e) }.should raise_exception(
35
- ModBus::Errors::IllegalDataValue,
35
+ ModBus::Errors::IllegalDataValue,
36
36
  "A value contained in the query data field is not an allowable value for server"
37
37
  )
38
38
  end
39
39
 
40
40
  it "should send exception if addr not valid" do
41
41
  lambda { @slave.read_coils(2, 8) }.should raise_exception(
42
- ModBus::Errors::IllegalDataAddress,
42
+ ModBus::Errors::IllegalDataAddress,
43
43
  "The data address received in the query is not an allowable address for the server"
44
44
  )
45
45
  end
@@ -90,10 +90,22 @@ describe TCPServer do
90
90
  @server.holding_registers.should == [1,2,3,1,2,3,4,5,9]
91
91
  end
92
92
 
93
+ it "should have options :host" do
94
+ host = '192.168.0.1'
95
+ srv = ModBus::TCPServer.new(1010, 1, :host => '192.168.0.1')
96
+ srv.host.should eql(host)
97
+ end
98
+
99
+ it "should have options :max_connection" do
100
+ max_conn = 5
101
+ srv = ModBus::TCPServer.new(1010, 1, :max_connection => 5)
102
+ srv.maxConnections.should eql(max_conn)
103
+ end
104
+
93
105
  after do
94
- @cl.close
106
+ @cl.close
95
107
  @server.stop unless @server.stopped?
96
- while GServer.in_service?(8502)
108
+ while GServer.in_service?(8502)
97
109
  end
98
110
  end
99
111
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rmodbus
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.3
5
+ version: 1.0.4
6
6
  platform: java
7
7
  authors:
8
8
  - A.Timin, J. Sanders, K. Reynolds
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-16 00:00:00 +06:00
13
+ date: 2011-08-10 00:00:00 +06:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -120,6 +120,7 @@ files:
120
120
  - spec/rtu_via_tcp_client_spec.rb
121
121
  - spec/rtu_server_spec.rb
122
122
  - spec/tcp_client_spec.rb
123
+ - spec/rtu_via_tcp_server_spec.rb
123
124
  - spec/exception_spec.rb
124
125
  - spec/rtu_client_spec.rb
125
126
  - spec/slave_spec.rb