Source code for codeair.crtp

"""Python interface to CodeAIR's Crazyflie flight controller across the UART on the STM32.

Reference for `Crazy Real Time Protocol (CRTP) <https://www.bitcraze.io/documentation/repository/crazyflie-firmware/master/functional-areas/crtp/>`_

This is the low-layer driver used by the `flight_lib/flight_lib` code on CodeAIR. (implemented in C, download below)

Example:

    .. code-block:: python

        >>> crtp.send(15, 1, b'')  # Send 'source' command [ port=CRTP_PORT_LINK(15), channel=1 ]
        >>> crtp.receive()
        (15, 1, b'Bitcraze Crazyflie\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')

"""

[docs]def init(): """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. """ pass
[docs]def deinit(): """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. """ pass
[docs]def send(port, channel, data): """Send a CRTP message to the flight controller. Args: port (int) : CRTP port channel (int) : CRTP channel data (bytes) : Payload data to send (Or b'' if none needed) """ pass
[docs]def receive(): """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). Returns: tuple (int, int, bytes): A tuple containing: - port (int): The CRTP port number. - channel (int): The CRTP channel number. - data (bytes): The actual data received from the flight controller. None: If no buffered packets are available. """ pass
[docs]def flush(): """Clear all buffered CRTP packets, so next receive() will return None. Returns: None """ pass
[docs]def log_read(): """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: tuple : (log_block_id, timestamp_ms, log_data) """ pass
[docs]def console_read(): """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: str : Console output. Will have embedded newline characters, which will format properly when passed to print() or written to a file. """ pass
[docs]def console_stdout(do_enable): """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. Args: do_enable (bool) : True to enable, False to disable """ pass