├── .gitignore ├── .gitmodules ├── CubedOS.code-workspace ├── README.md ├── TODO.md ├── bench ├── Message-Passing.xlsx ├── NOTES.txt └── messages │ ├── gnat.adc │ ├── messages.gpr │ ├── obj │ └── .gitkeep │ └── src │ ├── last_chance_handler.adb │ ├── last_chance_handler.ads │ ├── leds.adb │ ├── leds.ads │ ├── main.adb │ ├── message_manager.ads │ ├── receiver-api.adb │ ├── receiver-api.ads │ ├── receiver-internals.adb │ ├── receiver-internals.ads │ ├── receiver-messages.adb │ ├── receiver-messages.ads │ ├── receiver.ads │ ├── registers.ads │ ├── sender-internals.adb │ ├── sender-internals.ads │ ├── sender-messages.adb │ ├── sender-messages.ads │ ├── sender.ads │ ├── stm32f4-gpio.ads │ ├── stm32f4-reset_clock_control.ads │ ├── stm32f4-sysconfig_control.ads │ └── stm32f4.ads ├── bin ├── CubeSatSetup.md ├── CubeSatSetup.sh ├── README.md ├── jenkins.sh ├── mercury.sh └── run-gnatcheck.sh ├── build.xml ├── doc ├── .vscode │ ├── ltex.dictionary.en-US.txt │ ├── ltex.disabledRules.en-US.txt │ └── settings.json ├── Architecture-Code.tex ├── Architecture-Encoding.tex ├── Architecture-Overview.tex ├── Architecture-Priorities.tex ├── CFDP-Organization.odg ├── CubedOS.tex ├── Development-Architecture.tex ├── Development-Design.tex ├── Development-Requirements.tex ├── Development.tex ├── Figure-CubedOS.odg ├── Figure-CubedOS.pdf ├── Figure-Hybrid.odg ├── Figure-Hybrid.pdf ├── Figure-MultiDomain.odg ├── Figure-MultiDomain.pdf ├── Figure-Traditional.odg ├── Figure-Traditional.pdf ├── Introduction.tex ├── Manual-CoreModules.tex ├── Manual-Samples.tex ├── Manual-Tutorial.tex ├── Manual.tex ├── Mercury-Design.tex ├── Mercury-Requirements.tex ├── Mercury-Tutorial.tex ├── Mercury.tex ├── NOTES.md ├── README.md ├── Submit NOI Result.pdf ├── XDR2OS3.odt ├── build.xml ├── flashingCF2-1.odt ├── macros.tex ├── papers │ ├── .gitignore │ ├── 2015-IAC │ │ ├── README.md │ │ └── brandon-chapin-IAC-2015.docx │ ├── 2017-AUJ │ │ ├── AUJ 38-3-cube.pdf │ │ ├── AUJarticle.cls │ │ ├── Figure-140324-1123P-good_earth.pdf │ │ ├── Figure-Assembly-with-Deployed-Pumpkin-Panels-with-labels-v2.pdf │ │ ├── Figure-CubedOS.odg │ │ ├── Figure-CubedOS.pdf │ │ ├── Figure-Hybrid.odg │ │ ├── Figure-Hybrid.pdf │ │ ├── Figure-MultiDomain.odg │ │ ├── Figure-MultiDomain.pdf │ │ ├── Figure-Traditional.odg │ │ ├── Figure-Traditional.pdf │ │ ├── IEEEtran.bst │ │ ├── REVIEWS.txt │ │ ├── architecture.tex │ │ ├── conclusion.tex │ │ ├── introduction.tex │ │ ├── macros.tex │ │ ├── main.tex │ │ ├── message-encoding.tex │ │ └── related-work.tex │ ├── README.md │ ├── mercury │ │ ├── MXDR.tex │ │ ├── Updater.mxdr │ │ ├── code-generation.tex │ │ ├── conclusion.tex │ │ ├── introduction.tex │ │ ├── llncs.cls │ │ ├── macros.tex │ │ ├── main.tex │ │ ├── performance.tex │ │ └── splncs03.bst │ └── multidomain │ │ ├── conclusion.tex │ │ ├── introduction.tex │ │ ├── llncs.cls │ │ ├── macros.tex │ │ ├── main.tex │ │ └── splncs03.bst ├── presentations │ └── CubedOS-Architecture.pptx ├── references-CubeSat.bib ├── references-General.bib ├── references-SPARK.bib ├── references │ └── rfc4506.txt └── slides │ ├── Vermont-Tech-Badge.jpg │ ├── Vermont-Tech-Stack.jpg │ ├── main.tex │ └── slide-macros.tex ├── mercury ├── .gitignore ├── README.md ├── TODO.md ├── bin │ ├── grun.bat │ └── grun.sh ├── build.sbt ├── project │ ├── build.properties │ ├── metals.sbt │ ├── sbt-antlr4.sbt │ └── sbt-assembly.sbt ├── src │ ├── main │ │ ├── antlr4 │ │ │ └── MXDR.g4 │ │ └── scala │ │ │ └── edu │ │ │ └── vermontstate │ │ │ └── mercury │ │ │ ├── BasicConsoleReporter.scala │ │ │ ├── BasicSymbolTable.scala │ │ │ ├── BodyGenerator.scala │ │ │ ├── Main.scala │ │ │ ├── Reporter.scala │ │ │ ├── STPopulation.scala │ │ │ ├── SemanticAnalyzer.scala │ │ │ ├── SpecificationGenerator.scala │ │ │ ├── SymbolTable.scala │ │ │ └── TypeRep.scala │ └── test │ │ └── scala │ │ └── edu │ │ └── vermontstate │ │ └── mercury │ │ ├── CodeGeneratorSpec.scala │ │ ├── ExpectedMessage.scala │ │ ├── MercurySpec.scala │ │ ├── SemanticSpec.scala │ │ ├── SyntaxSpec.scala │ │ ├── TestReporter.scala │ │ ├── TrivialSpec.scala │ │ └── UnitSpec.scala ├── templates │ ├── template.adb │ └── template.ads └── testData │ ├── CodeGeneration │ ├── .gitignore │ ├── CubedOS-m0001.mxdr │ ├── CubedOS-m0002.mxdr │ ├── CubedOS-m0003.mxdr │ ├── CubedOS-m0004.mxdr │ ├── code_generation.gpr │ ├── cubedos-m0001.ads │ ├── cubedos-m0002.ads │ ├── cubedos-m0003.ads │ ├── cubedos-m0004.ads │ ├── expected-m0001.adb │ ├── expected-m0001.ads │ ├── expected-m0002.adb │ ├── expected-m0002.ads │ ├── expected-m0003.adb │ ├── expected-m0003.ads │ ├── expected-m0004.adb │ ├── expected-m0004.ads │ └── message_manager.ads │ ├── Semantics │ └── 0001.mxdr │ └── Syntax │ ├── 0001.mxdr │ ├── 0002.mxdr │ ├── 0003.mxdr │ ├── 0004.mxdr │ ├── 0005.mxdr │ └── 0006.mxdr ├── samples ├── BBB │ ├── README.md │ ├── bbbdemo.gpr │ ├── build │ │ └── .gitkeep │ ├── gnat.adc │ └── src │ │ ├── echo_client-messages.adb │ │ ├── echo_client-messages.ads │ │ ├── echo_client.ads │ │ ├── echo_server-messages.adb │ │ ├── echo_server-messages.ads │ │ ├── echo_server.ads │ │ ├── main.adb │ │ ├── message_manager.ads │ │ └── mxdr │ │ ├── .gitignore │ │ ├── echo_server-api.adb │ │ └── echo_server-api.ads ├── NUCLEO-F446ZE │ ├── build │ │ └── .gitkeep │ ├── gnat.adc │ ├── src │ │ ├── main.adb │ │ ├── message_manager.ads │ │ ├── mxdr │ │ │ └── .gitignore │ │ └── name_resolver.ads │ └── stmdemo.gpr ├── README.md ├── STM32F4 │ ├── README.md │ ├── TODO.md │ ├── build │ │ └── .gitkeep │ ├── gnat.adc │ ├── module_map.txt │ ├── src │ │ ├── button.adb │ │ ├── button.ads │ │ ├── button_driver-messages.adb │ │ ├── button_driver-messages.ads │ │ ├── button_driver.ads │ │ ├── control-messages.adb │ │ ├── control-messages.ads │ │ ├── control.ads │ │ ├── last_chance_handler.adb │ │ ├── last_chance_handler.ads │ │ ├── led_driver-messages.adb │ │ ├── led_driver-messages.ads │ │ ├── led_driver.ads │ │ ├── leds.adb │ │ ├── leds.ads │ │ ├── main.adb │ │ ├── message_manager.ads │ │ ├── mxdr │ │ │ ├── .gitignore │ │ │ ├── LED_Driver.mxdr │ │ │ ├── led_driver-api.adb │ │ │ └── led_driver-api.ads │ │ ├── name_resolver.ads │ │ ├── registers.ads │ │ ├── stm32f4-gpio.ads │ │ ├── stm32f4-reset_clock_control.ads │ │ ├── stm32f4-sysconfig_control.ads │ │ └── stm32f4.ads │ └── stmdemo.gpr ├── TODO.md ├── build │ └── .gitkeep ├── echo │ ├── README.md │ ├── build │ │ └── .gitkeep │ ├── echo.gpr │ └── src │ │ ├── echo_client-messages.adb │ │ ├── echo_client-messages.ads │ │ ├── echo_client.ads │ │ ├── echo_server-messages.adb │ │ ├── echo_server-messages.ads │ │ ├── echo_server.ads │ │ ├── main.adb │ │ ├── message_manager.ads │ │ ├── mxdr │ │ ├── .gitignore │ │ ├── Echo_Server.mxdr │ │ └── Makefile │ │ └── name_resolver.ads ├── echo_alire │ ├── .gitignore │ ├── README.md │ ├── alire.toml │ ├── echo.gpr │ └── src │ │ ├── echo.adb │ │ ├── echo_client-messages.adb │ │ ├── echo_client-messages.ads │ │ ├── echo_client.ads │ │ ├── echo_server-messages.adb │ │ ├── echo_server-messages.ads │ │ ├── echo_server.ads │ │ ├── message_manager.ads │ │ ├── mxdr │ │ ├── .gitignore │ │ ├── echo_server-api.adb │ │ └── echo_server-api.ads │ │ └── name_resolver.ads ├── line_rider │ ├── README.md │ ├── build │ │ └── .gitkeep │ ├── gnat.adc │ ├── line_rider.gpr │ └── src │ │ ├── last_chance_handler.adb │ │ ├── last_chance_handler.ads │ │ ├── led_driver-internals.adb │ │ ├── led_driver-internals.ads │ │ ├── led_driver-messages.adb │ │ ├── led_driver-messages.ads │ │ ├── led_driver.ads │ │ ├── leds.adb │ │ ├── leds.ads │ │ ├── line_rider-main.adb │ │ ├── line_rider-states.adb │ │ ├── line_rider-states.ads │ │ ├── line_rider.ads │ │ ├── message_manager.ads │ │ ├── motor_driver-internals.adb │ │ ├── motor_driver-internals.ads │ │ ├── motor_driver-messages.adb │ │ ├── motor_driver-messages.ads │ │ ├── motor_driver.ads │ │ ├── mxdr │ │ ├── .gitignore │ │ ├── LED_Driver.mxdr │ │ ├── led_driver-api.adb │ │ ├── led_driver-api.ads │ │ ├── motor_driver-api.adb │ │ ├── motor_driver-api.ads │ │ ├── sensor_driver-api.adb │ │ └── sensor_driver-api.ads │ │ ├── name_resolver.ads │ │ ├── registers.ads │ │ ├── sensor_driver-internals.adb │ │ ├── sensor_driver-internals.ads │ │ ├── sensor_driver-messages.adb │ │ ├── sensor_driver-messages.ads │ │ ├── sensor_driver.ads │ │ ├── stm32f4-gpio.ads │ │ ├── stm32f4-reset_clock_control.ads │ │ ├── stm32f4-sysconfig_control.ads │ │ └── stm32f4.ads ├── moonshot │ ├── build │ │ ├── .gitkeep │ │ ├── Image-Copernicus.jpg │ │ └── Image-Korolev.jpg │ ├── moonshot.gpr │ └── src │ │ ├── camera-messages.adb │ │ ├── camera-messages.ads │ │ ├── camera.ads │ │ ├── controller-messages.adb │ │ ├── controller-messages.ads │ │ ├── controller.ads │ │ ├── main.adb │ │ ├── message_manager.ads │ │ ├── mxdr │ │ ├── .gitignore │ │ ├── Camera.mxdr │ │ └── Makefile │ │ └── name_resolver.ads ├── networking │ ├── Common │ │ ├── domainb_server-api.adb │ │ ├── domainb_server-api.ads │ │ ├── domainb_server.ads │ │ ├── name_resolver.ads │ │ ├── network_configuration.adb │ │ └── network_configuration.ads │ ├── DomainA │ │ ├── domaina_client-messages.adb │ │ ├── domaina_client-messages.ads │ │ ├── domaina_client.ads │ │ ├── main.adb │ │ └── message_manager.ads │ ├── DomainB │ │ ├── domainb_server-messages.adb │ │ ├── domainb_server-messages.ads │ │ ├── main.adb │ │ └── message_manager.ads │ ├── build │ │ ├── DomainA │ │ │ └── .gitkeep │ │ └── DomainB │ │ │ └── .gitkeep │ └── networking.gpr ├── pathfinder │ ├── Makefile │ ├── TODO.md │ ├── build │ │ └── .gitkeep │ ├── gnat.adc │ ├── pathfinder.gpr │ └── src │ │ ├── fibonacci.adb │ │ ├── fibonacci.ads │ │ ├── main.adb │ │ ├── message_manager.ads │ │ ├── mxdr │ │ ├── .gitignore │ │ ├── random_number_generator-api.adb │ │ ├── random_number_generator-api.ads │ │ ├── system_bus-api.adb │ │ ├── system_bus-api.ads │ │ ├── telemetry-api.adb │ │ └── telemetry-api.ads │ │ ├── name_resolver.ads │ │ ├── pnumbers.adb │ │ ├── pnumbers.ads │ │ ├── random_number_generator-messages.adb │ │ ├── random_number_generator-messages.ads │ │ ├── random_number_generator.ads │ │ ├── read_number-messages.adb │ │ ├── read_number-messages.ads │ │ ├── read_number.ads │ │ ├── system_bus-messages.adb │ │ ├── system_bus-messages.ads │ │ ├── system_bus.ads │ │ ├── telemetry-messages.adb │ │ ├── telemetry-messages.ads │ │ └── telemetry.ads ├── samples.gpr └── tests │ ├── cubedos-lib-octet_io.adb │ ├── cubedos-lib-octet_io.ads │ ├── cubedos-lib-serial_port.ads │ └── main_sorters.adb ├── scriptbuilder ├── .gitignore ├── .idea │ ├── .gitignore │ ├── ScriptBuilder.iml │ ├── inspectionProfiles │ │ └── profiles_settings.xml │ ├── misc.xml │ ├── modules.xml │ └── vcs.xml ├── README.md ├── bin │ ├── antlr4 │ ├── generate-parser │ └── grun ├── docs │ └── .gitkeep ├── requirements.txt ├── scripter │ ├── __init__.py │ ├── address.py │ ├── args.py │ ├── command.py │ ├── command_group.py │ ├── cos_module.py │ ├── cubedos_time.py │ └── main.py └── tests │ └── .gitkeep ├── src ├── .vscode │ └── ltex.dictionary.en-US.txt ├── README.md ├── check │ ├── build │ │ ├── .gitkeep │ │ └── example.txt │ ├── check_lib_crc.adb │ ├── check_lib_crc.ads │ ├── check_lib_xdr.adb │ ├── check_lib_xdr.ads │ ├── check_trivial.adb │ ├── check_trivial.ads │ ├── crc.c │ ├── cubedlib_suite.adb │ ├── cubedlib_suite.ads │ ├── cubedos-lib-bounded_strings-check.adb │ ├── cubedos-lib-bounded_strings-check.ads │ ├── cubedos_check.adb │ ├── main.adb │ ├── main_file.adb │ ├── main_message_manager.adb │ ├── main_time.adb │ ├── message_manager.ads │ ├── name_resolver.ads │ ├── network_configuration.adb │ └── network_configuration.ads ├── cubedos-casing-exceptions.txt ├── cubedos-rules.txt ├── cubedos.aru ├── cubedos.gpr ├── cubedos.hdr ├── gnat.adc ├── library │ ├── TODO.md │ ├── cubedlib.gpr │ ├── cubedos-casing-exceptions.txt │ ├── cubedos-lib-bounded_strings.adb │ ├── cubedos-lib-bounded_strings.ads │ ├── cubedos-lib-compressors.adb │ ├── cubedos-lib-compressors.ads │ ├── cubedos-lib-crc.adb │ ├── cubedos-lib-crc.ads │ ├── cubedos-lib-generic_rid_map.adb │ ├── cubedos-lib-generic_rid_map.ads │ ├── cubedos-lib-sorters.adb │ ├── cubedos-lib-sorters.ads │ ├── cubedos-lib-space_packets.adb │ ├── cubedos-lib-space_packets.ads │ ├── cubedos-lib-tc_frames.adb │ ├── cubedos-lib-tc_frames.ads │ ├── cubedos-lib-vectors3.adb │ ├── cubedos-lib-vectors3.ads │ ├── cubedos-lib-xdr.adb │ ├── cubedos-lib-xdr.ads │ ├── cubedos-lib.ads │ ├── cubedos.ads │ ├── doc │ │ └── .gitkeep │ ├── lib │ │ ├── Debug │ │ │ └── .gitkeep │ │ └── Release │ │ │ └── .gitkeep │ └── obj │ │ ├── Debug │ │ └── .gitkeep │ │ └── Release │ │ └── .gitkeep └── modules │ ├── cubedos-file_server-api.adb │ ├── cubedos-file_server-api.ads │ ├── cubedos-file_server-messages.adb │ ├── cubedos-file_server-messages.ads │ ├── cubedos-file_server.ads │ ├── cubedos-generic_message_manager.adb │ ├── cubedos-generic_message_manager.ads │ ├── cubedos-interpreter-api.adb │ ├── cubedos-interpreter-api.ads │ ├── cubedos-interpreter-messages.adb │ ├── cubedos-interpreter-messages.ads │ ├── cubedos-interpreter.ads │ ├── cubedos-log_server-api.adb │ ├── cubedos-log_server-api.ads │ ├── cubedos-log_server-messages.adb │ ├── cubedos-log_server-messages.ads │ ├── cubedos-log_server.ads │ ├── cubedos-publish_subscribe_server-api.adb │ ├── cubedos-publish_subscribe_server-api.ads │ ├── cubedos-publish_subscribe_server-messages.adb │ ├── cubedos-publish_subscribe_server-messages.ads │ ├── cubedos-publish_subscribe_server.ads │ ├── cubedos-time_server-api.adb │ ├── cubedos-time_server-api.ads │ ├── cubedos-time_server-messages.adb │ ├── cubedos-time_server-messages.ads │ ├── cubedos-time_server.ads │ ├── cubedos-transport_udp-messages.adb │ ├── cubedos-transport_udp-messages.ads │ ├── cubedos-transport_udp.ads │ └── mxdr │ ├── CubedOS-File_Server.mxdr │ ├── CubedOS-Publish_Subscribe_Server.mxdr │ └── CubedOS-Time_Server.mxdr └── templates ├── SAMPLE_MODULE-api.adb ├── SAMPLE_MODULE-api.ads ├── SAMPLE_MODULE-messages.adb ├── SAMPLE_MODULE-messages.ads └── SAMPLE_MODULE.ads /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | src/library/obj 3 | src/library/lib 4 | src/library/doc 5 | 6 | # LaTeX build artifacts 7 | *.aux 8 | *.bbl 9 | *.blg 10 | *.log 11 | *.out 12 | Getting-Started.pdf 13 | CubedOS.pdf 14 | *.toc 15 | 16 | # Generated API packages 17 | src/modules/MXDR/*.ads 18 | src/modules/MXDR/*.adb 19 | 20 | *.DS_Store -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "ADL"] 2 | path = ADL 3 | url = https://github.com/AdaCore/Ada_Drivers_Library.git 4 | -------------------------------------------------------------------------------- /CubedOS.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "src" 5 | }, 6 | { 7 | "path": "samples" 8 | }, 9 | { 10 | "name": "aunit", 11 | "path": "../../../../AdaCore/gnat/include/aunit" 12 | }, 13 | { 14 | "path": "doc" 15 | }, 16 | { 17 | "path": "mercury" 18 | }, 19 | { 20 | "path": "scriptbuilder" 21 | } 22 | ], 23 | "settings": { 24 | "cSpell.words": [ 25 | "Alire", 26 | "cancelation", 27 | "Merc", 28 | "Ravenscar", 29 | "subfolders" 30 | ], 31 | "files.watcherExclude": { 32 | "**/target": true 33 | }, 34 | "rewrap.wrappingColumn": 96 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /bench/Message-Passing.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/bench/Message-Passing.xlsx -------------------------------------------------------------------------------- /bench/NOTES.txt: -------------------------------------------------------------------------------- 1 | 2 | CubedOS Benchmarks 3 | ================== 4 | 5 | All measurements below were taking on a STM32F4DISCOVERY board using GNAT GPL 2014 as the Ada 6 | compiler. Compilations were done without debugging and with -O2. 7 | 8 | Message Passing 9 | --------------- 10 | 11 | Measured time to pass 1,000,000 messages from a trivial sender to a trivial receiver. 12 | 13 | Size (bytes) Time (us) Diff (us) 14 | ---------------------------------- 15 | 16 9.0 - 16 | 32 9.5 0.5 17 | 48 10.3 0.8 18 | 64 14.9 4.6 19 | 80 16.4 1.5 20 | 96 17.8 1.4 21 | 112 19.2 1.4 22 | 128 20.6 1.4 23 | ... ... 24 | 256 31.8 11.2 = 8*1.4 25 | (The behavior is now linear in the size of the message) 26 | 27 | -------------------------------------------------------------------------------- /bench/messages/gnat.adc: -------------------------------------------------------------------------------- 1 | pragma Profile(Ravenscar); 2 | pragma Partition_Elaboration_Policy(Sequential); 3 | pragma Warnings(Off, "pragma Restrictions (No_Exception_Propagation) in effect"); 4 | pragma Warnings(Off, """Constraint_Error"" may call Last_Chance_Handler"); -------------------------------------------------------------------------------- /bench/messages/messages.gpr: -------------------------------------------------------------------------------- 1 | project Messages is 2 | 3 | for Languages use ("Ada"); 4 | for Runtime ("Ada") use "ravenscar-sfp-stm32f4"; 5 | 6 | for Main use ("main.adb"); 7 | for Source_Dirs use ("src", "../../src"); 8 | for Object_Dir use "obj"; 9 | 10 | package Compiler is 11 | for Default_Switches ("Ada") use ("-O2", "-gnatwa", "-gnatQ", "-gnat12"); 12 | end Compiler; 13 | 14 | package Builder is 15 | for Global_Configuration_Pragmas use "gnat.adc"; 16 | end Builder; 17 | 18 | package Ide is 19 | for Gnat use "arm-eabi-gnat"; 20 | for Gnatlist use "arm-eabi-gnatls"; 21 | for Debugger_Command use "arm-eabi-gdb"; 22 | for Program_Host use "localhost:4242"; 23 | for Communication_Protocol use "remote"; 24 | end Ide; 25 | 26 | end Messages; 27 | 28 | -------------------------------------------------------------------------------- /bench/messages/obj/.gitkeep: -------------------------------------------------------------------------------- 1 | This file exists to ensure the enclosing folder is created. 2 | -------------------------------------------------------------------------------- /bench/messages/src/main.adb: -------------------------------------------------------------------------------- 1 | 2 | 3 | -- The "last chance handler" is the user-defined routine that is called when an exception is 4 | -- propagated. We need it in the executable, therefore it must be somewhere in the closure of 5 | -- the context clauses. 6 | -- 7 | with Last_Chance_Handler; 8 | pragma Unreferenced(Last_Chance_Handler); 9 | 10 | with Sender.Messages; 11 | pragma Unreferenced(Sender.Messages); 12 | 13 | with Receiver.Messages; 14 | pragma Unreferenced(Receiver.Messages); 15 | 16 | with LEDs; 17 | with Message_Manager; 18 | with System; 19 | 20 | procedure Main is 21 | pragma Priority (System.Priority'First); 22 | 23 | Null_Message : Message_Manager.Message_Record; 24 | begin 25 | -- Create an empty message. 26 | Null_Message.Sender := 1; -- Never used so value doesn't matter. 27 | Null_Message.Data := (others => 0); 28 | Null_Message.Size := 0; 29 | 30 | -- Send a triggering message to the sender to start the process. 31 | -- The content of this message is irrelevant (it is ignored by the sender). 32 | LEDs.On(LEDs.Blue); 33 | Message_Manager.Mailboxes(Sender.ID).Unchecked_Send(Null_Message); 34 | 35 | -- After sending the message there is nothing useful to do. 36 | loop 37 | null; 38 | end loop; 39 | end Main; 40 | -------------------------------------------------------------------------------- /bench/messages/src/message_manager.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : message_manager.adb 3 | -- SUBJECT : Package holding the mailboxes used by CubedOS message passing. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | 8 | with CubedOS.Generic_Message_Manager; 9 | 10 | package Message_Manager is 11 | new CubedOS.Generic_Message_Manager 12 | (Module_Count => 2, 13 | Mailbox_Size => 1, 14 | Maximum_Message_Size => 256); 15 | -------------------------------------------------------------------------------- /bench/messages/src/receiver-api.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : receiver-api.adb 3 | -- SUBJECT: Body of a package that simplifies use of the receiver. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | package body Receiver.API is 10 | 11 | function Make_Message(Sender : Module_ID) return Message_Record is 12 | Message : Message_Record; 13 | begin 14 | Message.Sender := Sender; 15 | Message.Data := (others => 0); 16 | Message.Size := Message.Data'Length; 17 | return Message; 18 | end Make_Message; 19 | 20 | end Receiver.API; 21 | -------------------------------------------------------------------------------- /bench/messages/src/receiver-api.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : receiver-api.ads 3 | -- SUBJECT: Specification of a package that simplifies use of the receiver. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -- All the subprograms in this package must be task safe. They can be simultaneously called 7 | -- from multiple tasks. If possible, make every subprogram here a pure function. 8 | -- 9 | -------------------------------------------------------------------------------- 10 | pragma SPARK_Mode(On); 11 | 12 | with Message_Manager; 13 | 14 | use Message_Manager; 15 | 16 | package Receiver.API is 17 | 18 | function Make_Message(Sender : Module_ID) return Message_Record; 19 | 20 | end Receiver.API; 21 | -------------------------------------------------------------------------------- /bench/messages/src/receiver-internals.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : receiver-internals.adb 3 | -- SUBJECT: Body of a package that implements the main part of the receiver. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with LEDs; 10 | 11 | package body Receiver.Internals is 12 | 13 | Message_Count : Natural := 0; 14 | 15 | 16 | procedure Process_Message(Incoming_Message : in Message_Record) is 17 | pragma Unreferenced(Incoming_Message); 18 | begin 19 | Message_Count := Message_Count + 1; 20 | if Message_Count = 1_000_000 then 21 | LEDs.On(LEDs.Green); 22 | end if; 23 | end Process_Message; 24 | 25 | 26 | end Receiver.Internals; 27 | 28 | -------------------------------------------------------------------------------- /bench/messages/src/receiver-internals.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : receiver-internals.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the receiver. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with Message_Manager; 10 | 11 | use Message_Manager; 12 | 13 | private package Receiver.Internals is 14 | 15 | procedure Process_Message(Incoming_Message : in Message_Record); 16 | 17 | end Receiver.Internals; 18 | -------------------------------------------------------------------------------- /bench/messages/src/receiver-messages.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : receiver-messages.adb 3 | -- SUBJECT: Body of the LED driver receiver package. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | -- pragma SPARK_Mode(On); 8 | 9 | with Message_Manager; 10 | with Receiver.Internals; 11 | 12 | package body Receiver.Messages is 13 | 14 | task body Message_Loop is 15 | Incoming_Message : Message_Manager.Message_Record; 16 | begin 17 | loop 18 | Message_Manager.Mailboxes(ID).Receive(Incoming_Message); 19 | Internals.Process_Message(Incoming_Message); 20 | end loop; 21 | end Message_Loop; 22 | 23 | end Receiver.Messages; 24 | -------------------------------------------------------------------------------- /bench/messages/src/receiver-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : receiver-messages.ads 3 | -- SUBJECT: Specification of the receiving message handler package. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | -- pragma SPARK_Mode(On); 8 | 9 | with System; 10 | 11 | package Receiver.Messages is 12 | 13 | task Message_Loop is 14 | pragma Storage_Size(8 * 1024); 15 | pragma Priority(System.Default_Priority + 1); 16 | end Message_Loop; 17 | 18 | end Receiver.Messages; 19 | -------------------------------------------------------------------------------- /bench/messages/src/receiver.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : receiver.ads 3 | -- SUBJECT: Top level package of a CubedOS driver for the receiver. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with Message_Manager; 10 | 11 | package Receiver is 12 | 13 | ID : Message_Manager.Module_ID := 2; 14 | 15 | end Receiver; 16 | -------------------------------------------------------------------------------- /bench/messages/src/sender-internals.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : sender-internals.adb 3 | -- SUBJECT: Body of a package that implements the main part of the sender. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with LEDs; 10 | with Receiver; 11 | with Receiver.API; 12 | 13 | package body Sender.Internals is 14 | use type Message_Manager.Status_Type; 15 | 16 | procedure Process_Message(Incoming_Message : in Message_Manager.Message_Record) is 17 | pragma Unreferenced(Incoming_Message); 18 | 19 | Status : Message_Manager.Status_Type; 20 | begin 21 | for I in 1 .. 1_000_000 loop 22 | Message_Manager.Mailboxes(Receiver.ID).Send(Receiver.API.Make_Message(ID), Status); 23 | if Status = Message_Manager.Mailbox_Full then 24 | LEDs.On(LEDs.Red); 25 | end if; 26 | end loop; 27 | end Process_Message; 28 | 29 | end Sender.Internals; 30 | 31 | -------------------------------------------------------------------------------- /bench/messages/src/sender-internals.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : sender-internals.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the sender. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with Message_Manager; 10 | 11 | private package Sender.Internals is 12 | 13 | procedure Process_Message(Incoming_Message : in Message_Manager.Message_Record); 14 | 15 | end Sender.Internals; 16 | -------------------------------------------------------------------------------- /bench/messages/src/sender-messages.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : sender-messages.adb 3 | -- SUBJECT: Body of the sender message handler package. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | -- pragma SPARK_Mode(On); 8 | 9 | with Message_Manager; 10 | with Sender.Internals; 11 | 12 | package body Sender.Messages is 13 | 14 | task body Message_Loop is 15 | Incoming_Message : Message_Manager.Message_Record; 16 | begin 17 | loop 18 | Message_Manager.Mailboxes(ID).Receive(Incoming_Message); 19 | Internals.Process_Message(Incoming_Message); 20 | end loop; 21 | end Message_Loop; 22 | 23 | end Sender.Messages; 24 | -------------------------------------------------------------------------------- /bench/messages/src/sender-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : sender-messages.ads 3 | -- SUBJECT: Specification of the sender message handler package. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | -- pragma SPARK_Mode(On); 8 | 9 | with System; 10 | 11 | package Sender.Messages is 12 | 13 | task Message_Loop is 14 | pragma Storage_Size(8 * 1024); 15 | pragma Priority(System.Default_Priority); 16 | end Message_Loop; 17 | 18 | end Sender.Messages; 19 | -------------------------------------------------------------------------------- /bench/messages/src/sender.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : sender.ads 3 | -- SUBJECT: Top level package of a CubedOS message sender. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with Message_Manager; 10 | 11 | package Sender is 12 | 13 | ID : Message_Manager.Module_ID := 1; 14 | 15 | end Sender; 16 | -------------------------------------------------------------------------------- /bin/README.md: -------------------------------------------------------------------------------- 1 | 2 | README 3 | ====== 4 | 5 | The script `mercury.sh` runs the Mercury tool. It is written in a way that it will run even when 6 | launched via a symbolic link somewhere else. Thus, you can add a symbolic link to the script in, 7 | for example, a personal `bin` directory to run Mercury conveniently from anywhere. 8 | 9 | The script assumes Mercury has already been built via: 10 | 11 | $ sbt assembly 12 | 13 | from inside the `mercury` folder. 14 | 15 | The `jenkins.sh` script is used by Jenkins-CI to build and test the CubedOS system and its 16 | various components, test & sample programs, and documentation. It builds Mercury as well, since 17 | Mercury is a prerequisite for the CubedOS build. 18 | 19 | See the comments in `run-gnatcheck.sh` for an explaination of what it does and why it exists. 20 | -------------------------------------------------------------------------------- /bin/mercury.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Get the directory where the script is located and use that as a base for the paths below. 4 | SCRIPT_DIR=$(dirname $(realpath $0)) 5 | 6 | java -jar $SCRIPT_DIR/../mercury/target/scala-3.4.2/Mercury-assembly-0.1.0-SNAPSHOT.jar \ 7 | -t$SCRIPT_DIR/../mercury/templates $* 8 | -------------------------------------------------------------------------------- /doc/.vscode/ltex.dictionary.en-US.txt: -------------------------------------------------------------------------------- 1 | CubedOS 2 | Ravenscar 3 | Merc 4 | AdaCore 5 | Alire 6 | GNATstudio 7 | messageable 8 | ONC 9 | XDR 10 | pragmas 11 | Jorvik 12 | autogenerate 13 | BasicLEO 14 | STMicroelectronics 15 | VxWorks 16 | OSAL 17 | OSAL 18 | RTEMS 19 | ScriptBuilder 20 | ANTLR 21 | postcondition 22 | VTSU 23 | unmarshal 24 | unmarshaling 25 | Korolev 26 | datagram 27 | APID 28 | mxdr 29 | -------------------------------------------------------------------------------- /doc/.vscode/ltex.disabledRules.en-US.txt: -------------------------------------------------------------------------------- 1 | EN_COMPOUNDS 2 | -------------------------------------------------------------------------------- /doc/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "cSpell.words": [ 3 | "ANTLR", 4 | "datagram", 5 | "Jorvik", 6 | "Korolev", 7 | "Merc", 8 | "messageable", 9 | "microkernel", 10 | "multicasting", 11 | "MXDR", 12 | "OSAL", 13 | "postcondition", 14 | "Ravenscar", 15 | "RTEMS", 16 | "unmarshaling" 17 | ], 18 | "rewrap.wrappingColumn": 96, 19 | "latex-workshop.latex.autoBuild.run": "never" 20 | } -------------------------------------------------------------------------------- /doc/CFDP-Organization.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/CFDP-Organization.odg -------------------------------------------------------------------------------- /doc/Development-Architecture.tex: -------------------------------------------------------------------------------- 1 | 2 | \section{Architecture} 3 | \label{sec:development-architecture} 4 | 5 | In this chapter we describe the high level architecture of CubedOS. This includes both the 6 | architecture of the system and the architecture of the development environment. 7 | 8 | \input{Architecture-Overview} 9 | \input{Architecture-Priorities} 10 | \input{Architecture-Encoding} 11 | \input{Architecture-Code} 12 | -------------------------------------------------------------------------------- /doc/Development.tex: -------------------------------------------------------------------------------- 1 | 2 | \newpage 3 | \chapter{Development} 4 | \label{chapt:development} 5 | 6 | This chapter describes the internal design of CubedOS. It is of interest to developers who wish 7 | to extend the functionality of CubedOS or users who want to better understand the system's 8 | internal architecture. 9 | 10 | This chapter is broken into several sections. The first section describes the requirements that 11 | CubedOS is intended to meet. The second section describes the overall architecture of CubedOS. 12 | The third section provides a detailed design of the CubedOS core modules. 13 | 14 | \input{Development-Requirements} 15 | \input{Development-Architecture} 16 | \input{Development-Design} 17 | -------------------------------------------------------------------------------- /doc/Figure-CubedOS.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/Figure-CubedOS.odg -------------------------------------------------------------------------------- /doc/Figure-CubedOS.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/Figure-CubedOS.pdf -------------------------------------------------------------------------------- /doc/Figure-Hybrid.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/Figure-Hybrid.odg -------------------------------------------------------------------------------- /doc/Figure-Hybrid.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/Figure-Hybrid.pdf -------------------------------------------------------------------------------- /doc/Figure-MultiDomain.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/Figure-MultiDomain.odg -------------------------------------------------------------------------------- /doc/Figure-MultiDomain.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/Figure-MultiDomain.pdf -------------------------------------------------------------------------------- /doc/Figure-Traditional.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/Figure-Traditional.odg -------------------------------------------------------------------------------- /doc/Figure-Traditional.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/Figure-Traditional.pdf -------------------------------------------------------------------------------- /doc/Manual.tex: -------------------------------------------------------------------------------- 1 | 2 | \newpage 3 | \chapter{Manual} 4 | \label{chapt:manual} 5 | 6 | This chapter contains the user's manual for CubedOS. The intended audience of this chapter is 7 | CubedOS application developers. Contributors to the CubedOS core and runtime library may also 8 | find the information in this chapter useful. 9 | 10 | The information in this chapter is intended to support both new and experienced CubedOS 11 | application developers. If you are new to CubedOS and not sure how to get started, begin by 12 | reading the Section~\ref{sec:manual-tutorial} tutorial that describes how to create a CubedOS 13 | application from scratch. 14 | 15 | Documentation on the CubedOS core modules is in Section~\ref{sec:manual-core-modules}. 16 | Documentation about the sample programs provided with the CubedOS distribution is in 17 | Section~\ref{sec:manual-samples}. 18 | 19 | \input{Manual-Tutorial.tex} 20 | \input{Manual-CoreModules.tex} 21 | \input{Manual-Samples.tex} 22 | -------------------------------------------------------------------------------- /doc/Mercury.tex: -------------------------------------------------------------------------------- 1 | 2 | \chapter{Mercury} 3 | \label{chapt:mercury} 4 | 5 | Mercury is an interface definition language (IDL) compiler for CubedOS. It takes as input a file 6 | describing the messages a CubedOS module receives (requests) or sends (replies), and outputs an 7 | Ada package that defines the API to that module. The package provides subprograms for encoding 8 | messages, decoding messages, and classifying messages. 9 | 10 | One unique aspect of Mercury is that it generates \SPARK\ code that can be proved free of 11 | runtime error without any further intervention by the user. 12 | 13 | The IDL used by Mercury is an extension of XDR as defined in RFC-4506 \cite{rfc-4506}, that we 14 | call modified XDR or MXDR. The modifications incorporate features that facilitate \SPARK's 15 | ability to prove the absence of runtime errors. 16 | 17 | Mercury is written in Scala and is invoked from the command line. 18 | 19 | In this chapter we describe the requirements, design, and usage of Mercury. 20 | 21 | \input{Mercury-Tutorial.tex} 22 | \input{Mercury-Requirements.tex} 23 | \input{Mercury-Design.tex} 24 | -------------------------------------------------------------------------------- /doc/NOTES.md: -------------------------------------------------------------------------------- 1 | 2 | Notes 3 | ===== 4 | 5 | These notes are "lessons" learned from the BasicLEO flight. This information should be brought 6 | forward as we design and implement the ion drive demonstration system. 7 | 8 | + Including time-outs on these bus communications is essential. We don't want the system getting 9 | hung waiting indefinitely for communications that never occur. 10 | 11 | + Don't use the main software loop as a timing mechanism. It is inaccurate, of course, but more 12 | than that it causes problems if the loop is heavily delayed due to time-outs (see above). 13 | Instead, some kind of real-time clock hardware should be used. 14 | 15 | + Don't underestimate the importance of minimizing writes to SD cards. Frequent error logs, for 16 | example, can "quickly" consume all the writes the card can withstand causing premature 17 | failures. Ideally some kind of estimate should be done of minimum useful life of an SD card 18 | based on write activity and that life should be compared to the expected duration of the 19 | mission. 20 | 21 | -------------------------------------------------------------------------------- /doc/README.md: -------------------------------------------------------------------------------- 1 | 2 | README 3 | ====== 4 | 5 | This folder contains the official documentation set for CubedOS. The master document is 6 | CubedOS.tex. That document includes, directly or indirectly, all the other document components. 7 | 8 | To build the documentation, first be sure you have a LaTeX system installed. The precise way to 9 | do this depends on your system and is outside the scope of this document. Then, issue the 10 | following commands: 11 | 12 | > pdflatex CubedOS 13 | > bibtex CubedOS 14 | > pdflatex CubedOS 15 | > pdflatex CubedOS 16 | 17 | It is necessary to run the `pdflatex` command multiple times to ensure that all cross references 18 | are resolved properly. The resulting documentation will be in `CubedOS.pdf`. 19 | 20 | LaTeX Resources 21 | --------------- 22 | 23 | For a quick primer on LaTeX see the [LaTeX at 24 | VTSU](https://www.pchapin.org/VTSU/LaTeX/LaTeX.zip) document. The [Not So Short Introduction to 25 | LaTeX2e](http://tobi.oetiker.ch/lshort/lshort.pdf) is also an excellent resource. 26 | 27 | We recommend using [JabRef](http://jabref.sourceforge.net/) for managing BibTeX databases. Note 28 | that a text editor is technically all that is necessary but JabRef provides many useful services 29 | most text editors do not. 30 | -------------------------------------------------------------------------------- /doc/Submit NOI Result.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/Submit NOI Result.pdf -------------------------------------------------------------------------------- /doc/XDR2OS3.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/XDR2OS3.odt -------------------------------------------------------------------------------- /doc/flashingCF2-1.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/flashingCF2-1.odt -------------------------------------------------------------------------------- /doc/papers/.gitignore: -------------------------------------------------------------------------------- 1 | main.pdf 2 | -------------------------------------------------------------------------------- /doc/papers/2015-IAC/README.md: -------------------------------------------------------------------------------- 1 | 2 | README 3 | ====== 4 | 5 | This folder contains the [IAC-2015](http://www.iac2015.org/) paper. 6 | 7 | 8 | -------------------------------------------------------------------------------- /doc/papers/2015-IAC/brandon-chapin-IAC-2015.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/papers/2015-IAC/brandon-chapin-IAC-2015.docx -------------------------------------------------------------------------------- /doc/papers/2017-AUJ/AUJ 38-3-cube.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/papers/2017-AUJ/AUJ 38-3-cube.pdf -------------------------------------------------------------------------------- /doc/papers/2017-AUJ/Figure-140324-1123P-good_earth.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/papers/2017-AUJ/Figure-140324-1123P-good_earth.pdf -------------------------------------------------------------------------------- /doc/papers/2017-AUJ/Figure-Assembly-with-Deployed-Pumpkin-Panels-with-labels-v2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/papers/2017-AUJ/Figure-Assembly-with-Deployed-Pumpkin-Panels-with-labels-v2.pdf -------------------------------------------------------------------------------- /doc/papers/2017-AUJ/Figure-CubedOS.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/papers/2017-AUJ/Figure-CubedOS.odg -------------------------------------------------------------------------------- /doc/papers/2017-AUJ/Figure-CubedOS.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/papers/2017-AUJ/Figure-CubedOS.pdf -------------------------------------------------------------------------------- /doc/papers/2017-AUJ/Figure-Hybrid.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/papers/2017-AUJ/Figure-Hybrid.odg -------------------------------------------------------------------------------- /doc/papers/2017-AUJ/Figure-Hybrid.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/papers/2017-AUJ/Figure-Hybrid.pdf -------------------------------------------------------------------------------- /doc/papers/2017-AUJ/Figure-MultiDomain.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/papers/2017-AUJ/Figure-MultiDomain.odg -------------------------------------------------------------------------------- /doc/papers/2017-AUJ/Figure-MultiDomain.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/papers/2017-AUJ/Figure-MultiDomain.pdf -------------------------------------------------------------------------------- /doc/papers/2017-AUJ/Figure-Traditional.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/papers/2017-AUJ/Figure-Traditional.odg -------------------------------------------------------------------------------- /doc/papers/2017-AUJ/Figure-Traditional.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/papers/2017-AUJ/Figure-Traditional.pdf -------------------------------------------------------------------------------- /doc/papers/2017-AUJ/conclusion.tex: -------------------------------------------------------------------------------- 1 | 2 | \section{Conclusion} 3 | 4 | CubedOS is an application framework based on message passing that is intended to support the 5 | flight software of space missions, particularly CubeSat missions. Our early experience with 6 | CubedOS is favorable. The architecture seems to provide an effective way to organize 7 | flight software. 8 | 9 | Unlike similar projects such as cFE and Kubos, CubedOS is written entirely in \SPARK\ and proved 10 | free of runtime errors in the sense meant by \SPARK. It is necessary to manully suppress certain 11 | \SPARK\ messages related to information flow through the CubedOS mailbox array. However, we feel 12 | the danger of doing this is minimal since the easy to understand architecture of the system 13 | ensures no flow problems will actually arise in practice. 14 | 15 | CubedOS provides a great deal of concurrency and runtime flexibility, but sacrifices some static 16 | type safety to achieve this. We mitigate the danger using a tool, XDR2OS3, that generates 17 | message encoding and decoding subprograms based on strongly typed message descriptions. The 18 | output of the tool is verified by \SPARK. 19 | 20 | We intend to release CubedOS to the open source CubeSat community once we have completed an ITAR 21 | review of our code base and possibly release both ITAR compliant and U.S non ITAR compliant versions. 22 | We anticipate that release to be some time in mid-2018. 23 | -------------------------------------------------------------------------------- /doc/papers/README.md: -------------------------------------------------------------------------------- 1 | Papers 2 | ====== 3 | 4 | This folder contains papers and presentations created by Vermont State University's CubeSat 5 | Laboratory. Folders with names including a date contain published works where the folder name 6 | reflects the venue and date of publication. Folders with descriptive names reflect works in 7 | progress or proposed works. 8 | -------------------------------------------------------------------------------- /doc/papers/mercury/Updater.mxdr: -------------------------------------------------------------------------------- 1 | 2 | // Rudimentary system for updating files over DSN protocols. One of 10 CubeSats comprising the 3 | // networked "swarm" is the "controller". It accepts files, sends a receipt and makes sure the 4 | // update happens. Please add to this! Or point out impossibilities and stupidities! 5 | 6 | // Min number in swarm. Controller 7 | const Min = 0; 8 | 9 | // Max number in swarm 10 | const Max = 9; 11 | 12 | // Memory addresses 13 | typedef unsigned hyper Memory_Locale; 14 | 15 | // Module 16 | typedef int Module_ID; 17 | 18 | // CubeSat 19 | typedef struct { 20 | Memory_Locale Address; 21 | Module_ID Module; 22 | int Swarm_Position; 23 | } CubeSat[10]; 24 | 25 | // Message structs 26 | message struct <- File_Accept { 27 | int Module_Destination_ID; 28 | CubeSat Swarm; 29 | }; 30 | 31 | message struct -> File_Receipt { 32 | string Message; 33 | }; 34 | 35 | message struct <- Update { 36 | int Module_Destination_ID; 37 | CubeSat Swarm; 38 | bool Errors; 39 | bool Check_Swarm[10]; 40 | } with message_invariant => Module_Destination_ID >= Min, 41 | with message_invariant => Module_Destination_ID <= Max; 42 | -------------------------------------------------------------------------------- /doc/papers/mercury/code-generation.tex: -------------------------------------------------------------------------------- 1 | 2 | \section{Code Generation} 3 | \label{sec:code-generation} 4 | -------------------------------------------------------------------------------- /doc/papers/mercury/conclusion.tex: -------------------------------------------------------------------------------- 1 | 2 | \section{Conclusion} 3 | \label{sec:conclusion} 4 | 5 | Merc is wonderful. Using it will change your life forever. 6 | -------------------------------------------------------------------------------- /doc/papers/mercury/performance.tex: -------------------------------------------------------------------------------- 1 | 2 | \section{Performance} 3 | \label{sec:performance} -------------------------------------------------------------------------------- /doc/papers/multidomain/conclusion.tex: -------------------------------------------------------------------------------- 1 | 2 | \section{Conclusion} 3 | \label{sec:conclusion} 4 | 5 | This paper is a work of genius. 6 | -------------------------------------------------------------------------------- /doc/papers/multidomain/introduction.tex: -------------------------------------------------------------------------------- 1 | 2 | \section{Introduction} 3 | \label{sec:introduction} 4 | 5 | Blah, blah, blah, and etc\ldots 6 | 7 | -------------------------------------------------------------------------------- /doc/presentations/CubedOS-Architecture.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/presentations/CubedOS-Architecture.pptx -------------------------------------------------------------------------------- /doc/references-SPARK.bib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/references-SPARK.bib -------------------------------------------------------------------------------- /doc/slides/Vermont-Tech-Badge.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/slides/Vermont-Tech-Badge.jpg -------------------------------------------------------------------------------- /doc/slides/Vermont-Tech-Stack.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/doc/slides/Vermont-Tech-Stack.jpg -------------------------------------------------------------------------------- /doc/slides/main.tex: -------------------------------------------------------------------------------- 1 | % 2 | % This is a template for creating slides with LaTeX. 3 | % 4 | 5 | \documentclass[landscape]{slides} 6 | \usepackage{amsmath} 7 | \usepackage{amssymb} 8 | \usepackage{amstext} 9 | \usepackage{color} 10 | \usepackage{fancyvrb} 11 | \usepackage[pdftex]{graphicx} 12 | \usepackage{listings} 13 | \usepackage{times} 14 | \usepackage{url} 15 | 16 | \input{slide-macros} 17 | 18 | % Default settings for code listings. 19 | \lstset{ 20 | language=C, 21 | basicstyle=\ttfamily, 22 | stringstyle=\ttfamily, 23 | commentstyle=\ttfamily, 24 | xleftmargin=0.25in, 25 | showstringspaces=false} 26 | 27 | \lstMakeShortInline[basicstyle=\ttfamily]! 28 | 29 | \title{\color{titlecolor}THE TITLE} 30 | \author{ 31 | \begin{tabular}{c} 32 | \\[3mm] 33 | \Large{Peter C. Chapin} \\[2mm] 34 | \normalsize{Computer Information Systems}\\[5mm] 35 | \includegraphics[scale=0.80]{Vermont-Tech-Stack.jpg}\\[16mm] 36 | \end{tabular} 37 | } 38 | \date{October 31, 2013} 39 | 40 | \begin{document} 41 | 42 | \color{Black} 43 | \pagecolor{Background} 44 | 45 | \maketitle 46 | 47 | \startslide{SLIDE 1} 48 | \begin{citemize} 49 | \item Life is good! 50 | \item Life is very good!! 51 | \item Life is very very good!!! 52 | \end{citemize} 53 | How good is it? 54 | \stopslide 55 | 56 | \end{document} 57 | -------------------------------------------------------------------------------- /mercury/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # IntelliJ files that should not be versioned. 3 | .idea 4 | build 5 | 6 | # Visual Studio Code files that should not be versioned. 7 | .bloop 8 | .metals 9 | 10 | # SBT generated folders. 11 | target 12 | .bsp 13 | # There is a weird thing where Metals creates a deeply nested collection of project folders 14 | # when it imports changes to the SBT file. I'm unclear if this is normal or some sort of issue. 15 | # In any case, since it is auto-generated, I'm ignoring it here (pchapin) 16 | project/project 17 | -------------------------------------------------------------------------------- /mercury/README.md: -------------------------------------------------------------------------------- 1 | 2 | Mercury 3 | ======= 4 | 5 | A tool for compiling CubedOS message definitions into message encoding/decoding subprograms. 6 | 7 | Mercury is the CubedOS interface definition language (IDL) compiler. This tool converts a 8 | description of CubedOS messages into provable SPARK packages containing message encoding and 9 | decoding subprograms. The IDL is an extended version of the eXternal Data Representation (XDR) 10 | standard described in RFC-4506. We call our extended XDR "modified" XDR, or MXDR. 11 | 12 | Build Instructions 13 | ------------------ 14 | 15 | Mercury is an [SBT](https://www.scala-sbt.org/)-based project. After [installing a suitable 16 | JVM](https://www.oracle.com/java/technologies/downloads/) (we recommend version 21.x.y for some 17 | x, y) and SBT, run an SBT interactive session while inside the top level Merc folder. There you 18 | can use the usual SBT commands such as `compile`, `package`, `test`, and `assembly` to build and 19 | exercise the code. Any IDE that supports SBT integration, such as IntelliJ or VSCode can also be 20 | used. 21 | -------------------------------------------------------------------------------- /mercury/TODO.md: -------------------------------------------------------------------------------- 1 | 2 | TODO 3 | ==== 4 | 5 | This file contains todo-items for the Mercury subproject. 6 | 7 | + **Issues**. There are a number of Mercury issues listed on GitHub. Getting some, many, or all 8 | of them fixed would be worthwhile! 9 | 10 | + **Generated File Names**. Right now Mercury thinks it is only creating APIs for CubedOS core 11 | modules, and names files and packages accordingly. This is very limiting since it prevents the 12 | tool from being used by ordinary application developers! This must be fixed (it's also a 13 | GitHub issue). 14 | 15 | + **Review/Refresh Generated Code**. The generated code needs updating to reflect the 16 | multi-domain support architecture CubedOS now uses. It should also be reviewed to follow our 17 | style guide as closely as possible. One application of Mercury is to do the initial generation 18 | of an API package, but for that package to be further edited (and then maintained) by hand. In 19 | that case, highly readible and style-consistent code is a must. 20 | 21 | -------------------------------------------------------------------------------- /mercury/bin/grun.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | REM 3 | REM This is the testing tool described in "Definitive ANTRL 4." 4 | REM 5 | 6 | cd build\production\Merc 7 | java -cp .;..\..\..\..\..\..\lib\antlr4-4.5.3.jar org.antlr.v4.runtime.misc.TestRig edu.vermontstate.merc.Main %1 %2 %3 %4 8 | cd ..\..\..\.. 9 | -------------------------------------------------------------------------------- /mercury/bin/grun.sh: -------------------------------------------------------------------------------- 1 | # 2 | # This is the testing tool described in "Definitive ANTRL 4." 3 | # 4 | 5 | cd build/production/Merc 6 | java -cp .:../../../../../../lib/antlr4-4.5.3.jar org.antlr.v4.runtime.misc.TestRig edu.vermontstate.merc.Main $1 $2 $3 $4 7 | cd ../../../.. 8 | -------------------------------------------------------------------------------- /mercury/build.sbt: -------------------------------------------------------------------------------- 1 | 2 | enablePlugins(Antlr4Plugin) 3 | 4 | ThisBuild / organization := "edu.vermontstate" 5 | ThisBuild / version := "0.1.0-SNAPSHOT" 6 | ThisBuild / scalaVersion := "3.4.2" 7 | ThisBuild / scalacOptions := 8 | Seq("-encoding", "UTF-8", // Encoding of the source files. 9 | "-feature", 10 | "-deprecation", // Tell us about deprecated things. 11 | "-unchecked", 12 | "-Wunused:nowarn") // Warn if the nowarn annotation doesn't actually suppress a warning. 13 | 14 | libraryDependencies += "org.scalactic" %% "scalactic" % "3.2.17" 15 | libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.17" % "test" 16 | 17 | Test / logBuffered := false 18 | 19 | lazy val mercury = (project in file(".")) 20 | .settings( 21 | name := "Mercury", 22 | 23 | Antlr4 / antlr4Version := "4.13.1", 24 | Antlr4 / antlr4PackageName := Some("edu.vermontstate.mercury"), 25 | Antlr4 / antlr4GenListener := true, 26 | Antlr4 / antlr4GenVisitor := true 27 | ) 28 | -------------------------------------------------------------------------------- /mercury/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.9.7 -------------------------------------------------------------------------------- /mercury/project/metals.sbt: -------------------------------------------------------------------------------- 1 | // format: off 2 | // DO NOT EDIT! This file is auto-generated. 3 | 4 | // This file enables sbt-bloop to create bloop config files. 5 | 6 | addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % "1.6.0") 7 | 8 | // format: on 9 | -------------------------------------------------------------------------------- /mercury/project/sbt-antlr4.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("com.simplytyped" % "sbt-antlr4" % "0.8.3") 2 | -------------------------------------------------------------------------------- /mercury/project/sbt-assembly.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.5") 2 | 3 | -------------------------------------------------------------------------------- /mercury/src/main/scala/edu/vermontstate/mercury/BasicConsoleReporter.scala: -------------------------------------------------------------------------------- 1 | package edu.vermontstate.mercury 2 | 3 | /** 4 | * An implementation of the Reporter trait that outputs messages to the console. 5 | */ 6 | class BasicConsoleReporter extends Reporter { 7 | 8 | var errorCount = 0 9 | var warningCount = 0 10 | 11 | def reportError(line: Int, column: Int, message: String): Unit = { 12 | errorCount += 1 13 | printf("ERR: [Line: %3d, Column: %3d] %s\n", line, column, message) 14 | } 15 | 16 | 17 | def reportWarning(line: Int, column: Int, message: String): Unit = { 18 | warningCount += 1 19 | printf("WRN: [Line: %3d, Column: %3d] %s\n", line, column, message) 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /mercury/src/main/scala/edu/vermontstate/mercury/Reporter.scala: -------------------------------------------------------------------------------- 1 | package edu.vermontstate.mercury 2 | 3 | /** 4 | * This trait describes the interface to error reporting objects. Different implementations 5 | * report errors in different ways. By centralizing the way errors are reported, changes can be 6 | * made to this important function without modifying the bulk of the compiler where errors are 7 | * detected. 8 | */ 9 | trait Reporter { 10 | 11 | /** 12 | * Used to report an error condition. If an error is detected code can not be generated. 13 | * 14 | * @param line The line in the source file where the error was detected. 15 | * @param column The column on the line where the error was detected. 16 | * @param message The human readable message describing the error. 17 | */ 18 | def reportError(line: Int, column: Int, message: String): Unit 19 | 20 | /** 21 | * Used to report a warning condition. Warnings do not prevent code from being generated. 22 | * 23 | * @param line The line in the source file where the warning was detected. 24 | * @param column THe column on hte line where the warning was detected. 25 | * @param message THe human readable message describing the warning. 26 | */ 27 | def reportWarning(line: Int, column: Int, message: String): Unit 28 | } 29 | 30 | 31 | object Reporter { 32 | 33 | /** 34 | * Internal compiler errors are handled by throwing instances of this exception. They are not 35 | * reported in the usual way. Instead the compiler is intended to abort. 36 | * 37 | * @param message A human readable message describing the error. 38 | */ 39 | class InternalErrorException(message: String) extends Exception(message) 40 | } 41 | -------------------------------------------------------------------------------- /mercury/src/main/scala/edu/vermontstate/mercury/SemanticAnalyzer.scala: -------------------------------------------------------------------------------- 1 | package edu.vermontstate.mercury 2 | 3 | import TypeRep.* 4 | 5 | class SemanticAnalyzer( 6 | nameOfFile : String, 7 | symbolTable: BasicSymbolTable, 8 | reporter : Reporter) extends MXDRBaseVisitor[(String, TypeRep.Rep)] { 9 | 10 | // TODO: Implement me! 11 | 12 | } 13 | -------------------------------------------------------------------------------- /mercury/src/main/scala/edu/vermontstate/mercury/TypeRep.scala: -------------------------------------------------------------------------------- 1 | package edu.vermontstate.mercury 2 | 3 | object TypeRep { 4 | 5 | abstract class Rep 6 | 7 | // Placeholder for situations where there is no type. 8 | case object NoTypeRep extends Rep 9 | 10 | // Unstructured types. 11 | case class IDERep(name: String) extends Rep // What is this for? 12 | case class IDRep(name: Rep) extends Rep // What is this for? 13 | case object BoolRep extends Rep 14 | case object DataRep extends Rep // What is this for? 15 | case object DoubleRep extends Rep 16 | case object FloatRep extends Rep 17 | case object HyperRep extends Rep 18 | case object IntRep extends Rep 19 | case object OpaqueRep extends Rep 20 | case object QuadRep extends Rep 21 | case object StringRep extends Rep 22 | case object TimeRep extends Rep // It seems a shame to hard code support for this. 23 | case object TimeSpanRep extends Rep // It seems a shame to hard code support for this. 24 | //case object TypeDefRep extends Rep 25 | case object UHyperRep extends Rep 26 | case object UIntRep extends Rep 27 | case object VoidRep extends Rep 28 | 29 | // Structured and composite types. 30 | case class ArrayRep(size: Int, elementType: Rep) extends Rep 31 | case class ComponentRep(components: List[(String, Rep, String)]) extends Rep 32 | case class ConstRep (name: String, value: String) extends Rep 33 | case class EnumRep (name: String, components: ComponentRep) extends Rep 34 | case class MStructRep(name: String, components: ComponentRep) extends Rep 35 | case class StructRep (name: String, components: ComponentRep) extends Rep 36 | case class UnionRep (name: String, components: ComponentRep) extends Rep 37 | } 38 | -------------------------------------------------------------------------------- /mercury/src/test/scala/edu/vermontstate/mercury/ExpectedMessage.scala: -------------------------------------------------------------------------------- 1 | package edu.vermontstate.mercury 2 | 3 | /** 4 | * Instances of this case class are used to hold expected messages during testing. 5 | * 6 | * @param line The line number where the message is expected. 7 | * @param column The column position where the message is expected. 8 | * @param message The text of the expected message. 9 | */ 10 | case class ExpectedMessage(line: Int, column: Int, message: String) 11 | -------------------------------------------------------------------------------- /mercury/src/test/scala/edu/vermontstate/mercury/MercurySpec.scala: -------------------------------------------------------------------------------- 1 | package edu.vermontstate.mercury 2 | 3 | class MercurySpec extends UnitSpec { 4 | 5 | "Command line processing" should "behave as specified" in { 6 | val testCases: List[Array[String]] = List( 7 | Array("file.mxdr"), // Basic case, no switches. 8 | Array("-tfolder", "file.mxdr"), // The -t switch. 9 | Array("-k", "file.mxdr"), // The -k switch. 10 | Array("-k", "-tfolder", "file.mxdr"), // Both switches. 11 | Array("-tfolder", "-k", "file.mxdr"), // Both switches (other order). 12 | Array("-k"), // Missing file name. 13 | Array() // Empty command line. 14 | ) 15 | 16 | val expectedResults: List[Option[(Map[Char, String], String)]] = List( 17 | Some((Map(), "file.mxdr")), 18 | Some((Map('t' -> "folder"), "file.mxdr")), 19 | Some((Map('k' -> ""), "file.mxdr")), 20 | Some((Map('k' -> "", 't' -> "folder"), "file.mxdr")), 21 | Some((Map('k' -> "", 't' -> "folder"), "file.mxdr")), 22 | None, 23 | None 24 | ) 25 | 26 | for (i <- testCases.indices) { 27 | assert( 28 | Main.analyzeCommandLine(testCases(i)) == expectedResults(i), 29 | s"command line test with index $i failed") 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /mercury/src/test/scala/edu/vermontstate/mercury/SemanticSpec.scala: -------------------------------------------------------------------------------- 1 | package edu.vermontstate.mercury 2 | 3 | import java.io.File 4 | import org.antlr.v4.runtime.* 5 | 6 | class SemanticSpec extends UnitSpec { 7 | 8 | case class TestCase( 9 | fileName : String, 10 | expectedErrors : Array[ExpectedMessage], 11 | expectedWarnings: Array[ExpectedMessage]) 12 | 13 | "The SemanticAnalyzer" should "detect semantic errors in MXDR" in { 14 | val testCases = Array( 15 | TestCase("0001.mxdr", 16 | Array(ExpectedMessage(5, 22, "Invalid!: That Identifier already exists!")), 17 | Array())) 18 | 19 | for (testCase <- testCases) { 20 | val TestCase(fileName, expectedErrors, expectedWarnings) = testCase 21 | 22 | val fullName = "testData" + File.separator + "Semantics" + File.separator + fileName 23 | 24 | val codePointCharStream = CharStreams.fromFileName(fullName) 25 | val lexer = new MXDRLexer(codePointCharStream) 26 | val tokens = new CommonTokenStream(lexer) 27 | val parser = new MXDRParser(tokens) 28 | val tree = parser.specification() 29 | 30 | // Walk the tree created during the parse and analyze it for semantic errors. 31 | val symbolTable = new BasicSymbolTable 32 | val reporter = new TestReporter(expectedErrors, expectedWarnings) 33 | val myTable = new STPopulation(fileName, symbolTable, reporter) 34 | myTable.visit(tree) 35 | val myAnalyzer = new SemanticAnalyzer(fileName, symbolTable, reporter) 36 | myAnalyzer.visit(tree) 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /mercury/src/test/scala/edu/vermontstate/mercury/SyntaxSpec.scala: -------------------------------------------------------------------------------- 1 | package edu.vermontstate.mercury 2 | 3 | import java.io.File 4 | import org.antlr.v4.runtime.* 5 | 6 | class SyntaxSpec extends UnitSpec { 7 | 8 | "The MercuryParser" should "parse MXDR" in { 9 | val fileNames = 10 | Array("0001.mxdr", "0002.mxdr", "0003.mxdr", "0004.mxdr", "0005.mxdr", 11 | "0006.mxdr") 12 | 13 | for (fileName <- fileNames) { 14 | val fullName = "testData" + File.separator + "Syntax" + File.separator + fileName 15 | 16 | val codePointCharStream = CharStreams.fromFileName(fullName) 17 | val lexer = new MXDRLexer(codePointCharStream) 18 | val tokens = new CommonTokenStream(lexer) 19 | val parser = new MXDRParser(tokens) 20 | val tree = parser.specification() // 'tree' is intentionally ignored. 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /mercury/src/test/scala/edu/vermontstate/mercury/TestReporter.scala: -------------------------------------------------------------------------------- 1 | package edu.vermontstate.mercury 2 | 3 | class TestReporter( 4 | expectedErrors : Array[ExpectedMessage], 5 | expectedWarnings: Array[ExpectedMessage]) extends Reporter { 6 | 7 | var nextError = 0 8 | var nextWarning = 0 9 | 10 | def reportError(line: Int, column: Int, message: String): Unit = { 11 | assert( 12 | nextError < expectedErrors.length, 13 | s"Unexpected error generated. Line: $line, Column: $column, Message: $message") 14 | 15 | assert( 16 | ExpectedMessage(line, column, message) == expectedErrors(nextError), 17 | s"Got: ${ExpectedMessage(line, column, message)}, Expected: ${expectedErrors(nextError)}") 18 | nextError += 1 19 | } 20 | 21 | 22 | def reportWarning(line: Int, column: Int, message: String): Unit = { 23 | assert( 24 | nextWarning < expectedWarnings.length, 25 | s"Unexpected warning generated. Line: $line, Column: $column, Message: $message") 26 | 27 | assert( 28 | ExpectedMessage(line, column, message) == expectedWarnings(nextWarning), 29 | s"Got: ${ExpectedMessage(line, column, message)}, Expected: ${expectedWarnings(nextWarning)}") 30 | nextWarning += 1 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /mercury/src/test/scala/edu/vermontstate/mercury/TrivialSpec.scala: -------------------------------------------------------------------------------- 1 | package edu.vermontstate.mercury 2 | 3 | class TrivialSpec extends UnitSpec { 4 | 5 | "The universe" should "work correctly" in { 6 | val s = "Hello" 7 | 8 | assert(true != false) 9 | 10 | assertResult(2) { 11 | 1 + 1 12 | } 13 | 14 | assertThrows[IndexOutOfBoundsException] { 15 | s.charAt(5) 16 | } 17 | 18 | val caught = intercept[IndexOutOfBoundsException] { 19 | s.charAt(5) 20 | } 21 | assert(caught.getMessage.indexOf("5") != -1) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /mercury/src/test/scala/edu/vermontstate/mercury/UnitSpec.scala: -------------------------------------------------------------------------------- 1 | package edu.vermontstate.mercury 2 | 3 | import org.scalatest.* 4 | import flatspec.* 5 | import matchers.* 6 | 7 | class UnitSpec extends AnyFlatSpec with should.Matchers 8 | -------------------------------------------------------------------------------- /mercury/templates/template.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : %FILENAME%-api.adb 3 | -- SUBJECT: Body of a package that implements the %MODULENAME% API 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -- All the subprograms in this package are task safe. 7 | -- 8 | -- THIS FILE WAS GENERATED BY Merc. DO NOT EDIT UNLESS NECESSARY!! 9 | -------------------------------------------------------------------------------- 10 | pragma SPARK_Mode(On); 11 | 12 | with CubedOS.Lib; 13 | with CubedOS.Log_Server.API; 14 | use CubedOS.Lib; 15 | 16 | package body %MODULENAME%.API is 17 | 18 | %BULK% 19 | 20 | end %MODULENAME%.API; 21 | -------------------------------------------------------------------------------- /mercury/templates/template.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : %FILENAME%-api.ads 3 | -- SUBJECT: Specification of a package that defines the %MODULENAME% API 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -- All the subprograms in this package are task safe. 7 | -- 8 | -- THIS FILE WAS GENERATED BY Merc. DO NOT EDIT UNLESS NECESSARY!! 9 | -------------------------------------------------------------------------------- 10 | pragma SPARK_Mode(On); 11 | 12 | with CubedOS.Lib; 13 | with Message_Manager; use Message_Manager; 14 | with System; 15 | with Name_Resolver; 16 | with CubedOS.Lib.XDR; 17 | use CubedOS.Lib.XDR; 18 | 19 | package %MODULENAME%.API is 20 | 21 | %BULK% 22 | 23 | end %MODULENAME%.API; 24 | -------------------------------------------------------------------------------- /mercury/testData/CodeGeneration/.gitignore: -------------------------------------------------------------------------------- 1 | cubedos-m0001-api.ads 2 | cubedos-m0001-api.adb 3 | cubedos-m0002-api.ads 4 | cubedos-m0002-api.adb 5 | cubedos-m0003-api.ads 6 | cubedos-m0003-api.adb 7 | cubedos-m0004-api.ads 8 | cubedos-m0004-api.adb 9 | -------------------------------------------------------------------------------- /mercury/testData/CodeGeneration/CubedOS-m0001.mxdr: -------------------------------------------------------------------------------- 1 | 2 | // A trivial case... 3 | 4 | message struct -> Trivial_Request { 5 | int M1; 6 | }; 7 | 8 | message struct <- Trivial_Reply { 9 | int M1; 10 | }; 11 | -------------------------------------------------------------------------------- /mercury/testData/CodeGeneration/CubedOS-m0002.mxdr: -------------------------------------------------------------------------------- 1 | enum {red, green, blue} Color; 2 | 3 | typedef unsigned int Hello range 1 .. 2; 4 | 5 | const gorilla = 2; 6 | 7 | const whatever = 1; 8 | 9 | typedef double arnold[10]; 10 | 11 | typedef bool boo; 12 | 13 | typedef hyper hyp range 1 .. 200; 14 | 15 | typedef unsigned hyper hyp2 range 1 .. 200; 16 | 17 | typedef unsigned int Width_Type range 1 .. 100; 18 | 19 | typedef unsigned int horse is Width_Type range 1 .. 10; 20 | 21 | typedef unsigned int banana range 0 .. whatever; 22 | 23 | typedef unsigned int grape range 1 .. gorilla; 24 | 25 | typedef unsigned int seed range 0 .. grape'Last; 26 | 27 | typedef unsigned int stem is seed range 0 .. seed'Last; 28 | 29 | typedef stem branch[10000]; 30 | 31 | struct bat { 32 | Color h; 33 | Width_Type j; 34 | branch Tree_Limb; 35 | }; 36 | 37 | struct cat { 38 | bat u; 39 | double i; 40 | unsigned int y; 41 | }; 42 | 43 | struct sat { 44 | int k; 45 | cat led; 46 | bat u; 47 | }; 48 | 49 | typedef enum {yellow, orange, violet} Other_Colors; 50 | 51 | message struct -> Reddish { 52 | Color i; 53 | int y; 54 | banana b; 55 | boo bo; 56 | hyp2 hypey2; 57 | }; 58 | 59 | message struct <- Bluish { 60 | Other_Colors r; 61 | grape g; 62 | arnold a; 63 | float schwarz; 64 | seed s; 65 | }; 66 | 67 | message struct -> Example { 68 | Width_Type thing; 69 | sat cube; 70 | hyp hypey; 71 | }; 72 | -------------------------------------------------------------------------------- /mercury/testData/CodeGeneration/CubedOS-m0004.mxdr: -------------------------------------------------------------------------------- 1 | //test3.mxdr 2 | 3 | typedef int f1 range 1 .. 100; 4 | typedef f1 f2[5]; 5 | 6 | typedef unsigned int f3 range 1 .. 100; 7 | typedef f3 f4[5]; 8 | 9 | typedef hyper f5 range 1 .. 100; 10 | typedef f5 f6[5]; 11 | 12 | typedef unsigned hyper f7 range -11 .. 100; 13 | typedef f7 f8[5]; 14 | 15 | typedef float f9 range -1.12 .. 100; 16 | typedef f9 f10[5]; 17 | 18 | typedef double f11 range 1.23 .. 100.67; 19 | typedef f11 f12[5]; 20 | 21 | enum {red, blue, green} e1[2]; 22 | 23 | typedef bool b; 24 | typedef b b1[2]; 25 | 26 | int int_var[2]; 27 | 28 | struct { 29 | f2 fs1; 30 | f4 fs2; 31 | f6 fs3; 32 | f8 fs4; 33 | f10 fs5; 34 | f12 fs6; 35 | e1 e2; 36 | int_var iv; 37 | int i[9]; 38 | hyper hyp1[3]; 39 | } s1[2]; 40 | 41 | message struct <- ms { 42 | s1 mss1; 43 | e1 e3; 44 | b1 b2; 45 | int h1[2]; 46 | }; 47 | 48 | message struct <- ms1 { 49 | void; 50 | }; 51 | -------------------------------------------------------------------------------- /mercury/testData/CodeGeneration/code_generation.gpr: -------------------------------------------------------------------------------- 1 | --with "../../../CubedOS/src/cubedos.gpr"; 2 | 3 | project Code_Generation is 4 | 5 | for Main use ("main.adb"); 6 | for Object_Dir use "build"; 7 | for Source_Dirs use (".", "../../../CubedOS/src"); 8 | for Languages use ("Ada"); 9 | 10 | package Compiler is 11 | for Default_Switches ("ada") use ("-fstack-check", "-gnatwa", "-gnata", "-g"); 12 | end Compiler; 13 | 14 | package Prove is 15 | for Switches use ("-j2", "--level=2"); 16 | end Prove; 17 | 18 | end Code_Generation; 19 | 20 | -------------------------------------------------------------------------------- /mercury/testData/CodeGeneration/cubedos-m0001.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : cubedos-0001.ads 3 | -- SUBJECT: Specification of the 0001 module. 4 | -- AUTHOR : (C) Copyright 2018 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with Message_Manager; 10 | 11 | package CubedOS.M0001 is 12 | 13 | ID : constant Message_Manager.Module_ID_Type := 1; 14 | 15 | end CubedOS.M0001; 16 | -------------------------------------------------------------------------------- /mercury/testData/CodeGeneration/cubedos-m0002.ads: -------------------------------------------------------------------------------- 1 | pragma SPARK_Mode(On); 2 | 3 | with Message_Manager; 4 | 5 | package CubedOS.m0002 is 6 | 7 | ID : constant Message_Manager.Module_ID_Type := 1; 8 | 9 | end CubedOS.m0002; 10 | -------------------------------------------------------------------------------- /mercury/testData/CodeGeneration/cubedos-m0003.ads: -------------------------------------------------------------------------------- 1 | pragma SPARK_Mode(On); 2 | 3 | with Message_Manager; 4 | 5 | package CubedOS.m0003 is 6 | 7 | ID : constant Message_Manager.Module_ID_Type := 1; 8 | 9 | end CubedOS.m0003; 10 | -------------------------------------------------------------------------------- /mercury/testData/CodeGeneration/cubedos-m0004.ads: -------------------------------------------------------------------------------- 1 | pragma SPARK_Mode(On); 2 | 3 | with Message_Manager; 4 | 5 | package CubedOS.m0004 is 6 | 7 | ID : constant Message_Manager.Module_ID_Type := 1; 8 | 9 | end CubedOS.m0004; 10 | -------------------------------------------------------------------------------- /mercury/testData/CodeGeneration/message_manager.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : message_manager.adb 3 | -- SUBJECT : Package holding the mailboxes used by CubedOS message passing. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | pragma Profile(Ravenscar); 9 | pragma Partition_Elaboration_Policy(Sequential); 10 | 11 | with CubedOS.Generic_Message_Manager; 12 | pragma Elaborate_All(CubedOS.Generic_Message_Manager); 13 | 14 | package Message_Manager is 15 | new CubedOS.Generic_Message_Manager 16 | (Domain_Number => 1, 17 | Module_Count => 16, 18 | Mailbox_Size => 8, 19 | Maximum_Message_Size => 1024); 20 | -------------------------------------------------------------------------------- /mercury/testData/Semantics/0001.mxdr: -------------------------------------------------------------------------------- 1 | 2 | // Are double declarations detected? 3 | 4 | typedef int T1; 5 | typedef unsigned int T1; // Error! 6 | -------------------------------------------------------------------------------- /mercury/testData/Syntax/0002.mxdr: -------------------------------------------------------------------------------- 1 | 2 | // Constant declarations... 3 | 4 | const Minimum = -10; 5 | const Maximum = 10; 6 | const With_Sign = +10; 7 | 8 | // Currently Merc has no concept of constant expressions. Should it? 9 | //const X = 1 + 2; 10 | //const Y = X + 3; 11 | 12 | -------------------------------------------------------------------------------- /mercury/testData/Syntax/0003.mxdr: -------------------------------------------------------------------------------- 1 | 2 | // Enumeration declarations 3 | 4 | // Introducing enumeration types using special syntax (no typedef). 5 | enum X1 { A, B, C }; 6 | enum X2 { A }; 7 | enum X3 { A = 1, B = 2, C = 3 }; 8 | enum X4 { A = -1, B = -2, C = -3 }; 9 | 10 | // Introducing enumeration types using typedef. 11 | typedef enum { A, B, C } X1; 12 | typedef enum { A } X2; 13 | typedef enum { A = 1, B = 2, C = 3 } X3; 14 | typedef enum { A = -1, B = -2, C = -3 } X4; 15 | 16 | // Declaration members using anonymous enumeration types. 17 | struct S1 { 18 | enum { A, B, C } M1; 19 | enum { A } M2; 20 | enum { A = 1, B = 2, C = 3 } M3; 21 | enum { A = -1, B = -2, C = -3 } M4; 22 | }; 23 | 24 | // Using previously declaraed enumeration type names. 25 | struct S2 { 26 | X1 M1; 27 | X2 M2; 28 | X3 M3; 29 | X4 M4; 30 | }; 31 | -------------------------------------------------------------------------------- /mercury/testData/Syntax/0004.mxdr: -------------------------------------------------------------------------------- 1 | 2 | // Testing the Ada specific built-in types. 3 | 4 | // Using fully qualified names... 5 | typedef Ada.Real_Time.Time My_Time1; 6 | typedef Ada.Real_Time.Time_Span My_Time_Span1; 7 | 8 | struct S1FQ { 9 | Ada.Real_Time.Time T1; 10 | Ada.Real_Time.Time_Span T2; 11 | }; 12 | 13 | struct S2FQ { 14 | My_Time1 T1; 15 | My_Time_Span1 T2; 16 | }; 17 | 18 | // Using short names... 19 | typedef Time My_Time2; 20 | typedef Time_Span My_Time_Span2; 21 | 22 | struct S1S { 23 | Time T1; 24 | Time_Span T2; 25 | }; 26 | 27 | struct S2S { 28 | My_Time2 T1; 29 | My_Time_Span2 T2; 30 | }; 31 | -------------------------------------------------------------------------------- /mercury/testData/Syntax/0005.mxdr: -------------------------------------------------------------------------------- 1 | 2 | // Range constraints on type definitions. 3 | 4 | typedef int T1 range 1 .. 2; 5 | typedef int T2 range 1 .. T1'Last; 6 | typedef int T3 range -1 .. +1; 7 | 8 | // Merc currently doesn't support the use of 'First at the start of a range. 9 | // typedef int T4 range T1'First .. T1'Last; 10 | typedef int T5 is T1 range 1 .. 1; 11 | 12 | typedef int T6 is Natural range 0 .. 10; 13 | -------------------------------------------------------------------------------- /mercury/testData/Syntax/0006.mxdr: -------------------------------------------------------------------------------- 1 | 2 | message struct -> M_Request { 3 | int M1; 4 | int M2; 5 | } with Message_Invariant => (M1 = M2); 6 | 7 | message struct -> M_Request { 8 | int M1; 9 | int M2; 10 | } with Message_Invariant => (M1 /= M2); 11 | 12 | message struct -> M_Request { 13 | int M1; 14 | int M2; 15 | } with Message_Invariant => (M1 <= M2); 16 | 17 | message struct -> M_Request { 18 | int M1; 19 | int M2; 20 | } with Message_Invariant => (M1 >= M2); 21 | 22 | message struct -> M_Request { 23 | int M1; 24 | int M2; 25 | } with Message_Invariant => (M1 < M2); 26 | 27 | message struct -> M_Request { 28 | int M1; 29 | int M2; 30 | } with Message_Invariant => (M1 > M2); 31 | 32 | // Of course this makes no sense... it's just a syntax check! 33 | //message struct -> M_Request { 34 | // int M1; 35 | // int M2; 36 | //} with Message_Invariant => (M1 = M2 && 37 | // M1 /= M2 && 38 | // M1 <= M2 && 39 | // M1 < M2 && 40 | // (M1 >= M2 || 41 | // M1 > M2)); 42 | 43 | -------------------------------------------------------------------------------- /samples/BBB/README.md: -------------------------------------------------------------------------------- 1 | 2 | BBB Demo 3 | ======== 4 | 5 | This folder contains a CubedOS demonstration program for the BeagleBone Black. It is a copy of 6 | the echo client/server demo, except using the BBB as the target system. 7 | -------------------------------------------------------------------------------- /samples/BBB/bbbdemo.gpr: -------------------------------------------------------------------------------- 1 | project BBBdemo is 2 | 3 | for Languages use ("Ada"); 4 | -- for Runtime ("Ada") use "ravenscar-sfp-stm32f4"; 5 | for Target use "arm-linux-gnueabihf"; 6 | 7 | for Main use ("main.adb"); 8 | for Source_Dirs use ("./src", "../../src/modules", "../../src/library", "./src/mxdr"); 9 | for Object_Dir use "build"; 10 | 11 | package Builder is 12 | for Global_Configuration_Pragmas use "gnat.adc"; 13 | end Builder; 14 | 15 | package Compiler is 16 | for Default_Switches ("Ada") use ("-gnat2022", "-gnatW8", "-g", "-gnatwa"); 17 | end Compiler; 18 | 19 | -- package Ide is 20 | -- for Connection_Tool use "st-util"; 21 | -- for Program_Host use "localhost:4242"; 22 | -- for Communication_Protocol use "remote"; 23 | -- end Ide; 24 | 25 | package Check is 26 | for Default_Switches ("Ada") use ("-rules", "-from=../../src/cubedos-rules.txt"); 27 | end Check; 28 | 29 | end BBBdemo; 30 | 31 | -------------------------------------------------------------------------------- /samples/BBB/build/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/samples/BBB/build/.gitkeep -------------------------------------------------------------------------------- /samples/BBB/gnat.adc: -------------------------------------------------------------------------------- 1 | -- This file is used to ensure that the CubedOS core is Ravenscar and SPARKable. 2 | -- 3 | --pragma SPARK_Mode(On); 4 | pragma Profile(Jorvik); 5 | pragma Partition_Elaboration_Policy(Sequential); 6 | pragma Warnings(Off, "may call Last_Chance_Handler"); 7 | -------------------------------------------------------------------------------- /samples/BBB/src/echo_client-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : echo_client-messages.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the module. 4 | -- AUTHOR : (C) Copyright 2021 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with System; 8 | 9 | package Echo_Client.Messages is 10 | 11 | task Message_Loop is 12 | pragma Storage_Size(4 * 1024); 13 | pragma Priority(System.Default_Priority); 14 | end Message_Loop; 15 | 16 | end Echo_Client.Messages; 17 | -------------------------------------------------------------------------------- /samples/BBB/src/echo_client.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : echo_client.ads 3 | -- SUBJECT: Top level package of the echo client module. 4 | -- AUTHOR : (C) Copyright 2021 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with Message_Manager; 8 | 9 | package Echo_Client is 10 | ID : constant Message_Manager.Module_ID_Type := 5; 11 | end Echo_Client; 12 | -------------------------------------------------------------------------------- /samples/BBB/src/echo_server-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : echo_server-messages.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the module. 4 | -- AUTHOR : (C) Copyright 2021 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with System; 8 | 9 | package Echo_Server.Messages is 10 | 11 | task Message_Loop is 12 | pragma Storage_Size(4 * 1024); 13 | pragma Priority(System.Default_Priority); 14 | end Message_Loop; 15 | 16 | end Echo_Server.Messages; 17 | -------------------------------------------------------------------------------- /samples/BBB/src/echo_server.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : echo_server.ads 3 | -- SUBJECT: Top level package of the echo server module. 4 | -- AUTHOR : (C) Copyright 2021 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | 8 | with Message_Manager; 9 | 10 | package Echo_Server is 11 | ID : constant Message_Manager.Module_ID_Type := 6; 12 | end Echo_Server; 13 | -------------------------------------------------------------------------------- /samples/BBB/src/main.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : main.adb 3 | -- SUBJECT: Main program of the echo client/server CubedOS demonstration program. 4 | -- AUTHOR : (C) Copyright 2021 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with Ada.Real_Time; 8 | with System; 9 | 10 | -- Bring in the necessary modules, both from CubedOS and from this application. 11 | 12 | with Echo_Client.Messages; 13 | with Echo_Server.Messages; 14 | 15 | pragma Unreferenced(Echo_Client.Messages); 16 | pragma Unreferenced(Echo_Server.Messages); 17 | 18 | procedure Main is 19 | 20 | pragma Priority(System.Priority'First); 21 | use type Ada.Real_Time.Time; 22 | Next_Release : Ada.Real_Time.Time := Ada.Real_Time.Clock + Ada.Real_Time.Milliseconds(1000); 23 | begin 24 | -- This loop does nothing at the lowest priority. It spends most of its time sleeping. 25 | loop 26 | delay until Next_Release; 27 | Next_Release := Next_Release + Ada.Real_Time.Milliseconds(1000); 28 | return; 29 | end loop; 30 | end Main; 31 | -------------------------------------------------------------------------------- /samples/BBB/src/message_manager.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : message_manager.adb 3 | -- SUBJECT : Package holding the mailboxes used by CubedOS message passing. 4 | -- AUTHOR : (C) Copyright 2021 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with CubedOS.Generic_Message_Manager; 8 | pragma Elaborate_All(CubedOS.Generic_Message_Manager); 9 | 10 | package Message_Manager is 11 | new CubedOS.Generic_Message_Manager 12 | (Domain_Number => 1, 13 | Module_Count => 6, 14 | Mailbox_Size => 8, 15 | Maximum_Message_Size => 1024); 16 | -------------------------------------------------------------------------------- /samples/BBB/src/mxdr/.gitignore: -------------------------------------------------------------------------------- 1 | *.ads 2 | *.adb 3 | *.sh 4 | 5 | -------------------------------------------------------------------------------- /samples/NUCLEO-F446ZE/build/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/samples/NUCLEO-F446ZE/build/.gitkeep -------------------------------------------------------------------------------- /samples/NUCLEO-F446ZE/gnat.adc: -------------------------------------------------------------------------------- 1 | -- This file is used to ensure that the CubedOS core is Ravenscar and SPARKable. 2 | -- 3 | --pragma SPARK_Mode(On); 4 | pragma Profile(Jorvik); 5 | pragma Partition_Elaboration_Policy(Sequential); 6 | pragma Warnings(Off, "may call Last_Chance_Handler"); 7 | -------------------------------------------------------------------------------- /samples/NUCLEO-F446ZE/src/main.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : main.adb 3 | -- SUBJECT: Main program of the NUCLEO-F446ZE demonstration. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with System; 8 | 9 | -- Bring in the necessary modules, both from CubedOS and from this application. 10 | with CubedOS.Log_Server.Messages; 11 | with CubedOS.Time_Server.Messages; 12 | 13 | pragma Unreferenced(CubedOS.Log_Server.Messages); 14 | pragma Unreferenced(CubedOS.Time_Server.Messages); 15 | 16 | procedure Main is 17 | pragma Priority(System.Priority'First); 18 | begin 19 | null; 20 | end Main; 21 | -------------------------------------------------------------------------------- /samples/NUCLEO-F446ZE/src/message_manager.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : message_manager.adb 3 | -- SUBJECT : Package holding the mailboxes used by CubedOS message passing. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | 8 | with CubedOS.Generic_Message_Manager; 9 | 10 | package Message_Manager is 11 | new CubedOS.Generic_Message_Manager 12 | (Domain_Number => 1, 13 | Module_Count => 4, 14 | Mailbox_Size => 4, 15 | Maximum_Message_Size => 256); 16 | -------------------------------------------------------------------------------- /samples/NUCLEO-F446ZE/src/mxdr/.gitignore: -------------------------------------------------------------------------------- 1 | *.ads 2 | *.adb 3 | *.sh 4 | -------------------------------------------------------------------------------- /samples/NUCLEO-F446ZE/src/name_resolver.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : name_resolver.ads 3 | -- SUBJECT : Specification holding Domain IDs and Module IDs 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with Message_Manager; use Message_Manager; 8 | 9 | package Name_Resolver is 10 | 11 | -- Core Modules 12 | Log_Server : constant Message_Address := (0, 1); 13 | Time_Server : constant Message_Address := (0, 2); 14 | 15 | -- Application-Specific Modules 16 | 17 | end Name_Resolver; 18 | -------------------------------------------------------------------------------- /samples/NUCLEO-F446ZE/stmdemo.gpr: -------------------------------------------------------------------------------- 1 | project STMdemo is 2 | 3 | for Languages use ("Ada"); 4 | for Runtime ("Ada") use "light-tasking-stm32f4"; 5 | for Target use "arm-eabi"; 6 | 7 | for Main use ("main.adb"); 8 | for Source_Dirs use ("./src", "../../src/modules", "../../src/library", "./src/mxdr"); 9 | for Object_Dir use "build"; 10 | 11 | package Builder is 12 | for Global_Configuration_Pragmas use "gnat.adc"; 13 | end Builder; 14 | 15 | package Compiler is 16 | for Default_Switches ("Ada") use ("-gnat2022", "-gnatW8", "-g", "-gnatwa"); 17 | end Compiler; 18 | 19 | package Ide is 20 | for Connection_Tool use "st-util"; 21 | for Program_Host use "localhost:4242"; 22 | for Communication_Protocol use "remote"; 23 | end Ide; 24 | 25 | package Check is 26 | for Default_Switches ("Ada") use ("-rules", "-from=../../src/cubedos-rules.txt"); 27 | end Check; 28 | 29 | end STMdemo; 30 | -------------------------------------------------------------------------------- /samples/STM32F4/TODO.md: -------------------------------------------------------------------------------- 1 | 2 | TODO 3 | ==== 4 | 5 | This project should have a SPARK machine properties configuration file since the SPARK analysis 6 | needs to be done for a non-native processor. Specifically, the STM32F407VG processor on the 7 | board is a 32-bit ARM CPU. However, the development station is running a 64-bit processor. 8 | 9 | Showing how to configure SPARK in this setting is an essential part of this example, so this 10 | matter really needs to addressed! 11 | -------------------------------------------------------------------------------- /samples/STM32F4/build/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/samples/STM32F4/build/.gitkeep -------------------------------------------------------------------------------- /samples/STM32F4/gnat.adc: -------------------------------------------------------------------------------- 1 | -- This file is used to ensure that the CubedOS core is Ravenscar and SPARKable. 2 | -- 3 | --pragma SPARK_Mode(On); 4 | pragma Profile(Jorvik); 5 | pragma Partition_Elaboration_Policy(Sequential); 6 | pragma Warnings(Off, "may call Last_Chance_Handler"); 7 | -------------------------------------------------------------------------------- /samples/STM32F4/src/button_driver-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : button_driver-messages.ads 3 | -- SUBJECT: Specification of a package that implements the Button driver. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with System; 10 | 11 | package Button_Driver.Messages is 12 | 13 | pragma Elaborate_Body; 14 | 15 | task Message_Loop is 16 | -- pragma Storage_Size(4 * 1024); 17 | pragma Priority(System.Default_Priority); 18 | end Message_Loop; 19 | 20 | 21 | end Button_Driver.Messages; 22 | -------------------------------------------------------------------------------- /samples/STM32F4/src/button_driver.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : button_driver.ads 3 | -- SUBJECT: Top level package of a CubedOS Button driver for the STM32F4 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | pragma Warnings (Off, "unit ""Message_Manager"" is not referenced"); 10 | with Message_Manager; 11 | 12 | package Button_Driver is 13 | 14 | end Button_Driver; 15 | -------------------------------------------------------------------------------- /samples/STM32F4/src/control-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : control.ads 3 | -- SUBJECT: Specification of a package that implements the controller message loop. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with System; 10 | 11 | package Control.Messages is 12 | 13 | task Message_Loop is 14 | -- pragma Storage_Size(4 * 1024); 15 | pragma Priority(System.Default_Priority); 16 | end Message_Loop; 17 | 18 | end Control.Messages; 19 | -------------------------------------------------------------------------------- /samples/STM32F4/src/control.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : control.ads 3 | -- SUBJECT: Top level package of the STM demo controller module. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | pragma Warnings (Off, "unit ""Message_Manager"" is not referenced"); 10 | with Message_Manager; 11 | 12 | package Control is 13 | 14 | end Control; 15 | -------------------------------------------------------------------------------- /samples/STM32F4/src/led_driver-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : led_driver-messages.ads 3 | -- SUBJECT: Specification of a package that implements the LED driver. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with System; 10 | 11 | package LED_Driver.Messages is 12 | 13 | task Message_Loop is 14 | -- pragma Storage_Size(4 * 1024); 15 | pragma Priority(System.Default_Priority); 16 | end Message_Loop; 17 | 18 | end LED_Driver.Messages; 19 | -------------------------------------------------------------------------------- /samples/STM32F4/src/led_driver.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : led_driver.ads 3 | -- SUBJECT: Top level package of a CubedOS LED driver for the STM32F4 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | pragma Warnings (Off, "unit ""Message_Manager"" is not referenced"); 10 | with Message_Manager; 11 | 12 | package LED_Driver is 13 | type LED_Type is (Green, Orange, Red, Blue); 14 | end LED_Driver; 15 | -------------------------------------------------------------------------------- /samples/STM32F4/src/main.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : main.adb 3 | -- SUBJECT: Main program of the STM32F4 demonstration. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with System; 8 | 9 | -- Bring in the necessary modules, both from CubedOS and from this application. 10 | with CubedOS.Log_Server.Messages; 11 | with CubedOS.Publish_Subscribe_Server.Messages; 12 | with CubedOS.Time_Server.Messages; 13 | 14 | with LED_Driver.Messages; 15 | with Button_Driver.Messages; 16 | with Control.Messages; 17 | 18 | pragma Unreferenced(CubedOS.Log_Server.Messages); 19 | pragma Unreferenced(CubedOS.Publish_Subscribe_Server.Messages); 20 | pragma Unreferenced(CubedOS.Time_Server.Messages); 21 | 22 | pragma Unreferenced(LED_Driver.Messages); 23 | pragma Unreferenced(Button_Driver.Messages); 24 | pragma Unreferenced(Control.Messages); 25 | 26 | 27 | procedure Main is 28 | pragma Priority(System.Priority'First); 29 | begin 30 | null; 31 | end Main; 32 | -------------------------------------------------------------------------------- /samples/STM32F4/src/message_manager.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : message_manager.adb 3 | -- SUBJECT : Package holding the mailboxes used by CubedOS message passing. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | 8 | with CubedOS.Generic_Message_Manager; 9 | 10 | package Message_Manager is 11 | new CubedOS.Generic_Message_Manager 12 | (Domain_Number => 1, 13 | Module_Count => 6, 14 | Mailbox_Size => 4, 15 | Maximum_Message_Size => 256); 16 | -------------------------------------------------------------------------------- /samples/STM32F4/src/mxdr/.gitignore: -------------------------------------------------------------------------------- 1 | *.ads 2 | *.adb 3 | *.sh 4 | -------------------------------------------------------------------------------- /samples/STM32F4/src/mxdr/LED_Driver.mxdr: -------------------------------------------------------------------------------- 1 | // FILE: led_driver.mxdr 2 | // 3 | // The interface definition of the LED driver module. 4 | 5 | enum { Green, Orange, Red, Blue } LED_Type; 6 | 7 | // Request to turn an LED on. 8 | message struct -> On_Request { 9 | LED_Type LED; // The LED to turn on. 10 | }; 11 | 12 | 13 | // Request to turn an LED off. 14 | message struct -> Off_Request { 15 | LED_Type LED; // The LED to turn off. 16 | }; 17 | 18 | 19 | // Request to turn all LEDs on. 20 | message struct -> All_On_Request { 21 | void; 22 | }; 23 | 24 | 25 | // Request to turn all LEDs of. 26 | message struct -> All_Off_Request { 27 | void; 28 | }; 29 | 30 | -------------------------------------------------------------------------------- /samples/STM32F4/src/name_resolver.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : name_resolver.ads 3 | -- SUBJECT : Specification holding Domain IDs and Module IDs 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with Message_Manager; use Message_Manager; 8 | 9 | package Name_Resolver is 10 | 11 | -- Core Modules 12 | Log_Server : constant Message_Address := (0, 1); 13 | Publish_Subscribe_Server : constant Message_Address := (0, 2); 14 | Time_Server : constant Message_Address := (0, 3); 15 | 16 | -- Application-Specific Modules 17 | LED_Driver : constant Message_Address := (0, 4); 18 | Button_Driver : constant Message_Address := (0, 5); 19 | Control : constant Message_Address := (0, 6); 20 | 21 | end Name_Resolver; 22 | -------------------------------------------------------------------------------- /samples/STM32F4/stmdemo.gpr: -------------------------------------------------------------------------------- 1 | project STMdemo is 2 | 3 | for Languages use ("Ada"); 4 | for Runtime ("Ada") use "light-tasking-stm32f4"; 5 | for Target use "arm-eabi"; 6 | 7 | for Main use ("main.adb"); 8 | for Source_Dirs use ("./src", "../../src/modules", "../../src/library", "./src/mxdr"); 9 | for Object_Dir use "build"; 10 | 11 | package Builder is 12 | for Global_Configuration_Pragmas use "gnat.adc"; 13 | end Builder; 14 | 15 | package Compiler is 16 | for Default_Switches ("Ada") use ("-gnat2022", "-gnatW8", "-g", "-gnatwa"); 17 | end Compiler; 18 | 19 | package Ide is 20 | for Connection_Tool use "st-util"; 21 | for Program_Host use "localhost:4242"; 22 | for Communication_Protocol use "remote"; 23 | end Ide; 24 | 25 | package Check is 26 | for Default_Switches ("Ada") use ("-rules", "-from=../../src/cubedos-rules.txt"); 27 | end Check; 28 | 29 | end STMdemo; 30 | -------------------------------------------------------------------------------- /samples/TODO.md: -------------------------------------------------------------------------------- 1 | 2 | TODO 3 | ==== 4 | 5 | Here are some todo-items related to the sample programs. 6 | 7 | + The `BBB` sample is the `echo` sample executing on a BeagleBone Black (a Linux-based 8 | single-board computer). It has not been updated to reflect the architectural changes made for 9 | multi-domain support. Also, since it is intended to essentially be a duplicate of the `echo` 10 | sample, it should probably really be implemented as a new build scenario in the `echo` sample 11 | rather than as a separate sample of its own. 12 | 13 | + The `echo_alire` sample is intended to demonstrate the use of Alire as a build/packaging tool 14 | for CubedOS. Does it still work? Should we consider deleting it? We are very far from using 15 | Alire, but we would need to start somewhere. 16 | 17 | + The `line_rider` sample is in the process of being converted to the new architecture. Can we 18 | find any hardware to run this on to properly test it? Even once it is converted, it may not 19 | work at all. 20 | 21 | + The `moonshot` sample is our version of the tutorial application described in the 22 | documentation. 23 | 24 | + The `pathfinder` sample compiles and runs. It is intended to demonstrate priority inversion, 25 | but it hasn't been checked to see if that is really true. 26 | 27 | + The `STM32F4` sample compiles and runs on a target STM32F4DISCOVERY board. However, it doesn't 28 | work 100%. In particular, there is no response to pressing the "User" button. This might be a 29 | problem with the publish/subscribe server not forwarding button-press messages, but that is 30 | unclear. 31 | 32 | + The contents of the `tests` folder should be reviewed, moved, and eliminated. 33 | 34 | -------------------------------------------------------------------------------- /samples/build/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/samples/build/.gitkeep -------------------------------------------------------------------------------- /samples/echo/README.md: -------------------------------------------------------------------------------- 1 | 2 | Demo 3 | ==== 4 | 5 | This folder contains a CubedOS demonstration program consisting of two modules that trade 6 | messages back and forth (echo client/server modules). This is effectively the "Hello, World" 7 | program of message passing systems. 8 | 9 | This program is intended to be compiled for a conventional operating system such as Windows or 10 | Linux. It allows one to experiment with the CubedOS system in an environment that is a little 11 | easier to manipulate than an embedded environment. 12 | 13 | Notice that in this demonstration program there is no Echo_Client API. This is because only 14 | server modules define messages. In a realistic CubedOS application a module might play the role 15 | of both a client and a server. However, in that case it would only define messages related to 16 | its server role. 17 | -------------------------------------------------------------------------------- /samples/echo/build/.gitkeep: -------------------------------------------------------------------------------- 1 | This file exists to ensure that the enclosing folder is created. 2 | -------------------------------------------------------------------------------- /samples/echo/echo.gpr: -------------------------------------------------------------------------------- 1 | 2 | project Echo is 3 | for Main use ("main.adb"); 4 | for Object_Dir use "build"; 5 | for Source_Dirs use ("./src", "../../src/modules", "../../src/library", "./src/mxdr"); 6 | for Languages use ("Ada"); 7 | 8 | package Compiler is 9 | for Default_Switches ("ada") use ("-gnat2022", "-gnatW8", "-fstack-check", "-gnatwa", "-gnata", "-g"); 10 | end Compiler; 11 | 12 | package Check is 13 | for Default_Switches ("Ada") use ("-rules", "-from=../../src/cubedos-rules.txt"); 14 | end Check; 15 | 16 | end Echo; 17 | -------------------------------------------------------------------------------- /samples/echo/src/echo_client-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : echo_client-messages.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the module. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with System; 8 | 9 | package Echo_Client.Messages is 10 | 11 | task Message_Loop is 12 | pragma Storage_Size(4 * 1024); 13 | pragma Priority(System.Default_Priority); 14 | end Message_Loop; 15 | 16 | end Echo_Client.Messages; 17 | -------------------------------------------------------------------------------- /samples/echo/src/echo_client.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : echo_client.ads 3 | -- SUBJECT: Top level package of the echo client module. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma Warnings (Off, "unit ""Message_Manager"" is not referenced"); 8 | with Message_Manager; 9 | 10 | package Echo_Client is 11 | 12 | end Echo_Client; 13 | -------------------------------------------------------------------------------- /samples/echo/src/echo_server-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : echo_server-messages.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the module. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with System; 8 | 9 | package Echo_Server.Messages is 10 | 11 | task Message_Loop is 12 | pragma Storage_Size(4 * 1024); 13 | pragma Priority(System.Default_Priority); 14 | end Message_Loop; 15 | 16 | end Echo_Server.Messages; 17 | -------------------------------------------------------------------------------- /samples/echo/src/echo_server.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : echo_server.ads 3 | -- SUBJECT: Top level package of the echo server module. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma Warnings (Off, "unit ""Message_Manager"" is not referenced"); 8 | with Message_Manager; 9 | 10 | package Echo_Server is 11 | 12 | end Echo_Server; 13 | -------------------------------------------------------------------------------- /samples/echo/src/main.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : main.adb 3 | -- SUBJECT: Main program of the echo client/server CubedOS demonstration program. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with System; 8 | 9 | -- Bring in the necessary modules, both from CubedOS and from this application. 10 | 11 | with Echo_Client.Messages; 12 | with Echo_Server.Messages; 13 | with CubedOS.Log_Server.Messages; 14 | 15 | pragma Unreferenced(Echo_Client.Messages); 16 | pragma Unreferenced(Echo_Server.Messages); 17 | pragma Unreferenced(CubedOS.Log_Server.Messages); 18 | 19 | procedure Main is 20 | pragma Priority(System.Priority'First); 21 | begin 22 | null; 23 | end Main; 24 | -------------------------------------------------------------------------------- /samples/echo/src/message_manager.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : message_manager.adb 3 | -- SUBJECT : Package holding the mailboxes used by CubedOS message passing. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with CubedOS.Generic_Message_Manager; 8 | pragma Elaborate_All(CubedOS.Generic_Message_Manager); 9 | 10 | package Message_Manager is 11 | 12 | new CubedOS.Generic_Message_Manager 13 | (Domain_Number => 1, 14 | Module_Count => 3, 15 | Mailbox_Size => 8, 16 | Maximum_Message_Size => 512); 17 | -------------------------------------------------------------------------------- /samples/echo/src/mxdr/.gitignore: -------------------------------------------------------------------------------- 1 | *.ads 2 | *.adb 3 | *.sh 4 | 5 | -------------------------------------------------------------------------------- /samples/echo/src/mxdr/Echo_Server.mxdr: -------------------------------------------------------------------------------- 1 | // FILE: Echo_Server.mxdr 2 | 3 | enum {Success, Failure} Status_Type; 4 | 5 | message struct -> Ping_Request { 6 | void; 7 | }; 8 | 9 | message struct <- Ping_Reply { 10 | Status_Type Status; 11 | }; 12 | -------------------------------------------------------------------------------- /samples/echo/src/mxdr/Makefile: -------------------------------------------------------------------------------- 1 | MERCURY=../../../../bin/mercury.sh 2 | 3 | # List of generated specification files. 4 | all: echo_server-api.ads 5 | 6 | .PHONY: clean 7 | 8 | clean: 9 | rm -f *.ads *.adb 10 | 11 | echo_server-api.ads: Echo_Server.mxdr 12 | $(MERCURY) $^ 13 | -------------------------------------------------------------------------------- /samples/echo/src/name_resolver.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : name_resolver.ads 3 | -- SUBJECT : Specification holding Domain IDs and Module IDs 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with Message_Manager; use Message_Manager; 8 | 9 | package Name_Resolver is 10 | 11 | -- Core Modules 12 | Log_Server : constant Message_Address := (0, 3); 13 | 14 | -- Application-Specific Modules 15 | Echo_Client : constant Message_Address := (0, 1); 16 | Echo_Server : constant Message_Address := (0, 2); 17 | 18 | end Name_Resolver; 19 | -------------------------------------------------------------------------------- /samples/echo_alire/.gitignore: -------------------------------------------------------------------------------- 1 | /obj/ 2 | /bin/ 3 | /alire/ 4 | /config/ 5 | -------------------------------------------------------------------------------- /samples/echo_alire/README.md: -------------------------------------------------------------------------------- 1 | 2 | Demo 3 | ==== 4 | 5 | This folder contains an Alire executable crate configuration for the CubedOS Echo demonstration program. The Echo program consists of two modules that trade 6 | messages back and forth (echo client/server modules). This is effectively the "Hello, World" 7 | program of message passing systems. For more on the Echo program, see `samples/Echo`. 8 | 9 | This program is intended to be used with the Alire package manager. 10 | 11 | Setup 12 | ===== 13 | 14 | - install [Alire](https://alire.ada.dev/docs/#getting-started) 15 | - build and run the executable using `alr run` 16 | -------------------------------------------------------------------------------- /samples/echo_alire/alire.toml: -------------------------------------------------------------------------------- 1 | name = "echo" 2 | description = "Shiny new project" 3 | version = "0.1.0-dev" 4 | 5 | authors = ["Sevo"] 6 | maintainers = ["Sevo "] 7 | maintainers-logins = ["sevanbadal"] 8 | 9 | executables = ["echo"] 10 | -------------------------------------------------------------------------------- /samples/echo_alire/echo.gpr: -------------------------------------------------------------------------------- 1 | with "config/echo_config.gpr"; 2 | project Echo is 3 | 4 | for Source_Dirs use ("src", "config", "../../src/modules", "../../src/library", "./src/mxdr"); 5 | for Object_Dir use "obj/" & Echo_Config.Build_Profile; 6 | for Create_Missing_Dirs use "True"; 7 | for Exec_Dir use "bin"; 8 | for Main use ("echo.adb"); 9 | 10 | package Compiler is 11 | for Default_Switches ("Ada") use Echo_Config.Ada_Compiler_Switches; 12 | end Compiler; 13 | 14 | package Binder is 15 | for Switches ("Ada") use ("-Es"); -- Symbolic traceback 16 | end Binder; 17 | 18 | package Check is 19 | for Default_Switches ("Ada") use ("-rules", "-from=../../src/cubedos-rules.txt"); 20 | end Check; 21 | 22 | package Install is 23 | for Artifacts (".") use ("share"); 24 | end Install; 25 | 26 | end Echo; 27 | -------------------------------------------------------------------------------- /samples/echo_alire/src/echo.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : main.adb 3 | -- SUBJECT: Main program of the echo client/server CubedOS demonstration program. 4 | -- AUTHOR : (C) Copyright 2021 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with Ada.Real_Time; 8 | with System; 9 | 10 | -- Bring in the necessary modules, both from CubedOS and from this application. 11 | 12 | with Echo_Client.Messages; 13 | with Echo_Server.Messages; 14 | 15 | pragma Unreferenced(Echo_Client.Messages); 16 | pragma Unreferenced(Echo_Server.Messages); 17 | 18 | procedure Echo is 19 | 20 | pragma Priority(System.Priority'First); 21 | use type Ada.Real_Time.Time; 22 | Next_Release : Ada.Real_Time.Time := Ada.Real_Time.Clock + Ada.Real_Time.Milliseconds(1000); 23 | begin 24 | -- This loop does nothing at the lowest priority. It spends most of its time sleeping. 25 | loop 26 | delay until Next_Release; 27 | Next_Release := Next_Release + Ada.Real_Time.Milliseconds(1000); 28 | return; 29 | end loop; 30 | end Echo; 31 | -------------------------------------------------------------------------------- /samples/echo_alire/src/echo_client-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : echo_client-messages.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the module. 4 | -- AUTHOR : (C) Copyright 2021 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with System; 8 | 9 | package Echo_Client.Messages is 10 | 11 | task Message_Loop is 12 | pragma Storage_Size(4 * 1024); 13 | pragma Priority(System.Default_Priority); 14 | end Message_Loop; 15 | 16 | end Echo_Client.Messages; 17 | -------------------------------------------------------------------------------- /samples/echo_alire/src/echo_client.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : echo_client.ads 3 | -- SUBJECT: Top level package of the echo client module. 4 | -- AUTHOR : (C) Copyright 2021 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma Warnings (Off, "unit ""Message_Manager"" is not referenced"); 8 | with Message_Manager; 9 | 10 | package Echo_Client is 11 | 12 | end Echo_Client; 13 | -------------------------------------------------------------------------------- /samples/echo_alire/src/echo_server-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : echo_server-messages.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the module. 4 | -- AUTHOR : (C) Copyright 2021 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with System; 8 | 9 | package Echo_Server.Messages is 10 | 11 | task Message_Loop is 12 | pragma Storage_Size(4 * 1024); 13 | pragma Priority(System.Default_Priority); 14 | end Message_Loop; 15 | 16 | end Echo_Server.Messages; 17 | -------------------------------------------------------------------------------- /samples/echo_alire/src/echo_server.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : echo_server.ads 3 | -- SUBJECT: Top level package of the echo server module. 4 | -- AUTHOR : (C) Copyright 2021 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma Warnings (Off, "unit ""Message_Manager"" is not referenced"); 8 | with Message_Manager; 9 | 10 | package Echo_Server is 11 | 12 | end Echo_Server; 13 | -------------------------------------------------------------------------------- /samples/echo_alire/src/message_manager.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : message_manager.adb 3 | -- SUBJECT : Package holding the mailboxes used by CubedOS message passing. 4 | -- AUTHOR : (C) Copyright 2021 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with CubedOS.Generic_Message_Manager; 8 | pragma Elaborate_All(CubedOS.Generic_Message_Manager); 9 | 10 | package Message_Manager is 11 | new CubedOS.Generic_Message_Manager 12 | (Domain_Number => 1, 13 | Module_Count => 2, 14 | Mailbox_Size => 8, 15 | Maximum_Message_Size => 512); 16 | -------------------------------------------------------------------------------- /samples/echo_alire/src/mxdr/.gitignore: -------------------------------------------------------------------------------- 1 | *.sh 2 | *.adb 3 | *.ads 4 | -------------------------------------------------------------------------------- /samples/echo_alire/src/name_resolver.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : name_resolver.ads 3 | -- SUBJECT : Specification holding Domain IDs and Module IDs 4 | -- AUTHOR : (C) Copyright 2021 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with Message_Manager; use Message_Manager; 8 | 9 | package Name_Resolver is 10 | 11 | -- Core Modules 12 | 13 | -- Application-Specific Modules 14 | Echo_Client : constant Message_Address := (1,1); 15 | Echo_Server : constant Message_Address := (1,2); 16 | 17 | end Name_Resolver; 18 | -------------------------------------------------------------------------------- /samples/line_rider/README.md: -------------------------------------------------------------------------------- 1 | 2 | LineRider 3 | ========= 4 | 5 | This folder contains the Ada version of the LineRider program. 6 | -------------------------------------------------------------------------------- /samples/line_rider/build/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/samples/line_rider/build/.gitkeep -------------------------------------------------------------------------------- /samples/line_rider/gnat.adc: -------------------------------------------------------------------------------- 1 | pragma Profile(Ravenscar); 2 | pragma Partition_Elaboration_Policy(Sequential); 3 | pragma Warnings(Off, "pragma Restrictions (No_Exception_Propagation) in effect"); 4 | pragma Warnings(Off, """Constraint_Error"" may call Last_Chance_Handler"); 5 | -------------------------------------------------------------------------------- /samples/line_rider/line_rider.gpr: -------------------------------------------------------------------------------- 1 | project Line_Rider is 2 | 3 | for Languages use ("Ada"); 4 | for Runtime ("Ada") use "light-tasking-stm32f4"; 5 | for Target use "arm-eabi"; 6 | 7 | for Main use ("line_rider-main.adb"); 8 | for Source_Dirs use ("src", "../../src/modules", "../../src/library", "./src/mxdr"); 9 | for Object_Dir use "build"; 10 | 11 | package Builder is 12 | for Global_Configuration_Pragmas use "gnat.adc"; 13 | end Builder; 14 | 15 | package Compiler is 16 | for Default_Switches ("Ada") use ("-gnat2022", "-gnatW8", "-g", "-gnatwa", "-gnatQ"); 17 | end Compiler; 18 | 19 | package Ide is 20 | for Program_Host use "localhost:4242"; 21 | for Communication_Protocol use "remote"; 22 | end Ide; 23 | 24 | package Check is 25 | for Default_Switches ("Ada") use ("-rules", "-from=../../src/cubedos-rules.txt"); 26 | end Check; 27 | 28 | end Line_Rider; 29 | -------------------------------------------------------------------------------- /samples/line_rider/src/led_driver-internals.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : led_driver-internals.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the LED driver. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with Message_Manager; 10 | with Registers; 11 | 12 | use Message_Manager; 13 | 14 | private package LED_Driver.Internals is 15 | 16 | On_Message : constant Octet := 1; 17 | Off_Message : constant Octet := 2; 18 | All_On_Message : constant Octet := 3; 19 | All_Off_Message : constant Octet := 4; 20 | 21 | procedure Initialize 22 | with Global => (In_Out => (Registers.RCC, Registers.GPIOD)); 23 | 24 | procedure Process_Message(Incoming_Message : in Message_Record) 25 | with Global => (In_Out => Registers.GPIOD); 26 | 27 | end LED_Driver.Internals; 28 | -------------------------------------------------------------------------------- /samples/line_rider/src/led_driver-messages.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : led_driver-messages.adb 3 | -- SUBJECT: Body of the LED driver message handler package. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with LED_Driver.Internals; 8 | with Message_Manager; 9 | 10 | package body LED_Driver.Messages is 11 | 12 | task body Message_Loop is 13 | Incoming_Message : Message_Manager.Message_Record; 14 | begin 15 | -- Initialize the LEDs before trying to process any messages for them. 16 | Internals.Initialize; 17 | loop 18 | Message_Manager.Mailboxes(ID).Receive(Incoming_Message); 19 | Internals.Process_Message(Incoming_Message); 20 | end loop; 21 | end Message_Loop; 22 | 23 | end LED_Driver.Messages; 24 | -------------------------------------------------------------------------------- /samples/line_rider/src/led_driver-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : led_driver-messages.ads 3 | -- SUBJECT: Specification of the LED driver message handler package. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with System; 8 | 9 | package LED_Driver.Messages is 10 | 11 | task Message_Loop is 12 | pragma Storage_Size(4 * 1024); 13 | pragma Priority(System.Default_Priority); 14 | end Message_Loop; 15 | 16 | end LED_Driver.Messages; 17 | -------------------------------------------------------------------------------- /samples/line_rider/src/led_driver.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : led_driver.ads 3 | -- SUBJECT: Top level package of a CubedOS driver for the LEDs. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | pragma Warnings (Off, "unit ""Message_Manager"" is not referenced"); 10 | with Message_Manager; 11 | 12 | package LED_Driver is 13 | 14 | ID : constant Message_Manager.Module_ID := 5; 15 | 16 | end LED_Driver; 17 | -------------------------------------------------------------------------------- /samples/line_rider/src/line_rider-main.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : line_rider-main.adb 3 | -- SUBJECT: Main program of the Line Rider application. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with System; 8 | 9 | -- The "last chance handler" is the user-defined routine that is called when an exception tries 10 | -- to propagate. We need it in the executable, therefore it must be somewhere in the closure of 11 | -- the context clauses. 12 | -- 13 | with Last_Chance_Handler; pragma Unreferenced(Last_Chance_Handler); 14 | with Line_Rider.States; pragma Unreferenced(Line_Rider.States); 15 | with Sensor_Driver.API; pragma Unreferenced(Sensor_Driver.API); 16 | 17 | procedure Line_Rider.Main is 18 | pragma Priority(System.Priority'First); 19 | begin 20 | null; 21 | end Line_Rider.Main; 22 | -------------------------------------------------------------------------------- /samples/line_rider/src/line_rider-states.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : line_rider-states.ads 3 | -- SUBJECT: Specification of state machine package. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with System; 8 | 9 | package Line_Rider.States is 10 | 11 | task Controller is 12 | pragma Storage_Size(4 * 1024); 13 | pragma Priority(System.Default_Priority); 14 | end Controller; 15 | 16 | end Line_Rider.States; 17 | -------------------------------------------------------------------------------- /samples/line_rider/src/line_rider.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : line_rider.ads 3 | -- SUBJECT: Specification of application parent package. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | pragma Warnings (Off, "unit ""Message_Manager"" is not referenced"); 10 | with Message_Manager; 11 | 12 | package Line_Rider is 13 | 14 | end Line_Rider; 15 | -------------------------------------------------------------------------------- /samples/line_rider/src/message_manager.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : message_manager.adb 3 | -- SUBJECT : Package holding the mailboxes used by CubedOS message passing. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | 8 | with CubedOS.Generic_Message_Manager; 9 | 10 | package Message_Manager is 11 | new CubedOS.Generic_Message_Manager 12 | (Domain_Number => 1, 13 | Module_Count => 8, 14 | Mailbox_Size => 4, 15 | Maximum_Message_Size => 256); 16 | -------------------------------------------------------------------------------- /samples/line_rider/src/motor_driver-internals.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : motor_driver-internals.adb 3 | -- SUBJECT: Body of a package that implements the main part of the motor driver. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | 8 | package body Motor_Driver.Internals is 9 | 10 | procedure Initialize is 11 | begin 12 | null; 13 | end Initialize; 14 | 15 | 16 | procedure Process_Message(Incoming_Message : in Message_Manager.Message_Record) is 17 | begin 18 | null; 19 | end Process_Message; 20 | 21 | 22 | end Motor_Driver.Internals; 23 | -------------------------------------------------------------------------------- /samples/line_rider/src/motor_driver-internals.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : motor_driver-internals.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the motor driver. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with Message_Manager; 8 | 9 | private package Motor_Driver.Internals is 10 | 11 | procedure Initialize; 12 | 13 | procedure Process_Message(Incoming_Message : in Message_Manager.Message_Record); 14 | 15 | end Motor_Driver.Internals; 16 | -------------------------------------------------------------------------------- /samples/line_rider/src/motor_driver-messages.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : motor_driver-messages.adb 3 | -- SUBJECT: Body of the motor driver message handler package. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with Message_Manager; 8 | with Motor_Driver.Internals; 9 | 10 | package body Motor_Driver.Messages is 11 | 12 | task body Message_Loop is 13 | Incoming_Message : Message_Manager.Message_Record; 14 | begin 15 | -- Initialize the motors before trying to process any messages for them. 16 | Internals.Initialize; 17 | 18 | -- Process messages as they arrive. 19 | loop 20 | Message_Manager.Mailboxes(ID).Receive(Incoming_Message); 21 | Internals.Process_Message(Incoming_Message); 22 | end loop; 23 | end Message_Loop; 24 | 25 | end Motor_Driver.Messages; 26 | -------------------------------------------------------------------------------- /samples/line_rider/src/motor_driver-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : motor_driver-messages.ads 3 | -- SUBJECT: Specification of the motor driver message handler package. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with System; 8 | 9 | private package Motor_Driver.Messages is 10 | 11 | task Message_Loop is 12 | pragma Storage_Size(4 * 1024); 13 | pragma Priority(System.Default_Priority); 14 | end Message_Loop; 15 | 16 | end Motor_Driver.Messages; 17 | -------------------------------------------------------------------------------- /samples/line_rider/src/motor_driver.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : motor_driver.ads 3 | -- SUBJECT: Top level package of a CubedOS driver for the motors. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with Message_Manager; 10 | 11 | package Motor_Driver is 12 | 13 | ID : constant Message_Manager.Module_ID := 7; 14 | 15 | end Motor_Driver; 16 | -------------------------------------------------------------------------------- /samples/line_rider/src/mxdr/.gitignore: -------------------------------------------------------------------------------- 1 | *.ads 2 | *.adb 3 | *.sh 4 | -------------------------------------------------------------------------------- /samples/line_rider/src/mxdr/LED_Driver.mxdr: -------------------------------------------------------------------------------- 1 | // FILE: LED_Driver.mxdr 2 | // 3 | // This is the interface to the STM32F4 LED subsystem. There are four LEDs with colors as 4 | // indicated below. The driver can be asked to turn these LEDs on or off. There are no reply 5 | // messages from this module. 6 | 7 | enum LED_Type { Green, Orange, Red, Blue }; 8 | 9 | message struct -> On_Request { 10 | LED_Type LED; 11 | }; 12 | 13 | message struct -> Off_Request { 14 | LED_Type LED; 15 | }; 16 | 17 | message struct -> All_On_Request { 18 | void; 19 | }; 20 | 21 | message struct -> All_Off_Request { 22 | void; 23 | }; 24 | -------------------------------------------------------------------------------- /samples/line_rider/src/mxdr/led_driver-api.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : led_driver-api.ads 3 | -- SUBJECT: Specification of a package that simplifies use of the LED driver. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -- All the subprograms in this package must be task safe. They can be simultaneously called 7 | -- from multiple tasks. If possible, make every subprogram here a pure function. 8 | -- 9 | -------------------------------------------------------------------------------- 10 | pragma SPARK_Mode(On); 11 | 12 | with Message_Manager; 13 | 14 | use Message_Manager; 15 | 16 | package LED_Driver.API is 17 | 18 | type LED_Type is (Green, Orange, Red, Blue); 19 | 20 | -- Return a message for turning on the given LED. 21 | function Turn_On_Message(Sender : Module_ID; LED : LED_Type) return Message_Record 22 | with Global => null; 23 | 24 | -- Return a message for turning off the given LED. 25 | function Turn_Off_Message(Sender : Module_ID; LED : LED_Type) return Message_Record 26 | with Global => null; 27 | 28 | -- Return a message for turning on all LEDs. 29 | function Turn_On_All_Message(Sender : Module_ID) return Message_Record 30 | with Global => null; 31 | 32 | -- Return a message for turning off all LEDs. 33 | function Turn_Off_All_Message(Sender : Module_ID) return Message_Record 34 | with Global => null; 35 | 36 | end LED_Driver.API; 37 | -------------------------------------------------------------------------------- /samples/line_rider/src/mxdr/motor_driver-api.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : motor_driver-api.adb 3 | -- SUBJECT: Body of a package that simplifies use of the motor driver. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with Motor_Driver.Messages; 10 | pragma Unreferenced(Motor_Driver.Messages); 11 | 12 | package body Motor_Driver.API is 13 | 14 | function Drive_Straight_Message(Sender : Module_ID) return Message_Record is 15 | Message : Message_Record; 16 | begin 17 | Message.Sender := Sender; 18 | return Message; 19 | end Drive_Straight_Message; 20 | 21 | 22 | function Turn_Left_Message(Sender : Module_ID) return Message_Record is 23 | Message : Message_Record; 24 | begin 25 | Message.Sender := Sender; 26 | return Message; 27 | end Turn_Left_Message; 28 | 29 | 30 | function Turn_Right_Message(Sender : Module_ID) return Message_Record is 31 | Message : Message_Record; 32 | begin 33 | Message.Sender := Sender; 34 | return Message; 35 | end Turn_Right_Message; 36 | 37 | end Motor_Driver.API; 38 | -------------------------------------------------------------------------------- /samples/line_rider/src/mxdr/motor_driver-api.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : motor_driver-api.ads 3 | -- SUBJECT: Specification of a package that simplifies use of the motor driver. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -- All the subprograms in this package must be task safe. They can be simultaneously called 7 | -- from multiple tasks. If possible, make every subprogram here a pure function. 8 | -- 9 | -------------------------------------------------------------------------------- 10 | pragma SPARK_Mode(On); 11 | 12 | with Message_Manager; use Message_Manager; 13 | 14 | package Motor_Driver.API is 15 | 16 | type State_Type is (Off, On); 17 | 18 | -- Return a message that commands the motors to go straight data. 19 | function Drive_Straight_Message(Sender : Module_ID) return Message_Record 20 | with Global => null; 21 | 22 | -- Return a message that commands the motors to turn left. 23 | function Turn_Left_Message(Sender : Module_ID) return Message_Record 24 | with Global => null; 25 | 26 | -- Return a message that commands the motors to turn right. 27 | function Turn_Right_Message(Sender : Module_ID) return Message_Record 28 | with Global => null; 29 | 30 | end Motor_Driver.API; 31 | -------------------------------------------------------------------------------- /samples/line_rider/src/mxdr/sensor_driver-api.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : sensor_driver-api.adb 3 | -- SUBJECT: Body of a package that simplifies use of the sensor driver. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with Sensor_Driver.Messages; 10 | pragma Unreferenced(Sensor_Driver.Messages); 11 | 12 | package body Sensor_Driver.API is 13 | 14 | function Sensor_Data_Message(Sender : Module_ID) return Message_Record is 15 | Message : Message_Record; 16 | begin 17 | Message.Sender := Sender; 18 | return Message; 19 | end Sensor_Data_Message; 20 | 21 | end Sensor_Driver.API; 22 | -------------------------------------------------------------------------------- /samples/line_rider/src/mxdr/sensor_driver-api.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : sensor_driver-api.ads 3 | -- SUBJECT: Specification of a package that simplifies use of the sensor driver. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -- All the subprograms in this package must be task safe. They can be simultaneously called 7 | -- from multiple tasks. If possible, make every subprogram here a pure function. 8 | -- 9 | -------------------------------------------------------------------------------- 10 | pragma SPARK_Mode(On); 11 | 12 | with Message_Manager; use Message_Manager; 13 | 14 | package Sensor_Driver.API is 15 | 16 | type State_Type is (Off, On); 17 | 18 | -- Return a message containing sensor data. 19 | function Sensor_Data_Message(Sender : Module_ID_Type) return Message_Record 20 | with Global => null; 21 | 22 | end Sensor_Driver.API; 23 | -------------------------------------------------------------------------------- /samples/line_rider/src/name_resolver.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : name_resolver.ads 3 | -- SUBJECT : Specification holding Domain IDs and Module IDs 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with Message_Manager; use Message_Manager; 8 | 9 | package Name_Resolver is 10 | 11 | -- Core Modules 12 | Publish_Subscribe_Server : constant Message_Address := (0, 1); 13 | Time_Server : constant Message_Address := (0, 2); 14 | 15 | -- Application-Specific Modules 16 | LED_Driver : constant Message_Address := (0, 3); 17 | Motor_Driver : constant Message_Address := (0, 4); 18 | Sensor_Driver : constant Message_Address := (0, 6); 19 | Line_Rider : constant Message_Address := (0, 8); 20 | 21 | end Name_Resolver; 22 | -------------------------------------------------------------------------------- /samples/line_rider/src/sensor_driver-internals.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : sensor_driver-internals.adb 3 | -- SUBJECT: Body of a package that implements the main part of the sensor driver. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | 8 | package body Sensor_Driver.Internals is 9 | 10 | procedure Initialize is 11 | begin 12 | null; 13 | end Initialize; 14 | 15 | 16 | procedure Process_Message(Incoming_Message : in Message_Manager.Message_Record) is 17 | begin 18 | null; 19 | end Process_Message; 20 | 21 | 22 | end Sensor_Driver.Internals; 23 | -------------------------------------------------------------------------------- /samples/line_rider/src/sensor_driver-internals.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : sensor_driver-internals.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the sensor driver. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with Message_Manager; 8 | 9 | private package Sensor_Driver.Internals is 10 | 11 | procedure Initialize; 12 | 13 | procedure Process_Message(Incoming_Message : in Message_Manager.Message_Record); 14 | 15 | end Sensor_Driver.Internals; 16 | -------------------------------------------------------------------------------- /samples/line_rider/src/sensor_driver-messages.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : sensor_driver-messages.adb 3 | -- SUBJECT: Body of the sensor driver message handler package. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with CubedOS.Time_Server; 8 | with CubedOS.Time_Server.API; 9 | with Message_Manager; 10 | with Sensor_Driver.Internals; 11 | 12 | package body Sensor_Driver.Messages is 13 | 14 | task body Message_Loop is 15 | Incoming_Message : Message_Manager.Message_Record; 16 | begin 17 | -- Initialize the sensors before trying to process any messages for them. 18 | Internals.Initialize; 19 | 20 | -- Request a tick message every 100 ms. 21 | Message_Manager.Mailboxes(CubedOS.Time_Server.ID).Unchecked_Send 22 | (CubedOS.Time_Server.API.Periodic_Ticks_Message(ID, 100)); 23 | 24 | -- Process the tick messages as they arrive. 25 | loop 26 | Message_Manager.Mailboxes(ID).Receive(Incoming_Message); 27 | Internals.Process_Message(Incoming_Message); 28 | end loop; 29 | end Message_Loop; 30 | 31 | end Sensor_Driver.Messages; 32 | -------------------------------------------------------------------------------- /samples/line_rider/src/sensor_driver-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : sensor_driver-messages.ads 3 | -- SUBJECT: Specification of the sensor driver message handler package. 4 | -- AUTHOR : (C) Copyright 2015 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with System; 8 | 9 | private package Sensor_Driver.Messages is 10 | 11 | task Message_Loop is 12 | pragma Storage_Size(4 * 1024); 13 | pragma Priority(System.Default_Priority); 14 | end Message_Loop; 15 | 16 | end Sensor_Driver.Messages; 17 | -------------------------------------------------------------------------------- /samples/line_rider/src/sensor_driver.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : sensor_driver.ads 3 | -- SUBJECT: Top level package of a CubedOS driver for the sensors. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | pragma Warnings (Off, "unit ""Message_Manager"" is not referenced"); 10 | with Message_Manager; 11 | 12 | package Sensor_Driver is 13 | 14 | end Sensor_Driver; 15 | -------------------------------------------------------------------------------- /samples/moonshot/build/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/samples/moonshot/build/.gitkeep -------------------------------------------------------------------------------- /samples/moonshot/build/Image-Copernicus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/samples/moonshot/build/Image-Copernicus.jpg -------------------------------------------------------------------------------- /samples/moonshot/build/Image-Korolev.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/samples/moonshot/build/Image-Korolev.jpg -------------------------------------------------------------------------------- /samples/moonshot/moonshot.gpr: -------------------------------------------------------------------------------- 1 | 2 | project Moonshot is 3 | for Main use ("main.adb"); 4 | for Object_Dir use "build"; 5 | for Source_Dirs use ("./src", "../../src/modules", "../../src/library", "./src/mxdr"); 6 | for Languages use ("Ada"); 7 | 8 | package Compiler is 9 | for Default_Switches ("Ada") 10 | use ("-gnat2022", -- Use Ada 2022 11 | "-gnatW8", -- Enable UTF-8 source files 12 | "-fstack-check", -- Enable stack checking 13 | "-gnatwa", -- Enable all warnings 14 | "-gnata", -- Enable assertions 15 | "-g"); -- Enable debugging 16 | end Compiler; 17 | 18 | package Check is 19 | for Default_Switches ("Ada") use ("-rules", "-from=../../src/cubedos-rules.txt"); 20 | end Check; 21 | end Moonshot; 22 | -------------------------------------------------------------------------------- /samples/moonshot/src/camera-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : camera-messages.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the module. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with System; 10 | 11 | package Camera.Messages is 12 | 13 | task Message_Loop is 14 | pragma Priority(System.Default_Priority); 15 | end Message_Loop; 16 | 17 | end Camera.Messages; 18 | -------------------------------------------------------------------------------- /samples/moonshot/src/camera.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : Camera.ads 3 | -- SUBJECT: Top level package of a CubedOS Camera Module. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -------------------------------------------------------------------------------- 6 | pragma SPARK_Mode(On); 7 | 8 | package Camera is 9 | pragma Pure; 10 | end Camera; 11 | -------------------------------------------------------------------------------- /samples/moonshot/src/controller-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : controller-messages.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the module. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with System; 10 | 11 | package Controller.Messages is 12 | 13 | task Message_Loop is 14 | pragma Priority(System.Default_Priority); 15 | end Message_Loop; 16 | 17 | end Controller.Messages; 18 | -------------------------------------------------------------------------------- /samples/moonshot/src/controller.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : Controller.ads 3 | -- SUBJECT: Top level package of a CubedOS Controller. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | package Controller is 10 | pragma Pure; 11 | end Controller; 12 | -------------------------------------------------------------------------------- /samples/moonshot/src/main.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : main.adb 3 | -- SUBJECT: Main program of the Moonshot CubedOS tutorial application. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University. 5 | -- 6 | -------------------------------------------------------------------------------- 7 | 8 | -- Bring in the necessary modules, both from CubedOS and from this application. 9 | with CubedOS.Log_Server.Messages; 10 | with CubedOS.Time_Server.Messages; 11 | with CubedOS.File_Server.Messages; 12 | with CubedOS.Publish_Subscribe_Server.Messages; 13 | with Controller.Messages; 14 | with Camera.Messages; 15 | 16 | pragma Unreferenced(CubedOS.Log_Server.Messages); 17 | pragma Unreferenced(CubedOS.Time_Server.Messages); 18 | pragma Unreferenced(CubedOS.File_Server.Messages); 19 | pragma Unreferenced(CubedOS.Publish_Subscribe_Server.Messages); 20 | pragma Unreferenced(Controller.Messages); 21 | pragma Unreferenced(Camera.Messages); 22 | 23 | procedure Main is 24 | begin 25 | null; 26 | end Main; 27 | -------------------------------------------------------------------------------- /samples/moonshot/src/message_manager.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : message_manager.adb 3 | -- SUBJECT : Package holding the mailboxes used by CubedOS message passing. 4 | -- AUTHOR : (C) Copyright 2021 by Vermont State University. 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with CubedOS.Generic_Message_Manager; 8 | pragma Elaborate_All(CubedOS.Generic_Message_Manager); 9 | 10 | package Message_Manager is 11 | new CubedOS.Generic_Message_Manager 12 | (Domain_Number => 1, 13 | Module_Count => 8, 14 | Mailbox_Size => 8, 15 | Maximum_Message_Size => 1024); 16 | -------------------------------------------------------------------------------- /samples/moonshot/src/mxdr/.gitignore: -------------------------------------------------------------------------------- 1 | *.ads 2 | *.adb 3 | *.sh 4 | -------------------------------------------------------------------------------- /samples/moonshot/src/mxdr/Camera.mxdr: -------------------------------------------------------------------------------- 1 | // FILE: Camera.mxdr 2 | message struct -> Take_Image_Request { 3 | void; 4 | }; 5 | message struct <- Take_Image_Reply { 6 | string File_Name<128>; 7 | }; 8 | -------------------------------------------------------------------------------- /samples/moonshot/src/mxdr/Makefile: -------------------------------------------------------------------------------- 1 | 2 | # Adjust to reflect Mercury's location. 3 | MERCURY=../../../../bin/mercury.sh 4 | 5 | # List of generated specification files. 6 | all: camera-api.ads 7 | 8 | .PHONY: clean 9 | 10 | clean: 11 | rm -f *.ads *.adb 12 | 13 | camera-api.ads: Camera.mxdr 14 | $(MERCURY) $^ 15 | -------------------------------------------------------------------------------- /samples/moonshot/src/name_resolver.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : name_resolver.ads 3 | -- SUBJECT : Specification holding Domain IDs and Module IDs 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with Message_Manager; use Message_Manager; 8 | 9 | package Name_Resolver is 10 | 11 | -- Core Modules 12 | Log_Server : constant Message_Address := (0,5); 13 | Time_Server : constant Message_Address := (0,6); 14 | File_Server : constant Message_Address := (0,7); 15 | Publish_Subscribe_Server : constant Message_Address := (0,8); 16 | 17 | -- Application-Specific Modules 18 | Camera : constant Message_Address := (0,1); 19 | Radio : constant Message_Address := (0,2); 20 | -- Thruster : constant Message_Address := (0,3); 21 | Controller : constant Message_Address := (0,4); 22 | 23 | end Name_Resolver; 24 | -------------------------------------------------------------------------------- /samples/networking/Common/domainb_server.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : domainb_server.ads 3 | -- SUBJECT: Top level package of ... 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma Warnings(Off, "unit ""Message_Manager"" is not referenced"); 8 | with Message_Manager; 9 | 10 | package DomainB_Server is 11 | 12 | end DomainB_Server; 13 | -------------------------------------------------------------------------------- /samples/networking/Common/name_resolver.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : name_resolver.ads 3 | -- SUBJECT : Specification holding Domain IDs and Module IDs 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with Message_Manager; use Message_Manager; 8 | 9 | package Name_Resolver is 10 | 11 | -- Core Modules 12 | Name_Resolver : constant Module_ID_Type := 1; 13 | Network_Server : constant Module_ID_Type := 2; 14 | 15 | -- Application-Specific Modules 16 | DomainA_Client : constant Message_Address := (1, 3); 17 | DomainB_Server : constant Message_Address := (2, 3); 18 | 19 | Log_Server : constant Message_Address := (0, 3); 20 | Transport : constant Message_Address := (0, 4); 21 | 22 | end Name_Resolver; 23 | -------------------------------------------------------------------------------- /samples/networking/Common/network_configuration.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : network_configuration.adb 3 | -- SUBJECT : 4 | -- AUTHOR : (C) Copyright 2024 by State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | 8 | package body Network_Configuration is 9 | 10 | function Get_Address(Domain_ID : in Domain_ID_Type) return Inet_Addr_Type is 11 | Domain_Addr : Inet_Addr_Type; 12 | begin 13 | if Domain_ID = 1 then 14 | Domain_Addr := DomainA_Addr; 15 | elsif Domain_ID = 2 then 16 | Domain_Addr := DomainB_Addr; 17 | else 18 | Domain_Addr := Local_Host_Addr; 19 | end if; 20 | return Domain_Addr; 21 | end Get_Address; 22 | 23 | 24 | function Get_Port(Domain_ID : in Domain_ID_Type) return Port_Type is 25 | Port : Port_Type; 26 | begin 27 | if Domain_ID = 1 then 28 | Port := DomainA_Port; 29 | elsif Domain_ID = 2 then 30 | Port := DomainB_Port; 31 | else 32 | Port := Default_Port; 33 | end if; 34 | return Port; 35 | end Get_Port; 36 | 37 | end Network_Configuration; 38 | -------------------------------------------------------------------------------- /samples/networking/Common/network_configuration.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : network_configuration.ads 3 | -- SUBJECT : 4 | -- AUTHOR : (C) Copyright 2024 by State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with GNAT.Sockets; use GNAT.Sockets; 8 | with Message_Manager; use Message_Manager; 9 | 10 | package Network_Configuration is 11 | 12 | DomainA_Addr : Inet_Addr_Type := Inet_Addr ("127.0.0.1"); 13 | DomainB_Addr : Inet_Addr_Type := Inet_Addr("127.0.0.1"); 14 | Local_Host_Addr : Inet_Addr_Type := Inet_Addr("127.0.0.1"); 15 | 16 | DomainA_Port : Port_Type := 50000; 17 | DomainB_Port : Port_Type := 50001; 18 | Default_Port : Port_Type := 50000; 19 | 20 | function Get_Port(Domain_ID : in Domain_ID_Type) return Port_Type; 21 | 22 | function Get_Address(Domain_ID : in Domain_ID_Type) return Inet_Addr_Type; 23 | 24 | end Network_Configuration; 25 | -------------------------------------------------------------------------------- /samples/networking/DomainA/domaina_client-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : echo_client-messages.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the module. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with System; 8 | 9 | package DomainA_Client.Messages is 10 | 11 | task Message_Loop is 12 | -- pragma Storage_Size(4 * 1024); 13 | pragma Priority(System.Default_Priority); 14 | end Message_Loop; 15 | 16 | end DomainA_Client.Messages; 17 | -------------------------------------------------------------------------------- /samples/networking/DomainA/domaina_client.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : networking_client.ads 3 | -- SUBJECT: Top level package of the echo client module. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma Warnings(Off, "unit ""Message_Manager"" is not referenced"); 8 | with Message_Manager; 9 | 10 | package DomainA_Client is 11 | 12 | end DomainA_Client; 13 | -------------------------------------------------------------------------------- /samples/networking/DomainA/main.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : main.adb 3 | -- SUBJECT: Main program of the echo client/server CubedOS demonstration program. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with System; 8 | 9 | -- Bring in the necessary modules, both from CubedOS and from this application. 10 | with DomainA_Client.Messages; 11 | with CubedOS.Transport_UDP.Messages; 12 | with CubedOS.Log_Server.Messages; 13 | 14 | pragma Unreferenced(CubedOS.Log_Server.Messages); 15 | pragma Unreferenced(CubedOS.Transport_UDP.Messages); 16 | pragma Unreferenced(DomainA_Client.Messages); 17 | 18 | procedure Main is 19 | pragma Priority(System.Priority'First); 20 | begin 21 | null; 22 | end Main; 23 | -------------------------------------------------------------------------------- /samples/networking/DomainA/message_manager.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : message_manager.adb 3 | -- SUBJECT : Package holding the mailboxes used by CubedOS message passing. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with CubedOS.Generic_Message_Manager; 8 | pragma Elaborate_All(CubedOS.Generic_Message_Manager); 9 | 10 | package Message_Manager is 11 | new CubedOS.Generic_Message_Manager 12 | (Domain_Number => 1, 13 | Module_Count => 8, 14 | Mailbox_Size => 8, 15 | Maximum_Message_Size => 512); 16 | -------------------------------------------------------------------------------- /samples/networking/DomainB/domainb_server-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : networking_server-messages.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the module. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with System; 8 | 9 | package DomainB_Server.Messages is 10 | 11 | task Message_Loop is 12 | -- pragma Storage_Size(4 * 1024); 13 | pragma Priority(System.Default_Priority); 14 | end Message_Loop; 15 | 16 | end DomainB_Server.Messages; 17 | -------------------------------------------------------------------------------- /samples/networking/DomainB/main.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : main.adb 3 | -- SUBJECT: Main program of the echo client/server CubedOS demonstration program. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with System; 8 | 9 | -- Bring in the necessary modules, both from CubedOS and from this application. 10 | with DomainB_Server.Messages; 11 | with CubedOS.Transport_UDP.Messages; 12 | 13 | pragma Unreferenced(CubedOS.Transport_UDP.Messages); 14 | pragma Unreferenced(DomainB_Server.Messages); 15 | 16 | procedure Main is 17 | pragma Priority(System.Priority'First); 18 | begin 19 | null; 20 | end Main; 21 | -------------------------------------------------------------------------------- /samples/networking/DomainB/message_manager.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : message_manager.adb 3 | -- SUBJECT : Package holding the mailboxes used by CubedOS message passing. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with CubedOS.Generic_Message_Manager; 8 | pragma Elaborate_All(CubedOS.Generic_Message_Manager); 9 | 10 | package Message_Manager is 11 | new CubedOS.Generic_Message_Manager 12 | (Domain_Number => 2, 13 | Module_Count => 8, 14 | Mailbox_Size => 8, 15 | Maximum_Message_Size => 256); 16 | -------------------------------------------------------------------------------- /samples/networking/build/DomainA/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/samples/networking/build/DomainA/.gitkeep -------------------------------------------------------------------------------- /samples/networking/build/DomainB/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/samples/networking/build/DomainB/.gitkeep -------------------------------------------------------------------------------- /samples/networking/networking.gpr: -------------------------------------------------------------------------------- 1 | 2 | project Networking is 3 | type Program_Type is ("DomainA", "DomainB"); 4 | Program : Program_Type := external("BUILD", "DomainA"); 5 | 6 | case Program is 7 | when "DomainA" => 8 | for Main use ("main.adb"); 9 | for Object_Dir use "build/DomainA"; 10 | for Source_Dirs use ("DomainA", "Common", "../../src/modules", "../../src/library"); 11 | for Languages use ("Ada"); 12 | 13 | when "DomainB" => 14 | for Main use ("main.adb"); 15 | for Object_Dir use "build/DomainB"; 16 | for Source_Dirs use ("DomainB", "Common", "../../src/modules", "../../src/library"); 17 | for Languages use ("Ada"); 18 | end case; 19 | 20 | package Compiler is 21 | for Default_Switches ("ada") use ("-gnat2020", "-gnatW8", "-fstack-check", "-gnatwa", "-gnata", "-g"); 22 | end Compiler; 23 | 24 | package Check is 25 | for Default_Switches ("Ada") use ("-rules", "-from=../../src/cubedos-rules.txt"); 26 | end Check; 27 | 28 | end Networking; 29 | -------------------------------------------------------------------------------- /samples/pathfinder/Makefile: -------------------------------------------------------------------------------- 1 | VPATH = src build 2 | 3 | main: main.adb 4 | gprbuild 5 | 6 | .PHONY: clean 7 | clean: 8 | rm -rf build/* src/*~ 9 | gprclean 10 | -------------------------------------------------------------------------------- /samples/pathfinder/TODO.md: -------------------------------------------------------------------------------- 1 | 2 | TODO 3 | ==== 4 | 5 | + Verify that this application does, in fact, demonstrate priority inversion. 6 | 7 | + Use the log server for all informational messages. 8 | 9 | + Use the log server to report unexpected messages received by each module. 10 | 11 | + Improve names. Many are too abbreviated. 12 | 13 | + Flesh out the description of this sample in the main documentation. 14 | -------------------------------------------------------------------------------- /samples/pathfinder/build/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/samples/pathfinder/build/.gitkeep -------------------------------------------------------------------------------- /samples/pathfinder/gnat.adc: -------------------------------------------------------------------------------- 1 | -- This file is used to ensure that the code is Jorvik and SPARKable by default. 2 | -- 3 | -- Note that SPARK_Mode is set in the individual files. Not all sources are in SPARK. 4 | --pragma SPARK_Mode(On); 5 | 6 | pragma Profile(Jorvik); 7 | pragma Partition_Elaboration_Policy(Sequential); 8 | --pragma Warnings(Off, "may call Last_Chance_Handler"); 9 | -------------------------------------------------------------------------------- /samples/pathfinder/pathfinder.gpr: -------------------------------------------------------------------------------- 1 | 2 | project Pathfinder is 3 | 4 | for Main use ("main.adb"); 5 | for Object_Dir use "build"; 6 | for Source_Dirs use ("src/", "../../src/modules", "../../src/library", "./src/mxdr"); 7 | for Languages use ("Ada"); 8 | 9 | package Compiler is 10 | for Default_Switches ("ada") use ("-gnat2022", "-gnatW8", "-fstack-check", "-gnatwa", "-gnata", "-g"); 11 | end Compiler; 12 | 13 | package Builder is 14 | for Global_Configuration_Pragmas use "gnat.adc"; 15 | end Builder; 16 | 17 | package Check is 18 | for Default_Switches ("Ada") use ("-rules", "-from=../../src/cubedos-rules.txt"); 19 | end Check; 20 | 21 | end Pathfinder; 22 | -------------------------------------------------------------------------------- /samples/pathfinder/src/fibonacci.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : fibonacci.adb 3 | -- SUBJECT: 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | 8 | package body Fibonacci is 9 | 10 | function Gen_Recursive(N : in Fib_Seed) return Natural is 11 | Return_Value : Natural; 12 | begin 13 | if N = 0 or N = 1 then 14 | Return_Value := Natural(N); 15 | else 16 | Return_Value := Gen_Recursive(N - 1) + Gen_Recursive(N - 2); 17 | end if; 18 | return Return_Value; 19 | end Gen_Recursive; 20 | 21 | 22 | function Gen_Dynamic(N : in Fib_Seed) return Natural is 23 | Fib : array (0 .. N + 1) of Natural; 24 | begin 25 | Fib(0) := 0; 26 | Fib(1) := 1; 27 | 28 | for I in 2 .. N loop 29 | Fib(I) := Fib(I - 1) + Fib(I - 2); 30 | end loop; 31 | 32 | return Fib(N); 33 | end Gen_Dynamic; 34 | 35 | 36 | function Gen_Slowest(N : in Fib_Seed) return Natural is 37 | Fib_Num : Natural; 38 | Current_Seed : Fib_Seed; 39 | begin 40 | for I in 0 .. Natural(N) loop 41 | Current_Seed := Fib_Seed(I); 42 | Fib_Num := Gen_Recursive(Current_Seed); 43 | end loop; 44 | 45 | return Fib_Num; 46 | end Gen_Slowest; 47 | 48 | end Fibonacci; 49 | -------------------------------------------------------------------------------- /samples/pathfinder/src/fibonacci.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : fibonacci.ads 3 | -- SUBJECT: 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | 8 | package Fibonacci is 9 | 10 | type Fib_Seed is range 0 .. 46; 11 | 12 | function Gen_Recursive(N : in Fib_Seed) return Natural; 13 | function Gen_Dynamic (N : in Fib_Seed) return Natural; 14 | function Gen_Slowest (N : in Fib_Seed) return Natural; 15 | 16 | end Fibonacci; 17 | -------------------------------------------------------------------------------- /samples/pathfinder/src/main.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : main.adb 3 | -- SUBJECT: Main program of the Priority Inversion/Inhertiance demonstration program. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with System; 8 | 9 | -- Bring in the necessary modules, both from CubedOS and from this application. 10 | with CubedOS.Log_Server.Messages; 11 | with Random_Number_Generator.Messages; 12 | with Read_Number.Messages; 13 | with System_Bus.Messages; 14 | with Telemetry.Messages; 15 | 16 | pragma Unreferenced(CubedOS.Log_Server.Messages); 17 | pragma Unreferenced(Random_Number_Generator.Messages); 18 | pragma Unreferenced(Read_Number.Messages); 19 | pragma Unreferenced(System_Bus.Messages); 20 | pragma Unreferenced(Telemetry.Messages); 21 | 22 | procedure Main with 23 | Priority => System.Priority'First 24 | is 25 | begin 26 | null; 27 | end Main; 28 | -------------------------------------------------------------------------------- /samples/pathfinder/src/message_manager.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : message_manager.adb 3 | -- SUBJECT : Package holding the mailboxes used by CubedOS message passing. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with CubedOS.Generic_Message_Manager; 10 | pragma Elaborate_All(CubedOS.Generic_Message_Manager); 11 | 12 | package Message_Manager is new CubedOS.Generic_Message_Manager 13 | (Domain_Number => 1, 14 | Module_Count => 7, 15 | Mailbox_Size => 8, 16 | Maximum_Message_Size => 256); 17 | -------------------------------------------------------------------------------- /samples/pathfinder/src/mxdr/.gitignore: -------------------------------------------------------------------------------- 1 | *.ads 2 | *.adb 3 | *.sh 4 | 5 | -------------------------------------------------------------------------------- /samples/pathfinder/src/mxdr/telemetry-api.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : telemetry-api.adb 3 | -- SUBJECT: Body of a package that simplifies use of the module. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | package body Telemetry.API is 10 | 11 | function Telemetry_Encode 12 | (Sender_Address : in Message_Address; 13 | Request_ID : in Request_ID_Type; 14 | Priority : in System.Priority := Pri) return Message_Record 15 | is 16 | Message : constant Message_Record := 17 | Make_Empty_Message 18 | (Sender_Address, 19 | Name_Resolver.Telemetry, 20 | Request_ID, 21 | Message_Type'Pos(Telemetry_Request), 22 | Priority); 23 | begin 24 | return Message; 25 | end Telemetry_Encode; 26 | 27 | end Telemetry.API; 28 | -------------------------------------------------------------------------------- /samples/pathfinder/src/mxdr/telemetry-api.ads: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------------ 2 | -- FILE : telemetry-api.ads 3 | -- SUBJECT: Specification of a package that simplifies use of the module. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | ------------------------------------------------------------------------------ 7 | pragma SPARK_Mode(On); 8 | 9 | with Message_Manager; use Message_Manager; 10 | with Name_Resolver; 11 | with System; 12 | 13 | package Telemetry.API is 14 | 15 | type Status_Type is (Success, Failure); 16 | type Message_Type is (Telemetry_Request); 17 | 18 | function Telemetry_Encode 19 | (Sender_Address : in Message_Address; 20 | Request_ID : in Request_ID_Type; 21 | Priority : in System.Priority := Pri) return Message_Record 22 | with 23 | Global => null; 24 | 25 | function Is_Telemetry_Request(Message : in Message_Record) return Boolean is 26 | (Message.Receiver_Address = Name_Resolver.Telemetry and 27 | Message.Message_ID = Message_Type'Pos(Telemetry_Request)); 28 | 29 | -- No decoder is necessary for Telemetry_Request. The existence of the message itself is all that is needed. 30 | 31 | end Telemetry.API; 32 | -------------------------------------------------------------------------------- /samples/pathfinder/src/name_resolver.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : name_resolver.ads 3 | -- SUBJECT : Specification of a package holding Domain IDs and Module IDs 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with Message_Manager; use Message_Manager; 10 | 11 | package Name_Resolver is 12 | 13 | -- Core Modules. 14 | -- Declarations that are commented out are for currently unimplemented core modules. 15 | 16 | -- Note that the "Name_Resolver" module is reserved for a dynamic name resolver, 17 | -- which may never get implemented depending on how well this static system works! 18 | -- Network_Server is also has a reserved module ID (for now). 19 | 20 | Name_Resolver : constant Module_ID_Type := 1; 21 | Network_Server : constant Module_ID_Type := 2; 22 | Log_Server : constant Message_Address := (0, 3); 23 | 24 | -- Application-Specific Modules. 25 | -- Make up names as you see fit (typically the same as your module's top level package). 26 | -- Be sure there are no duplicate (Domain_ID, Module_ID) pairs. 27 | 28 | Random_Number_Generator : constant Message_Address := (0, 4); 29 | Read_Number : constant Message_Address := (0, 5); 30 | System_Bus : constant Message_Address := (0, 6); 31 | Telemetry : constant Message_Address := (0, 7); 32 | 33 | end Name_Resolver; 34 | -------------------------------------------------------------------------------- /samples/pathfinder/src/pnumbers.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : pnumbers.adb 3 | -- SUBJECT: 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with Ada.Numerics.Discrete_Random; 8 | 9 | package body PNumbers is 10 | 11 | package Random_Integer is new Ada.Numerics.Discrete_Random(Random_Range); 12 | 13 | Number_Generator : Random_Integer.Generator; 14 | 15 | function Get_Random_Number return Positive is 16 | Value : Random_Range; 17 | begin 18 | Value := Random_Integer.Random(Number_Generator); 19 | return Positive(Value); 20 | end Get_Random_Number; 21 | 22 | begin -- PNumbers 23 | Random_Integer.Reset(Number_Generator); 24 | end PNumbers; 25 | -------------------------------------------------------------------------------- /samples/pathfinder/src/pnumbers.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : pnumbers.ads 3 | -- SUBJECT: 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | 8 | package PNumbers is 9 | 10 | type Random_Range is range 1 .. 100; 11 | 12 | function Get_Random_Number return Positive; 13 | 14 | end PNumbers; 15 | -------------------------------------------------------------------------------- /samples/pathfinder/src/random_number_generator-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : random_number_generator-messages.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the module. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | package Random_Number_Generator.Messages is 10 | 11 | task Message_Loop with 12 | Priority => Pri, 13 | CPU => CPU_Number 14 | is 15 | -- pragma Storage_Size (4 * 1_024); 16 | end Message_Loop; 17 | 18 | end Random_Number_Generator.Messages; 19 | -------------------------------------------------------------------------------- /samples/pathfinder/src/random_number_generator.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : random_number_generator.ads 3 | -- SUBJECT: Top level package of a CubedOS Random Number Generator. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with Message_Manager; 10 | with System; 11 | with System.Multiprocessors; 12 | with Fibonacci; 13 | with System_Bus; 14 | 15 | package Random_Number_Generator is 16 | use type Fibonacci.Fib_Seed; 17 | 18 | R_ID : constant Message_Manager.Request_ID_Type := 101; 19 | Fibonacci_Seed : constant Fibonacci.Fib_Seed := System_Bus.Fibonacci_Seed + 3; 20 | Pri : constant System.Priority := 10; 21 | CPU_Number : constant System.Multiprocessors.CPU_Range := System.Multiprocessors.CPU'First; 22 | 23 | end Random_Number_Generator; 24 | -------------------------------------------------------------------------------- /samples/pathfinder/src/read_number-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : Read_Number-messages.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the module. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | package Read_Number.Messages is 10 | 11 | task Message_Loop with 12 | Priority => Pri, 13 | CPU => CPU_Number 14 | is 15 | -- pragma Storage_Size (4 * 1_024); 16 | end Message_Loop; 17 | 18 | end Read_Number.Messages; 19 | -------------------------------------------------------------------------------- /samples/pathfinder/src/read_number.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : Read_Number.ads 3 | -- SUBJECT: Top level package of a CubedOS Random Number Generator. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with Message_Manager; 10 | with System; 11 | with System.Multiprocessors; 12 | with Fibonacci; 13 | with System_Bus; 14 | 15 | package Read_Number is 16 | use type Fibonacci.Fib_Seed; 17 | 18 | R_ID : constant Message_Manager.Request_ID_Type := 103; 19 | Fibonacci_Seed : constant Fibonacci.Fib_Seed := System_Bus.Fibonacci_Seed + 1; 20 | Pri : constant System.Priority := 30; 21 | CPU_Number : constant System.Multiprocessors.CPU_Range := System.Multiprocessors.CPU'First; 22 | 23 | end Read_Number; 24 | -------------------------------------------------------------------------------- /samples/pathfinder/src/system_bus-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : SAMPLE_MODULE-messages.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the module. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | package System_Bus.Messages is 10 | 11 | task Message_Loop with 12 | Priority => Pri, 13 | CPU => CPU_Number 14 | is 15 | -- pragma Storage_Size (4 * 1_024); 16 | end Message_Loop; 17 | 18 | end System_Bus.Messages; 19 | -------------------------------------------------------------------------------- /samples/pathfinder/src/system_bus.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : system_bus.ads 3 | -- SUBJECT: Top level package of a CubedOS SAMPLE MODULE. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -- System_Bus is intended to be the main interface for the Pathfinder sample program. 7 | -------------------------------------------------------------------------------- 8 | pragma SPARK_Mode(On); 9 | 10 | with Message_Manager; 11 | with System; 12 | with System.Multiprocessors; 13 | with Fibonacci; 14 | 15 | package System_Bus is 16 | 17 | R_ID : constant Message_Manager.Request_ID_Type := 104; 18 | Fibonacci_Seed : constant Fibonacci.Fib_Seed := 37; 19 | Pri : constant System.Priority := 40; 20 | CPU_Number : constant System.Multiprocessors.CPU_Range := System.Multiprocessors.CPU'First; 21 | 22 | end System_Bus; 23 | -------------------------------------------------------------------------------- /samples/pathfinder/src/telemetry-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : telemetry-messages.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the module. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | package Telemetry.Messages is 10 | 11 | task Message_Loop 12 | with 13 | Priority => Pri, 14 | CPU => CPU_Number 15 | is 16 | -- pragma Storage_Size(4 * 1_024); 17 | end Message_Loop; 18 | 19 | end Telemetry.Messages; 20 | -------------------------------------------------------------------------------- /samples/pathfinder/src/telemetry.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : Telemetry.ads 3 | -- SUBJECT: Top level package of a CubedOS Random Number Generator. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with Message_Manager; 10 | with System; 11 | with System.Multiprocessors; 12 | with Fibonacci; 13 | with System_Bus; 14 | 15 | package Telemetry is 16 | use type Fibonacci.Fib_Seed; 17 | 18 | R_ID : constant Message_Manager.Request_ID_Type := 102; 19 | Fibonacci_Seed : constant Fibonacci.Fib_Seed := System_Bus.Fibonacci_Seed + 2; 20 | Pri : constant System.Priority := 20; 21 | CPU_Number : constant System.Multiprocessors.CPU_Range := System.Multiprocessors.CPU'First; 22 | 23 | end Telemetry; 24 | -------------------------------------------------------------------------------- /samples/samples.gpr: -------------------------------------------------------------------------------- 1 | aggregate project Samples is 2 | 3 | for Project_Files use ( 4 | "echo/echo.gpr", 5 | "moonshot/moonshot.gpr", 6 | "networking/networking.gpr", 7 | "NUCLEO-F446ZE/stmdemo.gpr", 8 | "pathfinder/pathfinder.gpr", 9 | "STM32F4/stmdemo.gpr"); 10 | 11 | for Object_Dir use "build"; 12 | 13 | end Samples; 14 | -------------------------------------------------------------------------------- /samples/tests/main_sorters.adb: -------------------------------------------------------------------------------- 1 | pragma SPARK_Mode(On); 2 | 3 | with Ada.Text_IO; 4 | with Ada.Integer_Text_IO; 5 | with CubedOS.Lib.Sorters; 6 | use Ada.Text_Io; 7 | use Ada.Integer_Text_Io; 8 | 9 | procedure Main_Sorters is 10 | 11 | 12 | type Integer_Array is array(Positive range <>) of Integer; 13 | package Integer_Sorters is new CubedOS.Lib.Sorters 14 | (Element_Type => Integer, Array_Type => Integer_Array); 15 | 16 | -- Create a test array. 17 | Test_Array1 : Integer_Array(1 .. 10) := (9, 12, 7, 3, 5, 4, 3, 0, 1, 0); 18 | Test_Array2 : Integer_Array(1 .. 10) := (7, 2, 3, 5, 6, 7, 8, 12, 13, 15); 19 | begin 20 | -- Sort the test array. 21 | Integer_Sorters.Insertion_Sort(Test_Array1); 22 | Integer_Sorters.Insertion_Sort(Test_Array2); 23 | 24 | -- Print the results. 25 | for I in Test_Array1'Range loop 26 | Put("Test_Array1("); Put(I); Put(") = "); Put(Test_Array1(I)); New_Line; 27 | end loop; 28 | New_Line; 29 | for I in Test_Array2'Range loop 30 | Put("Test_Array2("); Put(I); Put(") = "); Put(Test_Array2(I)); New_Line; 31 | end loop; 32 | 33 | end Main_Sorters; 34 | -------------------------------------------------------------------------------- /scriptbuilder/.gitignore: -------------------------------------------------------------------------------- 1 | venv 2 | scripter/parser 3 | 4 | -------------------------------------------------------------------------------- /scriptbuilder/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /scriptbuilder/.idea/ScriptBuilder.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /scriptbuilder/.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /scriptbuilder/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /scriptbuilder/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /scriptbuilder/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /scriptbuilder/bin/antlr4: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | java -jar /usr/local/lib/antlr-4.13.1-complete.jar $* 4 | -------------------------------------------------------------------------------- /scriptbuilder/bin/generate-parser: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script is intended to be run in the root folder of the project. 4 | # TODO: Add a test to check the above condition. 5 | 6 | cd scripter/parser 7 | ../../bin/antlr4 -Dlanguage=Python3 MXDR.g4 -visitor 8 | -------------------------------------------------------------------------------- /scriptbuilder/bin/grun: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export CLASSPATH=".:/usr/local/lib/antlr-4.9.3-complete.jar:$CLASSPATH" 4 | java org.antlr.v4.gui.TestRig $* 5 | -------------------------------------------------------------------------------- /scriptbuilder/docs/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/scriptbuilder/docs/.gitkeep -------------------------------------------------------------------------------- /scriptbuilder/requirements.txt: -------------------------------------------------------------------------------- 1 | antlr4-python3-runtime==4.13.1 2 | -------------------------------------------------------------------------------- /scriptbuilder/scripter/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/scriptbuilder/scripter/__init__.py -------------------------------------------------------------------------------- /scriptbuilder/scripter/address.py: -------------------------------------------------------------------------------- 1 | class Address: 2 | pass 3 | -------------------------------------------------------------------------------- /scriptbuilder/scripter/args.py: -------------------------------------------------------------------------------- 1 | class Args: 2 | pass 3 | -------------------------------------------------------------------------------- /scriptbuilder/scripter/cos_module.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/scriptbuilder/scripter/cos_module.py -------------------------------------------------------------------------------- /scriptbuilder/scripter/cubedos_time.py: -------------------------------------------------------------------------------- 1 | class CubedOSTime: 2 | pass 3 | -------------------------------------------------------------------------------- /scriptbuilder/scripter/main.py: -------------------------------------------------------------------------------- 1 | 2 | # This is just a sample of how to use the ANTLR generated MXDR parser. 3 | # It is assumed this material will get moved elsewhere at some point. 4 | 5 | import sys # For later 6 | import tkinter # For later 7 | from antlr4 import * 8 | from parser.MXDRLexer import MXDRLexer 9 | from parser.MXDRParser import MXDRParser 10 | from parser.MXDRVisitor import MXDRVisitor 11 | 12 | data = InputStream(input(">>> ")) # Get from a file eventually. 13 | lexer = MXDRLexer(data) # Create a lexer object. 14 | stream = CommonTokenStream(lexer) # Create a token stream using the lexer. 15 | parser = MXDRParser(stream) # Create a parser from the token stream. 16 | tree = parser.specification() # Parse using "specification" as the start symbol. 17 | visitor = MXDRVisitor() # Create a visitor object. 18 | output = visitor.visit(tree) # Vist the parse tree to process it. 19 | print(output) # Print the overall result. 20 | -------------------------------------------------------------------------------- /scriptbuilder/tests/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/scriptbuilder/tests/.gitkeep -------------------------------------------------------------------------------- /src/.vscode/ltex.dictionary.en-US.txt: -------------------------------------------------------------------------------- 1 | CubedOS 2 | AdaCore 3 | Alire 4 | VSCode 5 | GNATstudio 6 | ScriptBuilder 7 | subdocument 8 | subdocuments 9 | Skynet 10 | -------------------------------------------------------------------------------- /src/README.md: -------------------------------------------------------------------------------- 1 | 2 | README 3 | ====== 4 | 5 | This folder contains the CubedOS core modules, supporting library packages, and test programs 6 | for the same. The additional files are as follows: 7 | 8 | + `cubedos.aru`. This is a configuration file for the AdaControl style checker. We are not 9 | currently using AdaControl. This file is being retained for historic reasons and to facilitate 10 | using AdaControl in the future if we decide to do that. 11 | 12 | + `cubedos-casing-exceptions.txt`. This file contains exceptions to the casing rules when 13 | forming identifiers. It used by `gnatcheck`. 14 | 15 | + `cubedos.gpr`. The GNAT project file that controls the build of the core modules, library, and 16 | test programs. 17 | 18 | + `cubedos.hdr`. This is the standard header that appears on all CubedOS source files. It is 19 | used by AdaControl. 20 | 21 | + `cubedos-rules.txt`. This is the rules file used by `gnatcheck` to check the style of CubedOS 22 | code. 23 | 24 | + `gnat.adc`. This is the GNAT configuration file that contains program-wide compilation 25 | settings. It is currently not used in that its entire contents are commented out. 26 | -------------------------------------------------------------------------------- /src/check/build/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/src/check/build/.gitkeep -------------------------------------------------------------------------------- /src/check/build/example.txt: -------------------------------------------------------------------------------- 1 | Call me Ishmael. Some years ago - never mind how long precisely - having little or no money in 2 | my purse, and nothing particular to interest me on shore, I thought I would sail about a little 3 | and see the watery part of the world. It is a way I have of driving off the spleen and 4 | regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is 5 | a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin 6 | warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos 7 | get such an upper hand of me, that it requires a strong moral principle to prevent me from 8 | deliberately stepping into the street, and methodically knocking people's hats off - then, I 9 | account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. 10 | With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. 11 | There is nothing surprising in this. If they but knew it, almost all men in their degree, some 12 | time or other, cherish very nearly the same feelings towards the ocean with me. 13 | -------------------------------------------------------------------------------- /src/check/check_lib_crc.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : check_lib_crc.ads 3 | -- SUBJECT: Specification of a CRC unit test package 4 | -- AUTHOR : (C) Copyright 2022 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with AUnit; 8 | with AUnit.Test_Cases; 9 | 10 | package Check_Lib_CRC is 11 | 12 | type Lib_CRC_Test is new AUnit.Test_Cases.Test_Case with null record; 13 | 14 | procedure Register_Tests(T : in out Lib_CRC_Test); 15 | function Name(T : in Lib_CRC_Test) return AUnit.Message_String; 16 | 17 | end Check_Lib_CRC; 18 | -------------------------------------------------------------------------------- /src/check/check_lib_xdr.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : check_lib_xdr.ads 3 | -- SUBJECT: Specification of an XDR encoding/decoding unit test package. 4 | -- AUTHOR : (C) Copyright 2022 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with AUnit; 8 | with AUnit.Test_Cases; 9 | 10 | package Check_Lib_XDR is 11 | 12 | type Lib_XDR_Test is new AUnit.Test_Cases.Test_Case with null record; 13 | 14 | procedure Register_Tests(T : in out Lib_XDR_Test); 15 | function Name(T : in Lib_XDR_Test) return AUnit.Message_String; 16 | 17 | end Check_Lib_XDR; 18 | -------------------------------------------------------------------------------- /src/check/check_trivial.adb: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------------------------- 2 | -- FILE : check_trivial.adb 3 | -- SUBJECT : Package containing tests of nothing in particular. 4 | -- AUTHOR : (C) Copyright 2022 by Vermont Technical College 5 | -- 6 | --------------------------------------------------------------------------- 7 | -- with AUnit.Assertions; use AUnit.Assertions; 8 | 9 | package body Check_Trivial is 10 | 11 | procedure Test_Nothing(T : in out AUnit.Test_Cases.Test_Case'Class) is 12 | begin 13 | -- Use Assert to verify that an expected condition is actually true. 14 | -- The message is output if the assertion fails. 15 | -- 16 | -- Assert(0 = 0, "Zero is not zero!"); 17 | -- Assert(true = true, "True is the same as false!"); 18 | null; 19 | end Test_Nothing; 20 | 21 | 22 | procedure Register_Tests(T : in out Trivial_Test) is 23 | begin 24 | AUnit.Test_Cases.Registration.Register_Routine(T, Test_Nothing'Access, "Nothing Test"); 25 | end Register_Tests; 26 | 27 | 28 | function Name(T : in Trivial_Test) return AUnit.Message_String is 29 | pragma Unreferenced(T); 30 | begin 31 | return AUnit.Format("Trivial"); 32 | end Name; 33 | 34 | end Check_Trivial; 35 | -------------------------------------------------------------------------------- /src/check/check_trivial.ads: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------------------------- 2 | -- FILE : check_trivial.ads 3 | -- SUBJECT : Package containing tests of nothing in particular. 4 | -- AUTHOR : (C) Copyright 2022 by Vermont Technical College 5 | -- 6 | -- The "trivial" test is just a place holder. It can be used as a template for other tests. 7 | -- 8 | --------------------------------------------------------------------------- 9 | with AUnit; 10 | with AUnit.Test_Cases; 11 | 12 | package Check_Trivial is 13 | 14 | type Trivial_Test is new AUnit.Test_Cases.Test_Case with null record; 15 | 16 | procedure Register_Tests(T : in out Trivial_Test); 17 | function Name(T : in Trivial_Test) return AUnit.Message_String; 18 | 19 | end Check_Trivial; 20 | -------------------------------------------------------------------------------- /src/check/cubedlib_suite.ads: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------------------------- 2 | -- FILE : cubedlib_suite.ads 3 | -- SUBJECT : The main test suite of the CubedOS library unit test program. 4 | -- AUTHOR : (C) Copyright 2022 by Vermont Technical COllege 5 | -- 6 | --------------------------------------------------------------------------- 7 | with AUnit.Test_Suites; 8 | 9 | package CubedLib_Suite is 10 | function Suite return AUnit.Test_Suites.Access_Test_Suite; 11 | end CubedLib_Suite; 12 | -------------------------------------------------------------------------------- /src/check/cubedos-lib-bounded_strings-check.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : cubedos-lib-bounded_strings-check.ads 3 | -- SUBJECT: Package containing unit tests of bounded strings. 4 | -- AUTHOR : (C) Copyright 2022 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with AUnit; 8 | with AUnit.Test_Cases; 9 | 10 | package CubedOS.Lib.Bounded_Strings.Check is 11 | 12 | type Lib_Bounded_Strings_Test is new AUnit.Test_Cases.Test_Case with null record; 13 | 14 | procedure Register_Tests(T : in out Lib_Bounded_Strings_Test); 15 | function Name(T : in Lib_Bounded_Strings_Test) return AUnit.Message_String; 16 | 17 | end CubedOS.Lib.Bounded_Strings.Check; 18 | -------------------------------------------------------------------------------- /src/check/cubedos_check.adb: -------------------------------------------------------------------------------- 1 | --------------------------------------------------------------------------- 2 | -- FILE : cubedos_check.adb 3 | -- SUBJECT : Main procedure of the CubedOS library unit test program. 4 | -- AUTHOR : (C) Copyright 2022 by Vermont Technical College 5 | -- 6 | --------------------------------------------------------------------------- 7 | with AUnit.Run; 8 | with AUnit.Reporter.Text; 9 | 10 | with CubedLib_Suite; 11 | 12 | procedure CubedOS_Check is 13 | procedure Run is new AUnit.Run.Test_Runner(CubedLib_Suite.Suite); 14 | Reporter : AUnit.Reporter.Text.Text_Reporter; 15 | begin 16 | Run(Reporter); 17 | end CubedOS_Check; 18 | -------------------------------------------------------------------------------- /src/check/message_manager.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : message_manager.adb 3 | -- SUBJECT : Package holding the mailboxes used by CubedOS message passing. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | pragma Profile(Jorvik); 9 | pragma Partition_Elaboration_Policy(Sequential); 10 | 11 | with CubedOS.Generic_Message_Manager; 12 | pragma Elaborate_All(CubedOS.Generic_Message_Manager); 13 | 14 | package Message_Manager is 15 | new CubedOS.Generic_Message_Manager 16 | (Domain_Number => 1, 17 | Module_Count => 16, 18 | Mailbox_Size => 8, 19 | Maximum_Message_Size => 1024); 20 | -------------------------------------------------------------------------------- /src/check/network_configuration.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : network_configuration.adb 3 | -- SUBJECT : Package for retrieving addresses and ports for Domains in a distributed CubedOS application 4 | -- AUTHOR : (C) Copyright 2022 by Vermont Technical College 5 | ---------------------------------------------------------------------------------- 6 | package body Network_Configuration is 7 | 8 | function Get_Address 9 | (Domain_ID : in Domain_ID_Type) return Inet_Addr_Type 10 | is 11 | begin 12 | return Local_Host_Addr; 13 | end Get_Address; 14 | 15 | function Get_Port 16 | (Domain_ID : in Domain_ID_Type) return Port_Type 17 | is 18 | begin 19 | return Default_Port; 20 | end Get_Port; 21 | 22 | end Network_Configuration; 23 | -------------------------------------------------------------------------------- /src/check/network_configuration.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : network_configuration.ads 3 | -- SUBJECT : Specification of a package holding Domain IDs and Module IDs 4 | -- AUTHOR : (C) Copyright 2022 by Vermont Technical College 5 | -- 6 | -- Each distributed CubedOS application must provide a version of this file that maps 7 | -- "wellknown" network addresses and ports to domains in the distributed CubedOS 8 | -- application. The precise ID asssigments are arbitrary. 9 | -- 10 | -- Copy this file to your CubedOS application code base and edit it to mention 11 | -- only the address, ports, and domains you need 12 | -------------------------------------------------------------------------------- 13 | with GNAT.Sockets; use GNAT.Sockets; 14 | with Message_Manager; use Message_Manager; 15 | 16 | package Network_Configuration is 17 | 18 | Local_Host_Addr : Inet_Addr_Type := Inet_Addr("127.0.0.1"); 19 | Default_Port : Port_Type := 50000; 20 | 21 | function Get_Port 22 | (Domain_ID : in Domain_ID_Type) return Port_Type; 23 | 24 | function Get_Address 25 | (Domain_ID : in Domain_ID_Type) return Inet_Addr_Type; 26 | 27 | end Network_Configuration; 28 | -------------------------------------------------------------------------------- /src/cubedos-casing-exceptions.txt: -------------------------------------------------------------------------------- 1 | API 2 | BSI 3 | *APID* 4 | *CRC* 5 | *ID* 6 | *IO* 7 | *RID* 8 | *TC* 9 | *XDR* 10 | *LED* 11 | CubedOS 12 | CubedOS_Check 13 | CubedLib_Suite 14 | DomainA_Client 15 | DomainB_Client 16 | DomainB_Server 17 | DomainA_Addr 18 | DomainB_Addr 19 | DomainA_Port 20 | DomainB_Port 21 | CPU_Number 22 | PNumbers 23 | -------------------------------------------------------------------------------- /src/cubedos-rules.txt: -------------------------------------------------------------------------------- 1 | +RStyle_Checks:3 2 | +RWarnings:a 3 | +RToo_Many_Dependencies:8 4 | +RImplicit_IN_Mode_Parameters 5 | +RMetrics_Cyclomatic_Complexity:8 6 | +RMetrics_Cyclomatic_Complexity:Exempt_Case_Statements 7 | +RLocal_Packages 8 | +RVolatile_Objects_Without_Address_Clauses 9 | +REXIT_Statements_With_No_Loop_Name 10 | +RImproper_Returns 11 | +RMaximum_Parameters:6 12 | +ROverly_Nested_Control_Structures:4 13 | +RStyle_Checks:a 14 | +RStyle_Checks:A 15 | +RStyle_Checks:b 16 | +RStyle_Checks:e 17 | +RStyle_Checks:h 18 | +RStyle_Checks:i 19 | +RStyle_Checks:x 20 | +RImproperly_Located_Instantiations 21 | +RAnnotated_Comments:$TODO 22 | +RBoolean_Relational_Operators 23 | +ROuter_Loop_Exits 24 | +RImplicit_SMALL_For_Fixed_Point_Types 25 | +REnumeration_Ranges_In_CASE_Statements 26 | +RGOTO_Statements 27 | +RMisplaced_Representation_Items 28 | +RNull_Paths 29 | -- +RHeaders:cubedos.hdr 30 | +RIdentifier_Casing:Type=mixed 31 | +RIdentifier_Casing:Others=mixed 32 | +RIdentifier_Casing:Constant=mixed 33 | +RIdentifier_Casing:Enum=mixed 34 | +RIdentifier_Casing:Exclude=cubedos-casing-exceptions.txt 35 | +ROne_Construct_Per_Line 36 | +RUncommented_BEGIN_In_Package_Bodies 37 | +RStyle_Checks:f 38 | +RStyle_Checks:k 39 | +RStyle_Checks:l 40 | +RStyle_Checks:n 41 | +RStyle_Checks:p 42 | +RStyle_Checks:S 43 | +RStyle_Checks:M112 44 | +RStyle_Checks:C 45 | -------------------------------------------------------------------------------- /src/cubedos.gpr: -------------------------------------------------------------------------------- 1 | with "aunit.gpr"; 2 | with "library/cubedlib.gpr"; 3 | 4 | project CubedOS is 5 | 6 | for Main use ("main.adb", "main_message_manager.adb", "main_file.adb", "main_time.adb", 7 | "cubedos_check.adb"); 8 | for Object_Dir use "check/build"; 9 | for Source_Dirs use ("check", "modules"); 10 | for Languages use ("ada"); 11 | 12 | package Ide is 13 | for Default_Switches ("adacontrol") use ("-f", "cubedos.aru"); 14 | end Ide; 15 | 16 | package Compiler is 17 | for Default_Switches ("ada") use ("-gnat2022", "-gnatW8", "-fstack-check", "-gnatwa", "-gnata", "-g"); 18 | end Compiler; 19 | 20 | package Builder is 21 | end Builder; 22 | 23 | package Documentation is 24 | for Ignored_Subprojects use ("aunit"); 25 | end Documentation; 26 | 27 | package Prove is 28 | end Prove; 29 | 30 | package Linker is 31 | end Linker; 32 | 33 | package Check is 34 | for Default_Switches ("ada") use ("-rules", "-from=cubedos-rules.txt"); 35 | end Check; 36 | 37 | end CubedOS; 38 | 39 | -------------------------------------------------------------------------------- /src/cubedos.hdr: -------------------------------------------------------------------------------- 1 | ^--------------------------------------------------------------------------------$ 2 | ^-- FILE : 3 | ^-- SUBJECT: 4 | ^-- AUTHOR : \(C\) Copyright 2022 by Vermont Technical College$ 5 | ^--$ 6 | * 7 | ^--------------------------------------------------------------------------------$ 8 | -------------------------------------------------------------------------------- /src/gnat.adc: -------------------------------------------------------------------------------- 1 | -- This file is used to ensure that the CubedOS core uses Jorvik and SPARKable. 2 | -- 3 | -- This file isn't currently used. The profile and the partition elaboration policy are set in 4 | -- the specification of package CubedOS. 5 | -- 6 | --pragma Profile(Jorvik); 7 | --pragma Partition_Elaboration_Policy(Sequential); 8 | --pragma SPARK_Mode(On); 9 | -------------------------------------------------------------------------------- /src/library/cubedlib.gpr: -------------------------------------------------------------------------------- 1 | project CubedLib is 2 | 3 | for Library_Name use "cubedlib"; 4 | type Build_Type is ("Release", "Debug"); 5 | Build : Build_Type := external ("BUILD", "Debug"); 6 | 7 | case Build is 8 | when "Release" => 9 | for Library_Ali_Dir use "lib/Release"; 10 | for Library_Dir use "lib/Release"; 11 | for Object_Dir use "obj/Release"; 12 | when "Debug" => 13 | for Library_Ali_Dir use "lib/Debug"; 14 | for Library_Dir use "lib/Debug"; 15 | for Object_Dir use "obj/Debug"; 16 | end case; 17 | for Source_Dirs use (".", ".."); 18 | for Languages use ("ada"); 19 | 20 | package Ide is 21 | for Default_Switches ("adacontrol") use ("-f", "../cubedos.aru"); 22 | end Ide; 23 | 24 | package Compiler is 25 | case Build is 26 | when "Release" => 27 | for Default_Switches ("ada") use ("-gnat2022", "-gnatwa", "-gnatW8", "-O"); 28 | for Switches ("c") use ("-O"); 29 | 30 | when "Debug" => 31 | for Default_Switches ("ada") use ("-gnat2022", "-gnatwa", "-gnatW8", "-fstack-check", "-gnata", "-g"); 32 | for Switches ("c") use ("-g"); 33 | end case; 34 | end Compiler; 35 | 36 | package Documentation is 37 | for Documentation_Dir use "doc"; 38 | end Documentation; 39 | 40 | package Prove is 41 | end Prove; 42 | 43 | package Linker is 44 | end Linker; 45 | 46 | package Check is 47 | for Default_Switches ("ada") use ("-rules", "-from=../cubedos-rules.txt"); 48 | end Check; 49 | 50 | end CubedLib; 51 | -------------------------------------------------------------------------------- /src/library/cubedos-casing-exceptions.txt: -------------------------------------------------------------------------------- 1 | *ID* 2 | *XDR* 3 | API 4 | -------------------------------------------------------------------------------- /src/library/cubedos-lib-compressors.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : cubedos-lib-compressors.adb 3 | -- SUBJECT: Implementation of a package containing compression algorithms. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | package body CubedOS.Lib.Compressors is 10 | 11 | function Make return Trivial_Compressor is 12 | Result : Trivial_Compressor; 13 | begin 14 | Result.Operation_Count := 0; 15 | return Result; 16 | end Make; 17 | 18 | 19 | procedure Compress 20 | (C : in out Trivial_Compressor; 21 | Data_In : in Uncompressed_Block; 22 | Data_In_Size : in Block_Size_Type; 23 | Data_Out : out Compressed_Block; 24 | Data_Out_Size : out Block_Size_Type) 25 | is 26 | begin 27 | Data_Out := [others => 0]; 28 | for I in 1 .. Data_In_Size loop 29 | Data_Out(I) := Data_In(I); 30 | end loop; 31 | Data_Out_Size := Data_In_Size; 32 | if C.Operation_Count <= Integer'Last - 1 then 33 | C.Operation_Count := C.Operation_Count + 1; 34 | end if; 35 | end Compress; 36 | 37 | 38 | procedure Flush 39 | (C : in out Trivial_Compressor; 40 | Data_Out : out Compressed_Block; 41 | Data_Out_Size : out Block_Size_Type) 42 | is 43 | begin 44 | Data_Out := [others => 0]; 45 | Data_Out_Size := 0; 46 | if C.Operation_Count <= Integer'Last - 1 then 47 | C.Operation_Count := C.Operation_Count + 1; 48 | end if; 49 | end Flush; 50 | 51 | end CubedOS.Lib.Compressors; 52 | -------------------------------------------------------------------------------- /src/library/cubedos-lib-crc.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : cubedos-lib-crc.adb 3 | -- SUBJECT: Specification of a package for handling CRC calculations 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | package CubedOS.Lib.CRC is 10 | 11 | function CRC_Calculation 12 | (Buffer : in Octet_Array) return Double_Octet; 13 | 14 | function Continuation_CRC_Calculation 15 | (Buffer : in Octet_Array; 16 | Seed : in Double_Octet) return Double_Octet; 17 | 18 | end CubedOS.Lib.CRC; 19 | -------------------------------------------------------------------------------- /src/library/cubedos-lib-vectors3.adb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : cubedos-lib-vectors3.adb 3 | -- SUBJECT: Body of a package for manipulating 3D vectors of floating point numbers. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with Ada.Numerics.Generic_Elementary_Functions; 10 | 11 | package body CubedOS.Lib.Vectors3 is 12 | 13 | package Float_Type_Elementary_Functions is 14 | new Ada.Numerics.Generic_Elementary_Functions(Float_Type); 15 | use Float_Type_Elementary_Functions; 16 | 17 | function Cross(Left, Right : in Vector3) return Vector3 is 18 | New_X : Float_Type; 19 | New_Y : Float_Type; 20 | New_Z : Float_Type; 21 | begin 22 | New_X := Left.Y * Right.Z - Left.Z * Right.Y; 23 | New_Y := Left.Z * Right.X - Left.X * Right.Z; 24 | New_Z := Left.X * Right.Y - Left.Y * Right.X; 25 | return (New_X, New_Y, New_Z); 26 | end Cross; 27 | 28 | 29 | function Magnitude(V : in Vector3) return Float_Type is 30 | Result : Float_Type; 31 | begin 32 | Result := Sqrt( (V.X * V.X) + (V.Y * V.Y) + (V.Z * V.Z) ); 33 | return Result; 34 | end Magnitude; 35 | 36 | 37 | function Unit(V : in Vector3) return Vector3 is 38 | Length : constant Float_Type := Magnitude(V); 39 | begin 40 | return ( X => V.X/Length, Y => V.Y/Length, Z => V.Z/Length ); 41 | end Unit; 42 | 43 | end CubedOS.Lib.Vectors3; 44 | -------------------------------------------------------------------------------- /src/library/cubedos.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : cubedos.ads 3 | -- SUBJECT: Specification of a package serving as a parent to all of CubedOS. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma Profile(Jorvik); 8 | pragma Partition_Elaboration_Policy(Sequential); 9 | pragma SPARK_Mode(On); 10 | 11 | package CubedOS is 12 | pragma Pure; 13 | end CubedOS; 14 | -------------------------------------------------------------------------------- /src/library/doc/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/src/library/doc/.gitkeep -------------------------------------------------------------------------------- /src/library/lib/Debug/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/src/library/lib/Debug/.gitkeep -------------------------------------------------------------------------------- /src/library/lib/Release/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/src/library/lib/Release/.gitkeep -------------------------------------------------------------------------------- /src/library/obj/Debug/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/src/library/obj/Debug/.gitkeep -------------------------------------------------------------------------------- /src/library/obj/Release/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cubesatlab/cubedos/e1fdf351af83348f0f784fa65314cbd927d3bb03/src/library/obj/Release/.gitkeep -------------------------------------------------------------------------------- /src/modules/cubedos-file_server-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : cubedos-file_server-messages.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the file server. 4 | -- AUTHOR : (C) Copyright 2017 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with System; 10 | 11 | package CubedOS.File_Server.Messages is 12 | 13 | task Message_Loop is 14 | -- pragma Storage_Size(4 * 1024); 15 | pragma Priority(System.Default_Priority); 16 | end Message_Loop; 17 | 18 | -- pragma Annotate 19 | -- (GNATprove, 20 | -- Intentional, 21 | -- "multiple tasks might queue on protected entry", 22 | -- "Every module has a unique ID"); 23 | 24 | end CubedOS.File_Server.Messages; 25 | -------------------------------------------------------------------------------- /src/modules/cubedos-file_server.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : cubedos-file_server.ads 3 | -- SUBJECT: Specification of a package for a file server module. 4 | -- AUTHOR : (C) Copyright 2017 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | pragma Warnings (Off, "unit ""Message_Manager"" is not referenced"); 10 | with Message_Manager; 11 | 12 | package CubedOS.File_Server is 13 | 14 | end CubedOS.File_Server; 15 | -------------------------------------------------------------------------------- /src/modules/cubedos-interpreter-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : SAMPLE_MODULE-messages.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the module. 4 | -- AUTHOR : (C) Copyright 2021 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with System; 10 | 11 | package CubedOS.Interpreter.Messages is 12 | 13 | task Message_Loop is 14 | pragma Storage_Size(4 * 1024); 15 | pragma Priority(System.Default_Priority); 16 | end Message_Loop; 17 | 18 | end CubedOS.Interpreter.Messages; 19 | -------------------------------------------------------------------------------- /src/modules/cubedos-interpreter.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : cubedos-interpreter.ads 3 | -- SUBJECT: Top level package of the Interpreter module 4 | -- AUTHOR : (C) Copyright 2021 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | pragma Warnings (Off, "unit ""Message_Manager"" is not referenced"); 10 | with Message_Manager; 11 | 12 | package CubedOS.Interpreter is 13 | 14 | end CubedOS.Interpreter; 15 | -------------------------------------------------------------------------------- /src/modules/cubedos-log_server-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : cubedos.log_server-messages.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the log server. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -- This implementation makes use of the consol IO facilities of a hosted implemenation (i.e., an Ada 7 | -- implementation running on a full operating system such as Linux). In a mission, the application developers 8 | -- would likely create a specialized body for this package that stores logged messages in some other way. 9 | -- 10 | -------------------------------------------------------------------------------- 11 | pragma SPARK_Mode(On); 12 | 13 | -- This implementation makes use of console IO. 14 | with Ada.Real_Time; 15 | with Ada.Text_IO; 16 | with System; 17 | 18 | package CubedOS.Log_Server.Messages is 19 | 20 | -- These are declared here so they can be mentioned in the Global aspect of Message_Loop. 21 | -- My attempts to use Abstract_State didn't work; it required an initialization procedure for the state. 22 | Boot_Time : Ada.Real_Time.Time; -- When the system starts. 23 | Current_Time : Ada.Real_Time.Time; -- When the current message is fetched. 24 | 25 | task Message_Loop 26 | with 27 | Global => (Input => Ada.Real_Time.Clock_Time, 28 | In_Out => (Ada.Text_IO.File_System, Message_Manager.Mailboxes), 29 | Output => (Boot_Time, Current_Time)) 30 | is 31 | pragma Priority(System.Default_Priority); 32 | end Message_Loop; 33 | 34 | end CubedOS.Log_Server.Messages; 35 | -------------------------------------------------------------------------------- /src/modules/cubedos-log_server.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : cubedos-log_server.ads 3 | -- SUBJECT: Specification of a package that logs flight software activity. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | pragma Warnings (Off, "unit ""Message_Manager"" is not referenced"); 10 | with Message_Manager; 11 | 12 | package CubedOS.Log_Server is 13 | 14 | end CubedOS.Log_Server; 15 | -------------------------------------------------------------------------------- /src/modules/cubedos-publish_subscribe_server-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : cubedos-publish_subscribe_server-messages.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the module. 4 | -- AUTHOR : (C) Copyright 2021 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with System; 10 | 11 | package CubedOS.Publish_Subscribe_Server.Messages 12 | with 13 | Abstract_State => Database, 14 | Initializes => Database 15 | is 16 | 17 | task type Message_Loop 18 | with Global => (In_Out => (Database, Message_Manager.Mailboxes)), 19 | Priority => System.Default_Priority 20 | is 21 | -- pragma Storage_Size(4 * 1024); 22 | -- pragma Priority(System.Default_Priority); 23 | end Message_Loop; 24 | 25 | end CubedOS.Publish_Subscribe_Server.Messages; 26 | -------------------------------------------------------------------------------- /src/modules/cubedos-publish_subscribe_server.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : cubedos-publish_subscribe_server.ads 3 | -- SUBJECT: Top level package of a CubedOS Publish/Subscribe server. 4 | -- AUTHOR : (C) Copyright 2021 by Vermont Technical College 5 | -- 6 | -- This module supports a publish/subscribe message passing paradigm on top of the base CubedOS 7 | -- point-to-point message system. Publish/subscribe is often a useful way to broadcast or 8 | -- multicast messages throughout the system. 9 | -- 10 | -- In this system any module can publish or subscribe (or both) to any channel. If a message is 11 | -- published to a channel for which there are no subscribers, the message is lost. Subscribers 12 | -- only receive messages that are published after they subscribe; they do not see old messages. 13 | -- The number of messages queued on a channel is connected to the depth of the CubedOS mailbox 14 | -- used by the publish/subscribe server; Publish_Result messages can back up in that mailbox. 15 | -- However, since the CubedOS mailbox is shared by all channels (and also used for request 16 | -- messages), it's difficult to say how many backlogged messages are allowed for any given 17 | -- channel. 18 | -------------------------------------------------------------------------------- 19 | pragma SPARK_Mode(On); 20 | 21 | pragma Warnings (Off, "unit ""Message_Manager"" is not referenced"); 22 | with Message_Manager; 23 | 24 | package CubedOS.Publish_Subscribe_Server is 25 | 26 | end CubedOS.Publish_Subscribe_Server; 27 | -------------------------------------------------------------------------------- /src/modules/cubedos-time_server-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : cubedos-time_server-messages.ads 3 | -- SUBJECT: Specification of a package for a time server module. 4 | -- AUTHOR : (C) Copyright 2021 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | with Ada.Real_Time; 10 | with System; 11 | with Message_Manager; 12 | 13 | package CubedOS.Time_Server.Messages 14 | with 15 | Abstract_State => 16 | (Tick_Database with External), 17 | Initializes => 18 | (Message_Loop, Tick_Database) 19 | is 20 | 21 | task Message_Loop 22 | with 23 | Global => (Input => Ada.Real_Time.Clock_Time, In_Out => (Tick_Database, Message_Manager.Mailboxes)) 24 | is 25 | -- pragma Storage_Size(4 * 1024); 26 | pragma Priority(System.Default_Priority); 27 | end Message_Loop; 28 | 29 | end CubedOS.Time_Server.Messages; 30 | -------------------------------------------------------------------------------- /src/modules/cubedos-time_server.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : cubedos-time_server.ads 3 | -- SUBJECT: Specification of a package for a time server module. 4 | -- AUTHOR : (C) Copyright 2021 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | pragma Warnings (Off, "unit ""Message_Manager"" is not referenced"); 10 | with Message_Manager; 11 | 12 | package CubedOS.Time_Server is 13 | 14 | end CubedOS.Time_Server; 15 | -------------------------------------------------------------------------------- /src/modules/cubedos-transport_udp-messages.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : cubedos.transport_udp-messages.ads 3 | -- SUBJECT: Specification of a package that implements the main part of the module. 4 | -- AUTHOR : (C) Copyright 2022 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | with System; 8 | 9 | package CubedOS.Transport_UDP.Messages is 10 | 11 | task Network_Loop is 12 | pragma Priority(System.Default_Priority); 13 | end Network_Loop; 14 | 15 | task Message_Loop 16 | with Global => (In_Out => Message_Manager.Mailboxes) 17 | is 18 | -- pragma Storage_Size(4 * 1024); 19 | pragma Priority(System.Default_Priority); 20 | end Message_Loop; 21 | 22 | end CubedOS.Transport_UDP.Messages; 23 | -------------------------------------------------------------------------------- /src/modules/cubedos-transport_udp.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : cubedos-transport_udp.ads 3 | -- SUBJECT: Specification of a package that logs flight software activity. 4 | -- AUTHOR : (C) Copyright 2021 by Vermont Technical College 5 | -- 6 | -------------------------------------------------------------------------------- 7 | pragma SPARK_Mode(On); 8 | 9 | pragma Warnings(Off, "unit ""Message_Manager"" is not referenced"); 10 | with Message_Manager; 11 | 12 | 13 | package CubedOS.Transport_UDP is 14 | 15 | end CubedOS.Transport_UDP; 16 | -------------------------------------------------------------------------------- /templates/SAMPLE_MODULE.ads: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | -- FILE : SAMPLE_MODULE.ads 3 | -- SUBJECT: Top level package of a CubedOS SAMPLE MODULE. 4 | -- AUTHOR : (C) Copyright 2024 by Vermont State University 5 | -- 6 | -- This module is a skeleton, with comments, showing how to set up a standard CubedOS module. 7 | -- CubedOS modules do not need to follow this structure exactly, but it is recommended to at 8 | -- least start here. Note that many of the comments should be edited/erased in a real 9 | -- application. 10 | -------------------------------------------------------------------------------- 11 | pragma SPARK_Mode(On); 12 | 13 | package Sample_Module is 14 | pragma Pure; 15 | 16 | -- Every module has a domain ID number and a module ID number. However, those numbers are 17 | -- assigned by the application programming in a package Name_Resolver. Modules are not 18 | -- directly aware of their own ID numbers but instead look them up from the Name_Resolver 19 | -- just as clients must. 20 | end Sample_Module; 21 | --------------------------------------------------------------------------------