libmodbus4r 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,95 @@
1
+ require 'modbus4r'
2
+
3
+ describe ModBus::TCPSlave do
4
+
5
+ before(:each) do
6
+ @sl = ModBus::TCPSlave.new('127.0.0.1', 1502, 1)
7
+ @sl.start
8
+
9
+ @mstr = ModBus::TCPMaster.new('127.0.0.1', 1502, 1)
10
+ @mstr.connect
11
+ end
12
+
13
+ it "should have stoped" do
14
+ sl = ModBus::TCPSlave.new('127.0.0.1', 1512, 1)
15
+ sl.start.stoped? == false
16
+
17
+
18
+ mstr = ModBus::TCPMaster.new('127.0.0.1', 1512, 1)
19
+ mstr.connect.closed?.should == false
20
+
21
+ sl.stop.stoped? == true
22
+ lambda { mstr.connect }.should raise_error(ModBus::Errors::ModBusError)
23
+ sl.start.stoped? == false
24
+ end
25
+
26
+ it "should have coil status" do
27
+ @sl.coil_status.should == []
28
+ @sl.coil_status = [false, true, false]
29
+ @sl.coil_status.should == [false, true, false]
30
+
31
+ @mstr.read_coil_status(0, 3).should == [false, true, false]
32
+ @mstr.force_single_coil(2, true)
33
+
34
+ @sl.coil_status.should == [false, true ,true]
35
+
36
+ @mstr.force_multiple_coils(0, [true, true, true])
37
+
38
+ @sl.coil_status.should == [true, true, true]
39
+ @sl.coil_status[1] = false
40
+ @sl.coil_status.should == [true, false, true]
41
+
42
+ @mstr.read_coil_status(0, 3).should == [true, false, true]
43
+ end
44
+
45
+ it "should have input status" do
46
+ @sl.input_status.should == []
47
+ @sl.input_status = [false, false, false]
48
+ @sl.input_status.should == [false, false, false]
49
+
50
+ @mstr.read_input_status(0, 3).should == [false, false, false]
51
+
52
+ @sl.input_status[1] = true
53
+ @sl.input_status.should == [false, true, false]
54
+
55
+ @mstr.read_input_status(0, 3).should == [false, true, false]
56
+ end
57
+
58
+ it "should have holding registers" do
59
+ @sl.holding_registers.should == []
60
+ @sl.holding_registers = [0, 0, 0]
61
+ @sl.holding_registers.should == [0, 0, 0]
62
+
63
+ @mstr.read_holding_registers(0, 3).should == [0, 0, 0]
64
+ @mstr.preset_single_register(1, 10000)
65
+
66
+ @sl.holding_registers.should == [0, 10000, 0]
67
+
68
+ @mstr.preset_multiple_registers(0, [1, 2, 3])
69
+
70
+ @sl.holding_registers.should == [1, 2, 3]
71
+ @sl.holding_registers[2] = 55
72
+ @sl.holding_registers.should == [1, 2, 55]
73
+
74
+ @mstr.read_holding_registers(0, 3) == [1, 2, 55]
75
+ end
76
+
77
+ it "should have input registers" do
78
+ @sl.input_registers.should == []
79
+ @sl.input_registers = [0, 0, 0]
80
+ @sl.input_registers.should == [0, 0, 0]
81
+
82
+ @mstr.read_input_registers(0, 3).should == [0, 0, 0]
83
+
84
+ @sl.input_registers[2] = 55
85
+ @sl.input_registers.should == [0, 0, 55]
86
+
87
+ @mstr.read_input_registers(0, 3) == [1, 2, 55]
88
+ end
89
+
90
+ after(:each) do
91
+ @sl.stop unless @sl.stoped?
92
+ @mstr.close unless @mstr.closed?
93
+ end
94
+
95
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libmodbus4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksey Timin
@@ -9,12 +9,12 @@ autorequire: libmodbus4r
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-16 00:00:00 +06:00
12
+ date: 2009-09-21 00:00:00 +06:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
16
  description:
17
- email:
17
+ email: atimin@gmail.com
18
18
  executables: []
19
19
 
20
20
  extensions:
@@ -23,28 +23,38 @@ extra_rdoc_files:
23
23
  - README
24
24
  - LICENSE
25
25
  - NEWS
26
- - TODO
27
26
  files:
28
27
  - lib/modbus4r.rb
28
+ - examples/use_rtu_slave.rb
29
+ - examples/use_tcp_slave.rb
29
30
  - examples/use_rtu_master.rb
30
31
  - examples/use_tcp_master.rb
31
32
  - spec/rtu_master_spec.rb
32
33
  - spec/tcp_master_spec.rb
33
- - ext/tcp_master.c
34
- - ext/errors.c
35
- - ext/modbus4r.h
36
- - ext/extconf.rb
34
+ - spec/rtu_slave_spec.rb
35
+ - spec/tcp_slave_spec.rb
36
+ - ext/errors.h
37
+ - ext/slave.c
38
+ - ext/modbus.h
37
39
  - ext/master.h
40
+ - ext/modbus4r.h
38
41
  - ext/rtu_master.c
39
- - ext/tcp_master.h
42
+ - ext/extconf.rb
43
+ - ext/slave.h
40
44
  - ext/rtu_master.h
45
+ - ext/errors.c
41
46
  - ext/master.c
42
- - ext/errors.h
47
+ - ext/rtu_slave.c
48
+ - ext/rtu_slave.h
49
+ - ext/tcp_master.h
50
+ - ext/tcp_slave.c
51
+ - ext/tcp_slave.h
52
+ - ext/modbus.c
53
+ - ext/tcp_master.c
43
54
  - ext/modbus4r.c
44
55
  - README
45
56
  - LICENSE
46
57
  - NEWS
47
- - TODO
48
58
  has_rdoc: true
49
59
  homepage:
50
60
  licenses: []
data/TODO DELETED
@@ -1,5 +0,0 @@
1
- Next release 0.3.0
2
- ======================
3
- - Migrate on libmodbus-2.2.0
4
- - Add TCP\RTU slave
5
-