Crazyflie console is used to receive characters printed using printf from the firmware.
| 36 | |
| 37 | |
| 38 | class Console: |
| 39 | """ |
| 40 | Crazyflie console is used to receive characters printed using printf |
| 41 | from the firmware. |
| 42 | """ |
| 43 | |
| 44 | def __init__(self, crazyflie): |
| 45 | """ |
| 46 | Initialize the console and register it to receive data from the copter. |
| 47 | """ |
| 48 | |
| 49 | self.receivedChar = Caller() |
| 50 | |
| 51 | self.cf = crazyflie |
| 52 | self.cf.add_port_callback(CRTPPort.CONSOLE, self.incoming) |
| 53 | |
| 54 | def incoming(self, packet): |
| 55 | """ |
| 56 | Callback for data received from the copter. |
| 57 | """ |
| 58 | # This might be done prettier ;-) |
| 59 | console_text = packet.data.decode('UTF-8') |
| 60 | |
| 61 | self.receivedChar.call(console_text) |