This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
projects:crazyflie:crtp:log [2013-03-20 10:45] macke |
projects:crazyflie:crtp:log [2014-11-25 15:37] macke |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Logging ====== | ||
- | For more information on how to use this and how this is implemented have a look [[projects: | ||
- | ====== State machines ====== | ||
- | ===== Downloading the Table Of Contents ===== | ||
- | < | ||
- | / | ||
- | --> | Fetch TOC info |----->| Fetch TOC item |---->| More items? |--------> | ||
- | \----------------/ | ||
- | | ||
- | | ||
- | | ||
- | Yes | ||
- | </ | ||
- | ====== Communication protocol ====== | ||
- | |||
- | The log port is separated in 3 channels: | ||
- | |||
- | ^ **Port** | ||
- | | | ||
- | | | ||
- | | | ||
- | |||
- | ===== Table of content access ===== | ||
- | This channel is used to download the Table Of Contents that contains all the variables that are available for logging and what types they are. | ||
- | |||
- | The first byte of each messages correspond a command. All communication on this port are initated by the client and all answer from the copter will contain the same command byte. | ||
- | |||
- | ^ TOC command byte ^ Command | ||
- | | 0 | GET_ITEM | ||
- | | 1 | GET_INFO | ||
- | |||
- | ==== Get TOC item ==== | ||
- | |||
- | The GET_ITEM TOC command permits to retrieved the log variables name, group and types from the copter. This command is intended to be requested from all the ID from 0 to LOG_LEN (see GET_INFO). | ||
- | |||
- | < | ||
- | Request (PC to Copter): | ||
- | +--------------+----+ | ||
- | | GET_ITEM (0) | ID | | ||
- | +--------------+----+ | ||
- | Length | ||
- | |||
- | Answer (Copter to PC): | ||
- | +--------------+----+ | ||
- | | GET_ITEM (0) | ID | If index out of range | ||
- | +--------------+----+------+------------+--------------+ | ||
- | | GET_ITEM (0) | ID | Type | | ||
- | +--------------+----+------+------------+--------------+ | ||
- | Length | ||
- | </ | ||
- | ^ Byte ^ Request fields ^ Content | ||
- | | 0 | GET_ITEM | ||
- | | 1 | ID | ID of the item to be retrieved. The variables are numbered from 0 to LOG_LEN (see GET_INFO command) | | ||
- | |||
- | ^ Byte ^ Answer fields | ||
- | | 0 | GET_ITEM | ||
- | | 1 | ID | ID of the item returned | ||
- | | 2 | Type | Variable type of the element. See variable types list | | ||
- | | 3.. | Group | Null-terminated string containing variable group | | ||
- | | .. | Name | Null-terminated string containing the variable name | | ||
- | |||
- | Type, group and name are not sent if the required ID is higher than TOC_LEN-1. | ||
- | |||
- | ==== Get Info ==== | ||
- | |||
- | The get info command is intended to be requested first when connecting to the copter. This permits to know the number of variable, the limitations of the log implementation and the fingerprint of the log variables. | ||
- | |||
- | < | ||
- | Request (PC to Copter): | ||
- | +--------------+ | ||
- | | GET_INFO (1) | | ||
- | +--------------+ | ||
- | Length | ||
- | |||
- | Answer (Copter to PC): | ||
- | +--------------+---------+---------+-----------------+-------------+ | ||
- | | GET_INFO (1) | LOG_LEN | LOG_CRC | LOG_MAX_PACKET | LOG_MAX_OPS | | ||
- | +--------------+---------+---------+-----------------+-------------+ | ||
- | Length | ||
- | </ | ||
- | |||
- | ^ Byte ^ Request fields ^ Content | ||
- | | 0 | GET_INFO | ||
- | |||
- | ^ Byte ^ Answer fields | ||
- | | 0 | GET_INFO | ||
- | | 1 | LOG_LEN | ||
- | | 2 | LOG_CRC | ||
- | | 6 | LOG_MAX_PACKET | Maximum number of log packets that can be programmed in the copter | | ||
- | | 7 | LOG_MAX_OPS | ||
- | |||
- | ===== Log control ===== | ||
- | |||
- | The log control channel permits to setup, activate, deactivate and remove log packets. Like the TOC access channel the first data byte represents a command. | ||
- | |||
- | ^ Control command byte ^ Command | ||
- | | 0 | CREATE_BLOCK | ||
- | | 1 | APPEND_BLOCK | ||
- | | 2 | DELETE_BLOCK | ||
- | | 3 | START_BLOCK | ||
- | | 4 | STOP_BLOCK | ||
- | |||
- | ==== Create block ==== | ||
- | |||
- | ==== Append variable to block ==== | ||
- | |||
- | ==== Delete block ==== | ||
- | |||
- | ==== Start block ==== | ||
- | |||
- | ==== Stop block ==== | ||
- | |||
- | ===== Log data ===== | ||
- | |||
- | The log data channel is used by the copter to send the log blocks at the programmed rate. The packet format is | ||
- | |||
- | < | ||
- | Answer (Copter to PC): | ||
- | +---------+------------+---------// | ||
- | | BLOC_ID | TIME_STAMP | LOG VARIABLE VALUES | | ||
- | +---------+------------+---------// | ||
- | Length | ||
- | </ | ||
- | |||
- | ^ Byte ^ Answer fields | ||
- | | 0 | BLOCK_ID | ||
- | | 1 | ID | Timestamp in ms from the copter startup as a little-endian 3 bytes integer | | ||
- | | 4.. | Log variable values | Packed log values in little endian format | |