MCPcopy Create free account
hub / github.com/bitcraze/crazyflie-lib-python / reset_to_firmware

Method reset_to_firmware

cflib/bootloader/cloader.py:186–221  ·  view source on GitHub ↗

Reset to firmware The parameter cpuid shall correspond to the device to reset. Return true if the reset has been done

(self, target_id)

Source from the content-addressed store, hash-verified

184 return self._update_info()
185
186 def reset_to_firmware(self, target_id):
187 """ Reset to firmware
188 The parameter cpuid shall correspond to the device to reset.
189
190 Return true if the reset has been done
191 """
192 # The fake CPU ID is legacy from the Crazyflie 1.0
193 # In order to reset the CPU id had to be sent, but this
194 # was removed before launching it. But the length check is
195 # still in the bootloader. So to work around this bug so
196 # some extra data needs to be sent.
197 fake_cpu_id = (1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12)
198 # Send the reset to bootloader request
199 pk = CRTPPacket()
200 pk.set_header(0xFF, 0xFF)
201 pk.data = (target_id, 0xFF) + fake_cpu_id
202 self.link.send_packet(pk)
203
204 # Wait to ack the reset ...
205 pk = None
206 while True:
207 pk = self.link.receive_packet(2)
208 if not pk:
209 return False
210
211 if (pk.header == 0xFF and struct.unpack(
212 'B' * len(pk.data), pk.data)[:2] == (target_id, 0xFF)):
213 # Difference in CF1 and CF2 (CPU ID)
214 if target_id == 0xFE:
215 pk.data = (target_id, 0xF0, 0x01)
216 else:
217 pk.data = (target_id, 0xF0) + fake_cpu_id
218 self.link.send_packet(pk)
219 break
220
221 time.sleep(0.1)
222
223 def open_bootloader_uri(self, uri=None):
224 if self.link:

Callers

nothing calls this directly

Calls 4

set_headerMethod · 0.95
CRTPPacketClass · 0.90
send_packetMethod · 0.45
receive_packetMethod · 0.45

Tested by

no test coverage detected