Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 25 additions & 17 deletions .github/workflows/buildexe.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Build PyInstaller Executable

on:
workflow_dispatch:
release:
types: [published]

jobs:
buildwindows:
runs-on: windows-latest
Expand All @@ -15,13 +17,12 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r quality.txt
pip install -e ".[build]"

- name: Build executable
run: |
Expand All @@ -32,11 +33,15 @@ jobs:
run: |
echo pyX2Cscope.exe -w > dist\pyx2cscope\startWebInterface.bat

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: pyX2Cscope-windows
path: dist/pyX2Cscope
- name: Zip artifact
run: |
Compress-Archive -Path dist/pyX2Cscope -DestinationPath pyX2Cscope_win_amd64_${{ github.event.release.tag_name }}.zip

- name: Upload to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.event.release.tag_name }} pyX2Cscope_win_amd64_${{ github.event.release.tag_name }}.zip


buildlinux:
Expand All @@ -51,13 +56,12 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r quality.txt
pip install -e ".[build]"
sudo apt install libxcb-xinerama0

- name: Build executable
Expand All @@ -70,8 +74,12 @@ jobs:
echo './pyX2Cscope_linux -w' >> dist/pyX2Cscope_linux/startWebInterface.sh
chmod +x dist/pyX2Cscope_linux/startWebInterface.sh

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: pyX2Cscope-linux
path: dist/pyX2Cscope_linux
- name: Zip artifact
run: |
zip -r pyX2Cscope_linux_amd64_${{ github.event.release.tag_name }}.zip dist/pyX2Cscope_linux

- name: Upload to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.event.release.tag_name }} pyX2Cscope_linux_amd64_${{ github.event.release.tag_name }}.zip
91 changes: 78 additions & 13 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.12"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r quality.txt
pip install -e ".[dev]"

- name: Code Format Check
run: |
Expand All @@ -31,11 +31,11 @@ jobs:
# - name: Set up Python
# uses: actions/setup-python@v5
# with:
# python-version: "3.10"
# python-version: "3.14"
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install -r quality.txt
# pip install -e ".[dev]"
# - name: Check code with ruff
# run: |
# ruff ./pyx2cscope
Expand All @@ -51,7 +51,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.12"

- name: Install system dependencies for Qt
run: |
Expand All @@ -72,8 +72,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r quality.txt
pip install -e .
pip install -e ".[dev]"

- name: Run tests
env:
Expand All @@ -82,29 +81,95 @@ jobs:
run: |
Xvfb :99 -screen 0 1024x768x24 &
sleep 2
pytest -v
pytest -v

docs:
tests-matrix:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.13", "3.14"]
steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install system dependencies for Qt
run: |
sudo apt-get update
sudo apt-get install -y \
libxkbcommon-x11-0 \
libxcb-icccm4 \
libxcb-image0 \
libxcb-keysyms1 \
libxcb-randr0 \
libxcb-render-util0 \
libxcb-xinerama0 \
libxcb-xfixes0 \
libegl1 \
libgl1 \
xvfb

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"

- name: Run tests
env:
QT_QPA_PLATFORM: offscreen
DISPLAY: ":99.0"
run: |
Xvfb :99 -screen 0 1024x768x24 &
sleep 2
pytest -v

docs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: "3.12"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[docs]"

- name: Build documentation
run: |
sphinx-build -M html doc build --keep-going

docs-matrix:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.13", "3.14"]
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r quality.txt
pip install -e .
pip install -e ".[docs]"

- name: Build documentation
run: |
sphinx-build -M html doc build --keep-going
sphinx-build -M html doc build --keep-going

version-check:
runs-on: ubuntu-latest
Expand Down
17 changes: 11 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r quality.txt
pip install -e .
pip install -e ".[docs,build]"

- name: Build documentation
run: |
Expand All @@ -33,9 +32,15 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build/html

- name: Release to pypi with poetry
- name: Build package
run: |
poetry config pypi-token.pypi ${{ secrets.PYX2CSCOPE_PYPI }}
poetry publish -vvv --build
python -m build

- name: Release to pypi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYX2CSCOPE_PYPI }}
run: |
python -m twine upload dist/*


2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ celerybeat.pid
# Environments
.env
.venv
.venv*
env/
venv/
ENV/
Expand Down Expand Up @@ -143,3 +144,4 @@ dmypy.json
#backup files
.bkp
/.claude/
/.continue/
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Detailed documentation is hosted at GitHub.io:

## Install

pyX2Cscope currently supports Python `3.10` to `3.14`.

Create a virtual environment and install pyx2cscope using the following commands (Windows):
```
python -m venv .venv
Expand All @@ -40,12 +42,16 @@ To execute the Browser based version type:
```py
from pyx2cscope.x2cscope import X2CScope

# initialize the X2CScope class with serial port, by default baud rate is 115200
x2c_scope = X2CScope(port="COM8")
# instead of loading directly the elf file, we can import it after instantiating the X2CScope class
x2c_scope.import_variables(r"..\..\tests\data\qspin_foc_same54.elf")
# Option 1: Default UART with Auto-detect COM port (recommended for single device)
x2c_scope = X2CScope(elf_file="path/to/firmware.elf")

# Option 2: Specify COM port explicitly
# x2c_scope = X2CScope(port="COM8", elf_file="path/to/firmware.elf")

# Or import variables after instantiation
# x2c_scope.import_variables(r"..\..\tests\data\qspin_foc_same54.elf")

# Collect some variables.
# Collect some variables
speed_reference = x2c_scope.get_variable("motor.apiData.velocityReference")
speed_measured = x2c_scope.get_variable("motor.apiData.velocityMeasured")

Expand Down
7 changes: 5 additions & 2 deletions doc/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ source .venv\bin\activate
## Installing dev requirements

```bash
pip install -r requirements.txt
pip install -r quality.txt
pip install -e ".[dev,docs,build]"
```

## Publishing a release

Package releases are handled by GitHub Actions as part of the maintainer release workflow.

## Running tests

### ruff syntax check
Expand Down
26 changes: 25 additions & 1 deletion doc/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ variables = [
for var in variables:
x2c_scope.add_scope_channel(x2c_scope.get_variable(var))

x2c_scope.set_sample_time(0)
x2c_scope.set_sample_time(1)

# Create the plot
plt.ion() # Turn on interactive mode
Expand Down Expand Up @@ -287,6 +287,30 @@ with open(csv_file_path, mode="w", newline="") as file:
logging.info(f"Data saved in {csv_file_path}")
````

## Check ELF compatibility

````python

"""Check whether the loaded ELF file appears compatible with the connected target."""

from pyx2cscope.utils import get_com_port, get_elf_file_path
from pyx2cscope.x2cscope import X2CScope


x2c_scope = X2CScope(port=get_com_port())

try:
x2c_scope.import_variables(get_elf_file_path())

compatibility = x2c_scope.check_compatibility()
print("Compatibility report:")
for key, value in compatibility.items():
print(f" {key}: {value}")
finally:
x2c_scope.disconnect()

````

for more visit the [pyX2Cscope example directory ](https://github.com/X2Cscope/pyx2cscope/tree/develop/pyx2cscope/examples)


Expand Down
Loading
Loading