Skip to content

Commit

Permalink
Restructure COSMOS plugin file locations
Browse files Browse the repository at this point in the history
Restructure COSMOS plugin configuration file locations, COSMOS plugin helper script changed to use paths relative to CWD, and README updated to encourage user to check plugin configuration template and use helper script.

Update COSMOS build script to capture new plugin location
  • Loading branch information
Jbsco committed May 29, 2024
1 parent 82bca83 commit df94172
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 39 deletions.
2 changes: 1 addition & 1 deletion gnd/cosmos/build_cosmos_plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
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 }'`
plugin=`redo what 2>&1 | grep "cosmos" | awk '{ print $2 }'`
echo $plugin | xargs redo-ifchange
cd - >/dev/null
46 changes: 29 additions & 17 deletions gnd/cosmos/install_cosmos_plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,49 @@
# Copy COSMOS plugin configuration to argument directory
# This will likely be moved to the Adamant repository
# COSMOS install directory argument should be relative to the Linux example path
# Ex. `./install_cosmos_plugin.sh linux_example cosmos-project` if COSMOS is adjacent to adamant_example
# Ex. `./install_cosmos_plugin.sh ../../src/assembly/linux/linux_example.assembly.yaml ../../../cosmos-project` if COSMOS is adjacent to adamant_example

adamant_assembly_name=$1
cosmos_install_name=$2
adamant_assembly_dir=$1 # relative path to assembly yaml file
cosmos_install_dir=$2 # relative path to COSMOS installation
if [[ $1 == "" ]]
then
echo "Adamant assembly name argument not provided."
echo "Usage: \"./install_cosmos_plugin.sh Adamant_assembly_name path_to_COSMOS_directory\""
echo "Usage: \"./install_cosmos_plugin.sh ../../src/assembly/linux/linux_example.assembly.yaml ../../../cosmos-project\""
echo "Exiting."
exit 1
elif [[ $2 == "" ]]
then
echo "COSMOS installation location argument not provided."
echo "Usage: \"./install_cosmos_plugin.sh Adamant_assembly_name path_to_COSMOS_directory\""
echo "Usage: \"./install_cosmos_plugin.sh ../../src/assembly/linux/linux_example.assembly.yaml ../../../cosmos-project\""
echo "Exiting."
exit 1
fi
cosmos_install_dir=`realpath ../../../$cosmos_install_name`
adamant_assembly_name=${adamant_assembly_dir%.assembly.yaml}
adamant_assembly_name=${adamant_assembly_name##*/}
cosmos_plugin_dir=`realpath $cosmos_install_dir/openc3-cosmos-${adamant_assembly_name//_/-}`
# Get build directory:
adamant_assembly_name_short=(${adamant_assembly_name//_/ })
adamant_example_plugin_dir=`realpath ../../src/assembly/${adamant_assembly_name_short[0]}/build/cosmos/plugin`
adamant_example_template_dir=`realpath ../../src/assembly/${adamant_assembly_name_short[0]}/build/cosmos/template`
adamant_protocol_dir=`realpath ../../../adamant/gnd/cosmos`
# Get requested protocols in plugin.txt:
requested_protocol_array=($(grep \"*.rb "${adamant_example_plugin_dir}/${adamant_assembly_name}_ccsds_cosmos_plugin.txt" | cut -d' ' -f5))
cp $adamant_example_plugin_dir/${adamant_assembly_name}_ccsds_cosmos_commands.txt $cosmos_plugin_dir/targets/${adamant_assembly_name^^}/cmd_tlm/cmd.txt
cp $adamant_example_plugin_dir/${adamant_assembly_name}_ccsds_cosmos_telemetry.txt $cosmos_plugin_dir/targets/${adamant_assembly_name^^}/cmd_tlm/tlm.txt
cp $adamant_example_plugin_dir/${adamant_assembly_name}_ccsds_cosmos_plugin.txt $cosmos_plugin_dir/plugin.txt
# Check requested protocols against those available from Adamant:
for i in "${requested_protocol_array[@]}"; do
if [ -f $adamant_protocol_dir/$i ]
then cp $adamant_protocol_dir/$i $cosmos_plugin_dir/targets/${adamant_assembly_name^^}/lib/$i
fi
done
# Copy all protocol files (plugins compile with only needed protocols):
cp -a $adamant_protocol_dir/*.rb $cosmos_plugin_dir/targets/${adamant_assembly_name^^}/lib/
# Copy plugin configuration files with error checking:
if [[ -f "$adamant_example_plugin_dir/${adamant_assembly_name}_ccsds_cosmos_commands.txt" ]]; then
cp $adamant_example_plugin_dir/${adamant_assembly_name}_ccsds_cosmos_commands.txt $cosmos_plugin_dir/targets/${adamant_assembly_name^^}/cmd_tlm/cmd.txt
else
echo "\"${adamant_assembly_name}_ccsds_cosmos_commands.txt\" does not exist, run \"redo cosmos_config\" from the Adamant assembly."
exit 1
fi
if [[ -f "$adamant_example_plugin_dir/${adamant_assembly_name}_ccsds_cosmos_telemetry.txt" ]]; then
cp $adamant_example_plugin_dir/${adamant_assembly_name}_ccsds_cosmos_telemetry.txt $cosmos_plugin_dir/targets/${adamant_assembly_name^^}/cmd_tlm/tlm.txt
else
echo "\"${adamant_assembly_name}_ccsds_cosmos_telemetry.txt\" does not exist, run \"redo cosmos_config\" from the Adamant assembly."
exit 1
fi
if [[ -f "$adamant_example_template_dir/${adamant_assembly_name}_ccsds_cosmos_plugin.txt" ]]; then
cp $adamant_example_template_dir/${adamant_assembly_name}_ccsds_cosmos_plugin.txt $cosmos_plugin_dir/plugin.txt
else
echo "\"${adamant_assembly_name}_ccsds_cosmos_plugin.txt\" does not exist, run \"redo cosmos_config\" from the Adamant assembly."
exit 1
fi
24 changes: 3 additions & 21 deletions src/assembly/linux/main/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,31 +88,13 @@ $ cd adamant_example/src/assembly/linux/main
$ 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.
This generates the plugin configuration file and its respective command and telemetry configurations in the `adamant_example/src/assembly/linux/build/cosmos/plugin/` directory. The plugin configuration template file is located in the `adamant_example/src/assembly/linux/build/cosmos/template/` directory, and should be reviewed to ensure the interface and required protocols are correct. By default, this template applies settings specific to this example and should be modified for other configurations.

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/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:

```
adamant/gnd/cosmos/cmd_checksum.rb
```

And must be placed in the COSMOS plugin directory at:

```
cosmos-project/openc3-cosmos-linux-example/targets/LINUX_EXAMPLE/lib/cmd_checksum.rb
```

A helper script, which takes the Adamant assembly name and COSMOS install directory as arguments, is provided to copy the plugin configuration files, and any custom protocols requested by the configuration, to the correct directories. If the COSMOS and Adamant example project directories are adjacent, complete the configuration by running:
A helper script, which takes the relative paths to the Adamant assembly yaml file and COSMOS install directory as arguments, is provided to copy the plugin configuration files, and any custom protocols used by the configuration, to the correct directories. If the COSMOS and Adamant example project directories are adjacent, complete the configuration by running:

```
$ cd adamant_example/gnd/cosmos
$ ./install_cosmos_plugin.sh linux_example cosmos-project
$ ./install_cosmos_plugin.sh ../../src/assembly/linux/linux_example.assembly.yaml ../../../cosmos-project
```

The plugin can now be compiled. Next, run:
Expand Down

0 comments on commit df94172

Please sign in to comment.