From f794f285f371f3d8a40c61a1112acb100b592633 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sun, 3 Sep 2023 23:48:56 +0200 Subject: [PATCH] add some basic infrastructure for hfdl --- csdr/chain/dumphfdl.py | 14 +++++++++++++ csdr/chain/rtl433.py | 5 +++-- csdr/module/__init__.py | 18 +++++++++++++++++ htdocs/index.html | 1 + htdocs/lib/DemodulatorPanel.js | 4 +++- htdocs/lib/MessagePanel.js | 36 ++++++++++++++++++++++++++++++++++ htdocs/openwebrx.js | 20 +++++++------------ owrx/dsp.py | 3 +++ owrx/feature.py | 7 +++++++ owrx/hfdl/dumphfdl.py | 18 +++++++++++++++++ owrx/ism/rtl433.py | 15 -------------- owrx/modes.py | 8 ++++++++ 12 files changed, 118 insertions(+), 31 deletions(-) create mode 100644 csdr/chain/dumphfdl.py create mode 100644 owrx/hfdl/dumphfdl.py diff --git a/csdr/chain/dumphfdl.py b/csdr/chain/dumphfdl.py new file mode 100644 index 00000000..8c7b08f7 --- /dev/null +++ b/csdr/chain/dumphfdl.py @@ -0,0 +1,14 @@ +from csdr.chain.demodulator import ServiceDemodulator +from owrx.hfdl.dumphfdl import DumpHFDLModule +from csdr.module import JsonParser + + +class DumpHFDL(ServiceDemodulator): + def __init__(self): + super().__init__([ + DumpHFDLModule(), + JsonParser("HFDL"), + ]) + + def getFixedAudioRate(self) -> int: + return 12000 diff --git a/csdr/chain/rtl433.py b/csdr/chain/rtl433.py index 6b9f5704..f1f95341 100644 --- a/csdr/chain/rtl433.py +++ b/csdr/chain/rtl433.py @@ -1,4 +1,5 @@ -from owrx.ism.rtl433 import Rtl433Module, JsonParser +from csdr.module import JsonParser +from owrx.ism.rtl433 import Rtl433Module from csdr.chain.demodulator import ServiceDemodulator @@ -10,6 +11,6 @@ class Rtl433(ServiceDemodulator): super().__init__( [ Rtl433Module(), - JsonParser(), + JsonParser("ISM"), ] ) diff --git a/csdr/module/__init__.py b/csdr/module/__init__.py index 3ee0d0ec..df79e8ed 100644 --- a/csdr/module/__init__.py +++ b/csdr/module/__init__.py @@ -8,6 +8,9 @@ from subprocess import Popen, PIPE from functools import partial import pickle import logging +import json + +logger = logging.getLogger(__name__) class Module(BaseModule, metaclass=ABCMeta): @@ -146,6 +149,21 @@ class LineBasedModule(ThreadModule, metaclass=ABCMeta): pass +class JsonParser(LineBasedModule): + def __init__(self, mode: str): + self.mode = mode + super().__init__() + + def process(self, line): + try: + msg = json.loads(line.decode()) + msg["mode"] = self.mode + logger.debug(msg) + return msg + except json.JSONDecodeError: + logger.exception("error parsing rtl433 json") + + class PopenModule(AutoStartModule, metaclass=ABCMeta): def __init__(self): self.process = None diff --git a/htdocs/index.html b/htdocs/index.html index 8a9b3535..960e5c96 100644 --- a/htdocs/index.html +++ b/htdocs/index.html @@ -76,6 +76,7 @@ +