diff --git a/.idea/misc.xml b/.idea/misc.xml
index 3999087..bc8d735 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -4,4 +4,7 @@
+
+
+
\ No newline at end of file
diff --git a/revpicommander/debugcontrol.py b/revpicommander/debugcontrol.py
index c27845f..4b4726d 100644
--- a/revpicommander/debugcontrol.py
+++ b/revpicommander/debugcontrol.py
@@ -187,7 +187,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]
- value_procimg = ba_values[io[2]:io[2] + io[1]]
+ value_procimg = bytes(ba_values[io[2]:io[2] + io[1]])
if io[4] >= 0:
# Bit-IO
value_procimg = bool(
diff --git a/revpicommander/debugios.py b/revpicommander/debugios.py
index 4a012b1..9b79ceb 100644
--- a/revpicommander/debugios.py
+++ b/revpicommander/debugios.py
@@ -118,7 +118,13 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
# Bytes or string
val = QtWidgets.QLineEdit()
val.setReadOnly(read_only)
+ val.setProperty("big_endian", byteorder == "big")
+ val.setProperty("byte_length", byte_length)
+ val.setProperty("signed", signed)
+ val.setProperty("struct_type", "text")
+
val.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
+ val.customContextMenuRequested.connect(self.on_context_menu)
# Set alias to use the same function name on all widget types
val.setValue = val.setText
@@ -186,6 +192,14 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
sender = self.sender()
men = QtWidgets.QMenu(sender)
+ if sender.property("byte_length") > 4:
+ # Textbox needs format buttons
+ act_as_text = QtWidgets.QAction(self.tr("as text"))
+ men.addAction(act_as_text)
+ act_as_number = QtWidgets.QAction(self.tr("as number"))
+ men.addAction(act_as_number)
+ men.addSeparator()
+
act_signed = QtWidgets.QAction(self.tr("signed"), men)
act_signed.setCheckable(True)
act_signed.setChecked(sender.property("signed") or False)
@@ -215,10 +229,17 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
elif rc == act_byteorder:
sender.setProperty("big_endian", act_byteorder.isChecked())
- sender.setProperty("frm", "{0}{1}".format(
- ">" if act_byteorder.isChecked() else "<",
- sender.property("struct_type").lower() if act_signed.isChecked() else sender.property("struct_type").upper()
- ))
+ if sender.property("frm"):
+ sender.setProperty("frm", "{0}{1}".format(
+ ">" if act_byteorder.isChecked() else "<",
+ sender.property("struct_type").lower() if act_signed.isChecked()
+ else sender.property("struct_type").upper()
+ ))
+ elif sender.property("byte_length") > 4:
+ if rc == act_as_text:
+ sender.setProperty("struct_type", "text")
+ elif rc == act_as_number:
+ sender.setProperty("struct_type", "number")
self.set_value(sender.objectName(), actual_value)
men.deleteLater()
@@ -280,6 +301,23 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
return struct.pack(child.property("frm"), int(actual_value)), \
struct.pack(child.property("frm"), int(last_value))
elif type(actual_value) == str:
+ if child.property("struct_type") == "number":
+ try:
+ actual_value = int(actual_value).to_bytes(
+ child.property("byte_length"),
+ byteorder="big" if child.property("big_endian") else "little",
+ signed=child.property("signed") or False
+ )
+ last_value = int(last_value).to_bytes(
+ child.property("byte_length"),
+ byteorder="big" if child.property("big_endian") else "little",
+ signed=child.property("signed") or False
+ )
+ return actual_value, last_value
+ except Exception:
+ pi.logger.error("Could not convert '{0}' to bytes".format(actual_value))
+ pass
+
return actual_value.encode(), last_value.encode()
else:
return actual_value, last_value
@@ -311,8 +349,15 @@ class DebugIos(QtWidgets.QMainWindow, Ui_win_debugios):
child = self.__qwa[io_name]
if child.property("frm"):
value = struct.unpack(child.property("frm"), value)[0]
- elif type(value) == bytearray:
- value = value.decode()
+ elif type(value) == bytes:
+ 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)
child.setValue(value)
diff --git a/revpicommander/revpifiles.py b/revpicommander/revpifiles.py
index ea6a7c0..3540671 100644
--- a/revpicommander/revpifiles.py
+++ b/revpicommander/revpifiles.py
@@ -329,7 +329,7 @@ class RevPiFiles(QtWidgets.QMainWindow, Ui_win_files):
)
self.lbl_path_revpi.setToolTip(self.lbl_path_revpi.text())
- if lst_revpi:
+ if lst_revpi is not None:
lst_revpi.sort()
for path_file in lst_revpi: