Skip to content

Exception while reading transport, link probably closed? - Bolt UART CFLib Connection Issues #599

@n-jay

Description

@n-jay

We've been running into some problems trying to connect a CF Bolt 1.1 with a Raspberry Pi 3 board

When running the provided sample code given in the docs (posted below) we are getting the following output.

CPX UART transport
Connecting to UART on /dev/ttyAMA0 @ 576000...
255
Got start
0
Connected
Creating queue for CPXFunction.CRTP
Exception while reading transport, link probably closed?
release unlocked lock
Traceback (most recent call last):
  File "/home/sustain/crazyflie-lib-python/cflib/cpx/__init__.py", line 151, in run
    packet = self._transport.readPacket()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sustain/crazyflie-lib-python/cflib/cpx/transports.py", line 139, in readPacket
    self._lock.release()
RuntimeError: release unlocked lock

Exception while reading transport, link probably closed?
release unlocked lock
Traceback (most recent call last):
  File "/home/sustain/crazyflie-lib-python/cflib/cpx/__init__.py", line 151, in run
    packet = self._transport.readPacket()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/sustain/crazyflie-lib-python/cflib/cpx/transports.py", line 139, in readPacket
    self._lock.release()
RuntimeError: release unlocked lock

... (exceptions continue on forever)

We have followed all of the steps the UART communication docs, and have...

  1. Setup the raspberry pi's hardware uart (verified via seperate usb-uart interface)
  2. Re-flashed the Bolt v1.1 firmware (latest from github) using the cpxOverUART2 custom deck driver, configured with Support wired external host using CPX on UART enabled.

We've also tried the current CFLib version on pip, as well as the latest github repository at time of writing (0.1.28.post1.dev186+gc8bf3646b).

To rule out any other raspberry pi configuration issues, we've also used a known good usb to uart adapter from the raspberry-pi -> CF Bolt, but are having the same problems.

We were able to successfully use a reflashed CF 2.1 Brushless Drone, with both the raspberry pi and usb-uart adapter.

We aren't quite sure if this is a firmware or CFLib issue, but any help is appreciated!

Sample Code:

#!/usr/bin/env python3

import logging
import time

import cflib.crtp
from cflib.crazyflie import Crazyflie
from cflib.crazyflie.syncCrazyflie import SyncCrazyflie
from cflib.crazyflie.log import LogConfig
from cflib.crazyflie.syncLogger import SyncLogger

# choose the serial URI that matches the setup serial device
URI = 'serial://ttyAMA0'

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)
    cf = Crazyflie(rw_cache='./cache')
    cf.console.receivedChar.add_callback(console_callback)
    
    lg_stab = LogConfig(name='Stabilizer', period_in_ms=10)
    lg_stab.add_variable('stabilizer.roll', 'float')
    lg_stab.add_variable('stabilizer.pitch', 'float')
    lg_stab.add_variable('stabilizer.yaw', 'float')


    with SyncCrazyflie(URI) as scf:
        print('[host] Connected, use ctrl-c to quit.')
        with SyncLogger(scf, lg_stab) as logger:
            endTime = time.time() + 10
            for log_entry in logger:
                timestamp = log_entry[0]
                data = log_entry[1]
                logconf_name = log_entry[2]

                print('[%d][%s]: %s' % (timestamp, logconf_name, data))

                if time.time() > endTime:
                    break

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions