Skip to content

Commit 3da3fce

Browse files
X2CscopeEdras Pacolaedras
authored
Milestone v0.6.0 (#107)
* V0.6.0 (#106) * fix zip relative path for artifacts * tcp-ip interface implemented * optimizing code * enhanced interface factory for default values according to some arguments, we may select the default interface type default_args = { "port": LNetSerial, "host": LNetTcpIp, "bus": LNetCan, "id": LNetLin, } * unit test for tcp interface * adding dashboard tab to web view * Adding new widgets and config * including scripting tab on web view * including multiple interfaces * fix for trigger_level * transparent widgets on view * refactoring generic gui to best practices Moved from a single file to a more modular structure with separate files for controllers, dialogs, models, tabs, and workers. This should improve maintainability and readability of the codebase. The old generic_gui.py file has been renamed to generic_gui_old.py for reference during the transition period. Changes to be committed: modified: pyx2cscope/gui/generic_gui/__init__.py new file: pyx2cscope/gui/generic_gui/controllers/__init__.py new file: pyx2cscope/gui/generic_gui/controllers/config_manager.py new file: pyx2cscope/gui/generic_gui/controllers/connection_manager.py deleted: pyx2cscope/gui/generic_gui/detachable_gui.py new file: pyx2cscope/gui/generic_gui/dialogs/__init__.py new file: pyx2cscope/gui/generic_gui/dialogs/variable_selection.py renamed: pyx2cscope/gui/generic_gui/generic_gui.py -> pyx2cscope/gui/generic_gui/generic_gui_old.py new file: pyx2cscope/gui/generic_gui/main_window.py new file: pyx2cscope/gui/generic_gui/models/__init__.py new file: pyx2cscope/gui/generic_gui/models/app_state.py new file: pyx2cscope/gui/generic_gui/tabs/__init__.py new file: pyx2cscope/gui/generic_gui/tabs/base_tab.py new file: pyx2cscope/gui/generic_gui/tabs/scope_view_tab.py new file: pyx2cscope/gui/generic_gui/tabs/watch_plot_tab.py new file: pyx2cscope/gui/generic_gui/tabs/watch_view_tab.py new file: pyx2cscope/gui/generic_gui/workers/__init__.py new file: pyx2cscope/gui/generic_gui/workers/data_poller.py * color on scope view and moving scope position and tabs * dual window for watch and plot view * renaming generic_gui folder to qt fixing also imports adding tcp and can interface setting setup as default tab * loading message when connecting * scripting tab working * update doc for gui qt * update mchplnet pointer * unit tests for gui qt and web * ruff check * mchplnet v0.4.1 + fix utils.py + docs * added update rate on widgets * reading SFRs * including SFRs on Web and GUI Qt * update project version * fixed qt dependency on github actions * providing dashboard_view.py for test --------- Co-authored-by: Edras Pacola <edras.pacola@microchip.com> Co-authored-by: Edras Pacola <edras.pacola@gmail.com>
1 parent 407b003 commit 3da3fce

88 files changed

Lines changed: 13691 additions & 4060 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/settings.local.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(python -c \"from pyx2cscope.gui.generic_gui.tabs.watch_view_tab import WatchViewTab; from pyx2cscope.gui.generic_gui.tabs.scope_view_tab import ScopeViewTab; from pyx2cscope.gui.generic_gui.tabs.watch_plot_tab import WatchPlotTab; print\\(''All imports successful''\\)\")",
5+
"Bash(ruff check .)"
6+
]
7+
}
8+
}

.github/workflows/documentation.yml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,21 @@ jobs:
5353
with:
5454
python-version: "3.10"
5555

56-
# Since we moved to generic parser, we don't need to install the xc-16 compiler anymore,
57-
# because generic parser is based on pyelftools.
58-
#
59-
# - name: Set up Microchip XC16 v2.10 compiler
60-
# run: |
61-
# wget -nv -O /tmp/xc16 https://ww1.microchip.com/downloads/aemDocuments/documents/DEV/ProductDocuments/SoftwareTools/xc16-v2.10-full-install-linux64-installer.run && \
62-
# chmod +x /tmp/xc16 && \
63-
# sudo /tmp/xc16 --mode unattended --unattendedmodeui none --netservername localhost --LicenseType FreeMode --prefix /opt/microchip/xc16/v2.10 && \
64-
# rm /tmp/xc16
65-
# echo "/opt/microchip/xc16/v2.10/bin" >> $GITHUB_PATH
56+
- name: Install system dependencies for Qt
57+
run: |
58+
sudo apt-get update
59+
sudo apt-get install -y \
60+
libxkbcommon-x11-0 \
61+
libxcb-icccm4 \
62+
libxcb-image0 \
63+
libxcb-keysyms1 \
64+
libxcb-randr0 \
65+
libxcb-render-util0 \
66+
libxcb-xinerama0 \
67+
libxcb-xfixes0 \
68+
libegl1 \
69+
libgl1 \
70+
xvfb
6671
6772
- name: Install dependencies
6873
run: |
@@ -71,8 +76,13 @@ jobs:
7176
pip install -e .
7277
7378
- name: Run tests
79+
env:
80+
QT_QPA_PLATFORM: offscreen
81+
DISPLAY: ":99.0"
7482
run: |
75-
pytest
83+
Xvfb :99 -screen 0 1024x768x24 &
84+
sleep 2
85+
pytest -v
7686
7787
docs:
7888
runs-on: ubuntu-latest

doc/development.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,12 @@ sphinx-build -M html doc build --keep-going
6161
pyinstaller --noconfirm .\pyx2cscope_win.spec
6262
```
6363

64-
## Creating artifacts to upload to github release page
64+
## Creating artifacts to upload to Github release page
6565
This script will execute the pyinstaller command listed above,
6666
include the script file to start the web interface, zip
6767
the contents of the dist folder and add the whell file
6868
available on pypi in the dist folder.
6969

7070
```bash
71-
python -m scripts/build.py
71+
python scripts/build.py
7272
```
73-
74-
## Creating artifacts to upload to GitHu

doc/gui_qt.md

Lines changed: 162 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,43 +9,169 @@ application.
99
The GUI Qt is currently the default GUI, it runs out-of-the-box when running the command below:
1010

1111
```
12-
python -m pyx2cscope
13-
```
12+
python -m pyx2cscope
13+
```
1414

15-
It can also be executed over argument -q
15+
It can also be executed with the argument -q:
1616

1717
```
1818
python -m pyx2cscope -q
19-
```
20-
21-
## Getting Started with pyX2Cscope reference GUI
22-
## Tab: WatchPlot
23-
![WatchPlot](https://raw.githubusercontent.com/X2Cscope/pyx2cscope/refs/heads/main/doc/images/gui_watch_plot.jpg)
24-
1. pyX2Cscope-GUI is based on Serial interface.
25-
2. The Firmware of the microcontroller should have the X2Cscope library/Peripheral enabled.
26-
3. In Tab WatchPlot, five channels values can be viewed, modified and can be plotted in the plot window.
27-
4. In COM Port, either select **Auto Connect** or select the appropriate COM Port, Baud Rate from the drop-down menus and the ELF file of the project, the microcontroller programmed with. <br>
28-
5. Sample time can be changed during run time as well, by default its set to 500 ms.
29-
6. Press on **Connect**
30-
7. Once the connection between pyX2Cscope and Microcontroller takes place, the buttons will be enabled.
31-
8. Information related to the microcontroller will be displayed in the top-left corner.
32-
33-
## Tab: ScopeView
34-
![ScopeView](https://raw.githubusercontent.com/X2Cscope/pyx2cscope/refs/heads/main/doc/images/gui_scope_view.jpg)
35-
36-
1. ScopeView supports up to 8 PWM resolution channels for precise signal control.
37-
2. You can configure all trigger settings directly within the window. To enable the trigger for a variable, check the corresponding trigger checkbox.
38-
3. To apply modifications during sampling, first stop the sampling, make the necessary changes, then click Sample again to update and apply the modifications.
39-
4. From the plot window, User can export the plot in various formats, including CSV, image files, Matplotlib Window, and Scalable Vector Graphics (SVG).
40-
5. To zoom in on the plot, left-click and drag on the desired area. To return to the original view, right-click and select View All.
41-
42-
## Tab: WatchView
43-
![WatchView](https://raw.githubusercontent.com/X2Cscope/pyx2cscope/refs/heads/main/doc/images/gui_watch_view.jpg)
44-
45-
1. WatchView lets users add or remove variables as needed. To remove a variable, click the Remove button next to it.
46-
2. Users can visualize variables in live mode with an update rate of 500 milliseconds. This rate is the default setting and cannot be changed.
47-
3. Users can select, view, and modify all global variables during runtime, providing real-time control and adjustments.
48-
49-
## Save and Load Config.
50-
1. The Save and Load buttons, found at the bottom of the GUI, allow users to save or load the entire configuration, including the COM Port, Baud Rate, ELF file path, and all other selected variables across different tabs. This ensures a consistent setup, regardless of which tab is active.
51-
2. When a pre-saved configuration file is loaded, the system will automatically attempt to load the ELF file and establish a connection. If the ELF file is missing or unavailable at the specified path, user will need to manually select the correct ELF file path.
19+
```
20+
21+
## Getting Started with pyX2Cscope Reference GUI
22+
23+
The GUI consists of three main tabs: **Setup**, **Data Views**, and **Scripting**.
24+
25+
---
26+
27+
## Tab: Setup
28+
29+
The Setup tab is where you configure the connection to your microcontroller.
30+
31+
### Connection Settings
32+
33+
1. **ELF File**: Click "Select ELF file" to choose the ELF file of the project your microcontroller is programmed with.
34+
35+
2. **Interface**: Select the communication interface:
36+
- **UART**: Serial communication
37+
- **TCP/IP**: Network communication
38+
- **CAN**: CAN bus communication
39+
40+
3. **Connect**: Press to establish the connection. The button changes to "Disconnect" when connected.
41+
42+
### UART Settings
43+
44+
- **Port**: Select the COM port from the dropdown. Use the refresh button to update available ports.
45+
- **Baud Rate**: Select the baud rate (38400, 115200, 230400, 460800, 921600).
46+
47+
### TCP/IP Settings
48+
49+
- **Host**: Enter the IP address or hostname of the target device.
50+
- **Port**: Enter the TCP port number (default: 12666).
51+
52+
### CAN Settings
53+
54+
- **Bus Type**: Select USB or LAN.
55+
- **Channel**: Enter the CAN channel number.
56+
- **Baudrate**: Select from 125K, 250K, 500K, or 1M.
57+
- **Mode**: Select Standard or Extended.
58+
- **Tx-ID (hex)**: Transmit ID in hexadecimal (default: 7F1).
59+
- **Rx-ID (hex)**: Receive ID in hexadecimal (default: 7F0).
60+
61+
### Device Information
62+
63+
Once connected, device information is displayed on the right side:
64+
- Processor ID
65+
- UC Width
66+
- Date and Time
67+
- App Version
68+
- DSP State
69+
70+
> **Note**: All connection settings are automatically saved and restored on the next application start.
71+
72+
---
73+
74+
## Tab: Data Views
75+
76+
The Data Views tab provides two views that can be toggled independently using the buttons at the top:
77+
78+
- **WatchView**: Monitor and modify variable values in real-time
79+
- **ScopeView**: Capture and visualize variable waveforms
80+
81+
You can enable both views simultaneously for a split-screen layout. You can change the width of each column by dragging the line between them. For this to take effect, adjust the App window size accordingly.
82+
83+
### WatchView
84+
85+
1. Click "Add Variable" to add variables to monitor.
86+
2. Select variables from the dialog window.
87+
3. Configure scaling and offset for each variable.
88+
4. Enable "Live" checkbox to poll values at 500ms intervals.
89+
5. Enter new values and click "Write" to modify variables on the device.
90+
6. Click "Remove" to delete a variable row.
91+
92+
### ScopeView
93+
94+
1. ScopeView supports up to 8 channels for precise signal capture.
95+
2. Select variables for each channel from the dropdown.
96+
3. Configure trigger settings:
97+
- **Mode**: Auto (continuous) or Triggered
98+
- **Edge**: Rising or Falling
99+
- **Level**: Trigger threshold value
100+
- **Delay**: Trigger delay in samples
101+
4. Check the "Trigger" checkbox on the channel you want to use as trigger source.
102+
5. Click "Sample" to start capturing, "Single" for one-shot capture, or "Stop" to halt.
103+
6. Use the plot toolbar to zoom, pan, and export data (CSV, PNG, SVG, or Matplotlib window).
104+
105+
### Special Function Registers (SFR)
106+
107+
Both **WatchView** and **ScopeView** support searching and adding Special Function Registers
108+
(SFRs) — hardware peripheral registers such as `LATD`, `TMR1`, or `PORTA` — in addition to
109+
ordinary firmware variables.
110+
111+
When the variable selection dialog opens, an **SFR** checkbox appears next to the search bar:
112+
113+
- When the checkbox is **unchecked** (default) the list shows firmware variables.
114+
- When the checkbox is **checked** the list switches to SFRs parsed from the ELF file.
115+
116+
The checkbox is disabled (greyed out) if the connected ELF file contains no SFR entries.
117+
118+
Once an SFR is selected and confirmed, it is retrieved with `sfr=True` internally so it is
119+
mapped to its fixed hardware address. From that point it behaves exactly like any other
120+
variable — values can be read, polled live (WatchView), or captured as a scope channel
121+
(ScopeView).
122+
123+
### Save and Load Config
124+
125+
The **Save Config** and **Load Config** buttons allow you to:
126+
- Save the entire configuration including ELF file path, connection settings, and all variable configurations.
127+
- Load a previously saved configuration to quickly restore your setup.
128+
- When loading, the system automatically attempts to connect using the saved settings.
129+
130+
---
131+
132+
## Tab: Scripting
133+
134+
The Scripting tab allows you to run Python scripts with direct access to the x2cscope connection.
135+
136+
### Script Selection
137+
138+
1. Click **Browse** to select a Python script (.py file).
139+
2. Click **Edit (IDLE)** to open the script in Python's IDLE editor.
140+
3. Click **Help** for documentation on writing scripts.
141+
142+
### Execution Controls
143+
144+
1. Click **Execute** to run the selected script.
145+
2. Click **Stop** to request the script to stop (scripts must check `stop_requested()` in loops).
146+
3. Enable **Log output to file** and select a location to save script output.
147+
148+
### Output Tabs
149+
150+
- **Script Output**: Displays the actual output from your script (print statements, errors).
151+
- **Log**: Displays timestamped system messages (script started, stopped, connection status).
152+
153+
### Available Objects in Scripts
154+
155+
When running from the Scripting tab, your script has access to:
156+
157+
- **x2cscope**: The X2CScope instance (or `None` if not connected via Setup tab)
158+
- **stop_requested()**: Function that returns `True` when the Stop button is pressed
159+
160+
### Example Script
161+
162+
```python
163+
# Example: Read and print a variable value
164+
if globals().get("x2cscope") is not None:
165+
var = x2cscope.get_variable("myVariable")
166+
print(f"Value: {var.get_value()}")
167+
168+
# Example: Loop with stop support
169+
stop_requested = globals().get("stop_requested", lambda: False)
170+
while not stop_requested():
171+
var = x2cscope.get_variable("myVar")
172+
print(var.get_value())
173+
time.sleep(0.5)
174+
print("Script stopped.")
175+
```
176+
177+
> **Note**: Scripts run in the same process as the GUI. If connected via the Setup tab, scripts share the same x2cscope connection. Scripts can also create their own connections when running standalone.

0 commit comments

Comments
 (0)