cosmos 3.1.2 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/Manifest.txt +17 -1
- data/autohotkey/tools/test_runner2.ahk +1 -0
- data/autohotkey/tools/tlm_grapher.ahk +13 -1
- data/data/crc.txt +39 -30
- data/demo/config/data/crc.txt +3 -3
- data/demo/config/targets/TEMPLATED/lib/templated_interface.rb +3 -1
- data/demo/config/tools/cmd_tlm_server/cmd_tlm_server.txt +7 -1
- data/demo/config/tools/cmd_tlm_server/cmd_tlm_server2.txt +6 -1
- data/lib/cosmos.rb +2 -2
- data/lib/cosmos/gui/dialogs/about_dialog.rb +18 -5
- data/lib/cosmos/gui/dialogs/tlm_details_dialog.rb +0 -7
- data/lib/cosmos/gui/line_graph/overview_graph.rb +12 -2
- data/lib/cosmos/gui/utilities/script_module_gui.rb +11 -3
- data/lib/cosmos/interfaces/interface.rb +12 -0
- data/lib/cosmos/interfaces/stream_interface.rb +1 -21
- data/lib/cosmos/interfaces/tcpip_server_interface.rb +10 -0
- data/lib/cosmos/io/json_drb_object.rb +75 -56
- data/lib/cosmos/io/tcpip_server.rb +1 -11
- data/lib/cosmos/packet_logs.rb +1 -0
- data/lib/cosmos/packet_logs/ccsds_log_reader.rb +103 -0
- data/lib/cosmos/packets/packet.rb +70 -1
- data/lib/cosmos/packets/packet_config.rb +59 -611
- data/lib/cosmos/packets/parsers/format_string_parser.rb +58 -0
- data/lib/cosmos/packets/parsers/limits_parser.rb +146 -0
- data/lib/cosmos/packets/parsers/limits_response_parser.rb +52 -0
- data/lib/cosmos/packets/parsers/macro_parser.rb +116 -0
- data/lib/cosmos/packets/parsers/packet_item_parser.rb +215 -0
- data/lib/cosmos/packets/parsers/packet_parser.rb +123 -0
- data/lib/cosmos/packets/parsers/processor_parser.rb +63 -0
- data/lib/cosmos/packets/parsers/state_parser.rb +116 -0
- data/lib/cosmos/packets/structure.rb +59 -22
- data/lib/cosmos/packets/structure_item.rb +1 -1
- data/lib/cosmos/script/script.rb +4 -5
- data/lib/cosmos/streams/serial_stream.rb +5 -0
- data/lib/cosmos/streams/stream.rb +8 -2
- data/lib/cosmos/streams/stream_protocol.rb +1 -0
- data/lib/cosmos/streams/tcpip_client_stream.rb +37 -7
- data/lib/cosmos/streams/tcpip_socket_stream.rb +9 -6
- data/lib/cosmos/system/target.rb +3 -6
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_config.rb +57 -48
- data/lib/cosmos/tools/cmd_tlm_server/interface_thread.rb +7 -3
- data/lib/cosmos/tools/limits_monitor/limits_monitor.rb +1 -1
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_realtime_thread.rb +7 -1
- data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +1 -2
- data/lib/cosmos/top_level.rb +22 -11
- data/lib/cosmos/utilities/message_log.rb +14 -9
- data/lib/cosmos/version.rb +5 -5
- data/spec/interfaces/cmd_tlm_server_interface_spec.rb +16 -16
- data/spec/interfaces/linc_interface_spec.rb +3 -0
- data/spec/interfaces/tcpip_client_interface_spec.rb +1 -0
- data/spec/interfaces/tcpip_server_interface_spec.rb +9 -0
- data/spec/io/json_drb_object_spec.rb +1 -1
- data/spec/io/serial_driver_spec.rb +0 -1
- data/spec/packet_logs/packet_log_writer_spec.rb +5 -3
- data/spec/packets/packet_config_spec.rb +22 -837
- data/spec/packets/packet_item_spec.rb +10 -10
- data/spec/packets/packet_spec.rb +239 -1
- data/spec/packets/parsers/format_string_parser_spec.rb +122 -0
- data/spec/packets/parsers/limits_parser_spec.rb +282 -0
- data/spec/packets/parsers/limits_response_parser_spec.rb +149 -0
- data/spec/packets/parsers/macro_parser_spec.rb +184 -0
- data/spec/packets/parsers/packet_item_parser_spec.rb +306 -0
- data/spec/packets/parsers/packet_parser_spec.rb +99 -0
- data/spec/packets/parsers/processor_parser_spec.rb +114 -0
- data/spec/packets/parsers/state_parser_spec.rb +156 -0
- data/spec/packets/structure_item_spec.rb +14 -14
- data/spec/packets/structure_spec.rb +162 -16
- data/spec/streams/fixed_stream_protocol_spec.rb +7 -4
- data/spec/streams/length_stream_protocol_spec.rb +3 -0
- data/spec/streams/preidentified_stream_protocol_spec.rb +3 -0
- data/spec/streams/serial_stream_spec.rb +12 -0
- data/spec/streams/stream_protocol_spec.rb +14 -0
- data/spec/streams/stream_spec.rb +1 -0
- data/spec/streams/tcpip_client_stream_spec.rb +3 -0
- data/spec/streams/tcpip_socket_stream_spec.rb +15 -3
- data/spec/streams/template_stream_protocol_spec.rb +5 -0
- data/spec/streams/terminated_stream_protocol_spec.rb +4 -0
- data/spec/tools/cmd_tlm_server/cmd_tlm_server_config_spec.rb +21 -1
- data/spec/tools/cmd_tlm_server/interface_thread_spec.rb +1 -1
- data/spec/tools/cmd_tlm_server/interfaces_spec.rb +1 -1
- metadata +19 -3
@@ -41,6 +41,7 @@ module Cosmos
|
|
41
41
|
describe "read" do
|
42
42
|
it "should complain if no interface set" do
|
43
43
|
class MyStream < Stream
|
44
|
+
def connect; end
|
44
45
|
def connected?; true; end
|
45
46
|
def read; "\x01\x02\x03\x04"; end
|
46
47
|
end
|
@@ -51,6 +52,7 @@ module Cosmos
|
|
51
52
|
|
52
53
|
it "should read telemetry data from the stream" do
|
53
54
|
class MyStream < Stream
|
55
|
+
def connect; end
|
54
56
|
def connected?; true; end
|
55
57
|
def read; "\x01\x02"; end
|
56
58
|
end
|
@@ -60,19 +62,19 @@ module Cosmos
|
|
60
62
|
interface.target_names = %w(TEST COSMOS)
|
61
63
|
@fsp.interface = interface
|
62
64
|
packet = @fsp.read
|
63
|
-
packet.received_time.to_f.should be_within(0.
|
65
|
+
packet.received_time.to_f.should be_within(0.1).of(Time.now.to_f)
|
64
66
|
packet.target_name.should eql 'COSMOS'
|
65
67
|
packet.packet_name.should eql 'VERSION'
|
66
68
|
packet = @fsp.read
|
67
|
-
packet.received_time.to_f.should be_within(0.
|
69
|
+
packet.received_time.to_f.should be_within(0.1).of(Time.now.to_f)
|
68
70
|
packet.target_name.should eql 'COSMOS'
|
69
71
|
packet.packet_name.should eql 'LIMITS_CHANGE'
|
70
72
|
packet = @fsp.read
|
71
|
-
packet.received_time.to_f.should be_within(0.
|
73
|
+
packet.received_time.to_f.should be_within(0.1).of(Time.now.to_f)
|
72
74
|
packet.target_name.should eql 'COSMOS'
|
73
75
|
packet.packet_name.should eql 'VERSION'
|
74
76
|
packet = @fsp.read
|
75
|
-
packet.received_time.to_f.should be_within(0.
|
77
|
+
packet.received_time.to_f.should be_within(0.1).of(Time.now.to_f)
|
76
78
|
packet.target_name.should eql 'COSMOS'
|
77
79
|
packet.packet_name.should eql 'LIMITS_CHANGE'
|
78
80
|
end
|
@@ -82,6 +84,7 @@ module Cosmos
|
|
82
84
|
|
83
85
|
$index = 0
|
84
86
|
class MyStream < Stream
|
87
|
+
def connect; end
|
85
88
|
def connected?; true; end
|
86
89
|
def read
|
87
90
|
case $index
|
@@ -32,6 +32,7 @@ module Cosmos
|
|
32
32
|
describe "read" do
|
33
33
|
it "should read BIG_ENDIAN length fields from the stream" do
|
34
34
|
class MyStream < Stream
|
35
|
+
def connect; end
|
35
36
|
def connected?; true; end
|
36
37
|
def read
|
37
38
|
case $index
|
@@ -98,6 +99,7 @@ module Cosmos
|
|
98
99
|
|
99
100
|
it "should read LITTLE_ENDIAN length fields from the stream" do
|
100
101
|
class MyStream < Stream
|
102
|
+
def connect; end
|
101
103
|
def connected?; true; end
|
102
104
|
def read
|
103
105
|
case $index
|
@@ -166,6 +168,7 @@ module Cosmos
|
|
166
168
|
describe "write" do
|
167
169
|
it "should fill the length field and sync pattern if told to" do
|
168
170
|
class MyStream < Stream
|
171
|
+
def connect; end
|
169
172
|
@@written_data = nil
|
170
173
|
def self.written_data
|
171
174
|
@@written_data
|
@@ -30,6 +30,7 @@ module Cosmos
|
|
30
30
|
@psp = PreidentifiedStreamProtocol.new(nil, 5)
|
31
31
|
pkt = System.telemetry.packet("COSMOS","VERSION")
|
32
32
|
class MyStream < Stream
|
33
|
+
def connect; end
|
33
34
|
def connected?; true; end
|
34
35
|
def read; $buffer; end
|
35
36
|
def write(data); $buffer = data; end
|
@@ -58,6 +59,7 @@ module Cosmos
|
|
58
59
|
it "should create a packet header" do
|
59
60
|
pkt = System.telemetry.packet("COSMOS","VERSION")
|
60
61
|
class MyStream < Stream
|
62
|
+
def connect; end
|
61
63
|
def connected?; true; end
|
62
64
|
def read; $buffer; end
|
63
65
|
def write(data); $buffer = data; end
|
@@ -90,6 +92,7 @@ module Cosmos
|
|
90
92
|
pkt.write("PKT_ID", 1)
|
91
93
|
pkt.write("COSMOS", "TEST")
|
92
94
|
class MyStream < Stream
|
95
|
+
def connect; end
|
93
96
|
def connected?; true; end
|
94
97
|
def read; $buffer; end
|
95
98
|
def write(data); $buffer = data; end
|
@@ -100,6 +100,18 @@ module Cosmos
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
+
describe "connect" do
|
104
|
+
it "should support a connect method that does nothing" do
|
105
|
+
driver = double("driver")
|
106
|
+
expect(driver).to receive(:closed?).and_return(false)
|
107
|
+
expect(driver).to receive(:close).once
|
108
|
+
expect(SerialDriver).to receive(:new).and_return(driver)
|
109
|
+
ss = SerialStream.new(nil,'COM1',9600,:EVEN,1,nil,nil)
|
110
|
+
expect{ss.connect}.to_not raise_error
|
111
|
+
ss.disconnect
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
103
115
|
end
|
104
116
|
end
|
105
117
|
|
@@ -72,6 +72,7 @@ module Cosmos
|
|
72
72
|
it "should set the stream" do
|
73
73
|
class MyStream1 < Stream; end
|
74
74
|
stream = MyStream1.new
|
75
|
+
allow(stream).to receive(:connect)
|
75
76
|
@sp.connect(stream)
|
76
77
|
@sp.stream.should eql stream
|
77
78
|
end
|
@@ -84,6 +85,7 @@ module Cosmos
|
|
84
85
|
|
85
86
|
it "should return the status of the stream connection" do
|
86
87
|
class MyStream2 < Stream
|
88
|
+
def connect; end
|
87
89
|
def connected?; true; end
|
88
90
|
end
|
89
91
|
stream = MyStream2.new
|
@@ -96,6 +98,7 @@ module Cosmos
|
|
96
98
|
it "should call disconnect on the stream" do
|
97
99
|
$test = false
|
98
100
|
class MyStream3 < Stream
|
101
|
+
def connect; end
|
99
102
|
def disconnect; $test = true; end
|
100
103
|
end
|
101
104
|
stream = MyStream3.new
|
@@ -109,6 +112,7 @@ module Cosmos
|
|
109
112
|
describe "read" do
|
110
113
|
it "should read data from the stream" do
|
111
114
|
class MyStream33 < Stream
|
115
|
+
def connect; end
|
112
116
|
def connected?; true; end
|
113
117
|
def read; "\x01\x02\x03\x04"; end
|
114
118
|
end
|
@@ -120,6 +124,7 @@ module Cosmos
|
|
120
124
|
|
121
125
|
it "should handle timeouts from the stream" do
|
122
126
|
class MyStream4 < Stream
|
127
|
+
def connect; end
|
123
128
|
def connected?; true; end
|
124
129
|
def read; raise Timeout::Error; end
|
125
130
|
end
|
@@ -131,6 +136,7 @@ module Cosmos
|
|
131
136
|
it "should handle a sync pattern" do
|
132
137
|
$read_cnt = 0
|
133
138
|
class MyStream5 < Stream
|
139
|
+
def connect; end
|
134
140
|
def connected?; true; end
|
135
141
|
def read
|
136
142
|
$read_cnt += 1
|
@@ -154,6 +160,7 @@ module Cosmos
|
|
154
160
|
it "should handle a sync pattern split across reads" do
|
155
161
|
$read_cnt = 0
|
156
162
|
class MyStream6 < Stream
|
163
|
+
def connect; end
|
157
164
|
def connected?; true; end
|
158
165
|
def read
|
159
166
|
$read_cnt += 1
|
@@ -177,6 +184,7 @@ module Cosmos
|
|
177
184
|
it "should handle a false positive sync pattern" do
|
178
185
|
$read_cnt = 0
|
179
186
|
class MyStream7 < Stream
|
187
|
+
def connect; end
|
180
188
|
def connected?; true; end
|
181
189
|
def read
|
182
190
|
$read_cnt += 1
|
@@ -199,6 +207,7 @@ module Cosmos
|
|
199
207
|
|
200
208
|
it "should discard leading bytes from the stream" do
|
201
209
|
class MyStream8 < Stream
|
210
|
+
def connect; end
|
202
211
|
def connected?; true; end
|
203
212
|
def read
|
204
213
|
"\x01\x02\x03\x04"
|
@@ -214,6 +223,7 @@ module Cosmos
|
|
214
223
|
|
215
224
|
it "should call the post_read_data method on the inteface" do
|
216
225
|
class MyStream9 < Stream
|
226
|
+
def connect; end
|
217
227
|
def connected?; true; end
|
218
228
|
def read
|
219
229
|
"\x01\x02\x03\x04"
|
@@ -263,6 +273,7 @@ module Cosmos
|
|
263
273
|
|
264
274
|
it "should call the post_read_packet method on the inteface" do
|
265
275
|
class MyStream10 < Stream
|
276
|
+
def connect; end
|
266
277
|
def connected?; true; end
|
267
278
|
def read
|
268
279
|
"\x01\x02\x03\x04"
|
@@ -288,6 +299,7 @@ module Cosmos
|
|
288
299
|
it "should call pre_write_packet on the interface" do
|
289
300
|
$buffer = ''
|
290
301
|
class MyStream11 < Stream
|
302
|
+
def connect; end
|
291
303
|
def connected?; true; end
|
292
304
|
def write(buffer) $buffer = buffer; end
|
293
305
|
end
|
@@ -304,6 +316,7 @@ module Cosmos
|
|
304
316
|
it "should write the packet buffer to the stream" do
|
305
317
|
$buffer = ''
|
306
318
|
class MyStream11 < Stream
|
319
|
+
def connect; end
|
307
320
|
def connected?; true; end
|
308
321
|
def write(buffer) $buffer = buffer; end
|
309
322
|
end
|
@@ -318,6 +331,7 @@ module Cosmos
|
|
318
331
|
it "should write the raw buffer to the stream" do
|
319
332
|
$buffer = ''
|
320
333
|
class MyStream11 < Stream
|
334
|
+
def connect; end
|
321
335
|
def connected?; true; end
|
322
336
|
def write(buffer) $buffer = buffer; end
|
323
337
|
end
|
data/spec/streams/stream_spec.rb
CHANGED
@@ -19,6 +19,7 @@ module Cosmos
|
|
19
19
|
it "should raise an error" do
|
20
20
|
expect { Stream.new.read }.to raise_error(/not defined/)
|
21
21
|
expect { Stream.new.write(nil) }.to raise_error(/not defined/)
|
22
|
+
expect { Stream.new.connect }.to raise_error(/not defined/)
|
22
23
|
expect { Stream.new.connected? }.to raise_error(/not defined/)
|
23
24
|
expect { Stream.new.disconnect }.to raise_error(/not defined/)
|
24
25
|
end
|
@@ -33,18 +33,21 @@ module Cosmos
|
|
33
33
|
|
34
34
|
it "should use the same socket if read_port == write_port" do
|
35
35
|
ss = TcpipClientStream.new('localhost',8888,8888,nil,nil)
|
36
|
+
ss.connect
|
36
37
|
ss.connected?.should be_truthy
|
37
38
|
ss.disconnect
|
38
39
|
end
|
39
40
|
|
40
41
|
it "should create the write socket" do
|
41
42
|
ss = TcpipClientStream.new('localhost',8888,nil,nil,nil)
|
43
|
+
ss.connect
|
42
44
|
ss.connected?.should be_truthy
|
43
45
|
ss.disconnect
|
44
46
|
end
|
45
47
|
|
46
48
|
it "should create the read socket" do
|
47
49
|
ss = TcpipClientStream.new('localhost',nil,8888,nil,nil)
|
50
|
+
ss.connect
|
48
51
|
ss.connected?.should be_truthy
|
49
52
|
ss.disconnect
|
50
53
|
end
|
@@ -15,15 +15,16 @@ module Cosmos
|
|
15
15
|
|
16
16
|
describe TcpipSocketStream do
|
17
17
|
describe "initialize, connected?" do
|
18
|
-
it "should be connected when initialized" do
|
18
|
+
it "should be not be connected when initialized" do
|
19
19
|
ss = TcpipSocketStream.new(nil,nil,nil,nil)
|
20
|
-
ss.connected?.should
|
20
|
+
ss.connected?.should be_falsy
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
describe "read" do
|
25
25
|
it "should raise an error if no read socket given" do
|
26
26
|
ss = TcpipSocketStream.new('write',nil,nil,nil)
|
27
|
+
ss.connect
|
27
28
|
expect { ss.read }.to raise_error("Attempt to read from write only stream")
|
28
29
|
end
|
29
30
|
|
@@ -31,6 +32,7 @@ module Cosmos
|
|
31
32
|
read = double("read_socket")
|
32
33
|
expect(read).to receive(:recv_nonblock).and_return 'test'
|
33
34
|
ss = TcpipSocketStream.new(nil,read,nil,nil)
|
35
|
+
ss.connect
|
34
36
|
ss.read.should eql 'test'
|
35
37
|
end
|
36
38
|
|
@@ -48,6 +50,7 @@ module Cosmos
|
|
48
50
|
expect(IO).to receive(:select).at_least(:once).and_return([])
|
49
51
|
$index = 1
|
50
52
|
ss = TcpipSocketStream.new(nil,read,nil,nil)
|
53
|
+
ss.connect
|
51
54
|
ss.read.should eql 'test'
|
52
55
|
end
|
53
56
|
|
@@ -56,6 +59,7 @@ module Cosmos
|
|
56
59
|
allow(read).to receive(:recv_nonblock).and_raise(Errno::EWOULDBLOCK)
|
57
60
|
expect(IO).to receive(:select).at_least(:once).and_return(nil)
|
58
61
|
ss = TcpipSocketStream.new(nil,read,nil,nil)
|
62
|
+
ss.connect
|
59
63
|
expect { ss.read }.to raise_error(Timeout::Error)
|
60
64
|
end
|
61
65
|
|
@@ -63,6 +67,7 @@ module Cosmos
|
|
63
67
|
read = double("read_socket")
|
64
68
|
allow(read).to receive(:recv_nonblock).and_raise(Errno::ECONNRESET)
|
65
69
|
ss = TcpipSocketStream.new(nil,read,nil,nil)
|
70
|
+
ss.connect
|
66
71
|
ss.read.should eql ''
|
67
72
|
end
|
68
73
|
end
|
@@ -70,6 +75,7 @@ module Cosmos
|
|
70
75
|
describe "write" do
|
71
76
|
it "should raise an error if no write port given" do
|
72
77
|
ss = TcpipSocketStream.new(nil,'read',nil,nil)
|
78
|
+
ss.connect
|
73
79
|
expect { ss.write('test') }.to raise_error("Attempt to write to read only stream")
|
74
80
|
end
|
75
81
|
|
@@ -78,6 +84,7 @@ module Cosmos
|
|
78
84
|
# Simulate only writing two bytes at a time
|
79
85
|
expect(write).to receive(:write_nonblock).twice.and_return(2)
|
80
86
|
ss = TcpipSocketStream.new(write,nil,nil,nil)
|
87
|
+
ss.connect
|
81
88
|
ss.write('test')
|
82
89
|
end
|
83
90
|
|
@@ -95,6 +102,7 @@ module Cosmos
|
|
95
102
|
expect(IO).to receive(:select).at_least(:once).and_return([])
|
96
103
|
$index = 1
|
97
104
|
ss = TcpipSocketStream.new(write,nil,nil,nil)
|
105
|
+
ss.connect
|
98
106
|
ss.write('test')
|
99
107
|
end
|
100
108
|
|
@@ -103,6 +111,7 @@ module Cosmos
|
|
103
111
|
allow(write).to receive(:write_nonblock).and_raise(Errno::EWOULDBLOCK)
|
104
112
|
expect(IO).to receive(:select).at_least(:once).and_return(nil)
|
105
113
|
ss = TcpipSocketStream.new(write,nil,nil,nil)
|
114
|
+
ss.connect
|
106
115
|
expect { ss.write('test') }.to raise_error(Timeout::Error)
|
107
116
|
end
|
108
117
|
end
|
@@ -113,6 +122,7 @@ module Cosmos
|
|
113
122
|
expect(write).to receive(:closed?).and_return(false)
|
114
123
|
expect(write).to receive(:close)
|
115
124
|
ss = TcpipSocketStream.new(write,nil,nil,nil)
|
125
|
+
ss.connect
|
116
126
|
ss.connected?.should be_truthy
|
117
127
|
ss.disconnect
|
118
128
|
ss.connected?.should be_falsey
|
@@ -123,6 +133,7 @@ module Cosmos
|
|
123
133
|
expect(read).to receive(:closed?).and_return(false)
|
124
134
|
expect(read).to receive(:close)
|
125
135
|
ss = TcpipSocketStream.new(nil,read,nil,nil)
|
136
|
+
ss.connect
|
126
137
|
ss.connected?.should be_truthy
|
127
138
|
ss.disconnect
|
128
139
|
ss.connected?.should be_falsey
|
@@ -130,9 +141,10 @@ module Cosmos
|
|
130
141
|
|
131
142
|
it "shouldn't close the socket twice" do
|
132
143
|
socket = double("socket")
|
133
|
-
expect(socket).to receive(:closed?).and_return(false, true)
|
144
|
+
expect(socket).to receive(:closed?).and_return(false, true, true, true)
|
134
145
|
expect(socket).to receive(:close).once
|
135
146
|
ss = TcpipSocketStream.new(socket,socket,nil,nil)
|
147
|
+
ss.connect
|
136
148
|
ss.connected?.should be_truthy
|
137
149
|
ss.disconnect
|
138
150
|
ss.connected?.should be_falsey
|
@@ -32,6 +32,7 @@ module Cosmos
|
|
32
32
|
describe "connect" do
|
33
33
|
it "should support an initial read delay" do
|
34
34
|
class MyStream1 < Stream
|
35
|
+
def connect; end
|
35
36
|
def read_nonblock; []; end
|
36
37
|
end
|
37
38
|
stream = MyStream1.new
|
@@ -46,6 +47,7 @@ module Cosmos
|
|
46
47
|
it "should unblock the read queue" do
|
47
48
|
tsp = TemplateStreamProtocol.new('0xABCD','0xABCD')
|
48
49
|
class MyStream1 < Stream
|
50
|
+
def connect; end
|
49
51
|
def disconnect; end
|
50
52
|
end
|
51
53
|
tsp.connect(MyStream1.new)
|
@@ -63,6 +65,7 @@ module Cosmos
|
|
63
65
|
describe "read" do
|
64
66
|
it "should read packets from the stream" do
|
65
67
|
class MyStream < Stream
|
68
|
+
def connect; end
|
66
69
|
def connected?; true; end
|
67
70
|
def read
|
68
71
|
case $index
|
@@ -91,6 +94,7 @@ module Cosmos
|
|
91
94
|
it "should work without a response" do
|
92
95
|
$buffer = ''
|
93
96
|
class MyStream1 < Stream
|
97
|
+
def connect; end
|
94
98
|
def connected?; true; end
|
95
99
|
def write(buffer) $buffer = buffer; end
|
96
100
|
end
|
@@ -112,6 +116,7 @@ module Cosmos
|
|
112
116
|
$buffer = ''
|
113
117
|
$read_cnt = 0
|
114
118
|
class MyStream2 < Stream
|
119
|
+
def connect; end
|
115
120
|
def connected?; true; end
|
116
121
|
def write(buffer) $buffer = buffer; end
|
117
122
|
def read
|
@@ -32,6 +32,7 @@ module Cosmos
|
|
32
32
|
describe "read" do
|
33
33
|
it "should read packets from the stream" do
|
34
34
|
class MyStream < Stream
|
35
|
+
def connect; end
|
35
36
|
def connected?; true; end
|
36
37
|
def read
|
37
38
|
case $index
|
@@ -57,6 +58,7 @@ module Cosmos
|
|
57
58
|
|
58
59
|
it "should keep the the termination characters" do
|
59
60
|
class MyStream < Stream
|
61
|
+
def connect; end
|
60
62
|
def connected?; true; end
|
61
63
|
def read
|
62
64
|
case $index
|
@@ -86,6 +88,7 @@ module Cosmos
|
|
86
88
|
describe "write" do
|
87
89
|
it "should append termination characters to the packet" do
|
88
90
|
class MyStream < Stream
|
91
|
+
def connect; end
|
89
92
|
def connected?; true; end
|
90
93
|
def write(data); $buffer = data; end
|
91
94
|
end
|
@@ -104,6 +107,7 @@ module Cosmos
|
|
104
107
|
|
105
108
|
it "should complain if the packet buffer contains the termination characters" do
|
106
109
|
class MyStream < Stream
|
110
|
+
def connect; end
|
107
111
|
def connected?; true; end
|
108
112
|
def write(data); $buffer = data; end
|
109
113
|
end
|
@@ -259,6 +259,27 @@ module Cosmos
|
|
259
259
|
end
|
260
260
|
end
|
261
261
|
|
262
|
+
context "with OPTION" do
|
263
|
+
it "should complain about too few parameters" do
|
264
|
+
tf = Tempfile.new('unittest')
|
265
|
+
tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
|
266
|
+
tf.puts 'OPTION TRUE'
|
267
|
+
tf.close
|
268
|
+
expect { CmdTlmServerConfig.new(tf.path) }.to raise_error(ConfigParser::Error, "Not enough parameters for OPTION.")
|
269
|
+
tf.unlink
|
270
|
+
end
|
271
|
+
|
272
|
+
it "should set the interface to listen on a specific address" do
|
273
|
+
tf = Tempfile.new('unittest')
|
274
|
+
tf.puts "INTERFACE CtsConfigTestInterface cts_config_test_interface.rb"
|
275
|
+
tf.puts 'OPTION LISTEN_ADDRESS 127.0.0.1'
|
276
|
+
tf.close
|
277
|
+
config = CmdTlmServerConfig.new(tf.path)
|
278
|
+
config.interfaces['CTSCONFIGTESTINTERFACE'].options['LISTEN_ADDRESS'].should eql(['127.0.0.1'])
|
279
|
+
tf.unlink
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
262
283
|
context "with LOG" do
|
263
284
|
it "should complain about too many parameters" do
|
264
285
|
tf = Tempfile.new('unittest')
|
@@ -408,4 +429,3 @@ module Cosmos
|
|
408
429
|
end
|
409
430
|
end
|
410
431
|
end
|
411
|
-
|