Skip to content
Snippets Groups Projects
packets.md 11.13 KiB

Packet Information

The MicroCART project uses custom packets to communicate with the quad. This may seem complex at first, but the structure of all packets is the same, only the formatting of the data differs between packets.

Introduction

All packets are the same in the sense that they have consistent headers with a start character and all end with a checksum. The basic structure is shown below.

Index 0 1 2 3 4 5
Message Parameter Begin Character Message Type Message ID Data Length Data Checksum
Bytes 1 2 2 2 var 1

The begin character is defined in the Message enum in commands.h. Message types are defined within the MessageTypeID enum in commands.h. Message ID is managed within the backend backend.c and is just a counter that is used in client_recv to number packets. Data length varies with the command that is being sent, but the length of a command is constant. The data is sent in a specific format set by commands. Lastly, checksum is computed within packet.c.

All packets sent within the system are commands, defined by the MessageTypeID enum referenced earlier, or a VPRN packet. Much of the time when flying autonomously the commands that the user is responsible for are the getparam and setparam packets that are used to set waypoints or change values within the computation graph, see control_algorithm.c for the PID blocks.

Adding a new packet and/or command (CLI or GUI to Backend/Quad)

There are many files that need to be created and changed to add a packet and/or a command. If only adding a command that does not send a packet only the CLI and GUI, frontend, and backend must be changed. If also sending a packet then commands and quad_app must also be changed. The instructions below will take you through what must be changed in all the different areas to support new functionality. Many times a good method to creating the new files is to copy the files from another command and change what you need.

CLI and GUI