Skip to content

Commit

Permalink
Update uart_communication.md
Browse files Browse the repository at this point in the history
  • Loading branch information
knmcguire committed Jan 3, 2023
1 parent 936f445 commit 783ffdd
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions docs/development/uart_communication.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ If you are connecting to a Raspberry Pi look for the UART pins there connect the

- Crazyflie TX2 -- Raspberry Pi RX
- Crazyflie RX2 -- Raspberry Pi TX
- Crazyflie Gdn -- Raspberry Pi Gdn (if not both connected to same powersource)

## Crazyflie Firmware

Expand Down Expand Up @@ -71,15 +72,19 @@ URI = 'serial://ttyAMA0'
# Only output errors from the logging framework
logging.basicConfig(level=logging.ERROR)

def console_callback(text: str):
print(text, end='')

if __name__ == '__main__':
# Initialize the low-level drivers including the serial driver
cflib.crtp.init_drivers(enable_serial_driver=True)

with SyncCrazyflie(URI) as scf:
# We take off when the commander is created
with MotionCommander(scf) as mc:
print('Taking off!')
time.sleep(0.1)
# We land when the MotionCommander goes out of scope
print('Landing!')
print('[host] Connected, use ctrl-c to quit.')
while True:
time.sleep(1)
```

## Troubleshooting

If you see the a `CRC error` when running the script, make sure to install the cflib from source.

0 comments on commit 783ffdd

Please sign in to comment.