stc15: fix fuzzing test failure

This commit is contained in:
Grigori Goronzy 2021-01-06 20:08:26 +01:00
parent df2fbc23cd
commit 384471f765

View File

@ -1416,7 +1416,10 @@ class Stc15Protocol(Stc15AProtocol):
sys.stdout.flush()
packet = bytes([0x01])
packet += bytes([self.freq_count_24, 0x40])
packet += struct.pack(">H", int(65536 - self.mcu_clock_hz / self.baud_transfer / 4))
bauds = int(65536 - self.mcu_clock_hz / self.baud_transfer / 4)
if bauds >= 65536:
raise StcProtocolException("baudrate adjustment failed")
packet += struct.pack(">H", bauds)
iap_wait = self.get_iap_delay(self.mcu_clock_hz)
packet += bytes([0x00, 0x00, iap_wait])
self.write_packet(packet)