This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
projects:crazyflie:firmware:comm_protocol [2012-09-24 19:09] macke |
projects:crazyflie:firmware:comm_protocol [2013-09-16 16:20] ledvinap |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Overview ====== | ====== Overview ====== | ||
- | ===== CRTP ===== | + | CRTP is the protocol used to communicate |
- | The CRTP (Crazy RealTime Protocol) | + | |
- | * [[comm_protocol# | + | CRTP is implemented in 3 layers: |
- | | + | |
- | | + | < |
- | * ... | + | |
+ | | ||
+ | | ||
+ | | CRTP packets handling | | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | * **CRTP Link** is responsible for transferring the packets between the copter and the PC. It will typically handles packet size and error detection. | ||
+ | * **CRTP Packet handling** delivers the packet to the right subsystem in the copter and in the PC control software. | ||
+ | * **Application/ | ||
+ | |||
+ | Implemented link drivers: | ||
+ | ^ **Link** | ||
+ | | [[comm_protocol# | ||
+ | | [[comm_protocol# | ||
+ | | [[comm_protocol# | ||
+ | |||
+ | Current port allocation: | ||
+ | ^ **Port** | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
====== Communication ====== | ====== Communication ====== | ||
Line 21: | Line 47: | ||
| DATA 30 | | | DATA 30 | | ||
+---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ | ||
- | |||
- | +--------+--------+--------+--------+--------+--....--+--------+ | ||
- | | 0xAA | 0xAA | Header | Length | Data0 | Packet | CRC32 | | ||
- | +--------+--------+--------+--------+--------+--....--+--------+ | ||
</ | </ | ||
Line 39: | Line 61: | ||
==== 2.4 GHz NordicSemi Radio ==== | ==== 2.4 GHz NordicSemi Radio ==== | ||
- | 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. | + | 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 |
==== USB port ==== | ==== USB port ==== | ||
Line 45: | Line 67: | ||
==== Serial port ==== | ==== Serial port ==== | ||
+ | The serial port is configured in 115200 8N1. CRTP packets are sent and received asynchronously using the following packet format: | ||
+ | |||
< | < | ||
7 | 7 | ||
Line 52: | Line 76: | ||
| | | | ||
+---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ | ||
- | | R | | + | | |
+---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ | ||
| | | | ||
Line 62: | Line 86: | ||
| DATA 30 | | | DATA 30 | | ||
+---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ | ||
- | | | + | | |
+---+---+---+---+---+---+---+---+ | +---+---+---+---+---+---+---+---+ | ||
+--------+--------+--------+--------+--------+--....--+--------+ | +--------+--------+--------+--------+--------+--....--+--------+ | ||
- | | 0xAA | 0xAA | Header | Length | Data0 | Packet | CRC32 | | + | | 0xAA | 0xAA | Header | Length | Data0 | Packet | Cksum | |
+--------+--------+--------+--------+--------+--....--+--------+ | +--------+--------+--------+--------+--------+--....--+--------+ | ||
Line 72: | Line 96: | ||
^ **Field** ^ **Byte** ^ **Bit** ^ | ^ **Field** ^ **Byte** ^ **Bit** ^ | ||
| | | | ||
- | | | + | | |
- | | ::: | | + | | ::: | |
- | | ::: | | + | | ::: | |
- | | Size | + | | Size |
- | | Data | + | | Data |
- | | | + | | Cksum | |
- | ===== Ports ===== | + | === Examples |
- | The following ports are used during | + | To send setpoints to the [[projects: |
- | ^ | + | < |
- | | [[comm_protocol# | + | 0xaa 0xaa 0x30 0x0e 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x3e |
- | | | + | </ |
- | | | + | |
- | | | + | |
- | | | + | |
- | + | ||
- | ==== Console ==== | + | |
- | 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. | + | |
+ | To ping Crazyflie: | ||
< | < | ||
- | | + | |
- | +---+---+---+---+---+---+---+---+ | + | <- 0xaa 0xaa 0xf0 0x01 0x01 0xf2 # Received from the copter |
- | | CHAR 0 | | + | |
- | +---+---+---+---+---+---+---+---+ | + | |
- | : | + | |
- | +---+---+---+---+---+---+---+---+ | + | |
- | | CHAR 30 | | + | |
- | +---+---+---+---+---+---+---+---+ | + | |
- | + | ||
- | +--------+--------+--------+--------+--------+--....--+--------+ | + | |
- | | 0xAA | 0xAA | Header | Length | Data0 | | Data30 | | + | |
- | +--------+--------+--------+--------+--------+--....--+--------+ | + | |
</ | </ | ||
- | + | ===== Ports ===== | |
- | The contents of the buffer on the copter side is sent if any of the following is fulfulled: | + | |
- | * The output buffer (of 31 bytes) is full | + | |
- | * A " | + | |
- | * A flush command as been issued | + | |
==== Logging ==== | ==== Logging ==== | ||
Line 126: | Line 130: | ||
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' | 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' | ||
- | The logging variables are sequentially | + | The logging variables are requested by the receiver until all variables are returned. When the variable |
- | The CRC32 is a hash of the copter' | + | The CRC32 is a hash of the copter' |
The following messages are sent from the Client to the Crazyflie: | The following messages are sent from the Client to the Crazyflie: | ||
- | ^ **Command byte** ^ **Description** | + | ^ **Request for** ^ **Byte** ^ **Description** |
- | | | + | | TOC item | 0 | 0x00 to identify |
- | | | + | | ::: | 1 | The index of the TOC item to request |
- | | 3 | + | | TOC CRC and count | |
The following messages are sent from the Crazyflie to the Client: | The following messages are sent from the Crazyflie to the Client: | ||
- | ^ **Command byte** ^ **Byte** | + | ^ **Reply for** ^ **Byte** |
- | | 0 or 1 | | + | | TOC item | |
- | | ::: | + | | ::: |
- | | ::: | + | | ::: |
| ::: | | ::: | ||
| ::: | | ::: | ||
- | | 3 | + | | TOC CRC and count |
| ::: | | ::: | ||
- | | ::: | + | | ::: |
- | + | | ::: | 6 | |
- | < | + | | |
- | Bytes | + | |
- | +---+------------+------+----------+--------------+ | + | |
- | | + | |
- | +---+ Var ID | Type | Group | Name | | + | |
- | | 1 | | | + | |
- | +---+------------+------+---+------+--------------+ | + | |
- | | 3 | Num. Vars | + | |
- | +---+------------+----------+ | + | |
- | Bytes | + | |
- | </ | + | |
== Usage == | == Usage == | ||
Line 173: | Line 167: | ||
| | ||
| | ||
- | Reset TOC pointer | + | Request for TOC item 0 ---> |
- | Get next element | + | < |
- | | + | Request for TOC item 1 ---> |
- | | + | |
- | | + | |
- | Get next element | + | |
- | | + | Request for TOC item N-1 ---> |
- | Get next element | + | where N is Number of |
- | | + | total variables in TOC |
+ | < | ||
+ | [optional] | ||
+ | Request for TOC item N ---> | ||
+ | (or any higher) | ||
+ | < | ||
[Fetch complete] | [Fetch complete] | ||
</ | </ | ||
Line 189: | Line 188: | ||
== Messages == | == Messages == | ||
The following messages are sent from the Client to the Crazyflie: | The following messages are sent from the Client to the Crazyflie: | ||
- | ^ **Command byte** ^ **Byte** | + | ^ **Request for** ^ **Byte** |
- | | 0 | + | | |
| ::: | | ::: | ||
- | | ::: | + | | ::: |
- | | ::: | + | | |
- | | 1 | + | |
| ::: | | ::: | ||
| ::: | | ::: | ||
- | | 2 | + | | |
| ::: | | ::: | ||
- | | 3 | + | | Start a log block |
| ::: | | ::: | ||
- | | 4 | + | | ::: |
+ | | Stop a log block | ||
| ::: | | ::: | ||
+ | | Reset log | | ||
+ | |||
+ | |||
The response for all of the above messages is sent from the Crazyflie to the Client: | The response for all of the above messages is sent from the Crazyflie to the Client: | ||
Line 305: | Line 307: | ||
CF -> Computer : 0x[5,2] 0x55 0xBA 0xBE | CF -> Computer : 0x[5,2] 0x55 0xBA 0xBE | ||
</ | </ | ||
- | |||
==== 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 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: | ||
Line 348: | Line 349: | ||
**TODO** | **TODO** | ||
- | === Link layter | + | === Link layer === |
| 3: | | 3: | ||
| 3: | | 3: | ||
| 3: | | 3: | ||
| 3: | | 3: |