cosmos 4.2.4-java → 4.3.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile +1 -1
- data/Manifest.txt +12 -0
- data/autohotkey/tools/cmd_sequence.ahk +21 -20
- data/autohotkey/tools/cmd_sequence2.ahk +1 -1
- data/autohotkey/tools/config_editor.ahk +1 -1
- data/autohotkey/tools/launcher.ahk +1 -0
- data/autohotkey/tools/packet_viewer.ahk +6 -5
- data/autohotkey/tools/test_runner.ahk +8 -8
- data/bin/cosmos +37 -0
- data/bin/dart_util +0 -0
- data/data/config/item_modifiers.yaml +9 -0
- data/data/crc.txt +91 -86
- data/demo/Rakefile +2 -0
- data/demo/config/dart/Gemfile +1 -1
- data/demo/config/data/crc.txt +8 -5
- data/demo/config/system/system.txt +28 -0
- data/demo/config/system/system2.txt +21 -3
- data/demo/config/system/system_alt_ports.txt +69 -0
- data/demo/config/targets/INST/cmd_tlm/inst_tlm.txt +1 -0
- data/demo/config/tools/cmd_tlm_server/cmd_tlm_server_chain.txt +18 -0
- data/demo/procedures/cosmos_api_test.rb +18 -14
- data/demo/procedures/local_screen_example.rb +51 -0
- data/ext/cosmos/ext/cosmos_io/cosmos_io.c +32 -4
- data/ext/cosmos/ext/packet/packet.c +6 -0
- data/ext/mkrf_conf.rb +2 -2
- data/install/config/dart/Gemfile +1 -1
- data/install/config/data/crc.txt +2 -2
- data/install/config/system/system.txt +23 -1
- data/lib/cosmos/conversions.rb +2 -0
- data/lib/cosmos/conversions/packet_time_formatted_conversion.rb +38 -0
- data/lib/cosmos/conversions/packet_time_seconds_conversion.rb +38 -0
- data/lib/cosmos/core_ext/cosmos_io.rb +2 -1
- data/lib/cosmos/dart/Gemfile +1 -1
- data/lib/cosmos/dart/examples/dart_stream_client.rb +6 -2
- data/lib/cosmos/dart/lib/dart_common.rb +1 -1
- data/lib/cosmos/dart/lib/dart_database_cleaner.rb +2 -2
- data/lib/cosmos/dart/lib/dart_decommutator.rb +4 -4
- data/lib/cosmos/dart/lib/dart_importer.rb +3 -3
- data/lib/cosmos/dart/lib/dart_packet_log_writer.rb +2 -2
- data/lib/cosmos/dart/processes/dart_ingester.rb +2 -0
- data/lib/cosmos/dart/processes/dart_util.rb +4 -4
- data/lib/cosmos/dart/spec/dart/dart_reducer_manager_spec.rb +3 -3
- data/lib/cosmos/gui/dialogs/cmd_tlm_raw_dialog.rb +9 -5
- data/lib/cosmos/gui/dialogs/details_dialog.rb +29 -29
- data/lib/cosmos/gui/dialogs/exception_list_dialog.rb +1 -1
- data/lib/cosmos/gui/dialogs/find_replace_dialog.rb +3 -3
- data/lib/cosmos/gui/dialogs/interface_raw_dialog.rb +2 -2
- data/lib/cosmos/gui/dialogs/set_tlm_dialog.rb +1 -1
- data/lib/cosmos/gui/dialogs/tlm_details_dialog.rb +10 -10
- data/lib/cosmos/gui/qt.rb +10 -1
- data/lib/cosmos/gui/qt_tool.rb +17 -10
- data/lib/cosmos/gui/text/ruby_editor.rb +47 -8
- data/lib/cosmos/gui/utilities/classification_banner.rb +60 -0
- data/lib/cosmos/gui/utilities/script_module_gui.rb +26 -0
- data/lib/cosmos/interfaces.rb +1 -0
- data/lib/cosmos/interfaces/interface.rb +4 -0
- data/lib/cosmos/interfaces/protocols/ignore_packet_protocol.rb +46 -0
- data/lib/cosmos/interfaces/protocols/preidentified_protocol.rb +68 -23
- data/lib/cosmos/packet_logs/packet_log_reader.rb +69 -26
- data/lib/cosmos/packet_logs/packet_log_writer.rb +13 -1
- data/lib/cosmos/packets/commands.rb +5 -1
- data/lib/cosmos/packets/packet.rb +36 -2
- data/lib/cosmos/packets/packet_config.rb +0 -1
- data/lib/cosmos/packets/parsers/format_string_parser.rb +0 -1
- data/lib/cosmos/packets/parsers/xtce_parser.rb +1 -1
- data/lib/cosmos/packets/telemetry.rb +4 -0
- data/lib/cosmos/script/api_shared.rb +2 -0
- data/lib/cosmos/script/limits.rb +4 -0
- data/lib/cosmos/script/script.rb +27 -11
- data/lib/cosmos/script/telemetry.rb +3 -1
- data/lib/cosmos/script/tools.rb +18 -8
- data/lib/cosmos/system/system.rb +21 -0
- data/lib/cosmos/tools/cmd_extractor/cmd_extractor.rb +26 -24
- data/lib/cosmos/tools/cmd_sender/cmd_sender.rb +29 -29
- data/lib/cosmos/tools/cmd_sequence/cmd_sequence.rb +65 -40
- data/lib/cosmos/tools/cmd_sequence/sequence_item.rb +6 -6
- data/lib/cosmos/tools/cmd_tlm_server/api.rb +13 -0
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server.rb +12 -9
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_config.rb +7 -1
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb +8 -8
- data/lib/cosmos/tools/cmd_tlm_server/commanding.rb +13 -2
- data/lib/cosmos/tools/cmd_tlm_server/gui/interfaces_tab.rb +2 -2
- data/lib/cosmos/tools/cmd_tlm_server/gui/logging_tab.rb +13 -13
- data/lib/cosmos/tools/cmd_tlm_server/gui/packets_tab.rb +4 -4
- data/lib/cosmos/tools/cmd_tlm_server/gui/status_tab.rb +8 -8
- data/lib/cosmos/tools/cmd_tlm_server/gui/targets_tab.rb +5 -5
- data/lib/cosmos/tools/cmd_tlm_server/interface_thread.rb +35 -20
- data/lib/cosmos/tools/cmd_tlm_server/replay_backend.rb +15 -11
- data/lib/cosmos/tools/config_editor/config_editor.rb +69 -69
- data/lib/cosmos/tools/data_viewer/data_viewer.rb +42 -38
- data/lib/cosmos/tools/data_viewer/data_viewer_component.rb +1 -0
- data/lib/cosmos/tools/data_viewer/dump_component.rb +1 -0
- data/lib/cosmos/tools/handbook_creator/handbook_creator.rb +4 -4
- data/lib/cosmos/tools/launcher/launcher.rb +1 -1
- data/lib/cosmos/tools/limits_monitor/limits_monitor.rb +28 -24
- data/lib/cosmos/tools/opengl_builder/opengl_builder.rb +42 -42
- data/lib/cosmos/tools/packet_viewer/packet_viewer.rb +56 -53
- data/lib/cosmos/tools/script_runner/script_runner.rb +112 -95
- data/lib/cosmos/tools/script_runner/script_runner_frame.rb +48 -30
- data/lib/cosmos/tools/table_manager/table_manager.rb +42 -42
- data/lib/cosmos/tools/test_runner/test_runner.rb +45 -27
- data/lib/cosmos/tools/test_runner/test_runner_chooser.rb +3 -3
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor.rb +45 -45
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor_config.rb +4 -4
- data/lib/cosmos/tools/tlm_grapher/data_object_adders/xy_data_object_adder.rb +3 -3
- data/lib/cosmos/tools/tlm_grapher/data_object_editors/housekeeping_data_object_editor.rb +7 -7
- data/lib/cosmos/tools/tlm_grapher/data_object_editors/xy_data_object_editor.rb +10 -10
- data/lib/cosmos/tools/tlm_grapher/data_objects/housekeeping_data_object.rb +10 -3
- data/lib/cosmos/tools/tlm_grapher/data_objects/xy_data_object.rb +6 -6
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots/overview_tabbed_plots.rb +14 -14
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_tool.rb +83 -83
- data/lib/cosmos/tools/tlm_viewer/screen.rb +73 -13
- data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +15 -15
- data/lib/cosmos/tools/tlm_viewer/widgets.rb +1 -0
- data/lib/cosmos/tools/tlm_viewer/widgets/canvasellipse_widget.rb +40 -0
- data/lib/cosmos/tools/tlm_viewer/widgets/timegraph_widget.rb +1 -1
- data/lib/cosmos/tools/tlm_viewer/widgets/widget.rb +6 -1
- data/lib/cosmos/top_level.rb +14 -1
- data/lib/cosmos/version.rb +5 -5
- data/lib/cosmos/win32/excel.rb +63 -12
- data/make_gems.sh +10 -0
- data/spec/conversions/packet_time_formatted_conversion_spec.rb +58 -0
- data/spec/conversions/packet_time_seconds_conversion_spec.rb +60 -0
- data/spec/interfaces/protocols/ignore_packet_protocol_spec.rb +243 -0
- data/spec/interfaces/protocols/preidentified_protocol_spec.rb +227 -4
- data/spec/io/serial_driver_spec.rb +15 -13
- data/spec/packet_logs/packet_log_reader_spec.rb +72 -17
- data/spec/packets/packet_config_spec.rb +5 -16
- data/spec/packets/parsers/format_string_parser_spec.rb +0 -11
- data/spec/packets/parsers/macro_parser_spec.rb +36 -36
- data/spec/packets/parsers/state_parser_spec.rb +36 -0
- data/spec/packets/telemetry_spec.rb +11 -9
- data/spec/script/script_spec.rb +2 -3
- data/spec/script/scripting_spec.rb +2 -1
- data/spec/script/tools_spec.rb +0 -1
- data/spec/tools/cmd_tlm_server/api_spec.rb +28 -20
- data/spec/tools/cmd_tlm_server/cmd_tlm_server_config_spec.rb +33 -0
- data/spec/tools/cmd_tlm_server/commanding_spec.rb +25 -1
- data/spec/tools/cmd_tlm_server/interface_thread_spec.rb +15 -0
- data/tasks/gemfile_stats.rake +3 -2
- metadata +14 -2
data/make_gems.sh
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# export VERSION= before running this
|
2
|
+
git checkout master
|
3
|
+
git pull
|
4
|
+
rbenv global 2.4.4
|
5
|
+
rake release VERSION=$VERSION
|
6
|
+
rake commit_release VERSION=$VERSION
|
7
|
+
mv *.gem ~/share/.
|
8
|
+
rbenv global jruby-9.1.12.0
|
9
|
+
gem build cosmos.gemspec
|
10
|
+
mv *.gem ~/share/.
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# encoding: ascii-8bit
|
2
|
+
|
3
|
+
# Copyright 2018 Ball Aerospace & Technologies Corp.
|
4
|
+
# All Rights Reserved.
|
5
|
+
#
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
7
|
+
# under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
10
|
+
|
11
|
+
require 'spec_helper'
|
12
|
+
require 'cosmos/conversions/packet_time_formatted_conversion'
|
13
|
+
require 'cosmos/packets/packet'
|
14
|
+
|
15
|
+
module Cosmos
|
16
|
+
|
17
|
+
describe PacketTimeFormattedConversion do
|
18
|
+
|
19
|
+
describe "initialize" do
|
20
|
+
it "initializes converted_type and converted_bit_size" do
|
21
|
+
gc = PacketTimeFormattedConversion.new()
|
22
|
+
expect(gc.converted_type).to eql :STRING
|
23
|
+
expect(gc.converted_bit_size).to eql 0
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "call" do
|
28
|
+
it "returns the formatted packet time" do
|
29
|
+
gc = PacketTimeFormattedConversion.new()
|
30
|
+
packet = Packet.new("TGT","PKT")
|
31
|
+
packet.received_time = Time.new(2020,1,31,12,15,30)
|
32
|
+
expect(gc.call(nil,packet,nil)).to eql "2020/01/31 12:15:30.000"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns the formatted packet time from a packet item" do
|
36
|
+
gc = PacketTimeFormattedConversion.new()
|
37
|
+
packet = Packet.new("TGT","PKT")
|
38
|
+
item = packet.define_item("PACKET_TIME", 0, 0, :DERIVED)
|
39
|
+
item.read_conversion = GenericConversion.new("Time.new(2020,1,31,12,15,30)")
|
40
|
+
packet.received_time = nil
|
41
|
+
expect(gc.call(nil,packet,nil)).to eql "2020/01/31 12:15:30.000"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns a string if packet time isn't set" do
|
45
|
+
gc = PacketTimeFormattedConversion.new()
|
46
|
+
packet = Packet.new("TGT","PKT")
|
47
|
+
expect(gc.call(nil,packet,nil)).to eql "No Packet Time"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "to_s" do
|
52
|
+
it "returns the class" do
|
53
|
+
expect(PacketTimeFormattedConversion.new().to_s).to eql "PacketTimeFormattedConversion"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# encoding: ascii-8bit
|
2
|
+
|
3
|
+
# Copyright 2018 Ball Aerospace & Technologies Corp.
|
4
|
+
# All Rights Reserved.
|
5
|
+
#
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
7
|
+
# under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
10
|
+
|
11
|
+
require 'spec_helper'
|
12
|
+
require 'cosmos/conversions/packet_time_seconds_conversion'
|
13
|
+
require 'cosmos/packets/packet'
|
14
|
+
|
15
|
+
module Cosmos
|
16
|
+
|
17
|
+
describe PacketTimeSecondsConversion do
|
18
|
+
|
19
|
+
describe "initialize" do
|
20
|
+
it "initializes converted_type and converted_bit_size" do
|
21
|
+
gc = PacketTimeSecondsConversion.new()
|
22
|
+
expect(gc.converted_type).to eql :FLOAT
|
23
|
+
expect(gc.converted_bit_size).to eql 64
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "call" do
|
28
|
+
it "returns the formatted packet time" do
|
29
|
+
gc = PacketTimeSecondsConversion.new()
|
30
|
+
packet = Packet.new("TGT","PKT")
|
31
|
+
time = Time.new(2020,1,31,12,15,30)
|
32
|
+
packet.received_time = time
|
33
|
+
expect(gc.call(nil,packet,nil)).to eql time.to_f
|
34
|
+
end
|
35
|
+
|
36
|
+
it "returns the formatted packet time from a packet item" do
|
37
|
+
gc = PacketTimeSecondsConversion.new()
|
38
|
+
packet = Packet.new("TGT","PKT")
|
39
|
+
item = packet.define_item("PACKET_TIME", 0, 0, :DERIVED)
|
40
|
+
time = Time.new(2020,1,31,12,15,30)
|
41
|
+
item.read_conversion = GenericConversion.new("Time.new(2020,1,31,12,15,30)")
|
42
|
+
packet.received_time = nil
|
43
|
+
expect(gc.call(nil,packet,nil)).to eql time.to_f
|
44
|
+
end
|
45
|
+
|
46
|
+
it "returns 0.0 if packet time isn't set" do
|
47
|
+
gc = PacketTimeSecondsConversion.new()
|
48
|
+
packet = Packet.new("TGT","PKT")
|
49
|
+
expect(gc.call(nil,packet,nil)).to eql 0.0
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "to_s" do
|
54
|
+
it "returns the class" do
|
55
|
+
expect(PacketTimeSecondsConversion.new().to_s).to eql "PacketTimeSecondsConversion"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
@@ -0,0 +1,243 @@
|
|
1
|
+
# encoding: ascii-8bit
|
2
|
+
|
3
|
+
# Copyright 2014 Ball Aerospace & Technologies Corp.
|
4
|
+
# All Rights Reserved.
|
5
|
+
#
|
6
|
+
# This program is free software; you can modify and/or redistribute it
|
7
|
+
# under the terms of the GNU General Public License
|
8
|
+
# as published by the Free Software Foundation; version 3 with
|
9
|
+
# attribution addendums as found in the LICENSE.txt
|
10
|
+
|
11
|
+
require 'spec_helper'
|
12
|
+
require 'cosmos/interfaces/protocols/ignore_packet_protocol'
|
13
|
+
require 'cosmos/interfaces/interface'
|
14
|
+
require 'cosmos/streams/stream'
|
15
|
+
|
16
|
+
module Cosmos
|
17
|
+
describe IgnorePacketProtocol do
|
18
|
+
before(:each) do
|
19
|
+
$buffer = nil
|
20
|
+
@interface = StreamInterface.new
|
21
|
+
@interface.target_names = ['SYSTEM', 'INST']
|
22
|
+
allow(@interface).to receive(:connected?) { true }
|
23
|
+
end
|
24
|
+
|
25
|
+
class PreStream < Stream
|
26
|
+
def connect; end
|
27
|
+
def connected?; true; end
|
28
|
+
def disconnect; end
|
29
|
+
def read; $buffer; end
|
30
|
+
def write(data); $buffer = data; end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "initialize" do
|
34
|
+
it "complains if target is not given" do
|
35
|
+
expect { @interface.add_protocol(IgnorePacketProtocol, [], :READ_WRITE) }.to raise_error(ArgumentError)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "complains if packet is not given" do
|
39
|
+
expect { @interface.add_protocol(IgnorePacketProtocol, ['SYSTEM'], :READ_WRITE) }.to raise_error(ArgumentError)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "complains if the target is not found" do
|
43
|
+
expect { @interface.add_protocol(IgnorePacketProtocol, ['BLAH', 'META'], :READ_WRITE) }.to raise_error(/target 'BLAH' does not exist/)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "complains if the target is not found" do
|
47
|
+
expect { @interface.add_protocol(IgnorePacketProtocol, ['SYSTEM', 'BLAH'], :READ_WRITE) }.to raise_error(/packet 'SYSTEM BLAH' does not exist/)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "read" do
|
52
|
+
it "ignores the packet specified" do
|
53
|
+
@interface.instance_variable_set(:@stream, PreStream.new)
|
54
|
+
pkt = System.telemetry.packet("SYSTEM","META")
|
55
|
+
# Ensure the ID items are set so this packet can be identified
|
56
|
+
pkt.id_items.each do |item|
|
57
|
+
pkt.write_item(item, item.id_value)
|
58
|
+
end
|
59
|
+
pkt.received_time = Time.now
|
60
|
+
$buffer = nil
|
61
|
+
@interface.write(pkt)
|
62
|
+
# Verify the write went out
|
63
|
+
expect(pkt.buffer).to eql $buffer
|
64
|
+
# Verify we read the packet back
|
65
|
+
packet = @interface.read
|
66
|
+
expect(packet.buffer).to eql $buffer
|
67
|
+
|
68
|
+
# Now add the protocol to ignore the packet
|
69
|
+
@interface.add_protocol(IgnorePacketProtocol, ['SYSTEM', 'META'], :READ)
|
70
|
+
$buffer = nil
|
71
|
+
@interface.write(pkt)
|
72
|
+
packet = nil
|
73
|
+
# Try to read the interface
|
74
|
+
# We put this in a thread because it calls it continuously
|
75
|
+
thread = Thread.new do
|
76
|
+
packet = @interface.read
|
77
|
+
end
|
78
|
+
sleep 0.1
|
79
|
+
thread.kill
|
80
|
+
sleep 0.2 # Allow thread to die
|
81
|
+
expect(packet).to be_nil
|
82
|
+
end
|
83
|
+
|
84
|
+
it "can be added multiple times to ignore different packets" do
|
85
|
+
@interface.instance_variable_set(:@stream, PreStream.new)
|
86
|
+
|
87
|
+
pkt = System.telemetry.packet("INST","HEALTH_STATUS")
|
88
|
+
# Ensure the ID items are set so this packet can be identified
|
89
|
+
pkt.id_items.each do |item|
|
90
|
+
pkt.write_item(item, item.id_value)
|
91
|
+
end
|
92
|
+
pkt.received_time = Time.now
|
93
|
+
$buffer = nil
|
94
|
+
@interface.write(pkt)
|
95
|
+
expect($buffer).to eql pkt.buffer
|
96
|
+
|
97
|
+
# Verify we read the packet back
|
98
|
+
packet = @interface.read
|
99
|
+
expect(packet.buffer).to eql $buffer
|
100
|
+
|
101
|
+
# Now add the protocol to ignore the packet
|
102
|
+
@interface.add_protocol(IgnorePacketProtocol, ['INST', 'HEALTH_STATUS'], :READ)
|
103
|
+
$buffer = nil
|
104
|
+
@interface.write(pkt)
|
105
|
+
expect($buffer).to eql pkt.buffer
|
106
|
+
packet = nil
|
107
|
+
# Try to read the interface
|
108
|
+
# We put this in a thread because it calls it continuously
|
109
|
+
thread = Thread.new do
|
110
|
+
packet = @interface.read
|
111
|
+
end
|
112
|
+
sleep 0.1
|
113
|
+
thread.kill
|
114
|
+
sleep 0.2 # Allow thread to die
|
115
|
+
expect(packet).to be_nil
|
116
|
+
|
117
|
+
# Add another protocol to ignore another packet
|
118
|
+
@interface.add_protocol(IgnorePacketProtocol, ['INST', 'ADCS'], :READ)
|
119
|
+
|
120
|
+
pkt = System.telemetry.packet("INST","ADCS")
|
121
|
+
# Ensure the ID items are set so this packet can be identified
|
122
|
+
pkt.id_items.each do |item|
|
123
|
+
pkt.write_item(item, item.id_value)
|
124
|
+
end
|
125
|
+
pkt.received_time = Time.now
|
126
|
+
$buffer = nil
|
127
|
+
@interface.write(pkt)
|
128
|
+
expect($buffer).to eql pkt.buffer
|
129
|
+
|
130
|
+
packet = nil
|
131
|
+
# Try to read the interface
|
132
|
+
# We put this in a thread because it calls it continuously
|
133
|
+
thread = Thread.new do
|
134
|
+
packet = @interface.read
|
135
|
+
end
|
136
|
+
sleep 0.1
|
137
|
+
thread.kill
|
138
|
+
sleep 0.2 # Allow thread to die
|
139
|
+
expect(packet).to be_nil
|
140
|
+
|
141
|
+
pkt = System.telemetry.packet("INST","PARAMS")
|
142
|
+
# Ensure the ID items are set so this packet can be identified
|
143
|
+
pkt.id_items.each do |item|
|
144
|
+
pkt.write_item(item, item.id_value)
|
145
|
+
end
|
146
|
+
pkt.received_time = Time.now
|
147
|
+
$buffer = nil
|
148
|
+
@interface.write(pkt)
|
149
|
+
# Verify the write went out
|
150
|
+
expect($buffer).to eql pkt.buffer
|
151
|
+
|
152
|
+
packet = @interface.read
|
153
|
+
expect(packet.buffer).to eql pkt.buffer
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
describe "write" do
|
158
|
+
it "ignores the packet specified" do
|
159
|
+
@interface.instance_variable_set(:@stream, PreStream.new)
|
160
|
+
@interface.add_protocol(IgnorePacketProtocol, ['SYSTEM', 'META'], :WRITE)
|
161
|
+
pkt = System.telemetry.packet("SYSTEM","META")
|
162
|
+
pkt.write("COSMOS_VERSION", "TEST")
|
163
|
+
pkt.received_time = Time.now
|
164
|
+
$buffer = nil
|
165
|
+
@interface.write(pkt)
|
166
|
+
# Verify the write was ignored
|
167
|
+
expect($buffer).to be_nil
|
168
|
+
|
169
|
+
# Verify reading the interface works
|
170
|
+
$buffer = pkt.buffer
|
171
|
+
packet = @interface.read
|
172
|
+
expect(packet.buffer).to eql $buffer
|
173
|
+
end
|
174
|
+
|
175
|
+
it "can be added multiple times to ignore different packets" do
|
176
|
+
@interface.instance_variable_set(:@stream, PreStream.new)
|
177
|
+
@interface.add_protocol(IgnorePacketProtocol, ['INST', 'HEALTH_STATUS'], :WRITE)
|
178
|
+
@interface.add_protocol(IgnorePacketProtocol, ['INST', 'ADCS'], :WRITE)
|
179
|
+
|
180
|
+
pkt = System.telemetry.packet("INST","HEALTH_STATUS")
|
181
|
+
pkt.received_time = Time.now
|
182
|
+
$buffer = nil
|
183
|
+
@interface.write(pkt)
|
184
|
+
# Verify the write was ignored
|
185
|
+
expect($buffer).to be_nil
|
186
|
+
|
187
|
+
pkt = System.telemetry.packet("INST","ADCS")
|
188
|
+
pkt.received_time = Time.now
|
189
|
+
$buffer = nil
|
190
|
+
@interface.write(pkt)
|
191
|
+
# Verify the write was ignored
|
192
|
+
expect($buffer).to be_nil
|
193
|
+
|
194
|
+
pkt = System.telemetry.packet("INST","PARAMS")
|
195
|
+
pkt.received_time = Time.now
|
196
|
+
$buffer = nil
|
197
|
+
@interface.write(pkt)
|
198
|
+
# Verify the write went out
|
199
|
+
expect($buffer).to eql pkt.buffer
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
describe "read/write" do
|
204
|
+
it "ignores the packet specified" do
|
205
|
+
@interface.instance_variable_set(:@stream, PreStream.new)
|
206
|
+
@interface.add_protocol(IgnorePacketProtocol, ['SYSTEM', 'META'], :READ_WRITE)
|
207
|
+
pkt = System.telemetry.packet("SYSTEM","META")
|
208
|
+
pkt.write("COSMOS_VERSION", "TEST")
|
209
|
+
pkt.received_time = Time.now
|
210
|
+
$buffer = nil
|
211
|
+
@interface.write(pkt)
|
212
|
+
# Verify the write was ignored
|
213
|
+
expect($buffer).to be_nil
|
214
|
+
|
215
|
+
packet = nil
|
216
|
+
# Try to read the interface
|
217
|
+
thread = Thread.new do
|
218
|
+
packet = @interface.read
|
219
|
+
end
|
220
|
+
sleep 0.1
|
221
|
+
thread.kill
|
222
|
+
sleep 0.2 # Allow thread to die
|
223
|
+
expect(packet).to be_nil
|
224
|
+
end
|
225
|
+
|
226
|
+
it "reads and writes unknown packets" do
|
227
|
+
@interface.instance_variable_set(:@stream, PreStream.new)
|
228
|
+
@interface.add_protocol(IgnorePacketProtocol, ['SYSTEM', 'META'], :READ_WRITE)
|
229
|
+
$buffer = nil
|
230
|
+
pkt = Packet.new("TGT","PTK")
|
231
|
+
pkt.append_item("ITEM", 8, :INT)
|
232
|
+
pkt.write("ITEM", 33, :RAW)
|
233
|
+
@interface.write(pkt)
|
234
|
+
# Verify the write went out
|
235
|
+
expect(pkt.buffer).to eql $buffer
|
236
|
+
|
237
|
+
# Verify the read works
|
238
|
+
packet = @interface.read
|
239
|
+
expect(packet.buffer).to eq $buffer
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
@@ -56,6 +56,229 @@ module Cosmos
|
|
56
56
|
time = Time.new(2020,1,31,12,15,30.5)
|
57
57
|
pkt.received_time = time
|
58
58
|
@interface.write(pkt)
|
59
|
+
expect($buffer[0..0].unpack('C')[0]).to eql 0
|
60
|
+
expect($buffer[1..4].unpack('N')[0]).to eql time.to_f.to_i
|
61
|
+
expect($buffer[5..8].unpack('N')[0]).to eql 500000
|
62
|
+
offset = 9
|
63
|
+
tgt_name_length = $buffer[offset].unpack('C')[0]
|
64
|
+
offset += 1 # for the length field
|
65
|
+
expect($buffer[offset...(offset+tgt_name_length)]).to eql 'SYSTEM'
|
66
|
+
offset += tgt_name_length
|
67
|
+
pkt_name_length = $buffer[offset].unpack('C')[0]
|
68
|
+
offset += 1 # for the length field
|
69
|
+
expect($buffer[offset...(offset+pkt_name_length)]).to eql 'META'
|
70
|
+
offset += pkt_name_length
|
71
|
+
expect($buffer[offset..(offset+3)].unpack('N')[0]).to eql pkt.buffer.length
|
72
|
+
offset += 4
|
73
|
+
expect($buffer[offset..-1]).to eql pkt.buffer
|
74
|
+
end
|
75
|
+
|
76
|
+
it "creates a packet header with stored" do
|
77
|
+
@interface.instance_variable_set(:@stream, PreStream.new)
|
78
|
+
@interface.add_protocol(PreidentifiedProtocol, [nil, 5], :READ_WRITE)
|
79
|
+
pkt = System.telemetry.packet("SYSTEM","META").clone
|
80
|
+
time = Time.new(2020,1,31,12,15,30.5)
|
81
|
+
pkt.received_time = time
|
82
|
+
pkt.stored = true
|
83
|
+
@interface.write(pkt)
|
84
|
+
expect($buffer[0..0].unpack('C')[0]).to eql 0x80
|
85
|
+
expect($buffer[1..4].unpack('N')[0]).to eql time.to_f.to_i
|
86
|
+
expect($buffer[5..8].unpack('N')[0]).to eql 500000
|
87
|
+
offset = 9
|
88
|
+
tgt_name_length = $buffer[offset].unpack('C')[0]
|
89
|
+
offset += 1 # for the length field
|
90
|
+
expect($buffer[offset...(offset+tgt_name_length)]).to eql 'SYSTEM'
|
91
|
+
offset += tgt_name_length
|
92
|
+
pkt_name_length = $buffer[offset].unpack('C')[0]
|
93
|
+
offset += 1 # for the length field
|
94
|
+
expect($buffer[offset...(offset+pkt_name_length)]).to eql 'META'
|
95
|
+
offset += pkt_name_length
|
96
|
+
expect($buffer[offset..(offset+3)].unpack('N')[0]).to eql pkt.buffer.length
|
97
|
+
offset += 4
|
98
|
+
expect($buffer[offset..-1]).to eql pkt.buffer
|
99
|
+
end
|
100
|
+
|
101
|
+
it "creates a packet header with extra" do
|
102
|
+
@interface.instance_variable_set(:@stream, PreStream.new)
|
103
|
+
@interface.add_protocol(PreidentifiedProtocol, [nil, 5], :READ_WRITE)
|
104
|
+
pkt = System.telemetry.packet("SYSTEM","META").clone
|
105
|
+
time = Time.new(2020,1,31,12,15,30.5)
|
106
|
+
pkt.received_time = time
|
107
|
+
pkt.stored = false
|
108
|
+
extra_data = {"vcid" => 2}
|
109
|
+
pkt.extra = extra_data
|
110
|
+
@interface.write(pkt)
|
111
|
+
offset = 0
|
112
|
+
expect($buffer[0..0].unpack('C')[0]).to eql 0x40
|
113
|
+
json_extra = extra_data.to_json
|
114
|
+
offset += 1
|
115
|
+
expect($buffer[offset..(offset+3)].unpack('N')[0]).to eql json_extra.length
|
116
|
+
offset += 4
|
117
|
+
expect($buffer[offset..(offset + json_extra.length - 1)]).to eql json_extra
|
118
|
+
offset += json_extra.length
|
119
|
+
expect($buffer[offset..(offset + 3)].unpack('N')[0]).to eql time.to_f.to_i
|
120
|
+
expect($buffer[(offset + 4)..(offset + 7)].unpack('N')[0]).to eql 500000
|
121
|
+
offset = offset += 8 # time fields
|
122
|
+
tgt_name_length = $buffer[offset].unpack('C')[0]
|
123
|
+
offset += 1 # for the length field
|
124
|
+
expect($buffer[offset...(offset+tgt_name_length)]).to eql 'SYSTEM'
|
125
|
+
offset += tgt_name_length
|
126
|
+
pkt_name_length = $buffer[offset].unpack('C')[0]
|
127
|
+
offset += 1 # for the length field
|
128
|
+
expect($buffer[offset...(offset+pkt_name_length)]).to eql 'META'
|
129
|
+
offset += pkt_name_length
|
130
|
+
expect($buffer[offset..(offset+3)].unpack('N')[0]).to eql pkt.buffer.length
|
131
|
+
offset += 4
|
132
|
+
expect($buffer[offset..-1]).to eql pkt.buffer
|
133
|
+
end
|
134
|
+
|
135
|
+
it "creates a packet header with stored and extra" do
|
136
|
+
@interface.instance_variable_set(:@stream, PreStream.new)
|
137
|
+
@interface.add_protocol(PreidentifiedProtocol, [nil, 5], :READ_WRITE)
|
138
|
+
pkt = System.telemetry.packet("SYSTEM","META").clone
|
139
|
+
time = Time.new(2020,1,31,12,15,30.5)
|
140
|
+
pkt.received_time = time
|
141
|
+
pkt.stored = true
|
142
|
+
extra_data = {"vcid" => 2}
|
143
|
+
pkt.extra = extra_data
|
144
|
+
@interface.write(pkt)
|
145
|
+
offset = 0
|
146
|
+
expect($buffer[0..0].unpack('C')[0]).to eql 0xC0
|
147
|
+
json_extra = extra_data.to_json
|
148
|
+
offset += 1
|
149
|
+
expect($buffer[offset..(offset+3)].unpack('N')[0]).to eql json_extra.length
|
150
|
+
offset += 4
|
151
|
+
expect($buffer[offset..(offset + json_extra.length - 1)]).to eql json_extra
|
152
|
+
offset += json_extra.length
|
153
|
+
expect($buffer[offset..(offset + 3)].unpack('N')[0]).to eql time.to_f.to_i
|
154
|
+
expect($buffer[(offset + 4)..(offset + 7)].unpack('N')[0]).to eql 500000
|
155
|
+
offset = offset += 8 # time fields
|
156
|
+
tgt_name_length = $buffer[offset].unpack('C')[0]
|
157
|
+
offset += 1 # for the length field
|
158
|
+
expect($buffer[offset...(offset+tgt_name_length)]).to eql 'SYSTEM'
|
159
|
+
offset += tgt_name_length
|
160
|
+
pkt_name_length = $buffer[offset].unpack('C')[0]
|
161
|
+
offset += 1 # for the length field
|
162
|
+
expect($buffer[offset...(offset+pkt_name_length)]).to eql 'META'
|
163
|
+
offset += pkt_name_length
|
164
|
+
expect($buffer[offset..(offset+3)].unpack('N')[0]).to eql pkt.buffer.length
|
165
|
+
offset += 4
|
166
|
+
expect($buffer[offset..-1]).to eql pkt.buffer
|
167
|
+
end
|
168
|
+
|
169
|
+
it "handles a sync pattern" do
|
170
|
+
@interface.instance_variable_set(:@stream, PreStream.new)
|
171
|
+
@interface.add_protocol(PreidentifiedProtocol, ["DEAD"], :READ_WRITE)
|
172
|
+
pkt = System.telemetry.packet("SYSTEM","META")
|
173
|
+
time = Time.new(2020,1,31,12,15,30.5)
|
174
|
+
pkt.received_time = time
|
175
|
+
@interface.write(pkt)
|
176
|
+
expect($buffer[0..1]).to eql("\xDE\xAD")
|
177
|
+
expect($buffer[2..2].unpack('C')[0]).to eql 0
|
178
|
+
expect($buffer[3..6].unpack('N')[0]).to eql time.to_f.to_i
|
179
|
+
expect($buffer[7..10].unpack('N')[0]).to eql 500000
|
180
|
+
offset = 11
|
181
|
+
tgt_name_length = $buffer[offset].unpack('C')[0]
|
182
|
+
offset += 1 # for the length field
|
183
|
+
expect($buffer[offset...(offset+tgt_name_length)]).to eql 'SYSTEM'
|
184
|
+
offset += tgt_name_length
|
185
|
+
pkt_name_length = $buffer[offset].unpack('C')[0]
|
186
|
+
offset += 1 # for the length field
|
187
|
+
expect($buffer[offset...(offset+pkt_name_length)]).to eql 'META'
|
188
|
+
offset += pkt_name_length
|
189
|
+
expect($buffer[offset..(offset+3)].unpack('N')[0]).to eql pkt.buffer.length
|
190
|
+
offset += 4
|
191
|
+
expect($buffer[offset..-1]).to eql pkt.buffer
|
192
|
+
end
|
193
|
+
|
194
|
+
it "handles a sync pattern with stored and extra" do
|
195
|
+
@interface.instance_variable_set(:@stream, PreStream.new)
|
196
|
+
@interface.add_protocol(PreidentifiedProtocol, ["DEAD", 5], :READ_WRITE)
|
197
|
+
pkt = System.telemetry.packet("SYSTEM","META").clone
|
198
|
+
time = Time.new(2020,1,31,12,15,30.5)
|
199
|
+
pkt.received_time = time
|
200
|
+
pkt.stored = true
|
201
|
+
extra_data = {"vcid" => 2}
|
202
|
+
pkt.extra = extra_data
|
203
|
+
@interface.write(pkt)
|
204
|
+
expect($buffer[0..1]).to eql("\xDE\xAD")
|
205
|
+
offset = 2
|
206
|
+
expect($buffer[2..2].unpack('C')[0]).to eql 0xC0
|
207
|
+
json_extra = extra_data.to_json
|
208
|
+
offset += 1
|
209
|
+
expect($buffer[offset..(offset+3)].unpack('N')[0]).to eql json_extra.length
|
210
|
+
offset += 4
|
211
|
+
expect($buffer[offset..(offset + json_extra.length - 1)]).to eql json_extra
|
212
|
+
offset += json_extra.length
|
213
|
+
expect($buffer[offset..(offset + 3)].unpack('N')[0]).to eql time.to_f.to_i
|
214
|
+
expect($buffer[(offset + 4)..(offset + 7)].unpack('N')[0]).to eql 500000
|
215
|
+
offset = offset += 8 # time fields
|
216
|
+
tgt_name_length = $buffer[offset].unpack('C')[0]
|
217
|
+
offset += 1 # for the length field
|
218
|
+
expect($buffer[offset...(offset+tgt_name_length)]).to eql 'SYSTEM'
|
219
|
+
offset += tgt_name_length
|
220
|
+
pkt_name_length = $buffer[offset].unpack('C')[0]
|
221
|
+
offset += 1 # for the length field
|
222
|
+
expect($buffer[offset...(offset+pkt_name_length)]).to eql 'META'
|
223
|
+
offset += pkt_name_length
|
224
|
+
expect($buffer[offset..(offset+3)].unpack('N')[0]).to eql pkt.buffer.length
|
225
|
+
offset += 4
|
226
|
+
expect($buffer[offset..-1]).to eql pkt.buffer
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
describe "read" do
|
231
|
+
it "handles a sync pattern" do
|
232
|
+
@interface.instance_variable_set(:@stream, PreStream.new)
|
233
|
+
@interface.add_protocol(PreidentifiedProtocol, ["0x1234"], :READ_WRITE)
|
234
|
+
pkt = System.telemetry.packet("SYSTEM","META")
|
235
|
+
pkt.write("COSMOS_VERSION", "TEST")
|
236
|
+
time = Time.new(2020,1,31,12,15,30.5)
|
237
|
+
pkt.received_time = time
|
238
|
+
@interface.write(pkt)
|
239
|
+
expect($buffer[0]).to eql "\x12"
|
240
|
+
expect($buffer[1]).to eql "\x34"
|
241
|
+
packet = @interface.read
|
242
|
+
expect(packet.target_name).to eql 'SYSTEM'
|
243
|
+
expect(packet.packet_name).to eql 'META'
|
244
|
+
expect(packet.identified?).to be true
|
245
|
+
expect(packet.defined?).to be false
|
246
|
+
|
247
|
+
pkt2 = System.telemetry.update!("SYSTEM","META",packet.buffer)
|
248
|
+
expect(pkt2.read('COSMOS_VERSION')).to eql 'TEST'
|
249
|
+
expect(pkt2.identified?).to be true
|
250
|
+
expect(pkt2.defined?).to be true
|
251
|
+
end
|
252
|
+
|
253
|
+
it "returns a packet" do
|
254
|
+
@interface.instance_variable_set(:@stream, PreStream.new)
|
255
|
+
@interface.add_protocol(PreidentifiedProtocol, [], :READ_WRITE)
|
256
|
+
pkt = System.telemetry.packet("SYSTEM","META")
|
257
|
+
pkt.write("COSMOS_VERSION", "TEST")
|
258
|
+
time = Time.new(2020,1,31,12,15,30.5)
|
259
|
+
pkt.received_time = time
|
260
|
+
@interface.write(pkt)
|
261
|
+
packet = @interface.read
|
262
|
+
expect(packet.target_name).to eql 'SYSTEM'
|
263
|
+
expect(packet.packet_name).to eql 'META'
|
264
|
+
expect(packet.identified?).to be true
|
265
|
+
expect(packet.defined?).to be false
|
266
|
+
|
267
|
+
pkt2 = System.telemetry.update!("SYSTEM","META",packet.buffer)
|
268
|
+
expect(pkt2.read('COSMOS_VERSION')).to eql 'TEST'
|
269
|
+
expect(pkt2.identified?).to be true
|
270
|
+
expect(pkt2.defined?).to be true
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
describe "write in mode 2" do
|
275
|
+
it "creates a packet header" do
|
276
|
+
@interface.instance_variable_set(:@stream, PreStream.new)
|
277
|
+
@interface.add_protocol(PreidentifiedProtocol, [nil, 5, 2], :READ_WRITE)
|
278
|
+
pkt = System.telemetry.packet("SYSTEM","META")
|
279
|
+
time = Time.new(2020,1,31,12,15,30.5)
|
280
|
+
pkt.received_time = time
|
281
|
+
@interface.write(pkt)
|
59
282
|
expect($buffer[0..3].unpack('N')[0]).to eql time.to_f.to_i
|
60
283
|
expect($buffer[4..7].unpack('N')[0]).to eql 500000
|
61
284
|
offset = 8
|
@@ -74,7 +297,7 @@ module Cosmos
|
|
74
297
|
|
75
298
|
it "handles a sync pattern" do
|
76
299
|
@interface.instance_variable_set(:@stream, PreStream.new)
|
77
|
-
@interface.add_protocol(PreidentifiedProtocol, ["DEAD"], :READ_WRITE)
|
300
|
+
@interface.add_protocol(PreidentifiedProtocol, ["DEAD", nil, 2], :READ_WRITE)
|
78
301
|
pkt = System.telemetry.packet("SYSTEM","META")
|
79
302
|
time = Time.new(2020,1,31,12,15,30.5)
|
80
303
|
pkt.received_time = time
|
@@ -97,10 +320,10 @@ module Cosmos
|
|
97
320
|
end
|
98
321
|
end
|
99
322
|
|
100
|
-
describe "read" do
|
323
|
+
describe "read in mode 2" do
|
101
324
|
it "handles a sync pattern" do
|
102
325
|
@interface.instance_variable_set(:@stream, PreStream.new)
|
103
|
-
@interface.add_protocol(PreidentifiedProtocol, ["0x1234"], :READ_WRITE)
|
326
|
+
@interface.add_protocol(PreidentifiedProtocol, ["0x1234", nil, 2], :READ_WRITE)
|
104
327
|
pkt = System.telemetry.packet("SYSTEM","META")
|
105
328
|
pkt.write("COSMOS_VERSION", "TEST")
|
106
329
|
time = Time.new(2020,1,31,12,15,30.5)
|
@@ -122,7 +345,7 @@ module Cosmos
|
|
122
345
|
|
123
346
|
it "returns a packet" do
|
124
347
|
@interface.instance_variable_set(:@stream, PreStream.new)
|
125
|
-
@interface.add_protocol(PreidentifiedProtocol, [], :READ_WRITE)
|
348
|
+
@interface.add_protocol(PreidentifiedProtocol, [nil, nil, 2], :READ_WRITE)
|
126
349
|
pkt = System.telemetry.packet("SYSTEM","META")
|
127
350
|
pkt.write("COSMOS_VERSION", "TEST")
|
128
351
|
time = Time.new(2020,1,31,12,15,30.5)
|