[chirp_devel] [PATCH] [KGUV8D] Decode oem memory as ascii string
# HG changeset patch # User K. Arvanitis kosta@alumni.uvic.ca # Date 1425450338 28800 # Tue Mar 03 22:25:38 2015 -0800 # Node ID 73d36b4f773b254c23eef84cd5b27d915f90d5c0 # Parent d65875e0a02311063221304a62804ff606a516f1 [KGUV8D] Decode oem memory as ascii string
Address issue where the UV8D driver was not decoding strings from memory, but rather was treating them as raw memory which was preventing the app from displaying the raw memory as a string (which it can not do in cases where the string contains null characters, etc..);
This bug was causing the settings UI to not display any settings due to the exception being thrown by the radio driver;
It was not caught by the unit tests due to the fact the img checked into the tree for this radio is of a diff. version than the image reported by the user in the bug report.
Bug #2377
diff -r d65875e0a023 -r 73d36b4f773b chirp/drivers/kguv8d.py --- a/chirp/drivers/kguv8d.py Mon Mar 02 21:40:38 2015 -0800 +++ b/chirp/drivers/kguv8d.py Tue Mar 03 22:25:38 2015 -0800 @@ -83,14 +83,14 @@
#seekto 0x0400; struct { - char model[8]; - u8 unknown[2]; - char oem1[10]; - char oem2[10]; - char unknown2[8]; - char version[10]; - u8 unknown3[6]; - char date[8]; + u8 model[8]; + u8 unknown[2]; + u8 oem1[10]; + u8 oem2[10]; + u8 unknown2[8]; + u8 version[10]; + u8 unknown3[6]; + u8 date[8]; } oem_info;
#seekto 0x0480; @@ -888,27 +888,32 @@ # # OEM info # - _str = str(self._memobj.oem_info.model).split("\0")[0] + def _decode(lst): + _str = ''.join([chr(c) for c in lst + if chr(c) in chirp_common.CHARSET_ASCII]) + return _str + + _str = _decode(self._memobj.oem_info.model) val = RadioSettingValueString(0, 15, _str) val.set_mutable(False) rs = RadioSetting("model", "Model", val) oem_grp.append(rs) - _str = str(self._memobj.oem_info.oem1).split("\0")[0] + _str = _decode(self._memobj.oem_info.oem1) val = RadioSettingValueString(0, 15, _str) val.set_mutable(False) rs = RadioSetting("oem1", "OEM String 1", val) oem_grp.append(rs) - _str = str(self._memobj.oem_info.oem2).split("\0")[0] + _str = _decode(self._memobj.oem_info.oem2) val = RadioSettingValueString(0, 15, _str) val.set_mutable(False) rs = RadioSetting("oem2", "OEM String 2", val) oem_grp.append(rs) - _str = str(self._memobj.oem_info.version).split("\0")[0] + _str = _decode(self._memobj.oem_info.version) val = RadioSettingValueString(0, 15, _str) val.set_mutable(False) rs = RadioSetting("version", "Software Version", val) oem_grp.append(rs) - _str = str(self._memobj.oem_info.date).split("\0")[0] + _str = _decode(self._memobj.oem_info.date) val = RadioSettingValueString(0, 15, _str) val.set_mutable(False) rs = RadioSetting("date", "OEM Date", val)
participants (1)
-
K. Arvanitis