crtp
– Crazy Real Time Protocol¶
Python interface to CodeAIR’s Crazyflie flight controller across the UART on the STM32.
Reference for Crazy Real Time Protocol (CRTP)
This is the low-layer driver used by the Crazyflie Client Library code on CodeAIR. (implemented in C, download below)
Example
>>> crtp.send(15, 1, b'') # Send 'source' command [ port=CRTP_PORT_LINK(15), channel=1 ] >>> crtp.receive() (15, 1, b'Bitcraze Crazyflie')
-
codeair.crtp.
console_read
()[source]¶ - Read the buffered console output from the flight controller.
May require multiple reads to consume all console output. Up to 1024 bytes are buffered (older content is discarded). Also see console_stdout().
- Returns
- Console output.
Will have embedded newline characters, which will format properly when passed to print() or written to a file.
- Return type
-
codeair.crtp.
console_stdout
(do_enable)[source]¶ - Stream flight controller console output to CodeAIR stdout (Python console).
Try this and then call reset_controller() to see the full bootup messages of the flight controller.
- Parameters
do_enable (bool) – True to enable, False to disable
-
codeair.crtp.
deinit
()[source]¶ De-initialize CRTP. Free resources, including UART hardware. This is necessary before doing a firmware update on the flight controller, which also needs the UART. See load_fw() in the flight module for example.
-
codeair.crtp.
flush
()[source]¶ Clear all buffered CRTP packets, so next receive() will return None.
- Returns
None
-
codeair.crtp.
init
()[source]¶ Initialize CRTP. Starts background task to manage serial (UART) communications with the flight controller, and collect received data for Python access. This is internally called once before Python code starts. There’s no need to call it again unless deinit() has been called.
-
codeair.crtp.
log_read
()[source]¶ - Get a buffered CRTP log data packet. This is a filtered version of receive,
with its own internal queue. This is used by the ‘get_data()’ interface for optimized log data access.
- Returns
(log_block_id, timestamp_ms, log_data)
- Return type
-
codeair.crtp.
receive
()[source]¶ - Get a buffered CRTP packet received from the flight controller.
This will consume the packet; repeated receive() calls will return buffered packets in the order in which they were sent. This function reads from a “raw CRTP queue”, so you will see all CRTP messages, including console and log packets (which are also available via other functions below).