Browse Source

AP_MSP: handle utf-8 in string display

c415-sdk
Andrew Tridgell 5 years ago
parent
commit
5358c1e476
  1. 8
      libraries/AP_MSP/Tools/pymsp.py

8
libraries/AP_MSP/Tools/pymsp.py

@ -1,4 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*-
""" """
author: Alex Apostoli author: Alex Apostoli
@ -335,19 +336,18 @@ class PyMSP:
bf.append(checksum) bf.append(checksum)
return bf return bf
def evaluateCommand(self, cmd, dataSize): def evaluateCommand(self, cmd, dataSize):
if cmd in self.MESSAGES: if cmd in self.MESSAGES:
# most messages are parsed from the MESSAGES list # most messages are parsed from the MESSAGES list
self.MESSAGES[cmd].parse(self, dataSize) self.MESSAGES[cmd].parse(self, dataSize)
elif cmd == self.MSP_NAME: elif cmd == self.MSP_NAME:
s = '' s = bytearray()
for i in range(0,dataSize,1): for i in range(0,dataSize,1):
b = self.read8() b = self.read8()
if b == 0: if b == 0:
break break
s += chr(b) s.append(b)
self.msp_name['name'] = s self.msp_name['name'] = s.decode("utf-8")
elif cmd == self.MSP_ACC_CALIBRATION: elif cmd == self.MSP_ACC_CALIBRATION:
x = None x = None

Loading…
Cancel
Save