Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature support rtl_433 input #186

Merged
merged 47 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
8bb7ba3
Fixed netfix status command output
e100 Feb 1, 2025
48b0685
Removed print that was not needed
e100 Feb 1, 2025
5a042bd
Added rtl_433 plugin so we can collect data from various wireless sen…
e100 Feb 2, 2025
db2aabc
updated column names in client gui
e100 Feb 2, 2025
2c177f0
Added more example sensors for rtl_433
e100 Feb 2, 2025
1b73186
Added logging and ensure rtl_433 process is terminated on shutdown or…
e100 Feb 2, 2025
0eeee77
Fixed system plugin so it shutsdown cleanly
e100 Feb 2, 2025
dd85ec8
Updated rtl_433 to support running within a snap
e100 Feb 2, 2025
1fbfb4c
Starteed creating tests for rtl_433
e100 Feb 2, 2025
6809930
more test improvements for rtl_433
e100 Feb 2, 2025
be52c62
Updated tests and rtl_433 plugin to improve coverage and resolve some…
e100 Feb 2, 2025
60e62c3
Updated snapcraft to include nwer version of rtl_433
e100 Feb 2, 2025
f3a0a0e
Updated path for rtl_433 inside the snap
e100 Feb 2, 2025
6e4a1cb
Fixed status test in netfix tests so it passes
e100 Feb 2, 2025
7c7e49b
Changed version to 2.2.0
e100 Feb 2, 2025
e90d6fe
added unit tests for rtl_433
e100 Feb 2, 2025
9e944fe
updated all plugins to accept config_meta so we can start validating …
e100 Feb 2, 2025
a366da9
Starting adding configuration validation to rtl_433
e100 Feb 2, 2025
f8022f3
Updated tests to include config_meta and fixed typo in db_persister
e100 Feb 3, 2025
1ce21c8
Added config exception tests for rtl_433
e100 Feb 3, 2025
9e54851
More config tests/validation for rtl_433
e100 Feb 3, 2025
dfe26d5
Fixed CI so it runs apt update before install
e100 Feb 3, 2025
70f7b76
Fixed round: 0 is valid
e100 Feb 3, 2025
f32a74c
Race condition in netfix subscription test
e100 Feb 3, 2025
0ff286f
Added longer delay for processing in tests/plugins/rtl_433/test_plugi…
e100 Feb 3, 2025
2bbc791
Removed file commit by accident
e100 Feb 3, 2025
fda6985
Added additional tests and config validation to rtl_433, formatted wi…
e100 Feb 5, 2025
22b0a82
Temporarily switched to using my fork of rtl_433 so I can test with m…
e100 Feb 7, 2025
fa2c40c
Updated example rtl_433 config
e100 Feb 7, 2025
1126389
Updated rtl_433 to only track the protocol and id so one can distingu…
e100 Feb 7, 2025
1b9dcb3
Updated rtl_433 tests to match the database fixid changes
e100 Feb 7, 2025
eb7dacf
Fixed rtl_433 tests to account for including protocol in the json out…
e100 Feb 7, 2025
898ff51
Added delay in test to allow processing time before checking results
e100 Feb 7, 2025
b09a1c5
Updated test to use different port so it does not conflict with runni…
e100 Feb 7, 2025
641c3c9
Saving work snapcraft.yaml
e100 Feb 8, 2025
decce73
Updated rtl_433 to include the model number in the status output
e100 Feb 8, 2025
bf0a336
Fixed test to include model for rtl_433
e100 Feb 8, 2025
e185327
Updated example configuration for rtl_433
e100 Feb 8, 2025
0779326
Fixed access denied by fixing rpath
e100 Feb 8, 2025
53eefe3
Added additional test conditions for rtl_433
e100 Feb 8, 2025
884053f
Updated version to 2.2.1
e100 Feb 9, 2025
6502d4f
Merge branch 'master' into tpms
e100 Feb 9, 2025
ca8e491
Updated rtl_433 tests to gt 100% coverage
e100 Feb 9, 2025
b699072
Merge remote-tracking branch 'origin/tpms' into tpms
e100 Feb 9, 2025
21ace5c
Fixed expectd message in test to not include line number
e100 Feb 13, 2025
b80ad0a
Formattd rtl_433 related code with black
e100 Feb 13, 2025
f7b1cac
Updated snapcraft
e100 Feb 13, 2025
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
111 changes: 93 additions & 18 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ description: |
Release Notes:
* Drop support for armhf
* Enabled client GUI using fixgateway.client --gui
* Updated to core24 and python 3.12
The GUI is not stable but usable

Many new plugins that need your help testing:
* rtl_433, collect data from wirelss sensors such as TPMS
* dynon, collects AHRS data from Dynon D10/D100
* gpsd, obtains GPS data from gpsd network daemon
* mgl_serial RS-232 protocol, currently lacks custom configuration
Expand Down Expand Up @@ -46,6 +47,16 @@ platforms:
base: core24
confinement: strict

layout:
/usr/share/X11/locale:
symlink: $SNAP/gpu-2404/X11/locale
/usr/share/X11/xkb:
bind: $SNAP/usr/share/X11/xkb
/etc/fonts:
bind: $SNAP/etc/fonts
/usr/share/fonts:
bind: $SNAP/usr/share/fonts

parts:
extras:
source: ./extras
Expand All @@ -57,11 +68,18 @@ parts:
override-build: |
craftctl default
craftctl set version=$(python3 src/fixgw/version.py)
echo "Fixing RPATH for ELF binaries..."
find $SNAPCRAFT_PART_INSTALL -type f \( -name "*.so*" -o -perm -111 \) -exec sh -c '
if file "$1" | grep -q "ELF"; then
echo "Patching RPATH for $1"
patchelf --set-rpath "$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR" "$1"
fi
' sh {} \;

stage-packages:
- patchelf
- libxcb-cursor0
- libarchive13t64
- cmake
- build-essential
- python3.12-minimal
- libpython3.12-minimal
- libpython3.12-stdlib
Expand All @@ -72,30 +90,41 @@ parts:
- python3-psutil
- python3-pyqt6
- libblas3
- libc6
- liblapack3
- python3-packaging
- libc6-dev
- libblas-dev
- liblapack-dev
- libopenblas-dev
- python3-dev
- libhdf5-serial-dev
- python3-tables
- gcc
- g++
- libhdf5-dev
- pkg-config
- bzip2
- lzop
- rtl-433
- xkb-data
- x11-xkb-utils
- locales-all
- libxkbcommon0
- fonts-dejavu-core
- fonts-dejavu-extra
- libopenblas0
- libhdf5-103-1t64
# - librtlsdr2
# - libusb-1.0-0
build-environment:
- PARTS_PYTHON_INTERPRETER: python3.12
# - PIP_VERBOSE: 3
- PARTS_PYTHON_VENV_ARGS: --system-site-packages
- PIP_NO_UPGRADE: "1"
build-packages:
- file
- execstack
- libc6-dev
- cmake
- build-essential
- libblas-dev
- liblapack-dev
- libopenblas-dev
- python3-dev
- libhdf5-dev

# Remove exec stack bit from files causing manual review
override-prime: |
set -eu
Expand All @@ -105,26 +134,70 @@ parts:
execstack -c $f
fi
done

rtl-433:
plugin: cmake
# source: https://github.com/merbanan/rtl_433.git
source: https://github.com/e100/rtl_433.git
# source-tag: '24.10'
source-tag: 'gm_tpms'
source-depth: 1
source-type: git
build-packages:
- file
- build-essential
- cmake
- librtlsdr-dev
- libusb-1.0-0-dev
- pkg-config
- git
- libc6-dev
stage-packages:
- librtlsdr2
- libusb-1.0-0
- patchelf
cmake-parameters:
- -DCMAKE_INSTALL_PREFIX=/usr
build-attributes:
- enable-patchelf
override-build: |
snapcraftctl build
# Ensure correct RPATH (use libc6 from core24)
patchelf --set-rpath "/snap/core24/current/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR" $SNAPCRAFT_PART_INSTALL/usr/bin/rtl_433
echo "Fixing RPATH for ELF binaries..."
find $SNAPCRAFT_PART_INSTALL -type f \( -name "*.so*" -o -perm -111 \) -exec sh -c '
if file "$1" | grep -q "ELF"; then
echo "Patching RPATH for $1"
patchelf --set-rpath "$SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR" "$1"
fi
' sh {} \;
override-prime: |
set -eu
craftctl default
# Ensure libc6 is removed (use core24's libc6 instead)
rm -rf $SNAPCRAFT_PRIME/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libc.so.*
rm -rf $SNAPCRAFT_PRIME/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libc.so.*
apps:
rtl433:
rtl-433:
command: usr/bin/rtl_433
plugs:
- raw-usb
- network
- network-bind
- raw-usb
daemon:
command: bin/fixgw
daemon: simple
daemon-scope: user
# Woud be nice to also support options: https://snapcraft.io/docs/adding-snap-configuration
restart-condition: always
plugs: [ home, network-bind, network, can-bus, serial-port, i2c, spi]
plugs: [ home, network-bind, network, can-bus, serial-port, i2c, spi, raw-usb]
environment:
PATH: $SNAP/bin:$SNAP/usr/bin:$SNAP/usr/local/bin:$PATH
PYTHONPATH: $SNAP/lib/python3.12/site-packages:$SNAP/usr/lib/python3/dist-packages:$PYTHONPATH

server:
command: bin/fixgw
plugs: [ home, network-bind, network, can-bus, serial-port, i2c, spi]
plugs: [ home, network-bind, network, can-bus, serial-port, i2c, spi, raw-usb]
environment:
PATH: $SNAP/bin:$SNAP/usr/bin:$SNAP/usr/local/bin:$PATH
PYTHONPATH: $SNAP/lib/python3.12/site-packages:$SNAP/usr/lib/python3/dist-packages:$PYTHONPATH
Expand All @@ -137,11 +210,13 @@ apps:
- desktop-legacy
- wayland
- x11
- home

environment:
PATH: $SNAP/bin:$SNAP/usr/bin:$SNAP/usr/local/bin:$PATH
PYTHONPATH: $SNAP/lib/python3.12/site-packages:$SNAP/usr/lib/python3/dist-packages:$PYTHONPATH
QT_PLUGIN_PATH: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/qt6/plugins/
QT_QPA_PLATFORM: xcb


XKB_CONFIG_ROOT: $SNAP/usr/share/X11/xkb
QT_XKB_CONFIG_ROOT: $SNAP/usr/share/X11/xkb
QT_NO_SESSION_MANAGER: 1
3 changes: 2 additions & 1 deletion src/fixgw/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
__version__ = "2.2.0"
__version__ = "2.2.1"

2 changes: 1 addition & 1 deletion src/fixgw/client/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def setChecked(self, value):
class DataTable(QTableWidget):
def __init__(self, parent=None):
super(DataTable, self).__init__(parent)
cols = ["Value", "A", "O", "B", "F", "S", "Description"]
cols = ["Value", "Annun", "Old", "Bad", "Fail", "SFail", "Description"]
self.setColumnCount(len(cols))
self.setHorizontalHeaderLabels(cols)
self.horizontalHeader().setSectionResizeMode(
Expand Down
53 changes: 53 additions & 0 deletions src/fixgw/config/connections/rtl_433.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
rtl_433:
load: RTL_433
module: fixgw.plugins.rtl_433
frequency: 433920000
rtl_device: 0
#simulate: true
sensors:
- sensor_id: 2018052400 # TPMS ID for front wheel
decoder: 275 # The decoder needed to capture this data
mappings:
TIREP1:
source: "pressure_kPa"
#scale: 6.89476 # Convert kPa to PSI
round: 1
type: "float"
TIRET1:
source: "temperature_C"
#offset: -40
round: 0
type: "float"
TIREB1:
source: "battery_ok"
#threshold: 2.0 # Battery OK if voltage > 2.0 (1 = OK, 0 = Low)
type: "bool"
- sensor_id: 2017934177 # TPMS ID for front wheel
decoder: 275 # The decoder needed to capture this data
mappings:
TIREP2:
source: "pressure_kPa"
round: 1
type: "float"
TIRET2:
source: "temperature_C"
round: 0
type: "float"
TIREB2:
source: "battery_ok"
type: "bool"
- sensor_id: 2017968551 # TPMS ID for front wheel
decoder: 275 # The decoder needed to capture this data
mappings:
TIREP3:
source: "pressure_kPa"
round: 1
type: "float"
TIRET3:
source: "temperature_C"
round: 0
type: "float"
TIREB3:
source: "battery_ok"
type: "bool"

1 change: 1 addition & 0 deletions src/fixgw/config/database.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ entries:
- include: database/system.yaml
- include: database/control.yaml
- include: database/misc.yaml
- include: database/tires.yaml
#################################################
# If you want to modify or add new items place do so in the file
# database/custom.yaml
Expand Down
26 changes: 26 additions & 0 deletions src/fixgw/config/database/tires.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
items:
- key: TIREPw
description: Tire %w Pressure
type: float
tol: 300000 # 5 minutes
units: psi
min: 0.0
max: 150.0
initial: 0.0
aux: [Min,Max,lowWarn,highWarn,lowAlarm,highAlarm]

- key: TIRETw
description: Tire %w Temperature
type: float
tol: 300000 # 5 minutes
units: degC
min: -50.0
max: 85.0
initial: 0.0
aux: [highWarn,highAlarm]

- key: TIREBw
description: Tire %w Battery Status
type: bool
tol: 300000 # 5 minutes
initial: false
2 changes: 1 addition & 1 deletion src/fixgw/config/database/variables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ variables:
n: 5 # Nodes
s: 40 # Touchscreen buttons
d: 4 # MGL V16 Radios

w: 3 # Wheels
3 changes: 2 additions & 1 deletion src/fixgw/config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ auto start: true
# Plugins may overwrite this data as well.
initialization files:
- "{CONFIG}/init_data/default.ini"
- "{CONFIG}/init_data/tires.ini"
# - "{CONFIG}/init_data/airplanes/cessna/c170b.ini"
# - "{CONFIG}/init_data/flight_gear/cessna_172.ini"
# - "{CONFIG}/init_data/engines/aeromomentum/am13.ini"
Expand Down Expand Up @@ -66,7 +67,7 @@ connections:
- STROM_PI_CONFIG
- DYNON_CONFIG
- DEMO_CONFIG

- RTL_433_CONFIG
# Logging configuration - See Python logging.config module documenation
# This is logging for system messages, not system data
# If you want a Flight Data Recorder, see the file connections/data_recorder.yaml
Expand Down
30 changes: 30 additions & 0 deletions src/fixgw/config/init_data/tires.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# normal 15 psi
TIREP1.Min = 13
TIREP1.Max = 16
TIREP1.lowWarn = 13
TIREP1.lowAlarm = 10
TIREP1.highWarn = 16
TIREP1.highAlarm = 18

TIREP2.Min = 13
TIREP2.Max = 16
TIREP2.lowWarn = 13
TIREP2.lowAlarm = 10
TIREP2.highWarn = 16
TIREP2.highAlarm = 18

TIREP3.Min = 13
TIREP3.Max = 16
TIREP3.lowWarn = 13
TIREP3.lowAlarm = 10
TIREP3.highWarn = 16
TIREP3.highAlarm = 18

TIRET1.highWarn = 75
TIRET1.highAlarm = 85

TIRET2.highWarn = 75
TIRET2.highAlarm = 85

TIRET3.highWarn = 75
TIRET3.highAlarm = 85
3 changes: 2 additions & 1 deletion src/fixgw/config/preferences.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ includes:
STROM_PI_CONFIG: connections/strom_pi.yaml
DYNON_CONFIG: connections/dynon.yaml
DEMO_CONFIG: connections/demo.yaml
RTL_433_CONFIG: connections/rtl_433.yaml
# This section is used to turn things on or off
enabled:
QUORUM: false
Expand Down Expand Up @@ -69,4 +70,4 @@ enabled:
STROM_PI: false
DYNON: false
DEMO: true

RTL_433: false
3 changes: 2 additions & 1 deletion src/fixgw/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ class PluginFail(Exception):
# inherit this class and override at least the run function. See the
# skel.py file in the plugins directory for a basic example.
class PluginBase(object):
def __init__(self, name, config):
def __init__(self, name, config, config_meta):
self.name = name
self.log = logging.getLogger("fixgw." + name)
self.log.info("Initializing")
self.config = config
self.config_meta = config_meta
self.log.debug("Config: " + str(self.config))

self.running = False
Expand Down
4 changes: 2 additions & 2 deletions src/fixgw/plugins/annunciate.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ def __str__(self):


class Plugin(plugin.PluginBase):
def __init__(self, name, config):
super(Plugin, self).__init__(name, config)
def __init__(self, name, config, config_meta):
super(Plugin, self).__init__(name, config, config_meta)
self.items = []

def run(self):
Expand Down
4 changes: 2 additions & 2 deletions src/fixgw/plugins/canfix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ def stop(self):


class Plugin(plugin.PluginBase):
def __init__(self, name, config):
super(Plugin, self).__init__(name, config)
def __init__(self, name, config, config_meta):
super(Plugin, self).__init__(name, config, config_meta)
self.interface = config["interface"]
self.channel = config["channel"]
self.device = int(config["device"])
Expand Down
Loading
Loading