diff --git a/revpicommander/debugcontrol.py b/revpicommander/debugcontrol.py index a356fc7..a833f1b 100644 --- a/revpicommander/debugcontrol.py +++ b/revpicommander/debugcontrol.py @@ -186,7 +186,7 @@ class DebugControl(QtWidgets.QWidget, Ui_wid_debugcontrol): win = self.dict_windows[position] for io in self.dict_ios[io_type][position]: # type: list - # ['name', bitlength, byte_address, 'bmk', bitaddress, 'byteorder', signed] + # ['name', bytelen, byte_address, 'bmk', bitaddress, 'byteorder', signed] value_procimg = bytes(ba_values[io[2]:io[2] + io[1]]) if io[4] >= 0: # Bit-IO diff --git a/revpicommander/debugios.py b/revpicommander/debugios.py index d3b2f1e..8302cd0 100644 --- a/revpicommander/debugios.py +++ b/revpicommander/debugios.py @@ -344,14 +344,22 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios): if child.property("frm"): value = struct.unpack(child.property("frm"), value)[0] elif type(value) == bytes: + if child.property("struct_type") == "text": + try: + value = value.decode("utf-8") + except UnicodeDecodeError: + child.setProperty("struct_type", "number") + QtWidgets.QMessageBox.warning( + self, self.tr("Can not use format text"), self.tr( + "Can not convert bytes {0} to a text for IO '{1}'. Switch to number format instead!" + ).format(value, io_name) + ) if child.property("struct_type") == "number": value = str(int.from_bytes( value, byteorder="big" if child.property("big_endian") else "little", signed=child.property("signed") or False )) - else: - value = value.decode() child.setProperty("last_value", value) if not just_last_value: