Skip to content

Commit

Permalink
Initial commit: Basic UI
Browse files Browse the repository at this point in the history
+ Added basic UI
+ Added parsing and sending of ISOCan frames with FD support
+ Basic project structure
  • Loading branch information
Jules Atchoglo committed Oct 16, 2024
0 parents commit 6e6e934
Show file tree
Hide file tree
Showing 48 changed files with 1,975 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
{
"name": "CanExplorer Container",
"build": {
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerfile": "../Dockerfile",
"args": {
"network": "host",
"xhost": "+"
}
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined",
"--privileged",
"--network=host"
],
"appPort": [
"69:69"
],
"settings" : {
"git.path": "/usr/bin/git"
},
"mounts": [
"type=bind,source=/dev/bus/usb,target=/dev/bus/usb", // Make Debugger available.
"source=${localEnv:HOME}/.ssh,target=/home/devuser/.ssh,type=bind,consistency=cached", // Make ssh key available
"source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind,consistency=cached" // Mount graphic inside container to run GUIs
],
"containerEnv": {
"DISPLAY": "${localEnv:DISPLAY}"
},

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "cat /etc/os-release",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "can_explorer",
"customizations": {
"vscode": {
"extensions": [
"ms-azuretools.vscode-docker",
"ms-python.python",
"ms-python.debugpy",
"donjayamanne.python-environment-manager",
"asciidoctor.asciidoctor-vscode",
"FedericoVarela.pipenv-scripts"
]
}
}
}
60 changes: 60 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: build

on:
push:
branches:
- develop
pull_request:
branches:
- develop

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
prettier:
name: Format code using black
runs-on: ubuntu-20.04
timeout-minutes: 5
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Run black
uses: psf/back@stable
with:
options: "--check --verbose"
doctoc:
name: Build docs
runs-on: ubuntu-20.04
steps:
- name: Checkout Repo
uses: actions/checkout@v4

linter-py:
name: Lint code using PyLint
runs-on: ubuntu-20.04
steps:
- name: Checkout Repo
uses: actions/checkout@v4

build-gui-linux:
name: Build GUI for Linux (Ubuntu)
runs-on: ubuntu-20.04
steps:
- name: Checkout Repo
uses: actions/checkout@v4

build-gui-for-windows:
name: Build GUI for Windows
runs-on: windows-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4

build-gui-for-mac:
name: Build GUI for Mac
runs-on: macos-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
Empty file.
Empty file added .github/workflows/publish.yaml
Empty file.
Empty file added .github/workflows/release.yaml
Empty file.
Empty file added .github/workflows/security.yaml
Empty file.
135 changes: 135 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# Pipe
Pipfile.lock

# Jetbrains
.idea/
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
12 changes: 12 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "echo",
"type": "shell",
"command": "echo Hello"
}
]
}
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM ubuntu:noble

ENV TZ="Europe/Berlin"
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt -y update
RUN apt -y install git vim python3 python3-pip pipenv

RUN apt -y update
RUN apt -y install libglib2.0-0 libglu1-mesa-dev libxkbcommon-x11-0 build-essential libgl1-mesa-dev libdbus-1-dev libxcb-*

RUN useradd -ms /bin/bash can_explorer
Empty file added LICENSE.md
Empty file.
31 changes: 31 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
pyqt6 = "*"
pyinstaller = "*"
python-can = "*"
cantools = "*"
python-decouple = "*"
click = "*"
aiofile = "*"
aiohttp = "*"
numpy = "*"
matplotlib = "*"
schema = "*"

[dev-packages]
black = "*"
mypy = "*"
pytest = "*"
pylint = "*"
pytest-schema = "*"
pre-commit = "*"

[requires]
python_version = "3.12"

[scripts]
main = "python -m can_explorer"
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# CANExplorer
A CANbus-Analyse Tool for all platform.


## Roadmap
1. Project Setup
- [x] Initialize git project
- [x] Set basic project structure
- [x] Set package manager and install packages
- [x] Set docker and vscode devcontainer
- [x] Add basic working code
2. Transceive CAN messages
- [ ] Process IsoCan Frames
- [ ] Process ISoTp Frames
- [ ] Process J1939 Frames
- [ ] Process OpenCAN Frames
8 changes: 8 additions & 0 deletions can_explorer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from decouple import config

LOG_FORMAT = config('CANEXPLORER_LOG_FORMAT', cast=str)
LOG_LEVEL = config('CANEXPLORER_LOG_LEVEL', cast=str)
PROJECT_NAME = config('CANEXPLORER_PROJECT_NAME', cast=str)
PROJECT_BUILD_DATE = '12 October 2024'
PROJECT_PLATFORM = 'Linux'

40 changes: 40 additions & 0 deletions can_explorer/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import sys
import asyncio
import logging

from PyQt6.QtWidgets import QApplication
from can_explorer import LOG_FORMAT, LOG_LEVEL, PROJECT_NAME
from can_explorer.gui.main_window import MainWindow
from can_explorer.transport.can_connection import create_can_connection
from qasync import QEventLoop


logger = logging.getLogger(__name__)


async def main() -> None:
loop = asyncio.get_running_loop()
transport, protocol = await create_can_connection(loop=loop, protocol_factory=None, url=None, channel='vcan0', interface='socketcan', fd=True)
# protocol.write(bytearray([1, 2, 3]), arbitration_id=232)
logger.info(f'{transport=}, {protocol=}')
await asyncio.Future()

def run_app() -> int:
app = QApplication(sys.argv)
event_loop = QEventLoop(app)
asyncio.set_event_loop(event_loop)
async def show_window():
window = MainWindow(app)
window.show()
result = app.exec()
result = asyncio.run(show_window())
return result


if __name__ == "__main__":
logging.basicConfig(format=LOG_FORMAT, level=LOG_LEVEL)
logger.info(f'Starting: {PROJECT_NAME}')
# asyncio.run(main=main())
# asyncio.run(main=run_app())
run_app()
logger.info(f"Exiting: {PROJECT_NAME} ")
Loading

0 comments on commit 6e6e934

Please sign in to comment.