Skip to content

Commit

Permalink
initia working graphing per
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwinFairchild committed Oct 27, 2023
1 parent f12d2d0 commit 0705f24
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 35 deletions.
13 changes: 5 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -77,8 +77,6 @@ def __init__(self):
self.fileLen = None
self.fileCrc32 = None



# Initialize logging
console = logging.getLogger("PDexLogger")
handler = QLogHandler(self.ui.console)
Expand All @@ -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():
Expand Down Expand Up @@ -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':
Expand Down
5 changes: 4 additions & 1 deletion modules/btn_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
51 changes: 26 additions & 25 deletions modules/elf_insights.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -143,16 +144,16 @@ 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

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)
Expand Down Expand Up @@ -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 = '<IIIIIHHHH' # Use '<' for little-endian byte order

# if self.symbolName is not None:
# address = self.get_symbol_address_from_elf(self.elfFilePath, 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 = '<IIIIIHHHH' # Use '<' for little-endian byte order

# Unpack the binary data into a tuple
struct_byes = bytes(data)
struct_data = struct.unpack(format_string, struct_byes)
# # Unpack the binary data into a tuple
# struct_byes = bytes(data)
# struct_data = struct.unpack(format_string, struct_byes)

# Now, struct_data contains the values according to the struct's meaning
rxData, rxDataCrc, rxDataTimeout, txData, errData= struct_data
# # Now, struct_data contains the values according to the struct's meaning
# rxData, rxDataCrc, rxDataTimeout, txData, errData= struct_data

# Print the values
print(f"rxData: {rxData}")
print(f"rxDataCrc: {rxDataCrc}")
print(f"rxDataTimeout: {rxDataTimeout}")
print(f"txData: {txData}")
print(f"errData: {errData}")
# # Print the values
# print(f"rxData: {rxData}")
# print(f"rxDataCrc: {rxDataCrc}")
# print(f"rxDataTimeout: {rxDataTimeout}")
# print(f"txData: {txData}")
# print(f"errData: {errData}")


print(data)
# print(data)
else:
self.logger.warning("Symbol '%s' not found in ELF file.", self.symbolName)
self.symbolName = None
Expand Down
2 changes: 1 addition & 1 deletion modules/slots.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def update_connection_stats(interface, stats):
interface.ui.lbl_tx_data_count.setText("TX Data Count: " + str(stats[3]))
interface.ui.lbl_tx_data_err.setText("TX Data Error: " + str(stats[4]))
interface.ui.lbl_PER.setText("PER: " + str(stats[5]) + "%")

interface.update_variable_in_table('bbConnStats',(stats[5]))



Expand Down

0 comments on commit 0705f24

Please sign in to comment.