Skip to content

Commit ab885e8

Browse files
edrasEdras Pacola
andauthored
Milestone v0.4.3 - minor update, bit size variables and enhancements (#96)
* removed arguments from class Variable - Class Variable needs VariableInfo parameter and LNet to get instantiated. - Instead of adding more parameters to the constructor, we store the VariableInfo as a member. * moved set_value to Variable class, added _set_value as abstract function - moved call to checking value_range to parent class - enables generic processing before moving to specific processing * reading bit-size variables under unions / structs regardless variable's byte size * writing bit-size variables regardless byte size * increasing number of variables on generic_gui * changed default generic_gui logger level from warning to error - this avoids minor level messages showing up on terminal * fixed behavior when variable name is not found If the variable does not exist in elf file, we log message "Variable '{name} not found!" and return None If the variable is found, but an error occurred when parsing, we log the error message and return None * Changing prints over the code to logging.debug * Changed contact information * ruff check * bump version --------- Co-authored-by: Edras Pacola <[email protected]>
1 parent a37e7c2 commit ab885e8

File tree

10 files changed

+118
-115
lines changed

10 files changed

+118
-115
lines changed

pyproject.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "pyx2cscope"
7-
version = "0.4.2"
7+
version = "0.4.3"
88
description = "python implementation of X2Cscope"
99
authors = [
10-
"Yash Agarwal <[email protected]>",
11-
"Edras Pacola",
10+
"Yash Agarwal",
11+
"Edras Pacola <[email protected]>",
1212
"Christoph Baumgartner",
1313
"Mark Wendler",
1414
]
@@ -28,6 +28,7 @@ pyx2cscope = 'pyx2cscope.__main__:main'
2828
python = "^3.10"
2929
pyserial = "^3.5"
3030
pyelftools = "^0.31"
31+
pyyaml ="^6.0.1"
3132
numpy = "^1.26.0"
3233
matplotlib = "^3.7.2"
3334
PyQt5 = "^5.15.9"

pyx2cscope/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
"""This module contains the pyx2cscope package.
22
3-
Version: 0.4.2
3+
Version: 0.4.3
44
"""
55

66
import logging
77

8-
__version__ = "0.4.2"
8+
__version__ = "0.4.3"
99

1010

1111
def set_logger(

pyx2cscope/examples/demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Demo scripting for user to get started."""
22
from pyx2cscope.x2cscope import X2CScope
33

4-
elf_file =r"C:\Users\m67250\OneDrive - Microchip Technology Inc\Desktop\Training_Domel\motorbench_demo_domel.X\dist\default\production\motorbench_demo_domel.X.production.elf"
4+
elf_file =r"path to your elf file.elf"
55

66
x2cscope = X2CScope(port="COM39", elf_file=elf_file)
77

pyx2cscope/gui/generic_gui/detachable_gui.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from pyx2cscope.gui import img as img_src
3939
from pyx2cscope.x2cscope import TriggerConfig, X2CScope
4040

41-
logging.basicConfig(level=logging.DEBUG)
41+
logging.basicConfig(level=logging.ERROR)
4242

4343
matplotlib.use("QtAgg")
4444

@@ -100,9 +100,9 @@ def initialize_variables(self):
100100
self.plot_window_open = False
101101
self.settings = QSettings("MyCompany", "MyApp")
102102
self.file_path: str = self.settings.value("file_path", "", type=str)
103-
self.initi_variables()
103+
self.init_variables()
104104

105-
def initi_variables(self):
105+
def init_variables(self):
106106
"""Some extra variables define."""
107107
self.selected_var_indices = [
108108
0,
@@ -355,11 +355,12 @@ def create_variable_selection_group(self):
355355

356356
grid_layout_variable = QGridLayout()
357357
variable_layout.addLayout(grid_layout_variable)
358+
number_of_variables = 8
358359

359-
self.scope_var_lines = [QLineEdit() for _ in range(7)]
360-
self.trigger_var_checkbox = [QCheckBox() for _ in range(7)]
361-
self.scope_channel_checkboxes = [QCheckBox() for _ in range(7)]
362-
self.scope_scaling_boxes = [QLineEdit("1") for _ in range(7)]
360+
self.scope_var_lines = [QLineEdit() for _ in range(number_of_variables)]
361+
self.trigger_var_checkbox = [QCheckBox() for _ in range(number_of_variables)]
362+
self.scope_channel_checkboxes = [QCheckBox() for _ in range(number_of_variables)]
363+
self.scope_scaling_boxes = [QLineEdit("1") for _ in range(number_of_variables)]
363364

364365
for checkbox in self.scope_channel_checkboxes:
365366
checkbox.setChecked(True)
@@ -434,7 +435,7 @@ def handle_scope_checkbox_change(self, state, index):
434435
if i != index:
435436
checkbox.setChecked(False)
436437
self.triggerVariable = self.scope_var_combos[index].currentText()
437-
print(f"Checked variable: {self.scope_var_combos[index].currentText()}")
438+
logging.debug(f"Checked variable: {self.scope_var_combos[index].currentText()}")
438439
else:
439440
self.triggerVariable = None
440441

@@ -1309,7 +1310,7 @@ def configure_trigger(self):
13091310
else:
13101311
try:
13111312
trigger_level = float(trigger_level_text)
1312-
print(trigger_level)
1313+
logging.debug(trigger_level)
13131314
except ValueError:
13141315
logging.error(
13151316
f"Invalid trigger level value: {trigger_level_text}"

pyx2cscope/gui/generic_gui/generic_gui.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import logging
44

5-
logging.basicConfig(level=logging.DEBUG)
5+
logging.basicConfig(level=logging.ERROR)
66
import json
77
import os
88
import sys
@@ -487,11 +487,11 @@ def create_variable_selection_group(self):
487487

488488
grid_layout_variable = QGridLayout()
489489
variable_layout.addLayout(grid_layout_variable)
490-
491-
self.scope_var_lines = [QLineEdit() for _ in range(7)]
492-
self.trigger_var_checkbox = [QCheckBox() for _ in range(7)]
493-
self.scope_channel_checkboxes = [QCheckBox() for _ in range(7)]
494-
self.scope_scaling_boxes = [QLineEdit("1") for _ in range(7)]
490+
number_of_variables = 8
491+
self.scope_var_lines = [QLineEdit() for _ in range(number_of_variables)]
492+
self.trigger_var_checkbox = [QCheckBox() for _ in range(number_of_variables)]
493+
self.scope_channel_checkboxes = [QCheckBox() for _ in range(number_of_variables)]
494+
self.scope_scaling_boxes = [QLineEdit("1") for _ in range(number_of_variables)]
495495

496496
for checkbox in self.scope_channel_checkboxes:
497497
checkbox.setChecked(True)
@@ -568,7 +568,7 @@ def handle_scope_checkbox_change(self, state, index):
568568
if i != index:
569569
checkbox.setChecked(False)
570570
self.triggerVariable = self.scope_var_lines[index].text()
571-
print(f"Checked variable: {self.scope_var_lines[index].text()}")
571+
logging.debug(f"Checked variable: {self.scope_var_lines[index].text()}")
572572
else:
573573
self.triggerVariable = None
574574

@@ -1563,9 +1563,7 @@ def start_sampling(self):
15631563
self.real_sampletime = self.x2cscope.scope_sample_time(
15641564
scope_sample_time_us
15651565
)
1566-
print(
1567-
f"Real sample time: {self.real_sampletime} µs"
1568-
) # Check this value
1566+
logging.debug(f"Real sample time: {self.real_sampletime} µs") # Check this value
15691567

15701568
# Update the Total Time display
15711569
self.total_time_value.setText(str(self.real_sampletime))
@@ -1579,7 +1577,7 @@ def start_sampling(self):
15791577
single_shot=self.single_shot_checkbox.isChecked()
15801578
)
15811579
b = time.time()
1582-
print("time execution", b - a)
1580+
logging.debug(f"time execution '{b - a}'")
15831581
except Exception as e:
15841582
error_message = f"Error starting sampling: {e}"
15851583
logging.error(error_message)
@@ -1603,7 +1601,7 @@ def configure_trigger(self):
16031601
else:
16041602
try:
16051603
trigger_level = int(trigger_level_text) # YA
1606-
print(trigger_level)
1604+
logging.debug(trigger_level)
16071605
except ValueError:
16081606
logging.error(
16091607
f"Invalid trigger level value: {trigger_level_text}"
@@ -2287,7 +2285,7 @@ def eventFilter(self, source, event): # noqa: N802 #Overriding 3rd party functi
22872285
],
22882286
)
22892287
except Exception as e:
2290-
print(e)
2288+
logging.debug(e)
22912289

22922290
return super().eventFilter(source, event)
22932291

pyx2cscope/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
get_elf_file_path(key="path") -> str: Gets the path to the ELF file from the configuration.
66
get_com_port(key="com_port") -> str: Gets the COM port from the configuration.
77
"""
8-
8+
import logging
99
import os
1010
from configparser import ConfigParser
1111

@@ -28,7 +28,7 @@ def get_config_file() -> ConfigParser:
2828
config["COM_PORT"] = default_com
2929
with open(config_file, "w") as configfile:
3030
config.write(configfile)
31-
print(f"Config file '{config_file}' created with default values")
31+
logging.debug(f"Config file '{config_file}' created with default values")
3232
return config
3333

3434

0 commit comments

Comments
 (0)