cosmos 4.3.0-java → 4.4.0-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.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +30 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +19 -0
- data/.github/ISSUE_TEMPLATE/help---usage---general-question.md +12 -0
- data/.gitignore +1 -0
- data/.travis.yml +5 -5
- data/Manifest.txt +81 -44
- data/Rakefile +9 -0
- data/appveyor.yml +2 -1
- data/autohotkey/config/targets/INST/cmd_tlm/inst_cmds.txt +1 -1
- data/autohotkey/config/targets/INST/cmd_tlm/inst_tlm.txt +5 -5
- data/autohotkey/config/targets/INST/lib/sim_inst.rb +3 -1
- data/autohotkey/config/tools/handbook_creator/assets/css/bootstrap-theme.css +397 -0
- data/autohotkey/config/tools/handbook_creator/assets/css/bootstrap-theme.min.css +7 -0
- data/autohotkey/config/tools/handbook_creator/assets/css/bootstrap.css +7118 -0
- data/autohotkey/config/tools/handbook_creator/assets/css/bootstrap.min.css +7 -0
- data/autohotkey/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.eot +0 -0
- data/autohotkey/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.svg +229 -0
- data/autohotkey/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/autohotkey/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.woff +0 -0
- data/autohotkey/config/tools/handbook_creator/assets/js/bootstrap.js +2006 -0
- data/autohotkey/config/tools/handbook_creator/assets/js/bootstrap.min.js +7 -0
- data/autohotkey/config/tools/table_manager/ConfigTables_def.txt +2 -4
- data/autohotkey/config/tools/table_manager/SubTables/OneDimensionalSubTable_def.txt +31 -0
- data/autohotkey/config/tools/table_manager/SubTables/TwoDimensionalSubTable_def.txt +28 -0
- data/autohotkey/config/tools/test_runner/test_runner.txt +1 -1
- data/autohotkey/config/tools/test_runner/test_runner2.txt +1 -1
- data/autohotkey/config/tools/test_runner/test_runner3.txt +1 -1
- data/autohotkey/config/tools/test_runner/test_runner4.txt +1 -1
- data/autohotkey/tools/limits_monitor.ahk +1 -1
- data/autohotkey/tools/packet_viewer.ahk +1 -1
- data/autohotkey/tools/script_runner.ahk +16 -4
- data/bin/cosmos +1 -1
- data/bin/xtce_converter +1 -1
- data/cosmos.gemspec +5 -7
- data/data/config/_interfaces.yaml +4 -0
- data/data/config/cmd_sequence.yaml +14 -0
- data/data/config/housekeeping_params.yaml +14 -0
- data/data/config/interface_modifiers.yaml +11 -0
- data/data/config/item_modifiers.yaml +2 -1
- data/data/config/launcher.yaml +12 -2
- data/data/config/param_item_modifiers.yaml +2 -2
- data/data/config/parameter_modifiers.yaml +20 -0
- data/data/config/screen.yaml +2 -0
- data/data/config/script_runner.yaml +9 -0
- data/data/config/system.yaml +47 -10
- data/data/config/table_manager.yaml +7 -0
- data/data/config/target.yaml +12 -0
- data/data/config/telemetry_modifiers.yaml +3 -1
- data/data/config/test_runner.yaml +10 -9
- data/data/config/widgets.yaml +174 -11
- data/data/crc.txt +128 -125
- data/demo/Gemfile +1 -1
- data/demo/Launcher.bat +1 -9
- data/demo/Launcher2.bat +1 -0
- data/demo/LauncherMini.bat +1 -0
- data/demo/config/data/crc.txt +40 -20
- data/demo/config/system/system.txt +1 -1
- data/demo/config/system/system_alt_ports.txt +1 -1
- data/demo/config/targets/EXAMPLE/cmd_tlm_server.txt +1 -0
- data/demo/config/targets/INST/cmd_tlm/inst_cmds.txt +2 -1
- data/demo/config/targets/INST/cmd_tlm/inst_tlm.txt +7 -7
- data/demo/config/targets/INST/cmd_tlm_server.txt +2 -0
- data/demo/config/targets/INST/lib/sim_inst.rb +15 -3
- data/demo/config/targets/INST/screens/adcs.txt +2 -2
- data/demo/config/targets/INST/screens/block.txt +1 -1
- data/demo/config/targets/INST/screens/commanding.txt +1 -1
- data/demo/config/targets/INST/screens/ground.txt +27 -5
- data/demo/config/targets/INST/screens/ground_error.gif +0 -0
- data/demo/config/{data/groundoff.gif → targets/INST/screens/ground_off.gif} +0 -0
- data/demo/config/{data/groundon.gif → targets/INST/screens/ground_on.gif} +0 -0
- data/demo/config/targets/INST/screens/limits.txt +69 -31
- data/demo/config/targets/INST/screens/other.txt +13 -3
- data/demo/config/targets/INST/screens/params.txt +54 -0
- data/demo/config/targets/INST/screens/satellite.gif +0 -0
- data/demo/config/tools/data_viewer/data_viewer.txt +3 -0
- data/demo/config/tools/handbook_creator/assets/css/bootstrap-theme.css +397 -0
- data/demo/config/tools/handbook_creator/assets/css/bootstrap-theme.min.css +7 -0
- data/demo/config/tools/handbook_creator/assets/css/bootstrap.css +7118 -0
- data/demo/config/tools/handbook_creator/assets/css/bootstrap.min.css +7 -0
- data/demo/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.eot +0 -0
- data/demo/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.svg +229 -0
- data/demo/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/demo/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.woff +0 -0
- data/demo/config/tools/handbook_creator/assets/img/ball_logo.bmp +0 -0
- data/demo/config/tools/handbook_creator/assets/img/ball_logo.gif +0 -0
- data/demo/config/tools/handbook_creator/assets/img/ball_logo.jpg +0 -0
- data/demo/config/tools/handbook_creator/assets/js/bootstrap.js +2006 -0
- data/demo/config/tools/handbook_creator/assets/js/bootstrap.min.js +7 -0
- data/demo/config/tools/handbook_creator/assets/js/html5shiv.js +8 -0
- data/demo/config/tools/handbook_creator/assets/js/jquery-1.10.2.min.js +6 -0
- data/demo/config/tools/handbook_creator/assets/js/respond.min.js +6 -0
- data/demo/config/tools/script_runner/script_runner.txt +1 -2
- data/demo/config/tools/test_runner/test_runner.txt +3 -1
- data/demo/lib/example_background_task.rb +1 -0
- data/demo/procedures/cosmos_api_test.rb +1 -1
- data/demo/procedures/interactive.rb +22 -0
- data/ext/cosmos/ext/packet/packet.c +0 -77
- data/install/Gemfile +1 -1
- data/install/Launcher.bat +1 -9
- data/install/config/data/crc.txt +17 -1
- data/install/config/system/system.txt +1 -1
- data/install/config/tools/handbook_creator/assets/css/bootstrap-theme.css +397 -0
- data/install/config/tools/handbook_creator/assets/css/bootstrap-theme.min.css +7 -0
- data/install/config/tools/handbook_creator/assets/css/bootstrap.css +7118 -0
- data/install/config/tools/handbook_creator/assets/css/bootstrap.min.css +7 -0
- data/install/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.eot +0 -0
- data/install/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.svg +229 -0
- data/install/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/install/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.woff +0 -0
- data/install/config/tools/handbook_creator/assets/img/ball_logo.bmp +0 -0
- data/install/config/tools/handbook_creator/assets/img/ball_logo.gif +0 -0
- data/install/config/tools/handbook_creator/assets/img/ball_logo.jpg +0 -0
- data/install/config/tools/handbook_creator/assets/js/bootstrap.js +2006 -0
- data/install/config/tools/handbook_creator/assets/js/bootstrap.min.js +7 -0
- data/install/config/tools/handbook_creator/assets/js/html5shiv.js +8 -0
- data/install/config/tools/handbook_creator/assets/js/jquery-1.10.2.min.js +6 -0
- data/install/config/tools/handbook_creator/assets/js/respond.min.js +6 -0
- data/lib/cosmos/config/config_parser.rb +4 -5
- data/lib/cosmos/dart/lib/dart_common.rb +1 -1
- data/lib/cosmos/gui/dialogs/details_dialog.rb +16 -1
- data/lib/cosmos/gui/dialogs/tlm_details_dialog.rb +1 -0
- data/lib/cosmos/gui/dialogs/tlm_graph_dialog.rb +4 -2
- data/lib/cosmos/gui/opengl/earth_model.rb +1 -1
- data/lib/cosmos/gui/qt.rb +3 -1
- data/lib/cosmos/gui/qt_tool.rb +46 -23
- data/lib/cosmos/gui/text/ruby_editor.rb +44 -41
- data/lib/cosmos/gui/utilities/screenshot.rb +1 -1
- data/lib/cosmos/gui/utilities/script_module_gui.rb +92 -92
- data/lib/cosmos/interfaces.rb +1 -0
- data/lib/cosmos/interfaces/interface.rb +5 -1
- data/lib/cosmos/interfaces/protocols/fixed_protocol.rb +40 -18
- data/lib/cosmos/interfaces/protocols/template_protocol.rb +6 -1
- data/lib/cosmos/interfaces/simulated_target_interface.rb +14 -5
- data/lib/cosmos/io/json_drb.rb +11 -7
- data/lib/cosmos/packets/commands.rb +28 -11
- data/lib/cosmos/packets/packet.rb +69 -32
- data/lib/cosmos/packets/packet_config.rb +34 -1
- data/lib/cosmos/packets/parsers/state_parser.rb +0 -1
- data/lib/cosmos/packets/parsers/xtce_converter.rb +2 -0
- data/lib/cosmos/packets/parsers/xtce_parser.rb +4 -3
- data/lib/cosmos/packets/structure.rb +4 -2
- data/lib/cosmos/packets/telemetry.rb +19 -3
- data/lib/cosmos/script/api_shared.rb +12 -9
- data/lib/cosmos/script/scripting.rb +16 -14
- data/lib/cosmos/system/system.rb +39 -20
- data/lib/cosmos/system/target.rb +39 -9
- data/lib/cosmos/tools/cmd_extractor/cmd_extractor.rb +94 -35
- data/lib/cosmos/tools/cmd_sender/cmd_sender.rb +3 -0
- data/lib/cosmos/tools/cmd_sequence/sequence_item.rb +1 -1
- data/lib/cosmos/tools/cmd_tlm_server/background_tasks.rb +2 -0
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server.rb +30 -4
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_config.rb +1 -0
- data/lib/cosmos/tools/cmd_tlm_server/cmd_tlm_server_gui.rb +9 -12
- data/lib/cosmos/tools/cmd_tlm_server/gui/packets_tab.rb +5 -2
- data/lib/cosmos/tools/cmd_tlm_server/routers.rb +2 -0
- data/lib/cosmos/tools/config_editor/config_editor.rb +80 -24
- data/lib/cosmos/tools/config_editor/config_editor_frame.rb +2 -0
- data/lib/cosmos/tools/data_viewer/data_viewer.rb +15 -9
- data/lib/cosmos/tools/data_viewer/dump_component.rb +2 -9
- data/lib/cosmos/tools/data_viewer/text_component.rb +77 -0
- data/lib/cosmos/tools/handbook_creator/handbook_creator.rb +64 -38
- data/lib/cosmos/tools/launcher/launcher.rb +1 -0
- data/lib/cosmos/tools/limits_monitor/limits_monitor.rb +31 -17
- data/lib/cosmos/tools/packet_viewer/packet_viewer.rb +8 -6
- data/lib/cosmos/tools/script_runner/script_runner.rb +87 -29
- data/lib/cosmos/tools/script_runner/script_runner_config.rb +14 -0
- data/lib/cosmos/tools/script_runner/script_runner_frame.rb +41 -7
- data/lib/cosmos/tools/table_manager/table_config.rb +5 -3
- data/lib/cosmos/tools/table_manager/table_manager.rb +6 -3
- data/lib/cosmos/tools/test_runner/test_runner.rb +14 -9
- data/lib/cosmos/tools/test_runner/test_runner_chooser.rb +21 -9
- data/lib/cosmos/tools/tlm_extractor/tlm_extractor.rb +3 -3
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_realtime_thread.rb +5 -8
- data/lib/cosmos/tools/tlm_grapher/tabbed_plots_tool/tabbed_plots_tool.rb +11 -8
- data/lib/cosmos/tools/tlm_grapher/tlm_grapher.rb +9 -15
- data/lib/cosmos/tools/tlm_viewer/screen.rb +3 -1
- data/lib/cosmos/tools/tlm_viewer/tlm_viewer.rb +19 -13
- data/lib/cosmos/tools/tlm_viewer/widgets.rb +2 -0
- data/lib/cosmos/tools/tlm_viewer/widgets/aging_widget.rb +4 -5
- data/lib/cosmos/tools/tlm_viewer/widgets/array_widget.rb +3 -4
- data/lib/cosmos/tools/tlm_viewer/widgets/block_widget.rb +4 -5
- data/lib/cosmos/tools/tlm_viewer/widgets/canvas_clickable.rb +16 -2
- data/lib/cosmos/tools/tlm_viewer/widgets/canvas_widget.rb +17 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/canvasdot_widget.rb +1 -2
- data/lib/cosmos/tools/tlm_viewer/widgets/canvasellipse_widget.rb +1 -1
- data/lib/cosmos/tools/tlm_viewer/widgets/canvasimage_widget.rb +12 -7
- data/lib/cosmos/tools/tlm_viewer/widgets/canvasimagevalue_widget.rb +79 -29
- data/lib/cosmos/tools/tlm_viewer/widgets/canvaslabel_widget.rb +1 -0
- data/lib/cosmos/tools/tlm_viewer/widgets/canvaslabelvalue_widget.rb +2 -1
- data/lib/cosmos/tools/tlm_viewer/widgets/canvasline_widget.rb +2 -0
- data/lib/cosmos/tools/tlm_viewer/widgets/canvaslinevalue_widget.rb +4 -0
- data/lib/cosmos/tools/tlm_viewer/widgets/canvasvalue_widget.rb +33 -25
- data/lib/cosmos/tools/tlm_viewer/widgets/checkbutton_widget.rb +5 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/combobox_widget.rb +5 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/formatfontvalue_widget.rb +1 -1
- data/lib/cosmos/tools/tlm_viewer/widgets/formatvalue_widget.rb +4 -7
- data/lib/cosmos/tools/tlm_viewer/widgets/horizontal_widget.rb +5 -5
- data/lib/cosmos/tools/tlm_viewer/widgets/horizontalbox_widget.rb +6 -7
- data/lib/cosmos/tools/tlm_viewer/widgets/horizontalline_widget.rb +2 -4
- data/lib/cosmos/tools/tlm_viewer/widgets/label_widget.rb +10 -8
- data/lib/cosmos/tools/tlm_viewer/widgets/labelformatvalue_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/labelled_widget.rb +58 -0
- data/lib/cosmos/tools/tlm_viewer/widgets/labelprogressbar_widget.rb +3 -4
- data/lib/cosmos/tools/tlm_viewer/widgets/labeltrendlimitsbar_widget.rb +2 -4
- data/lib/cosmos/tools/tlm_viewer/widgets/labelvalue_widget.rb +2 -1
- data/lib/cosmos/tools/tlm_viewer/widgets/labelvaluedesc_widget.rb +3 -5
- data/lib/cosmos/tools/tlm_viewer/widgets/labelvaluelimitsbar_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/labelvaluelimitscolumn_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/labelvaluerangebar_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/labelvaluerangecolumn_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/layout_widget.rb +3 -5
- data/lib/cosmos/tools/tlm_viewer/widgets/led_widget.rb +108 -0
- data/lib/cosmos/tools/tlm_viewer/widgets/limits_widget.rb +60 -10
- data/lib/cosmos/tools/tlm_viewer/widgets/limitsbar_widget.rb +22 -8
- data/lib/cosmos/tools/tlm_viewer/widgets/limitscolor_widget.rb +19 -13
- data/lib/cosmos/tools/tlm_viewer/widgets/limitscolumn_widget.rb +22 -8
- data/lib/cosmos/tools/tlm_viewer/widgets/linegraph_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/matrixbycolumns_widget.rb +4 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/multi_widget.rb +1 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/progressbar_widget.rb +10 -5
- data/lib/cosmos/tools/tlm_viewer/widgets/radiobutton_widget.rb +7 -4
- data/lib/cosmos/tools/tlm_viewer/widgets/rangebar_widget.rb +4 -6
- data/lib/cosmos/tools/tlm_viewer/widgets/rangecolumn_widget.rb +3 -5
- data/lib/cosmos/tools/tlm_viewer/widgets/screenshotbutton_widget.rb +4 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/scrollwindow_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/sectionheader_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/spacer_widget.rb +4 -6
- data/lib/cosmos/tools/tlm_viewer/widgets/tabbook_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/tabitem_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/textbox_widget.rb +13 -4
- data/lib/cosmos/tools/tlm_viewer/widgets/textfield_widget.rb +3 -4
- data/lib/cosmos/tools/tlm_viewer/widgets/timegraph_widget.rb +2 -7
- data/lib/cosmos/tools/tlm_viewer/widgets/title_widget.rb +6 -12
- data/lib/cosmos/tools/tlm_viewer/widgets/trendbar_widget.rb +5 -10
- data/lib/cosmos/tools/tlm_viewer/widgets/trendlimitsbar_widget.rb +5 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/value_widget.rb +4 -4
- data/lib/cosmos/tools/tlm_viewer/widgets/valuelimitsbar_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/valuelimitscolumn_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/valuerangebar_widget.rb +3 -4
- data/lib/cosmos/tools/tlm_viewer/widgets/valuerangecolumn_widget.rb +2 -3
- data/lib/cosmos/tools/tlm_viewer/widgets/vertical_widget.rb +8 -7
- data/lib/cosmos/tools/tlm_viewer/widgets/verticalbox_widget.rb +9 -7
- data/lib/cosmos/tools/tlm_viewer/widgets/widget.rb +54 -46
- data/lib/cosmos/top_level.rb +23 -12
- data/lib/cosmos/version.rb +4 -4
- data/spec/gui/utilities/script_module_gui_spec.rb +44 -63
- data/spec/install/config/targets/INST/cmd_tlm/inst_cmds.txt +1 -1
- data/spec/install/config/targets/INST/cmd_tlm/inst_tlm.txt +5 -5
- data/spec/install/yaml_docs_spec.rb +112 -0
- data/spec/interfaces/protocols/fixed_protocol_spec.rb +20 -9
- data/spec/interfaces/protocols/template_protocol_spec.rb +78 -25
- data/spec/packets/commands_spec.rb +22 -0
- data/spec/packets/packet_config_spec.rb +24 -0
- data/spec/packets/packet_item_spec.rb +2 -2
- data/spec/packets/packet_spec.rb +39 -6
- data/spec/packets/parsers/state_parser_spec.rb +33 -11
- data/spec/packets/structure_spec.rb +41 -0
- data/spec/packets/telemetry_spec.rb +23 -0
- data/spec/streams/tcpip_socket_stream_spec.rb +32 -27
- data/spec/system/system_spec.rb +77 -2
- data/spec/system/target_spec.rb +62 -1
- data/spec/tools/cmd_tlm_server/api_spec.rb +1 -1
- data/spec/tools/cmd_tlm_server/background_tasks_spec.rb +15 -7
- data/spec/top_level/top_level_spec.rb +29 -5
- data/tasks/gemfile_stats.rake +28 -14
- data/test/performance/config/system/system.txt +0 -0
- data/test/performance/config/targets/PACKET/cmd_tlm/packet_tlm.txt +5 -5
- data/test/performance/config/tools/handbook_creator/assets/css/bootstrap-theme.css +397 -0
- data/test/performance/config/tools/handbook_creator/assets/css/bootstrap-theme.min.css +7 -0
- data/test/performance/config/tools/handbook_creator/assets/css/bootstrap.css +7118 -0
- data/test/performance/config/tools/handbook_creator/assets/css/bootstrap.min.css +7 -0
- data/test/performance/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.eot +0 -0
- data/test/performance/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.svg +229 -0
- data/test/performance/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/test/performance/config/tools/handbook_creator/assets/fonts/glyphicons-halflings-regular.woff +0 -0
- data/test/performance/config/tools/handbook_creator/assets/img/ball_logo.bmp +0 -0
- data/test/performance/config/tools/handbook_creator/assets/img/ball_logo.gif +0 -0
- data/test/performance/config/tools/handbook_creator/assets/img/ball_logo.jpg +0 -0
- data/test/performance/config/tools/handbook_creator/assets/js/bootstrap.js +2006 -0
- data/test/performance/config/tools/handbook_creator/assets/js/bootstrap.min.js +7 -0
- data/test/performance/config/tools/handbook_creator/assets/js/html5shiv.js +8 -0
- data/test/performance/config/tools/handbook_creator/assets/js/jquery-1.10.2.min.js +6 -0
- data/test/performance/config/tools/handbook_creator/assets/js/respond.min.js +6 -0
- data/test/performance/config/tools/test_runner/test_runner.txt +1 -1
- data/test/performance/procedures/cosmos_api_test.rb +1 -1
- data/test/performance/tools/identify_performance.rb +82 -0
- metadata +92 -55
|
@@ -28,6 +28,7 @@ module Cosmos
|
|
|
28
28
|
before(:each) do
|
|
29
29
|
@interface = StreamInterface.new
|
|
30
30
|
allow(@interface).to receive(:connected?) { true }
|
|
31
|
+
$write_buffer = ''
|
|
31
32
|
$read_buffer = ''
|
|
32
33
|
$read_cnt = 0
|
|
33
34
|
end
|
|
@@ -173,12 +174,20 @@ module Cosmos
|
|
|
173
174
|
end
|
|
174
175
|
|
|
175
176
|
it "processes responses with no ID fields" do
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
tf = Tempfile.new('unittest')
|
|
178
|
+
tf.puts 'TELEMETRY TGT READ_VOLTAGE BIG_ENDIAN'
|
|
179
|
+
tf.puts ' APPEND_ITEM VOLTAGE 16 UINT'
|
|
180
|
+
tf.close
|
|
181
|
+
pc = PacketConfig.new
|
|
182
|
+
pc.process_file(tf.path, "SYSTEM")
|
|
183
|
+
telemetry = Telemetry.new(pc)
|
|
184
|
+
tf.unlink
|
|
185
|
+
|
|
186
|
+
allow(System).to receive_message_chain(:telemetry).and_return(telemetry)
|
|
179
187
|
@interface.instance_variable_set(:@stream, TemplateStream.new)
|
|
180
188
|
@interface.add_protocol(TemplateProtocol, %w(0xABCD 0xABCD 0 nil 1 true 0 nil false nil nil), :READ_WRITE)
|
|
181
|
-
|
|
189
|
+
# Add extra target names to the interface to ensure we grab the correct one
|
|
190
|
+
@interface.target_names = ['BLAH','TGT','OTHER']
|
|
182
191
|
packet = Packet.new('TGT', 'CMD')
|
|
183
192
|
packet.append_item("VOLTAGE", 16, :UINT)
|
|
184
193
|
packet.get_item("VOLTAGE").default = 11
|
|
@@ -198,13 +207,21 @@ module Cosmos
|
|
|
198
207
|
@interface.write(packet)
|
|
199
208
|
sleep 0.55
|
|
200
209
|
expect($write_buffer).to eql("SOUR:VOLT 11, (@1)\xAB\xCD")
|
|
210
|
+
expect(read_result.read("VOLTAGE")).to eql(10)
|
|
201
211
|
end
|
|
202
212
|
|
|
203
213
|
it "sets the response ID to the defined ID value" do
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
214
|
+
tf = Tempfile.new('unittest')
|
|
215
|
+
tf.puts 'TELEMETRY TGT READ_VOLTAGE BIG_ENDIAN'
|
|
216
|
+
tf.puts ' APPEND_ID_ITEM PKT_ID 16 UINT 1'
|
|
217
|
+
tf.puts ' APPEND_ITEM VOLTAGE 16 UINT'
|
|
218
|
+
tf.close
|
|
219
|
+
pc = PacketConfig.new
|
|
220
|
+
pc.process_file(tf.path, "SYSTEM")
|
|
221
|
+
telemetry = Telemetry.new(pc)
|
|
222
|
+
tf.unlink
|
|
223
|
+
|
|
224
|
+
allow(System).to receive_message_chain(:telemetry).and_return(telemetry)
|
|
208
225
|
@interface.instance_variable_set(:@stream, TemplateStream.new)
|
|
209
226
|
@interface.add_protocol(TemplateProtocol, %w(0xABCD 0xABCD 0 nil 1 true 0 nil false nil nil), :READ_WRITE)
|
|
210
227
|
@interface.target_names = ['TGT']
|
|
@@ -230,14 +247,22 @@ module Cosmos
|
|
|
230
247
|
sleep 0.55
|
|
231
248
|
expect($write_buffer).to eql("SOUR:VOLT 11, (@1)\xAB\xCD")
|
|
232
249
|
expect(read_result.read("PKT_ID")).to eql(1) # Result ID set to the defined value
|
|
250
|
+
expect(read_result.read("VOLTAGE")).to eql(10)
|
|
233
251
|
end
|
|
234
252
|
|
|
235
253
|
it "handles multiple response IDs" do
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
254
|
+
tf = Tempfile.new('unittest')
|
|
255
|
+
tf.puts 'TELEMETRY TGT READ_VOLTAGE BIG_ENDIAN'
|
|
256
|
+
tf.puts ' APPEND_ID_ITEM APID 16 UINT 10'
|
|
257
|
+
tf.puts ' APPEND_ID_ITEM PKTID 16 UINT 20'
|
|
258
|
+
tf.puts ' APPEND_ITEM VOLTAGE 16 UINT'
|
|
259
|
+
tf.close
|
|
260
|
+
pc = PacketConfig.new
|
|
261
|
+
pc.process_file(tf.path, "SYSTEM")
|
|
262
|
+
telemetry = Telemetry.new(pc)
|
|
263
|
+
tf.unlink
|
|
264
|
+
|
|
265
|
+
allow(System).to receive_message_chain(:telemetry).and_return(telemetry)
|
|
241
266
|
@interface.instance_variable_set(:@stream, TemplateStream.new)
|
|
242
267
|
@interface.add_protocol(TemplateProtocol, %w(0xABCD 0xABCD 0 nil 1 true 0 nil false nil nil), :READ_WRITE)
|
|
243
268
|
@interface.target_names = ['TGT']
|
|
@@ -272,9 +297,16 @@ module Cosmos
|
|
|
272
297
|
end
|
|
273
298
|
|
|
274
299
|
it "handles templates with more values than the response" do
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
300
|
+
tf = Tempfile.new('unittest')
|
|
301
|
+
tf.puts 'TELEMETRY TGT READ_VOLTAGE BIG_ENDIAN'
|
|
302
|
+
tf.puts ' APPEND_ITEM VOLTAGE 16 UINT'
|
|
303
|
+
tf.close
|
|
304
|
+
pc = PacketConfig.new
|
|
305
|
+
pc.process_file(tf.path, "SYSTEM")
|
|
306
|
+
telemetry = Telemetry.new(pc)
|
|
307
|
+
tf.unlink
|
|
308
|
+
|
|
309
|
+
allow(System).to receive_message_chain(:telemetry).and_return(telemetry)
|
|
278
310
|
@interface.instance_variable_set(:@stream, TemplateStream.new)
|
|
279
311
|
@interface.add_protocol(TemplateProtocol, %w(0xABCD 0xABCD 0 nil 1 true 0 nil false nil), :READ_WRITE)
|
|
280
312
|
@interface.target_names = ['TGT']
|
|
@@ -304,9 +336,16 @@ module Cosmos
|
|
|
304
336
|
end
|
|
305
337
|
|
|
306
338
|
it "handles responses with more values than the template" do
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
339
|
+
tf = Tempfile.new('unittest')
|
|
340
|
+
tf.puts 'TELEMETRY TGT READ_VOLTAGE BIG_ENDIAN'
|
|
341
|
+
tf.puts ' APPEND_ITEM VOLTAGE 16 UINT'
|
|
342
|
+
tf.close
|
|
343
|
+
pc = PacketConfig.new
|
|
344
|
+
pc.process_file(tf.path, "SYSTEM")
|
|
345
|
+
telemetry = Telemetry.new(pc)
|
|
346
|
+
tf.unlink
|
|
347
|
+
|
|
348
|
+
allow(System).to receive_message_chain(:telemetry).and_return(telemetry)
|
|
310
349
|
@interface.instance_variable_set(:@stream, TemplateStream.new)
|
|
311
350
|
@interface.add_protocol(TemplateProtocol, %w(0xABCD 0xABCD 0 nil 1 true 0 nil false nil), :READ_WRITE)
|
|
312
351
|
@interface.target_names = ['TGT']
|
|
@@ -336,9 +375,16 @@ module Cosmos
|
|
|
336
375
|
end
|
|
337
376
|
|
|
338
377
|
it "ignores response lines" do
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
378
|
+
tf = Tempfile.new('unittest')
|
|
379
|
+
tf.puts 'TELEMETRY TGT READ_VOLTAGE BIG_ENDIAN'
|
|
380
|
+
tf.puts ' APPEND_ITEM VOLTAGE 16 UINT'
|
|
381
|
+
tf.close
|
|
382
|
+
pc = PacketConfig.new
|
|
383
|
+
pc.process_file(tf.path, "SYSTEM")
|
|
384
|
+
telemetry = Telemetry.new(pc)
|
|
385
|
+
tf.unlink
|
|
386
|
+
|
|
387
|
+
allow(System).to receive_message_chain(:telemetry).and_return(telemetry)
|
|
342
388
|
@interface.instance_variable_set(:@stream, TemplateStream.new)
|
|
343
389
|
@interface.add_protocol(TemplateProtocol, %w(0xAD 0xA 1), :READ_WRITE)
|
|
344
390
|
@interface.target_names = ['TGT']
|
|
@@ -365,9 +411,16 @@ module Cosmos
|
|
|
365
411
|
end
|
|
366
412
|
|
|
367
413
|
it "allows multiple response lines" do
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
414
|
+
tf = Tempfile.new('unittest')
|
|
415
|
+
tf.puts 'TELEMETRY TGT DATA BIG_ENDIAN'
|
|
416
|
+
tf.puts ' APPEND_ITEM STRING 512 STRINg'
|
|
417
|
+
tf.close
|
|
418
|
+
pc = PacketConfig.new
|
|
419
|
+
pc.process_file(tf.path, "SYSTEM")
|
|
420
|
+
telemetry = Telemetry.new(pc)
|
|
421
|
+
tf.unlink
|
|
422
|
+
|
|
423
|
+
allow(System).to receive_message_chain(:telemetry).and_return(telemetry)
|
|
371
424
|
@interface.instance_variable_set(:@stream, TemplateStream.new)
|
|
372
425
|
@interface.add_protocol(TemplateProtocol, %w(0xAD 0xA 0 nil 2), :READ_WRITE)
|
|
373
426
|
@interface.target_names = ['TGT']
|
|
@@ -140,6 +140,28 @@ module Cosmos
|
|
|
140
140
|
expect(pkt.item4).to eql 4
|
|
141
141
|
end
|
|
142
142
|
|
|
143
|
+
it "works in unique id mode or not" do
|
|
144
|
+
System.targets["TGT1"] = Target.new("TGT1")
|
|
145
|
+
target = System.targets["TGT1"]
|
|
146
|
+
target.cmd_unique_id_mode = false
|
|
147
|
+
buffer = "\x01\x02\x03\x04"
|
|
148
|
+
pkt = @cmd.identify(buffer,["TGT1"])
|
|
149
|
+
pkt.enable_method_missing
|
|
150
|
+
expect(pkt.item1).to eql 1
|
|
151
|
+
expect(pkt.item2).to eql 2
|
|
152
|
+
expect(pkt.item3).to eql 3
|
|
153
|
+
expect(pkt.item4).to eql 4
|
|
154
|
+
target.cmd_unique_id_mode = true
|
|
155
|
+
buffer = "\x01\x02\x01\x02"
|
|
156
|
+
pkt = @cmd.identify(buffer,["TGT1"])
|
|
157
|
+
pkt.enable_method_missing
|
|
158
|
+
expect(pkt.item1).to eql 1
|
|
159
|
+
expect(pkt.item2).to eql 2
|
|
160
|
+
expect(pkt.item3).to eql 1
|
|
161
|
+
expect(pkt.item4).to eql 2
|
|
162
|
+
target.cmd_unique_id_mode = false
|
|
163
|
+
end
|
|
164
|
+
|
|
143
165
|
it "returns nil with unknown targets given" do
|
|
144
166
|
buffer = "\x01\x02\x03\x04"
|
|
145
167
|
expect(@cmd.identify(buffer,["TGTX"])).to be_nil
|
|
@@ -114,6 +114,30 @@ module Cosmos
|
|
|
114
114
|
tf.unlink
|
|
115
115
|
end
|
|
116
116
|
end
|
|
117
|
+
|
|
118
|
+
it "builds the id value hash" do
|
|
119
|
+
@tlm_keywords.each do |keyword|
|
|
120
|
+
next if %w(PROCESSOR META).include? keyword
|
|
121
|
+
tf = Tempfile.new('unittest')
|
|
122
|
+
tf.puts 'TELEMETRY tgt1 pkt1 BIG_ENDIAN "Packet"'
|
|
123
|
+
tf.puts 'ID_ITEM myitem 0 8 UINT 13 "Test Item id=1"'
|
|
124
|
+
tf.puts 'APPEND_ID_ITEM myitem 8 UINT 114 "Test Item id=1"'
|
|
125
|
+
tf.puts 'COMMAND tgt1 pkt1 BIG_ENDIAN "Packet"'
|
|
126
|
+
tf.puts 'ID_PARAMETER myitem 0 8 UINT 12 12 12 "Test Item id=1"'
|
|
127
|
+
tf.puts 'APPEND_ID_PARAMETER myitem 8 UINT 115 115 115 "Test Item id=1"'
|
|
128
|
+
tf.close
|
|
129
|
+
@pc.process_file(tf.path, "TGT1")
|
|
130
|
+
expected_tlm_hash = {}
|
|
131
|
+
expected_tlm_hash["TGT1"] = {}
|
|
132
|
+
expected_tlm_hash["TGT1"][[13, 114]] = @pc.telemetry["TGT1"]["PKT1"]
|
|
133
|
+
expected_cmd_hash = {}
|
|
134
|
+
expected_cmd_hash["TGT1"] = {}
|
|
135
|
+
expected_cmd_hash["TGT1"][[12, 115]] = @pc.commands["TGT1"]["PKT1"]
|
|
136
|
+
expect(@pc.tlm_id_value_hash).to eql expected_tlm_hash
|
|
137
|
+
expect(@pc.cmd_id_value_hash).to eql expected_cmd_hash
|
|
138
|
+
tf.unlink
|
|
139
|
+
end
|
|
140
|
+
end
|
|
117
141
|
|
|
118
142
|
it "complains if there are too many parameters" do
|
|
119
143
|
@top_keywords.each do |keyword|
|
|
@@ -400,7 +400,7 @@ module Cosmos
|
|
|
400
400
|
@pi.read_conversion = GenericConversion.new("value / 2")
|
|
401
401
|
@pi.write_conversion = GenericConversion.new("value * 2")
|
|
402
402
|
@pi.description = "description"
|
|
403
|
-
@pi.units_full = "
|
|
403
|
+
@pi.units_full = "Celsius"
|
|
404
404
|
@pi.units = "C"
|
|
405
405
|
@pi.default = 0
|
|
406
406
|
@pi.range = (0..100)
|
|
@@ -428,7 +428,7 @@ module Cosmos
|
|
|
428
428
|
expect(hash["id_value"]).to eql 10
|
|
429
429
|
expect(hash["states"]).to include("TRUE"=>1,"FALSE"=>0)
|
|
430
430
|
expect(hash["description"]).to eql "description"
|
|
431
|
-
expect(hash["units_full"]).to eql "
|
|
431
|
+
expect(hash["units_full"]).to eql "Celsius"
|
|
432
432
|
expect(hash["units"]).to eql "C"
|
|
433
433
|
expect(hash["default"]).to eql 0
|
|
434
434
|
expect(hash["range"]).to eql (0..100)
|
data/spec/packets/packet_spec.rb
CHANGED
|
@@ -707,7 +707,7 @@ module Cosmos
|
|
|
707
707
|
end
|
|
708
708
|
|
|
709
709
|
describe "formatted" do
|
|
710
|
-
it "prints out all the items
|
|
710
|
+
it "prints out all the items" do
|
|
711
711
|
p = Packet.new("tgt","pkt")
|
|
712
712
|
p.append_item("test1", 8, :UINT, 16)
|
|
713
713
|
p.write("test1", [1,2])
|
|
@@ -727,6 +727,25 @@ module Cosmos
|
|
|
727
727
|
expect(p.formatted).to include("TEST2: TRUE")
|
|
728
728
|
expect(p.formatted).to include("TEST3: #{0x02030405}")
|
|
729
729
|
expect(p.formatted).to include("TEST4: Test")
|
|
730
|
+
# Test the data_type parameter
|
|
731
|
+
expect(p.formatted(:RAW)).to include("TEST1: [1, 2]")
|
|
732
|
+
expect(p.formatted(:RAW)).to include("TEST2: #{0x0304}")
|
|
733
|
+
expect(p.formatted(:RAW)).to include("TEST3: #{0x0406080A}")
|
|
734
|
+
expect(p.formatted(:RAW)).to include("00000000: 54 65 73 74") # Raw TEST4 block
|
|
735
|
+
# Test the indent parameter
|
|
736
|
+
expect(p.formatted(:CONVERTED, 4)).to include(" TEST1: [1, 2]")
|
|
737
|
+
# Test the buffer parameter
|
|
738
|
+
buffer = "\x02\x03\x04\x05\x00\x00\x00\x02\x44\x45\x41\x44"
|
|
739
|
+
expect(p.formatted(:CONVERTED, 0, buffer)).to include("TEST1: [2, 3]")
|
|
740
|
+
expect(p.formatted(:CONVERTED, 0, buffer)).to include("TEST2: #{0x0405}")
|
|
741
|
+
expect(p.formatted(:CONVERTED, 0, buffer)).to include("TEST3: 1")
|
|
742
|
+
expect(p.formatted(:CONVERTED, 0, buffer)).to include("TEST4: DEAD")
|
|
743
|
+
# Test the ignored parameter
|
|
744
|
+
string = p.formatted(:CONVERTED, 0, p.buffer, %w(TEST1 TEST4))
|
|
745
|
+
expect(string).not_to include("TEST1")
|
|
746
|
+
expect(string).to include("TEST2: TRUE")
|
|
747
|
+
expect(string).to include("TEST3: #{0x02030405}")
|
|
748
|
+
expect(string).not_to include("TEST4")
|
|
730
749
|
end
|
|
731
750
|
end
|
|
732
751
|
|
|
@@ -828,12 +847,26 @@ module Cosmos
|
|
|
828
847
|
it "returns an array of the identifying items" do
|
|
829
848
|
p = Packet.new("tgt","pkt")
|
|
830
849
|
p.define_item("item1",0,32,:FLOAT,nil,:BIG_ENDIAN,:ERROR,"%5.1f",nil,nil,nil)
|
|
831
|
-
p.define_item("item2",
|
|
832
|
-
p.define_item("item3",
|
|
833
|
-
p.define_item("item4",
|
|
850
|
+
p.define_item("item2",64,32,:FLOAT,nil,:BIG_ENDIAN,:ERROR,"%5.1f",nil,nil,5)
|
|
851
|
+
p.define_item("item3",96,32,:FLOAT,nil,:BIG_ENDIAN,:ERROR,"%5.1f",nil,nil,nil)
|
|
852
|
+
p.define_item("item4",32,32,:FLOAT,nil,:BIG_ENDIAN,:ERROR,"%5.1f",nil,nil,6)
|
|
834
853
|
expect(p.id_items).to be_a Array
|
|
835
|
-
expect(p.id_items[0].name).to eq "
|
|
836
|
-
expect(p.id_items[1].name).to eq "
|
|
854
|
+
expect(p.id_items[0].name).to eq "ITEM4"
|
|
855
|
+
expect(p.id_items[1].name).to eq "ITEM2"
|
|
856
|
+
end
|
|
857
|
+
end
|
|
858
|
+
|
|
859
|
+
describe "read_id_values" do
|
|
860
|
+
it "to read the right values" do
|
|
861
|
+
buffer = "\x00\x00\x00\x04\x00\x00\x00\x03\x00\x00\x00\x02\x00\x00\x00\x01"
|
|
862
|
+
p = Packet.new("tgt","pkt")
|
|
863
|
+
p.define_item("item1",0,32,:UINT,nil,:BIG_ENDIAN,:ERROR,nil,nil,nil,nil)
|
|
864
|
+
p.define_item("item2",64,32,:UINT,nil,:BIG_ENDIAN,:ERROR,nil,nil,nil,5)
|
|
865
|
+
p.define_item("item3",96,32,:UINT,nil,:BIG_ENDIAN,:ERROR,nil,nil,nil,nil)
|
|
866
|
+
p.define_item("item4",32,32,:UINT,nil,:BIG_ENDIAN,:ERROR,nil,nil,nil,6)
|
|
867
|
+
values = p.read_id_values(buffer)
|
|
868
|
+
expect(values[0]).to eq 3
|
|
869
|
+
expect(values[1]).to eq 2
|
|
837
870
|
end
|
|
838
871
|
end
|
|
839
872
|
|
|
@@ -54,17 +54,6 @@ module Cosmos
|
|
|
54
54
|
tf.unlink
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
it "complains if FORMAT_STRING defined" do
|
|
58
|
-
tf = Tempfile.new('unittest')
|
|
59
|
-
tf.puts 'TELEMETRY tgt1 pkt1 LITTLE_ENDIAN "Packet"'
|
|
60
|
-
tf.puts ' ITEM myitem 0 8 UINT "Test Item"'
|
|
61
|
-
tf.puts ' FORMAT_STRING "0x%x"'
|
|
62
|
-
tf.puts ' STATE ONE 1'
|
|
63
|
-
tf.close
|
|
64
|
-
expect { @pc.process_file(tf.path, "TGT1") }.to raise_error(ConfigParser::Error, /Items with FORMAT_STRING can't define STATE/)
|
|
65
|
-
tf.unlink
|
|
66
|
-
end
|
|
67
|
-
|
|
68
57
|
it "complains if UNITS defined" do
|
|
69
58
|
tf = Tempfile.new('unittest')
|
|
70
59
|
tf.puts 'TELEMETRY tgt1 pkt1 LITTLE_ENDIAN "Packet"'
|
|
@@ -135,6 +124,39 @@ module Cosmos
|
|
|
135
124
|
tf.unlink
|
|
136
125
|
end
|
|
137
126
|
|
|
127
|
+
it "uses state or FORMAT_STRING if no state" do
|
|
128
|
+
tf = Tempfile.new('unittest')
|
|
129
|
+
tf.puts 'TELEMETRY tgt1 pkt1 LITTLE_ENDIAN "Packet"'
|
|
130
|
+
tf.puts ' APPEND_ITEM item1 8 UINT "Test Item"'
|
|
131
|
+
tf.puts ' FORMAT_STRING "0x%x"'
|
|
132
|
+
tf.puts ' STATE ONE 1'
|
|
133
|
+
tf.close
|
|
134
|
+
@pc.process_file(tf.path, "TGT1")
|
|
135
|
+
tlm = Telemetry.new(@pc)
|
|
136
|
+
pkt = tlm.packet("TGT1", "PKT1")
|
|
137
|
+
pkt.write("ITEM1", 1)
|
|
138
|
+
expect(pkt.read("ITEM1", :FORMATTED)).to eql "ONE"
|
|
139
|
+
pkt.write("ITEM1", 2)
|
|
140
|
+
expect(pkt.read("ITEM1", :FORMATTED)).to eql "0x2"
|
|
141
|
+
tf.unlink
|
|
142
|
+
|
|
143
|
+
# Ensure the order of STATE vs FORMAT_STRING doesn't matter
|
|
144
|
+
tf = Tempfile.new('unittest')
|
|
145
|
+
tf.puts 'TELEMETRY tgt1 pkt1 LITTLE_ENDIAN "Packet"'
|
|
146
|
+
tf.puts ' APPEND_ITEM item1 8 UINT "Test Item"'
|
|
147
|
+
tf.puts ' STATE ONE 1'
|
|
148
|
+
tf.puts ' FORMAT_STRING "0x%x"'
|
|
149
|
+
tf.close
|
|
150
|
+
@pc.process_file(tf.path, "TGT1")
|
|
151
|
+
tlm = Telemetry.new(@pc)
|
|
152
|
+
pkt = tlm.packet("TGT1", "PKT1")
|
|
153
|
+
pkt.write("ITEM1", 1)
|
|
154
|
+
expect(pkt.read("ITEM1", :FORMATTED)).to eql "ONE"
|
|
155
|
+
pkt.write("ITEM1", 2)
|
|
156
|
+
expect(pkt.read("ITEM1", :FORMATTED)).to eql "0x2"
|
|
157
|
+
tf.unlink
|
|
158
|
+
end
|
|
159
|
+
|
|
138
160
|
it "allows an 'ANY' state" do
|
|
139
161
|
tf = Tempfile.new('unittest')
|
|
140
162
|
tf.puts 'TELEMETRY tgt1 pkt1 LITTLE_ENDIAN "Description"'
|
|
@@ -348,6 +348,20 @@ module Cosmos
|
|
|
348
348
|
expect(s.read("test1", :RAW, buffer)).to eql 1
|
|
349
349
|
end
|
|
350
350
|
|
|
351
|
+
it "reads until null byte for STRING items" do
|
|
352
|
+
s = Structure.new
|
|
353
|
+
s.define_item("test1", 0, 80, :STRING)
|
|
354
|
+
buffer = "\x4E\x4F\x4F\x50\x00\x4E\x4F\x4F\x50\x0A" # NOOP<NULL>NOOP\n
|
|
355
|
+
expect(s.read("test1", :CONVERTED, buffer)).to eql "NOOP"
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
it "reads the entire buffer for BLOCK items" do
|
|
359
|
+
s = Structure.new
|
|
360
|
+
s.define_item("test1", 0, 80, :BLOCK)
|
|
361
|
+
buffer = "\x4E\x4F\x4F\x50\x00\x4E\x4F\x4F\x50\x0A" # NOOP<NULL>NOOP\n
|
|
362
|
+
expect(s.read("test1", :CONVERTED, buffer)).to eql "NOOP\x00NOOP\n"
|
|
363
|
+
end
|
|
364
|
+
|
|
351
365
|
it "reads array data from the buffer" do
|
|
352
366
|
s = Structure.new
|
|
353
367
|
s.define_item("test1", 0, 8, :UINT, 16)
|
|
@@ -442,6 +456,33 @@ module Cosmos
|
|
|
442
456
|
expect(s.formatted(:CONVERTED, 4)).to include(" TEST3")
|
|
443
457
|
expect(s.formatted(:CONVERTED, 4)).to include(" 00000000: 07 08 09 0A")
|
|
444
458
|
end
|
|
459
|
+
|
|
460
|
+
it "processes uses a different buffer" do
|
|
461
|
+
s = Structure.new(:BIG_ENDIAN)
|
|
462
|
+
s.append_item("test1", 8, :UINT, 16)
|
|
463
|
+
s.write("test1", [1,2])
|
|
464
|
+
s.append_item("test2", 16, :UINT)
|
|
465
|
+
s.write("test2", 3456)
|
|
466
|
+
s.append_item("test3", 32, :BLOCK)
|
|
467
|
+
s.write("test3", "\x07\x08\x09\x0A")
|
|
468
|
+
buffer = "\x0A\x0B\x0C\x0D\xDE\xAD\xBE\xEF"
|
|
469
|
+
expect(s.formatted(:CONVERTED, 0, buffer)).to include("TEST1: [10, 11]")
|
|
470
|
+
expect(s.formatted(:CONVERTED, 0, buffer)).to include("TEST2: #{0x0C0D}")
|
|
471
|
+
expect(s.formatted(:CONVERTED, 0, buffer)).to include("TEST3")
|
|
472
|
+
expect(s.formatted(:CONVERTED, 0, buffer)).to include("00000000: DE AD BE EF")
|
|
473
|
+
end
|
|
474
|
+
|
|
475
|
+
it "ignores items" do
|
|
476
|
+
s = Structure.new(:BIG_ENDIAN)
|
|
477
|
+
s.append_item("test1", 8, :UINT, 16)
|
|
478
|
+
s.write("test1", [1,2])
|
|
479
|
+
s.append_item("test2", 16, :UINT)
|
|
480
|
+
s.write("test2", 3456)
|
|
481
|
+
s.append_item("test3", 32, :BLOCK)
|
|
482
|
+
s.write("test3", "\x07\x08\x09\x0A")
|
|
483
|
+
expect(s.formatted(:CONVERTED, 0, s.buffer, %w(TEST1 TEST3))).to eq("TEST2: 3456\n")
|
|
484
|
+
expect(s.formatted(:CONVERTED, 0, s.buffer, %w(TEST1 TEST2 TEST3))).to eq("")
|
|
485
|
+
end
|
|
445
486
|
end
|
|
446
487
|
|
|
447
488
|
describe "buffer" do
|
|
@@ -257,6 +257,29 @@ module Cosmos
|
|
|
257
257
|
expect(pkt.item3).to eql 6.0
|
|
258
258
|
expect(pkt.item4).to eql 8.0
|
|
259
259
|
end
|
|
260
|
+
|
|
261
|
+
it "works in unique id mode and not" do
|
|
262
|
+
System.targets["TGT1"] = Target.new("TGT1")
|
|
263
|
+
target = System.targets["TGT1"]
|
|
264
|
+
buffer = "\x01\x02\x03\x04"
|
|
265
|
+
target.tlm_unique_id_mode = false
|
|
266
|
+
pkt = @tlm.identify!(buffer,["TGT1"])
|
|
267
|
+
pkt.enable_method_missing
|
|
268
|
+
expect(pkt.item1).to eql 1
|
|
269
|
+
expect(pkt.item2).to eql 2
|
|
270
|
+
expect(pkt.item3).to eql 6.0
|
|
271
|
+
expect(pkt.item4).to eql 8.0
|
|
272
|
+
buffer = "\x01\x02\x01\x02"
|
|
273
|
+
target.tlm_unique_id_mode = true
|
|
274
|
+
@tlm.identify!(buffer,["TGT1"])
|
|
275
|
+
pkt = @tlm.packet("TGT1","PKT1")
|
|
276
|
+
pkt.enable_method_missing
|
|
277
|
+
expect(pkt.item1).to eql 1
|
|
278
|
+
expect(pkt.item2).to eql 2
|
|
279
|
+
expect(pkt.item3).to eql 2.0
|
|
280
|
+
expect(pkt.item4).to eql 4.0
|
|
281
|
+
target.tlm_unique_id_mode = false
|
|
282
|
+
end
|
|
260
283
|
|
|
261
284
|
it "returns nil with unknown targets given" do
|
|
262
285
|
buffer = "\x01\x02\x03\x04"
|