forked from Archive/PX4-Autopilot
fix px_uploader bytes and char comparison & remove python 2 support (#15859)
This commit is contained in:
parent
c2af7ba961
commit
74c9ba8d55
|
@ -287,13 +287,13 @@ class uploader(object):
|
||||||
if (len(data) != count):
|
if (len(data) != count):
|
||||||
raise RuntimeError("Ack Window %i not %i " % (len(data), count))
|
raise RuntimeError("Ack Window %i not %i " % (len(data), count))
|
||||||
for i in range(0, len(data), 2):
|
for i in range(0, len(data), 2):
|
||||||
if chr(data[i]) != self.INSYNC:
|
if bytes([data[i]]) != self.INSYNC:
|
||||||
raise RuntimeError("unexpected %s instead of INSYNC" % data[i])
|
raise RuntimeError("unexpected %s instead of INSYNC" % data[i])
|
||||||
if chr(data[i+1]) == self.INVALID:
|
if bytes([data[i+1]]) == self.INVALID:
|
||||||
raise RuntimeError("bootloader reports INVALID OPERATION")
|
raise RuntimeError("bootloader reports INVALID OPERATION")
|
||||||
if chr(data[i+1]) == self.FAILED:
|
if bytes([data[i+1]]) == self.FAILED:
|
||||||
raise RuntimeError("bootloader reports OPERATION FAILED")
|
raise RuntimeError("bootloader reports OPERATION FAILED")
|
||||||
if chr(data[i+1]) != self.OK:
|
if bytes([data[i+1]]) != self.OK:
|
||||||
raise RuntimeError("unexpected response 0x%x instead of OK" % ord(data[i+1]))
|
raise RuntimeError("unexpected response 0x%x instead of OK" % ord(data[i+1]))
|
||||||
|
|
||||||
# attempt to get back into sync with the bootloader
|
# attempt to get back into sync with the bootloader
|
||||||
|
@ -426,10 +426,7 @@ class uploader(object):
|
||||||
# send a PROG_MULTI command to write a collection of bytes
|
# send a PROG_MULTI command to write a collection of bytes
|
||||||
def __program_multi(self, data, windowMode):
|
def __program_multi(self, data, windowMode):
|
||||||
|
|
||||||
if runningPython3:
|
length = len(data).to_bytes(1, byteorder='big')
|
||||||
length = len(data).to_bytes(1, byteorder='big')
|
|
||||||
else:
|
|
||||||
length = chr(len(data))
|
|
||||||
|
|
||||||
self.__send(uploader.PROG_MULTI)
|
self.__send(uploader.PROG_MULTI)
|
||||||
self.__send(length)
|
self.__send(length)
|
||||||
|
@ -450,10 +447,7 @@ class uploader(object):
|
||||||
# verify multiple bytes in flash
|
# verify multiple bytes in flash
|
||||||
def __verify_multi(self, data):
|
def __verify_multi(self, data):
|
||||||
|
|
||||||
if runningPython3:
|
length = len(data).to_bytes(1, byteorder='big')
|
||||||
length = len(data).to_bytes(1, byteorder='big')
|
|
||||||
else:
|
|
||||||
length = chr(len(data))
|
|
||||||
|
|
||||||
self.__send(uploader.READ_MULTI)
|
self.__send(uploader.READ_MULTI)
|
||||||
self.__send(length)
|
self.__send(length)
|
||||||
|
@ -711,6 +705,9 @@ class uploader(object):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
# Python2 is EOL
|
||||||
|
if not runningPython3:
|
||||||
|
raise RuntimeError("Python 2 is not supported. Please try again using Python 3.")
|
||||||
|
|
||||||
# Parse commandline arguments
|
# Parse commandline arguments
|
||||||
parser = argparse.ArgumentParser(description="Firmware uploader for the PX autopilot system.")
|
parser = argparse.ArgumentParser(description="Firmware uploader for the PX autopilot system.")
|
||||||
|
|
Loading…
Reference in New Issue