diff --git a/cflib/crazyflie/__init__.py b/cflib/crazyflie/__init__.py index ebf508aea..862eb6571 100644 --- a/cflib/crazyflie/__init__.py +++ b/cflib/crazyflie/__init__.py @@ -360,9 +360,10 @@ def send_packet(self, pk, expected_reply=(), resend=False, timeout=0.2): raise Exception('Data part of packet is too large') self._send_lock.acquire() - if self.link is not None: + link = self.link + if link is not None: if len(expected_reply) > 0 and not resend and \ - self.link.needs_resending: + link.needs_resending: pattern = (pk.header,) + expected_reply logger.debug( 'Sending packet and expecting the %s pattern back', @@ -387,7 +388,7 @@ def send_packet(self, pk, expected_reply=(), resend=False, timeout=0.2): else: logger.debug('Resend requested, but no pattern found: %s', self._answer_patterns) - self.link.send_packet(pk) + link.send_packet(pk) self.packet_sent.call(pk) self._send_lock.release()