User Tools

Site Tools


projects:crazyflie:firmware:comm_protocol

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
projects:crazyflie:firmware:comm_protocol [2013-09-16 19:29]
ledvinap [Logging]
projects:crazyflie:firmware:comm_protocol [2021-06-24 16:49] (current)
kimberly
Line 1: Line 1:
 +<WRAP center round important 60%>
 +This page has deprecated and will be archived. Please go to [[https://www.bitcraze.io/]].
 +</WRAP>
 ====== Overview ====== ====== Overview ======
 CRTP is the protocol used to communicate with Crazyflie. Is originally stands for //Crazy RealTime Protocol//. The protocol permits to communicate independently with the copter subsystem and would have the capability to handle packet priorities. CRTP is the protocol used to communicate with Crazyflie. Is originally stands for //Crazy RealTime Protocol//. The protocol permits to communicate independently with the copter subsystem and would have the capability to handle packet priorities.
Line 124: Line 127:
 |            2        | [[comm_protocol#log_data_access|Log data access]] | |            2        | [[comm_protocol#log_data_access|Log data access]] |
  
-=== Table of content access ===+=== Table of content access (Port 5 channel 0) ===
 This channel is used to access the loggable variables table of content. This channel is used to access the loggable variables table of content.
  
Line 136: Line 139:
 The following messages are sent from the Client to the Crazyflie: The following messages are sent from the Client to the Crazyflie:
 ^  **Request for**  ^  **Byte**  ^  **Description**  ^ ^  **Request for**  ^  **Byte**  ^  **Description**  ^
-| TOC item  |          | 0x00 to identify the command  |+| TOC item  |          | 0x00 (CMD_GET_ITEM) to identify the command  |
 |   :::    |          | The index of the TOC item to request | |   :::    |          | The index of the TOC item to request |
-|  TOC CRC and count |  0   | 0x01 Request the TOC CRC and item count |+|  TOC CRC and count |  0   | 0x01 (CMD_GET_INFO) Request the TOC CRC and item count |
  
 The following messages are sent from the Crazyflie to the Client: The following messages are sent from the Crazyflie to the Client:
 ^  **Reply for**  ^  **Byte**  ^  **Description**  ^ ^  **Reply for**  ^  **Byte**  ^  **Description**  ^
-|     TOC item                | 0x00 to identify the command |+|     TOC item                | 0x00 (CMD_GET_ITEM) to identify the command |
 |        :::                  | Variable ID |        :::                  | Variable ID
 |        :::                  | Type (ref to variable type )  | |        :::                  | Type (ref to variable type )  |
 |        :::            3-n     | Null terminated string containing group name  | |        :::            3-n     | Null terminated string containing group name  |
 |        :::            n-m     | Null terminated string containing variable name  | |        :::            n-m     | Null terminated string containing variable name  |
-| TOC CRC and count  |          | 0x01 to identify the command  |+| TOC CRC and count  |          | 0x01 (CMD_GET_INFO) to identify the command  |
 |        :::                  | Number of total variables in TOC  | |        :::                  | Number of total variables in TOC  |
 |        :::            2-5     | CRC32 value of the TOC (calculated from raw contents of log TOC section)  | |        :::            2-5     | CRC32 value of the TOC (calculated from raw contents of log TOC section)  |
Line 183: Line 186:
 [Fetch complete]                    [Fetch complete]                   
 </code> </code>
-=== Log settings access ===+ 
 +=== Log settings access (Port 5 channel 1) ===
 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. 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.
  
Line 189: Line 193:
 The following messages are sent from the Client to the Crazyflie: The following messages are sent from the Client to the Crazyflie:
 ^  **Request for**  ^  **Byte**  ^  **Description**  ^ ^  **Request for**  ^  **Byte**  ^  **Description**  ^
-|  Adding a new log  |          | 0x00 for identifying the command to add a logging block  | +|  Create a new log block           |          | 0x00 (CONTROL_CREATE_BLOCK) for identifying the command to add a logging block  | 
-|        :::         |          | Desired block id  | +|        :::                        |          | Desired block id  | 
-|        :::         |    2-31    | [[comm_protocol#variable_format|Variables to log]]  | +|        :::                        |    2-31    | [[comm_protocol#variable_format|Variables to log]]  | 
-|  Append to log              | 0x01 for identifying the command to append logging variables to an existing block  | +|  Append to existing log block     |          | 0x01 (CONTROL_APPEND_BLOCK) for identifying the command to append logging variables to an existing block  | 
-|        :::         |          | Block ID | +|        :::                        |          | Block ID | 
-|        :::         |    2-31    | [[comm_protocol#variable_format|Variables to log]]  | +|        :::                        |    2-31    | [[comm_protocol#variable_format|Variables to log]]  | 
-|  Delete a log      |          | 0x02 to identify the command for delete an existing block  | +|  Delete a log block               |          | 0x02 (CONTROL_DELETE_BLOCK) to identify the command for delete an existing block  | 
-|        :::         |          | Block ID | +|        :::                        |          | Block ID | 
-| Start a log block  |          | 0x03 to identify the command for enabling logging data from an existing block  | +| Start a log block                 |          | 0x03 (CONTROL_START_BLOCK) to identify the command for enabling logging data from an existing block  | 
-|        :::         |          | Block ID | +|        :::                        |          | Block ID | 
-|        :::         |          | Period in 10th of ms +|        :::                        |          | Period in 10ms increments 
-|  Stop a log block  |          | 0x04 to identify the command for disabling logging data from an existing block  | +|  Stop a log block                 |          | 0x04 (CONTROL_STOP_BLOCK) to identify the command for disabling logging data from an existing block  | 
-|        :::         |          | Block ID | +|        :::                        |          | Block ID | 
-|     Reset log      |          | 0x05 to identify the command to reset log. All blocks are stopped and deleted   |+|     Reset log                     |          | 0x05 (CONTROL_RESET) to identify the command to reset log. All blocks are stopped and deleted   |
  
  
Line 209: Line 213:
 ^  **Byte**  ^  **Description**  ^ ^  **Byte**  ^  **Description**  ^
 |          | The command byte that was sent  | |          | The command byte that was sent  |
-|          | The ID of the log block that the command operated on |+|          | The ID of the log block that the command operated on (undefined for Reset log)  |
 |          | Return status for the command. If != 0 see [[comm_protocol#list_of_return_codes|list of return codes ]]  | |          | Return status for the command. If != 0 see [[comm_protocol#list_of_return_codes|list of return codes ]]  |
  
Line 238: Line 242:
 |                  | Memory address pointing to float32       | |                  | Memory address pointing to float32       |
  
-TOC variable request (Storage type is ignored):+TOC variable request (Storage type is ignored, it is taken from Crazyflie internal TOC):
 <code> <code>
   7               0   7               0
Line 267: Line 271:
  
  
-== List of return codes ( errno.h codes are used ) == +== List of return codes ( errno.h codes are used, returned values are positive ) == 
-^  **Error**  ^  **Description** +^  **Error**    ^  **Description** 
-|  0  | No error  | +|  0            | No error  | 
-|  ENOENT (2)  | Block or variable not found  | +|  ENOENT (2)   | Block or variable not found  | 
-|  E2BIG (7)  | Log block is too long  | +|  E2BIG (7)    | Log block is too long  | 
-|  ENOEXEC (8)  | unknown command received  |+|  ENOEXEC (8)  | Unknown command received  |
 |  ENOMEM (12)  | No memory to allocate Log Block or Log Item  | |  ENOMEM (12)  | No memory to allocate Log Block or Log Item  |
  
Line 302: Line 306:
 </code> </code>
  
-=== Log data access === +=== Log data access (Port 5 channel 2) === 
-Logging data is sent back to the copter as raw data with only the block id. This means that the lookup of what data is for what variable has to be done on the computer side.+Logging data is sent back to the copter as raw data with only the block id. This means that the lookup of what data is for what variable has to be done on the computer side. Log  
 +block header contains 3 byte timestamp, its value is number of microseconds from Crazyflie system start (it will wrap around in about 16 seconds. Is is also currently based on xTaskGetTickCount, so resolution is only 1ms). All values are sent in little endian format. 
 + 
 +^  **Byte**  ^  **Description** 
 +|          | Block ID | 
 +|    1-3     | Block send time timestamp in us, LSB first  | 
 +|    4-31    | Logged variable values, LSB first  |
  
 <code> <code>
-Adding a log block 0xbb logging variable ID 0x55 at 100ms interval and of type uint16:+Adding a log block 0xbb at 100ms interval logging variable ID 0x55 of type uint16:
 Computer -> CF : 0x[5,1] 0x00 0xbb 0x02 0x55       // create logging block Computer -> CF : 0x[5,1] 0x00 0xbb 0x02 0x55       // create logging block
-CF -> Computer : 0x[5,1] 0x00 0x55 0x00 +CF -> Computer : 0x[5,1] 0x00 0x55 0x00            // OK 
-Computer -> CF : 0x[5,1] 0x00 0xbb 0x0A            // start sending block with 100ms interval+Computer -> CF : 0x[5,1] 0x03 0xbb 0x0A            // start sending block with 100ms interval 
 +CF -> Computer : 0x[5,1] 0x03 0x55 0x00            // OK
  
-Receiving a log block 0xbb 1300ms logging variable (value 0xBABE)+Receiving a log block 0xbb with timestamp 130.532s (0x1FDE4 ms), logging uint16 variable with value 0xBABE: 
-CF -> Computer : 0x[5,2] 0xBB 0xA3 0xA2 0xA1 0xBA 0xBE+CF -> Computer : 0x[5,2] 0xBB 0xE4 0xFD 0x01 0xBE 0xBA
 </code> </code>
 ==== Parameters ==== ==== Parameters ====
-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:+The parameters system makes all the gettable and settable parameters of the copter accessibleThe copter holds a table of parameters which can be retrieved. In this table every parameter name is associated with an ID and a group name. Three IDs are used to acces the TOC and the parameters:
  
-| **Port**  | **Function**      | +Port      ^ Channel     Function          ^ 
-|  (0,9,0)  | TOC access        | +|  2        |           | TOC access        | 
-|  (0,9,1)  | Parameter read    | +|  2        |           | Parameter read    | 
-|  (0,9,2)  | Parameter write   |+|  2        | 2           | Parameter write   |
  
-=== TOC access === +=== TOC access (Port 2 channel 0) === 
-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:+These messages permit 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** | +^  Message ID  ^  Meaning in upstream packets  ^  Meaning in downstream packets      ^ 
-|            0 | Reset TOC pointer             | Last TOC element                +|            0 | Reset TOC pointer             | Last TOC element                    
-|            1 | Get next TOC element          | TOC element                     +|            1 | Get next TOC element          | TOC element (ID, type, group, name) 
-|            3 | Get TOC CRC32                 | TOC CRC32                       |+|            3 | Get TOC CRC32                 Number of parameters, TOC CRC32     |
  
-The upstream ID are commands and are sent alone. The downstream have the following formats:+The upstream ID are commands and are sent alone. The downstream has the following formats:
  
 <code> <code>
Line 344: Line 355:
 </code> </code>
  
-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 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 TOC CRC" command 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.+The CRC32 is a hash of the copter TOC. This is aimed at implementing caching of the TOC in the PC Utils to avoid fetching the full TOC each time the copter is connected.
  
-=== Parameter read === +=== Parameter read (Port 2 channel 1) and parameter write (Port 2 channel 2)=== 
-**TODO** + 
-=== Parameter write === +The following messages are sent from the client to the Crazyflie: 
-**TODO**+^  **Request for**   ^  **Byte**  ^  **Description**  ^ 
 +|  Parameter read    |          | The id of the parameter to read   | 
 +|  Parameter write   |          | The id of the parameter to write   | 
 +|   :::              |          | The value to set | 
 + 
 +The following messages are sent from the Crazyflie to the client: 
 +^  **Reply for**             **Byte**  ^  **Description** 
 +|  Parameter read & write            | Parameter id      | 
 +|   :::                         1-n    | Parameter value   |
  
 === Fight control ==== === Fight control ====
projects/crazyflie/firmware/comm_protocol.1379352566.txt.gz · Last modified: 2015-07-15 16:30 (external edit)