Skip to content

Commit

Permalink
updating readme with Cosmos example instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jbsco committed Jan 25, 2024
1 parent 6375f58 commit 5759b06
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions src/assembly/linux/main/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,96 @@ Starting Linux demo... Use Ctrl+C to exit.
0000168827.862054941 - Counter_Instance.Sending_Value (0x00000091) : (Value = 3)
...
```
## Commanding and Telemetry with OpenC3 Cosmos

![`Commanding and Telemetry with OpenC3 Cosmos`](img/cosmos.png "Commanding and Telemetry with OpenC3 Cosmos")

To best interact with the Linux assembly, we need to use a ground system interface, such as Cosmos. Before installing and running
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:

```
$ 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
```

To install OpenC3 Cosmos, navigate to an appropriate directory on your host machine and clone the Cosmos example project repository:

```
$ git clone https://github.com/openc3/cosmos-project.git
```

OpenC3 Cosmos runs inside of its own Docker containers. The Cosmos example project provides the necessary tools and commands to create an interface plugin from our generated configuration files. Navigate to the `cosmos-project` directory and run:

```
$ ./openc3.sh cli generate plugin LINUX_EXAMPLE
```

This create a new directory called `openc3-cosmos-linux-example`. Navigate to this directory and run:

```
$ ./../openc3.sh cli generate target LINUX_EXAMPLE
```

This creates the plugin directory structure as well as template configuration files that our generated configuration will replace. These files are located at:

```
cosmos-project/openc3-cosmos-linux-example/plugin.txt
cosmos-project/openc3-cosmos-linux-example/targets/LINUX_EXAMPLE/cmd_tlm/cmd.txt
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
```

If the Cosmos and Admant example project directories are adjacent:

```
$ 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
```

The Cosmos plugin uses a default CRC protocol provided by Cosmos, but needs a modifification to apply Adamant's command packet checksum correctly. Navigate to the `cosmos-project/openc3-cosmos-linux-example/targets/LINUX_EXAMPLE/lib` directory, then run:

```
$ wget https://github.com/OpenC3/cosmos/raw/main/openc3/lib/openc3/interfaces/protocols/crc_protocol.rb -O crc_8bc_protocol.rb
```

Modify the following lines of this file by running:

```
$ sed -i 's+CrcProtocol < Protocol+Crc8bcProtocol < CrcProtocol+g' crc_8bc_protocol.rb
$ sed -i 's+write_packet(packet)+write_packet(packet, seed = 0xFF)+g' crc_8bc_protocol.rb
$ sed -i 's+end_range = packet.get_item(@write_item_name).bit_offset / 8+crc = packet.buffer.bytes.reduce(seed, :^)+g' crc_8bc_protocol.rb
$ sed -i 's+crc = @crc.calc(packet.buffer(false)\[0...end_range\])++g' crc_8bc_protocol.rb
```

The plugin can now be compiled. Navigate to the plugin directory at `openc3-cosmos-linux-example` and run:

```
$ ./../openc3.sh cli rake build VERSION=1.0.0
```

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.

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.

With Cosmos running, here are some interesting things you can try:

1. View events generated from the Linux assembly in the main panel.
2. View telemetry from the Counter and Oscillator components by opening the `Telemetry Grapher` panel and selecting the corresponding packets and parameters.
3. Send any command by selecting it in the `Command Sender` panel. Try sending a NOOP or changing the Oscillator frequencies.
4. View the queue usage for each component by opening the `Packet Viewer` panel and selecting the corresponding packet.
5. Send an interrupt to the running assembly by running `sh send_interrupt.sh` from a new SSH session within within the Linux environment. You should see the software respond by printing out `Interrupt received` with a time stamp in the terminal where `redo run` was started.

## Commanding and Telemetry with Hydra

Expand Down
Binary file added src/assembly/linux/main/img/cosmos.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5759b06

Please sign in to comment.