diff --git a/main.py b/main.py index 7704dbd..fb9cc1d 100644 --- a/main.py +++ b/main.py @@ -48,7 +48,7 @@ class MainWindow(QMainWindow): axisY = QtCharts.QValueAxis() axisX.setRange(0, 10) axisY.setRange(-1, 1) - + elfFilePath = None def __init__(self): QMainWindow.__init__(self) @@ -77,8 +77,6 @@ def __init__(self): self.fileLen = None self.fileCrc32 = None - - # Initialize logging console = logging.getLogger("PDexLogger") handler = QLogHandler(self.ui.console) @@ -98,8 +96,6 @@ def __init__(self): self.connectedDevice.otas_progress_value.connect( lambda value: self.otas_progress_update(value)) - - self.update_rssi_thread = UpdateRSSIGraphThread(self) self.update_rssi_thread.dataUpdated.connect(self.update_graph) if self.ui.graph_enabled.isChecked(): @@ -812,9 +808,10 @@ def update_variable_in_table(self, var_name, value): # Convert or manipulate the value based on its type if var_type == 'float': self.logger.info("Var is float") - value_as_bytes = value.to_bytes(4, 'little') - value = c_float.from_buffer_copy(value_as_bytes).value - + if var_name != 'bbConnStats': + value_as_bytes = value.to_bytes(4, 'little') + value = c_float.from_buffer_copy(value_as_bytes).value + elif var_type == 'uint32_t': value = int(value) # Assuming 32-bit unsigned elif var_type == 'uint8_t': diff --git a/modules/btn_callbacks.py b/modules/btn_callbacks.py index 442e269..e789c2f 100644 --- a/modules/btn_callbacks.py +++ b/modules/btn_callbacks.py @@ -290,7 +290,7 @@ def handle_checkbox_state_change(state, var_name, address, address_dict, main_wi address_dict[var_name] = {"address": address, "watched_row_position": watched_row_position, "graphed": False} # TODO make user chose from a drop down - address_dict[var_name]['var_type'] = 'None' + address_dict[var_name]['var_type'] = 'float' else: @@ -552,6 +552,8 @@ def load_elf(main_window): # # Open a file dialog to select the ELF file options = QFileDialog.Options() filename, _ = QFileDialog.getOpenFileName(main_window, "Open ELF File", "", "ELF Files (*.elf);;All Files (*)", options=options) + main_window.var_watcher.elfFilePath = filename + # for faster debugging #filename = '/home/eddie/projects/ADI-Insight/BLE_dats/build/max32655.elf' #print("using hard coded elf filename") @@ -646,6 +648,7 @@ def enable_connection_stats(main_window): main_window.var_watcher.getConnStats = True main_window.ui.stats_frame.show() logger.info("Getting connection stats") + handle_checkbox_state_change(Qt.Checked, 'bbConnStats', 0, main_window.vars_watched_dict, main_window) else: main_window.var_watcher.getConnStats = False logger.info("Not getting connection stats") diff --git a/modules/elf_insights.py b/modules/elf_insights.py index 73270c3..726621a 100644 --- a/modules/elf_insights.py +++ b/modules/elf_insights.py @@ -65,6 +65,7 @@ class MonitoringThread(QThread): symbolName = None getConnStats = False connStatsAddress = None + elfFilePath = None #make a signal to update the connection stats as list connStatValues = Signal(list) def __init__(self, address_dict): @@ -143,8 +144,8 @@ def monitor_variables(self, target, addresses): for var_name, details in list(addresses.items()): address = details['address'] value = target.read32(address) - - self.signal_update_variable.emit(var_name, value) # Emitting the signal with the variable name and value + if address != 0: + self.signal_update_variable.emit(var_name, value) # Emitting the signal with the variable name and value if self.getCoreRegs is True: self.print_core_registers(target) self.getCoreRegs = False @@ -152,7 +153,7 @@ def monitor_variables(self, target, addresses): if self.getConnStats is True: if self.connStatsAddress is None: try: - self.connStatsAddress = self.get_symbol_address_from_elf('/home/eddie/projects/BLE-PyDex/max32655.elf', 'bbConnStats') + self.connStatsAddress = self.get_symbol_address_from_elf(self.elfFilePath, 'bbConnStats') except Exception as e: self.logger.setLevel(logging.WARNING) self.logger.warning("Error while monitoring variables: %s", e) @@ -185,33 +186,33 @@ def monitor_variables(self, target, addresses): self.connStatValues.emit([rxData, rxDataCrc, rxDataTimeout, txData, errData, per]) - - if self.symbolName is not None: - address = self.get_symbol_address_from_elf('/home/eddie/projects/BLE-PyDex/max32655.elf', self.symbolName) - if address is not None: - #print address in hex - # print("0x{:08x}".format(address)) - data = self.read_struct_from_memory(target,address, 20) - # Define the format string for the struct - # The format string corresponds to the data types and order in the struct - format_string = '