This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
projects:crazyflie:firmware:log [2012-11-11 18:15] arnaud [Communication protocol] |
projects:crazyflie:firmware:log [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:// | ||
+ | </ | ||
====== Crazyflie LOG subsystem ====== | ====== Crazyflie LOG subsystem ====== | ||
- | The purpose of the logging is to be able to log variables that are available in the copter during runtime. The Crazyflie log system is design in such a way that the copter firmware is mostly | + | The purpose of the logging is to be able to log variables that are available in the copter during runtime. The Crazyflie log system is design in such a way that the copter firmware is mostly |
This mechanism is used both for regular log operation (ie. user requested log to inspect and debug flight data) but also to update indication in the GUI application. | This mechanism is used both for regular log operation (ie. user requested log to inspect and debug flight data) but also to update indication in the GUI application. | ||
Line 9: | Line 12: | ||
{{: | {{: | ||
- | ===== Communication protocol | + | ===== Firmware usage ===== |
- | The log port is separated | + | A couple of macros are declared in //log.h// to define new log variables. All log variables should be in a log group. Example: |
- | ^ **Port** | + | < |
- | | | + | LOG_GROUP_START(stabilizer) |
- | | | + | LOG_ADD(LOG_FLOAT, roll, & |
- | | | + | LOG_ADD(LOG_FLOAT, pitch, & |
- | + | LOG_ADD(LOG_FLOAT, yaw, & | |
- | ==== Table of content access ==== | + | LOG_GROUP_STOP(stabilizer) |
- | + | ||
- | This channel is used to access the loggable variables table of content. | + | |
- | + | ||
- | 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 | + | |
- | | + | |
- | | GET_ITEM | + | |
- | | + | |
- | Length | + | |
- | + | ||
- | Answer | + | |
- | | + | |
- | | GET_ITEM | + | |
- | | + | |
- | | GET_ITEM | + | |
- | +--------------+----+------+------------+--------------+ | + | |
- | Length | + | |
</ | </ | ||
- | ^ Request fields ^ Content | ||
- | | GET_ITEM | ||
- | | ID | ID of the item to be retrieved. The variables are numbered from 0 to LOG_LEN (see GET_INFO command) | | ||
- | |||
- | ^ Answer fields | ||
- | | GET_ITEM | ||
- | | ID | ID of the item returned | ||
- | | Type | Variable type of the element. See variable types list | | ||
- | | 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 | ||
- | </ | ||
- | |||
- | ^ Request fields ^ Content | ||
- | | GET_INFO | ||
- | |||
- | ^ Answer fields | ||
- | | GET_INFO | ||
- | | LOG_LEN | ||
- | | LOG_CRC | ||
- | | LOG_MAX_PACKET | Maximum number of log packets that can be programmed in the copter | | ||
- | | 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 | ||
+ | ^ Macro ^ Usage ^ | ||
+ | | LOG_GROUP_START(grp_name) | ||
+ | | LOG_GROUP_STOP(grp_name) | ||
+ | | LOG_ADD(type, | ||
+ | ^ Type defines ^ Corresponding C99 type ^ Note ^ | ||
+ | | LOG_UINT8 | ||
+ | | LOG_UINT16 | ||
+ | | LOG_UINT32 | ||
+ | | LOG_INT8 | ||
+ | | LOG_INT16 | ||
+ | | LOG_INT32 | ||
+ | | LOG_FLOAT | ||
+ | | LOG_FP16 |