Reset to the bootloader The parameter cpuid shall correspond to the device to reset. Return true if the reset has been done and the contact with the bootloader is established.
(self, cpu_id)
| 135 | return False |
| 136 | |
| 137 | def reset_to_bootloader1(self, cpu_id): |
| 138 | """ Reset to the bootloader |
| 139 | The parameter cpuid shall correspond to the device to reset. |
| 140 | |
| 141 | Return true if the reset has been done and the contact with the |
| 142 | bootloader is established. |
| 143 | """ |
| 144 | # Send an echo request and wait for the answer |
| 145 | # Mainly aim to bypass a bug of the crazyflie firmware that prevents |
| 146 | # reset before normal CRTP communication |
| 147 | pk = CRTPPacket() |
| 148 | pk.port = CRTPPort.LINKCTRL |
| 149 | pk.data = (1, 2, 3) + cpu_id |
| 150 | self.link.send_packet(pk) |
| 151 | |
| 152 | pk = None |
| 153 | while True: |
| 154 | pk = self.link.receive_packet(2) |
| 155 | if not pk: |
| 156 | return False |
| 157 | |
| 158 | if pk.port == CRTPPort.LINKCTRL: |
| 159 | break |
| 160 | |
| 161 | # Send the reset to bootloader request |
| 162 | pk = CRTPPacket() |
| 163 | pk.set_header(0xFF, 0xFF) |
| 164 | pk.data = (0xFF, 0xFE) + cpu_id |
| 165 | self.link.send_packet(pk) |
| 166 | |
| 167 | # Wait to ack the reset ... |
| 168 | pk = None |
| 169 | while True: |
| 170 | pk = self.link.receive_packet(2) |
| 171 | if not pk: |
| 172 | return False |
| 173 | |
| 174 | if pk.port == 0xFF and tuple(pk.data) == (0xFF, 0xFE) + cpu_id: |
| 175 | pk.data = (0xFF, 0xF0) + cpu_id |
| 176 | self.link.send_packet(pk) |
| 177 | break |
| 178 | |
| 179 | time.sleep(0.1) |
| 180 | self.link.close() |
| 181 | self.link = cflib.crtp.get_link_driver(self.clink_address) |
| 182 | # time.sleep(0.1) |
| 183 | |
| 184 | return self._update_info() |
| 185 | |
| 186 | def reset_to_firmware(self, target_id): |
| 187 | """ Reset to firmware |
nothing calls this directly
no test coverage detected