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 .parser import Parser
|
||||
import re
|
||||
from js8py import Js8
|
||||
from js8py.frames import Js8FrameDirected, Js8FrameData, Js8FrameDataCompressed
|
||||
|
||||
import logging
|
||||
|
||||
@ -22,11 +24,24 @@ class Js8Parser(Parser):
|
||||
decoderRegex = re.compile(" ?<Decode(Started|Debug|Finished)>")
|
||||
|
||||
def parse(self, raw):
|
||||
freq, raw_msg = raw
|
||||
self.setDialFrequency(freq)
|
||||
msg = raw_msg.decode().rstrip()
|
||||
if Js8Parser.decoderRegex.match(msg):
|
||||
return
|
||||
if msg.startswith(" EOF on input file"):
|
||||
return
|
||||
logger.debug(msg)
|
||||
try:
|
||||
freq, raw_msg = raw
|
||||
self.setDialFrequency(freq)
|
||||
msg = raw_msg.decode().rstrip()
|
||||
if Js8Parser.decoderRegex.match(msg):
|
||||
return
|
||||
if msg.startswith(" EOF on input file"):
|
||||
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