use new library for js8 decoding
This commit is contained in:
parent
ddfd85c586
commit
bcb8a2315c
31
owrx/js8.py
31
owrx/js8.py
@ -1,6 +1,8 @@
|
|||||||
from .wsjt import WsjtChopper
|
from .wsjt import WsjtChopper
|
||||||
from .parser import Parser
|
from .parser import Parser
|
||||||
import re
|
import re
|
||||||
|
from js8py import Js8
|
||||||
|
from js8py.frames import Js8FrameDirected, Js8FrameData, Js8FrameDataCompressed
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -22,11 +24,24 @@ class Js8Parser(Parser):
|
|||||||
decoderRegex = re.compile(" ?<Decode(Started|Debug|Finished)>")
|
decoderRegex = re.compile(" ?<Decode(Started|Debug|Finished)>")
|
||||||
|
|
||||||
def parse(self, raw):
|
def parse(self, raw):
|
||||||
freq, raw_msg = raw
|
try:
|
||||||
self.setDialFrequency(freq)
|
freq, raw_msg = raw
|
||||||
msg = raw_msg.decode().rstrip()
|
self.setDialFrequency(freq)
|
||||||
if Js8Parser.decoderRegex.match(msg):
|
msg = raw_msg.decode().rstrip()
|
||||||
return
|
if Js8Parser.decoderRegex.match(msg):
|
||||||
if msg.startswith(" EOF on input file"):
|
return
|
||||||
return
|
if msg.startswith(" EOF on input file"):
|
||||||
logger.debug(msg)
|
return
|
||||||
|
|
||||||
|
logger.debug(msg)
|
||||||
|
|
||||||
|
frame = Js8().parse_message(msg)
|
||||||
|
if frame is None:
|
||||||
|
logger.warning("message could not be parsed")
|
||||||
|
elif isinstance(frame, Js8FrameDirected):
|
||||||
|
logger.debug("directed frame from: {0} to: {1}".format(frame.callsign_from, frame.callsign_to))
|
||||||
|
elif isinstance(frame, Js8FrameData) or isinstance(frame, Js8FrameDataCompressed):
|
||||||
|
logger.debug("message frame: {0}".format(frame.message))
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
logger.exception("error while parsing js8 message")
|
||||||
|
Loading…
Reference in New Issue
Block a user