Products
-
-
- Accessories
- Breakout boards
This is an old revision of the document!
The CRTP (Crazy RealTime Protocol) is the name of the protocol used to communication with the Crazyflie. The protocol is used for multiple physical layers:
A CRTP packet consists of a 8bit header followed by 0-31 bytes of data.
7 6 5 4 3 2 1 0 +---+---+---+---+---+---+---+---+ | R | Port | Channel | +---+---+---+---+---+---+---+---+ | DATA 0 | +---+---+---+---+---+---+---+---+ : : : : : : : : : +---+---+---+---+---+---+---+---+ | DATA 30 | +---+---+---+---+---+---+---+---+
Field | Byte | Bit | Description |
---|---|---|---|
Header | 0 | 0-2 | The destination channel |
0 | 3-6 | The destination port | |
0 | 7 | Resend flag. If R=1 the last packet needs to be resent | |
Data | 1-31 | The data in the packet |
A port maps to a major function in the Crazyflie that is normally implemented as a separate task. When a CRTP packet is received in the Crazyflie the packet is routed according to the port. The channel can be seen as a sub-set for the port where and can be used to further define commands for the receiving function but no routing will be done using the channel.
Below is the structures for the packages both for the wired serial interface and for the wireless interface. The limitation for the length of the data is set so that it will fit inside one packet for the wireless transmission.
The wireless interface will add additional header data like CRC when sending the packet and therefore the packet sent to the wireless interface is only a CRTP packet.
TODO
7 6 5 4 3 2 1 0 +---+---+---+---+---+---+---+---+ | 0xAA | +---+---+---+---+---+---+---+---+ | 0xAA | +---+---+---+---+---+---+---+---+ | R | Port | Channel | +---+---+---+---+---+---+---+---+ | Packet length | +---+---+---+---+---+---+---+---+ | DATA 0 | +---+---+---+---+---+---+---+---+ : : : : : : : : : +---+---+---+---+---+---+---+---+ | DATA 30 | +---+---+---+---+---+---+---+---+ | CRC | +---+---+---+---+---+---+---+---+
Field | Byte | Bit | Description |
---|---|---|---|
Start | 0-1 | 0-2 | Start token for synchronization (0xAAAA) |
Header | 2 | 0-2 | The destination channel |
2 | 3-6 | The destination port | |
2 | 7 | Resend flag. If R=1 the last packet needs to be resent | |
Size | 3 | The size of the packet | |
Data | 4-34 | The data in the packet | |
CRC | 35-36 | The CRC16 of the packet |
The following ports are used during the communication.
This port is used as a one-way text console. Printouts using printf will be sent on this port and can be read by a receiver if connected.
7 6 5 4 3 2 1 0 +---+---+---+---+---+---+---+---+ | CHAR 0 | +---+---+---+---+---+---+---+---+ : : : : : : : : : +---+---+---+---+---+---+---+---+ | CHAR 30 | +---+---+---+---+---+---+---+---+
The contents of the buffer on the copter side is sent if any of the following is fulfulled:
The purpose of the logging is to be able to log variables that are available in the copter during runtime. The available variables are listed using a TOC that can be read from the copter. A logging block can then be registered consisting of there variables and the data will be sent periodically via CRTP to a receiver.
Port | Channel | Function |
---|---|---|
5 | 0 | Table of content access |
5 | 1 | Log settings access |
5 | 2 | Log data access |
This channel is used to access the loggable variables table of content.
Each message uses an additional command byte that is followed by 0 to 31 bytes of data depending of the command. For every command byte there's a difference in usage depending on if the message is sent from the Crazyflie to a Computer or the other way around.
The logging variables are sequentially requested by the receiver until the end. When the last loggable variable is reached it has the ID 0 'Last TOC element'. The reset command permits to reset the TOC pointers so that the next sent TOC element will be the first one. The Get CRC commands also returns the number of loggable variables.
The CRC32 is a hash of the copter's loggable variable TOC. The aim of having this is to be able to cache data on the receiver end and to quickly check the validity of it when connecting.
The following messages are sent from the Client to the Crazyflie:
Command byte | Description |
---|---|
0 | Resets the TOC index pointer in the Crazyflie |
1 | Request the next item in the TOC |
3 | Request the CRC32 of the TOC |
The following messages are sent from the Crazyflie to the Client:
Command byte | Byte | Description |
---|---|---|
0 or 1 | 0 | The two command bytes has the same format but the command byte 0 indicates that it is the last item in the TOC |
1 | Variable ID | |
2 | Type TODO more explination | |
3-n | Null terminated string containing group name | |
n-m | Null terminated string containing variable name | |
3 | 0 | The TOC CRC32 command byte |
1 | Number of total variables in TOC | |
2-5 | CRC32 value of the TOC (of what exacly? group/names?) |
Bytes 1 1 1 Null terminated strings +---+------------+------+----------+--------------+ | 0 | | | | | +---+ Var ID | Type | Group | Name | | 1 | | | | | +---+------------+------+---+------+--------------+ | 3 | Num. Vars | CRC32 | +---+------------+----------+ Bytes 1 1 4
Example of checking the CRC of a TOC to determine if the TOC needs to be refreshed.
Computer Crazyflie -------- --------- Get TOC CRC32 ---> <--- TOC CRC32 [Compare CRC]
Example of downloading TOC contents from Crazyflie.
Computer Crazyflie -------- --------- Reset TOC pointer ---> [Pointer resets] Get next element ---> <--- TOC element .... .... Get next element ---> <--- TOC element Get next element ---> <--- Last TOC element [Fetch complete]
This channel is used to access the log settings to add/remove/append/start/stop logging. Once a logging block is added to the settings the data it is set to log will periodically be pushed from the Crazyflie to the Client.
The following messages are sent from the Client to the Crazyflie:
Command byte | Byte | Description |
---|---|---|
0 | 0 | Add a logging block |
1 | Period | |
2-31 | Variables to log | |
1 | 0 | Append logging variables to an existing block |
1 | Block ID | |
2-31 | Variables to log | |
2 | 0 | Delete an existing block |
1 | Block ID | |
3 | 0 | Enable logging data from an existing block |
1 | Block ID | |
4 | 0 | Disable logging data from an existing block |
1 | Block ID |
The following format is used to indentify a variable that is to be logged from the Crazyflie:
Blah blah
Adding a new log block to the settings:
Insert fancy ASCII graphics :-)
Deleting an existing log block from the settings:
Insert fancy ASCII graphics :-)
TODO
The parameters system aims at making accessible all the gettable and settable parameters of the copter. In the copter a table of parameters is hold and can be retrieved. In this table every parameter name is associated with an ID and a group name. Three ID are used to acces the TOC and the paramareters:
Port | Function |
(0,9,0) | TOC access |
(0,9,1) | Parameter read |
(0,9,2) | Parameter write |
This ports permits to access the parameters table of content. The first byte of the message is a message ID, three messages ID are defined:
Message ID | Meaning in upstream packets | Meaning in downstream packets |
0 | Reset TOC pointer | Last TOC element |
1 | Get next TOC element | TOC element |
3 | Get TOC CRC32 | TOC CRC32 |
The upstream ID are commands and are sent alone. The downstream have the following formats:
Bytes 1 1 1 Null terminated strings +---+------------+------+----------+--------------+ | 0 | | | | | +---+ Param ID | Type | Group | Name | | 1 | | | | | +---+------------+------+---+------+--------------+ | 3 | Num. Param | CRC32 | +---+------------+----------+ Bytes 1 1 4
The parameters are sequentially requested by the PC until the end. When the last parameter is reached it has the ID 0 'Last TOC element'. The reset command permits to reset the TOC pointers so that the next sent TOC element will be the first one. The Get CRC commands also returns the number of parameters.
The CRC32 is a hash of the copter TOC. This is aim at implementing caching of the TOC in the PC Utils to avoid fetching the full TOC each time the copter is connected.
TODO
TODO
TODO
3:15:0 | Echo (profiling) |
3:15:1 | Source (profiling) |
3:15:2 | Sink (profiling) |
3:15:3 | NULL packet |