Initiate flashing of data in the buffer to flash.
(self, addr, page_buffer, target_page, page_count)
| 361 | return buff[0:page_size] |
| 362 | |
| 363 | def write_flash(self, addr, page_buffer, target_page, page_count): |
| 364 | """Initiate flashing of data in the buffer to flash.""" |
| 365 | # print "Write page", flashPage |
| 366 | # print "Writing page [%d] and [%d] forward" % (flashPage, nPage) |
| 367 | pk = None |
| 368 | |
| 369 | # Flushing downlink ... |
| 370 | pk = self.link.receive_packet(0) |
| 371 | while pk is not None: |
| 372 | pk = self.link.receive_packet(0) |
| 373 | |
| 374 | retry_counter = 5 |
| 375 | # print "Flasing to 0x{:X}".format(addr) |
| 376 | while ((not pk or pk.header != 0xFF or |
| 377 | struct.unpack('<BB', pk.data[0:2]) != (addr, 0x18)) and |
| 378 | retry_counter >= 0): |
| 379 | pk = CRTPPacket() |
| 380 | pk.set_header(0xFF, 0xFF) |
| 381 | pk.data = struct.pack('<BBHHH', addr, 0x18, page_buffer, |
| 382 | target_page, page_count) |
| 383 | self.link.send_packet(pk) |
| 384 | |
| 385 | # Timeout for writing to flash is raised from 1s (used elsewhere |
| 386 | # in this module) to 2.5s because it may take more than a second |
| 387 | # to erase a page on the STM32F405. |
| 388 | # |
| 389 | # See https://github.com/bitcraze/crazyflie-lib-python/issues/98 |
| 390 | # for more details. |
| 391 | pk = self.link.receive_packet(2.5) |
| 392 | retry_counter -= 1 |
| 393 | |
| 394 | if retry_counter < 0: |
| 395 | self.error_code = -1 |
| 396 | return False |
| 397 | |
| 398 | self.error_code = pk.data[3] |
| 399 | |
| 400 | return pk.data[2] == 1 |
| 401 | |
| 402 | def decode_cpu_id(self, cpuid): |
| 403 | """Decode the CPU id into a string""" |
no test coverage detected