From 3c604d93103ec2d4b00ab681fa22f8f6747af077 Mon Sep 17 00:00:00 2001 From: Jbsco <90524106+Jbsco@users.noreply.github.com> Date: Sat, 3 Feb 2024 10:55:27 -0700 Subject: [PATCH] reducing cosmos setup commands to redo script --- gnd/cosmos/build_cosmos_plugin.sh | 12 ++++++++++++ src/assembly/linux/main/README.md | 25 +++++++++++++++--------- src/assembly/linux/main/cosmos_config.do | 6 ++++++ 3 files changed, 34 insertions(+), 9 deletions(-) create mode 100755 gnd/cosmos/build_cosmos_plugin.sh create mode 100644 src/assembly/linux/main/cosmos_config.do diff --git a/gnd/cosmos/build_cosmos_plugin.sh b/gnd/cosmos/build_cosmos_plugin.sh new file mode 100755 index 0000000..ee0ff66 --- /dev/null +++ b/gnd/cosmos/build_cosmos_plugin.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# +# Configure cosmos plugin +# + +assembly_dir=$1 +# Build all cosmos plugin command and telemetry files: +cd $assembly_dir +plugin=`redo what 2>&1 | grep "cosmos/plugin" | awk '{ print $2 }'` +echo $plugin | xargs redo-ifchange +cd - >/dev/null diff --git a/src/assembly/linux/main/README.md b/src/assembly/linux/main/README.md index 2f8c9bc..69ca744 100644 --- a/src/assembly/linux/main/README.md +++ b/src/assembly/linux/main/README.md @@ -40,14 +40,14 @@ To best interact with the Linux assembly, we need to use a ground system interfa Cosmos we need to build the Cosmos plugin configuration files. This will allow Cosmos to decode telemetry from the Linux assembly and properly format outgoing commands. -From the `adamant_example/src/assembly/linux` directory in your Adamant environment run: +These files are autocoded by Adamant. From the `adamant_example/src/assembly/linux/main` directory in your Adamant environment run: ``` -$ redo build/plugin/Config/linux_example_ccsds_commands.txt -$ redo build/plugin/Config/linux_example_ccsds_telemetry.txt -$ redo build/plugin/Config/linux_example_ccsds_plugin.txt +$ redo cosmos_config ``` +This generates the plugin configuration file and its respective command and telemetry configurations in the `adamant_example/src/assembly/linux/build/cosmos/plugin/` directory. + To install OpenC3 Cosmos, navigate to an appropriate directory on your host machine and clone the Cosmos example project repository: ``` @@ -77,7 +77,7 @@ cosmos-project/openc3-cosmos-linux-example/targets/LINUX_EXAMPLE/cmd_tlm/tlm.txt Replace the contents of these text files with the contents of the corresponding files generated by Redo, located in the Adamant example project directory at: ``` -adamant_example/src/assembly/linux/build/plugin/Config +adamant_example/src/assembly/linux/build/cosmos/plugin ``` The Cosmos plugin uses a default CRC protocol provided by Cosmos, but also needs a custom protocol to apply Adamant's command packet checksum correctly. The protocol file is located in the Adamant directory at: @@ -95,9 +95,9 @@ cosmos-project/openc3-cosmos-linux-example/targets/LINUX_EXAMPLE/lib/cmd_checksu If the Cosmos and Admant example project directories are adjacent, complete the configuration by running: ``` -$ cp adamant_example/src/assembly/linux/build/plugin/Config/linux_example_ccsds_commands.txt cosmos-project/openc3-cosmos-linux-example/targets/LINUX_EXAMPLE/cmd_tlm/cmd.txt -$ cp adamant_example/src/assembly/linux/build/plugin/Config/linux_example_ccsds_telemetry.txt cosmos-project/openc3-cosmos-linux-example/targets/LINUX_EXAMPLE/cmd_tlm/tlm.txt -$ cp adamant_example/src/assembly/linux/build/plugin/Config/linux_example_ccsds_plugin.txt cosmos-project/openc3-cosmos-linux-example/plugin.txt +$ cp adamant_example/src/assembly/linux/build/cosmos/plugin/linux_example_ccsds_cosmos_commands.txt cosmos-project/openc3-cosmos-linux-example/targets/LINUX_EXAMPLE/cmd_tlm/cmd.txt +$ cp adamant_example/src/assembly/linux/build/cosmos/plugin/linux_example_ccsds_cosmos_telemetry.txt cosmos-project/openc3-cosmos-linux-example/targets/LINUX_EXAMPLE/cmd_tlm/tlm.txt +$ cp adamant_example/src/assembly/linux/build/cosmos/plugin/linux_example_ccsds_cosmos_plugin.txt cosmos-project/openc3-cosmos-linux-example/plugin.txt $ cp adamant/gnd/cosmos/cmd_checksum.rb cosmos-project/openc3-cosmos-linux-example/targets/LINUX_EXAMPLE/lib/cmd_checksum.rb ``` @@ -107,9 +107,16 @@ The plugin can now be compiled. Navigate to the plugin directory at `openc3-cosm $ ./../openc3.sh cli rake build VERSION=1.0.0 ``` +The Cosmos Docker container must be configured to use the same ports as Adamant. Edit this configuration at `cosmos-project/compose.yaml` and add the following entry to the `openc3-operator:` section: + +``` + ports: + - "2003:2003/tcp" +``` + With the Linux assembly running, start Cosmos by navigating to the `cosmos-project` directory and running `./openc3.sh start`. After the containers start, open a web browser and navigate to `http://localhost:2900`. You will be prompted to configure a password, and then presented with the Cosmos interface. Some modules may still be loading, but after a minute the interface should be complete. Navigate to `ADMIN CONSOLE` and uninstall the "openc3-cosmos-demo" plugin by selecting the `Delete Plugin` icon. -Select `Click to select plugin .gem file to install` and navigate to the compiled plugin gem file at `cosmos-project/openc3-cosmos-linux-example/openc3-cosmos-linux-example-1.0.0.gem` to install our generated plugin. +Select `Click to select plugin .gem file to install` and navigate to the compiled plugin gem file at `cosmos-project/openc3-cosmos-linux-example/openc3-cosmos-linux-example-1.0.0.gem` to install our generated plugin. The plugin is templated to allow changing of parameters such as ports, but the default values are already set to correspond with this project. The plugin will be installed and you should see events being received every two seconds from the Linux assembly over the socket in the `CmdTLMServer` panel. diff --git a/src/assembly/linux/main/cosmos_config.do b/src/assembly/linux/main/cosmos_config.do new file mode 100644 index 0000000..bae9bcd --- /dev/null +++ b/src/assembly/linux/main/cosmos_config.do @@ -0,0 +1,6 @@ +# Create Cosmos plugin configuration files: +export TARGET= +this_dir=`dirname "$0"` +cosmos_dir=`realpath $this_dir/../../../../gnd/cosmos` +assembly_dir=`realpath $this_dir/..` +$cosmos_dir/build_cosmos_plugin.sh $assembly_dir >/dev/null