use new library for js8 decoding

This commit is contained in:
Jakob Ketterl 2020-04-13 16:35:31 +02:00
parent ddfd85c586
commit bcb8a2315c

View File

@ -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,6 +24,7 @@ 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):
try:
freq, raw_msg = raw freq, raw_msg = raw
self.setDialFrequency(freq) self.setDialFrequency(freq)
msg = raw_msg.decode().rstrip() msg = raw_msg.decode().rstrip()
@ -29,4 +32,16 @@ class Js8Parser(Parser):
return return
if msg.startswith(" EOF on input file"): if msg.startswith(" EOF on input file"):
return return
logger.debug(msg) 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")