Skip to content

Us the same link instance in send_packet() - #607

Open
ArisMorgens wants to merge 1 commit into
masterfrom
Aris/send_packet-link
Open

ArisMorgens wants to merge 1 commit into
masterfrom
Aris/send_packet-link

Conversation

@ArisMorgens

Copy link
Copy Markdown
Member

When flashing a Crazyflie 2.0 via cfclient, most of the times the process got stuck in "identifying decks to update", with this error:

crazyflie-lib-python/cflib/crazyflie/__init__.py", line 390, in send_packet
    self.link.send_packet(pk)
    ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'send_packet'

This was caused by send_packet() reading self.link twice: first in if self.link is not None: , and then in elf.link.send_packet(pk). Between these reads, other threads (e.g. close_link()) can set the link to None.

This PR fixes that by reading self.link only once, so the commands in send_packet() will always agree.

@ArisMorgens
ArisMorgens requested a review from gemenerik August 26, 2026 09:30

@gemenerik gemenerik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If another thread sets the link to None, isn't this supposed to fail?
I would say the problem is that we lose the connection while trying to identify the decks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants