def _change_baud_rate (self, baud_rate):
'''
If the bootloader on the board supports it and if it succeeds, try to
increase the baud rate to make everything faster.
'''
pkt = struct.pack('<BI', 0x01, baud_rate)
success, ret = self._issue_command(self.COMMAND_CHANGE_BAUD_RATE, pkt, True, 0, self.RESPONSE_OK, show_errors=False)
if success:
# The bootloader is new enough to support this.
# Increase the baud rate
self.sp.baudrate = baud_rate
# Now confirm that everything is working.
pkt = struct.pack('<BI', 0x02, baud_rate)
success, ret = self._issue_command(self.COMMAND_CHANGE_BAUD_RATE, pkt, False, 0, self.RESPONSE_OK, show_errors=False)
if not success:
# Something went wrong. Go back to old baud rate
self.sp.baudrate = 115200
评论列表
文章目录