Missing log blocking connection initialization

Firmware/software/electronics/mechanics
Post Reply
greensebastian
Beginner
Posts: 2
Joined: Mon Feb 11, 2019 3:51 pm

Missing log blocking connection initialization

Post by greensebastian »

Hi!

I've been trying to set up a system to connect to multiple crazyflies in sequence using the same radio, but sometimes the connection between the python api and the crazyflie does not initiate properly. Restarting the crazyflie and retrying always works, however is not really practical when using a larger swarm.

I have found a temporary fix in sending a CMD_RESET_LOGGING (channel 1 cmd 5) package to the crazyflie and closing/opening the link after a certain timeout period, however this causes the connection sequence in the python api to fall out of sync and produce an error as the TOC indexing seems to rely on threads and callbacks to initiate communication. I've added the relevant pieces of code and the console debug output below.

I want to be able to interrupt the connection sequence, reset all logging on the crazyflie (and perhaps also in the python library?) and retry, but i cant seem to find an entry point or callback in the lib that is suitable.

The "Error no LogEntry to handle id=1" error keeps repeating until a CMD_RESET_LOGGING command is sent, or the crazyflie is restarted.

Should also note that this error has occured both on the first crazyflie and on subsequent ones, however the frequency seems to increase the more connections are running simultaneously.

Is this something anyone has encountered before, and/or is there some part of the connecting/disconnecting sequence that I'm getting wrong?

Code: Select all

    @staticmethod
    def ext_open_link_cf(scf, timeout=3, retries=5):
        cf = scf.cf
        tries = 0
        while tries < retries and cf.is_connected() is not True:
            tries = tries + 1
            print('Connection attempt ' + str(tries) + ' for ' + scf._link_uri)
            thread = Thread(target=partial(cf.open_link, scf._link_uri))
            thread.start()
            if timeout > 0:
                timestep = 0.1
                steps = timeout/timestep
                for i in range(int(steps)):
                    time.sleep(timestep)
                    if cf.is_connected():
                        break
            else:
                thread.join()

            if cf.is_connected():
                scf._is_link_open = True
                return
            else:
                CFUtil.reset_logging(scf)
                cf.close_link()
                scf._is_link_open = False
                print('Connection attempt failed...')

    @staticmethod
    def reset_logging(scf):
        """Reset onboard logging for this Crazyflie"""
        print('Resetting onboard log settings for: ' + scf.cf.link_uri)
        CHAN_SETTINGS = 1
        CMD_RESET_LOGGING = 5
        if scf.cf.link is not None:
            pk = CRTPPacket()
            pk.set_header(5, CHAN_SETTINGS)
            pk.data = (CMD_RESET_LOGGING,)
            scf.cf.send_packet(pk)

Code: Select all

Connection attempt 1 for radio://0/80/2M/E7E7E7E704
INFO:cflib.crazyflie:Callback->Connection initialized[radio://0/80/2M/E7E7E7E704]
INFO:cflib.crazyflie:We are connected[radio://0/80/2M/E7E7E7E704], request connection setup
INFO:cflib.crazyflie:Callback->Connected to [radio://0/80/2M/E7E7E7E704]
WARNING:cflib.crazyflie.log:Error no LogEntry to handle id=1
WARNING:cflib.crazyflie.log:Error no LogEntry to handle id=1
WARNING:cflib.crazyflie.log:Error no LogEntry to handle id=1
.
.
.
WARNING:cflib.crazyflie.log:Error no LogEntry to handle id=1
WARNING:cflib.crazyflie.log:Error no LogEntry to handle id=1
WARNING:cflib.crazyflie.log:Error no LogEntry to handle id=1
Resetting onboard log settings for: radio://0/80/2M/E7E7E7E704
INFO:cflib.crazyflie:Closing link
WARNING:cflib.crazyflie.log:Error no LogEntry to handle id=1
WARNING:cflib.crazyflie.log:Error no LogEntry to handle id=1
INFO:cflib.crazyflie:Callback->Disconnected from [radio://0/80/2M/E7E7E7E704]
Connection attempt failed...
Connection attempt 2 for radio://0/80/2M/E7E7E7E704
INFO:cflib.crazyflie:Callback->Connection initialized[radio://0/80/2M/E7E7E7E704]
INFO:cflib.crazyflie:We are connected[radio://0/80/2M/E7E7E7E704], request connection setup
INFO:cflib.crazyflie:Callback->Connected to [radio://0/80/2M/E7E7E7E704]
WARNING:cflib.crazyflie.log:Error no LogEntry to handle id=1
WARNING:cflib.crazyflie.log:Error no LogEntry to handle id=1
WARNING:cflib.crazyflie.log:Error no LogEntry to handle id=1
.
.
.
WARNING:cflib.crazyflie.log:Error no LogEntry to handle id=1
WARNING:cflib.crazyflie.log:Error no LogEntry to handle id=1
WARNING:cflib.crazyflie.log:Error no LogEntry to handle id=1
DEBUG:cflib.crazyflie.log:Logging reset, continue with TOC download
DEBUG:cflib.crazyflie.toc:[5]: Using V2 protocol: 0
DEBUG:cflib.crazyflie.toc:[5]: Start fetching...
DEBUG:cflib.crazyflie:Adding callback on port [5] to [<bound method TocFetcher._new_packet_cb of <cflib.crazyflie.toc.TocFetcher object at 0x0AFAD1D0>>]
DEBUG:cflib.crazyflie.toc:[5]: Got TOC CRC, 255 items and crc=0x55C34AF1
ERROR:cflib.crazyflie:Exception while doing callback on port [5]

Traceback (most recent call last):
  File "C:\Program Files (x86)\python37\lib\site-packages\cflib\crazyflie\__init__.py", line 396, in run
    cb.callback(pk)
  File "C:\Program Files (x86)\python37\lib\site-packages\cflib\crazyflie\toc.py", line 172, in _new_packet_cb
    cache_data = self._toc_cache.fetch(self._crc)
AttributeError: 'NoneType' object has no attribute 'fetch'

INFO:cflib.crazyflie.platformservice:Procotol version: 4
DEBUG:cflib.crazyflie.log:Logging reset, continue with TOC download
DEBUG:cflib.crazyflie.toc:[5]: Using V2 protocol: 1
DEBUG:cflib.crazyflie.toc:[5]: Start fetching...
DEBUG:cflib.crazyflie:Adding callback on port [5] to [<bound method TocFetcher._new_packet_cb of <cflib.crazyflie.toc.TocFetcher object at 0x0AFAD430>>]
DEBUG:cflib.crazyflie.toc:[5]: Got TOC CRC, 23 items and crc=0xC34AF101
ERROR:cflib.crazyflie:Exception while doing callback on port [5]

Traceback (most recent call last):
  File "C:\Program Files (x86)\python37\lib\site-packages\cflib\crazyflie\__init__.py", line 396, in run
    cb.callback(pk)
  File "C:\Program Files (x86)\python37\lib\site-packages\cflib\crazyflie\toc.py", line 172, in _new_packet_cb
    cache_data = self._toc_cache.fetch(self._crc)
AttributeError: 'NoneType' object has no attribute 'fetch'

DEBUG:cflib.crazyflie.toc:[5]: Got TOC CRC, 279 items and crc=0x55C34AF1
INFO:cflib.crazyflie.toc:TOC for port [5] found in cache
DEBUG:cflib.crazyflie:Removing callback on port [5] to [<bound method TocFetcher._new_packet_cb of <cflib.crazyflie.toc.TocFetcher object at 0x0AFAD430>>]
DEBUG:cflib.crazyflie.toc:[5]: Done!
INFO:cflib.crazyflie:Log TOC finished updating
DEBUG:cflib.crazyflie.mem:Requesting number of memories
INFO:cflib.crazyflie.mem:6 memories found
DEBUG:cflib.crazyflie.mem:Requesting first id
DEBUG:cflib.crazyflie.mem:Requesting information about memory 1
DEBUG:cflib.crazyflie.mem:Memory: id=1, type=LED driver, size=24
.
.
.
Post Reply