Ejemplo n.º 1
0
    def parse(self, messages):
        for raw in messages:
            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

                frame = Js8().parse_message(msg)
                self.handler.write_js8_message(frame, self.dial_freq)

                self.pushDecode()

                if (isinstance(frame, Js8FrameHeartbeat) or isinstance(frame, Js8FrameCompound)) and frame.grid:
                    Map.getSharedInstance().updateLocation(
                        frame.callsign, LocatorLocation(frame.grid), "JS8", self.band
                    )
                    PskReporter.getSharedInstance().spot({
                        "callsign": frame.callsign,
                        "mode": "JS8",
                        "locator": frame.grid,
                        "freq": self.dial_freq + frame.freq,
                        "db": frame.db,
                        "timestamp": frame.timestamp,
                        "msg": str(frame)
                    })

            except Exception:
                logger.exception("error while parsing js8 message")
Ejemplo n.º 2
0
    def testFrameDataCompressed(self):
        test_data = [
            ("140000 -11  0.4 1050 A  qBdgE+EP++++         2", "IN ITALY TODAY")
        ]

        for raw_msg, expected in test_data:
            msg = Js8().parse_message(raw_msg)
            self.assertIsInstance(msg, Js8FrameDataCompressed)
            self.assertEqual(str(msg), expected)
Ejemplo n.º 3
0
    def testFrameCompoundDirected(self):
        # TODO: get verified samples
        test_data = [
            ("200345 -12  0.8 1001 A  H-jnbQvYe+ke         2", "G0WZM/A ACK -04"),
        ]

        for raw_msg, expected in test_data:
            msg = Js8().parse_message(raw_msg)
            self.assertIsInstance(msg, Js8FrameCompoundDirected)
            self.assertEqual(str(msg), expected)
Ejemplo n.º 4
0
    def testFrameData(self):
        test_data = [
            ("183500 -22  0.5 1519 A  iXvZfxW3Sju+         2", "KALHSPERA VNE"),
            ("201115 -16  0.6 1075 A  YNlWl7V+Uw-j         0", "F DIGI TOO DM7")
        ]

        for raw_msg, expected in test_data:
            msg = Js8().parse_message(raw_msg)
            self.assertIsInstance(msg, Js8FrameData)
            self.assertEqual(str(msg), expected)
Ejemplo n.º 5
0
    def testFrameCompound(self):
        # TODO: get verified samples
        test_data = [
            ("063545 -10 -0.2 1164 A  BYh0otuHOS3G         1", "SP5GSM:"),
            ("211315 -15  0.6 1250 A  B8giaUqYuUtG         1", "PE75OUW:"),
        ]

        for raw_msg, expected in test_data:
            msg = Js8().parse_message(raw_msg)
            self.assertIsInstance(msg, Js8FrameCompound)
            self.assertEqual(str(msg), expected)
Ejemplo n.º 6
0
    def testFrameHeartbeat(self):
        test_data = [
            ("172300 -12  0.4 1044 A  2jNlWSPIPQ-W         3", "LZ1CWK: CQ CQ CQ KN32"),
            ("192415 -15  0.4  953 A  1-ckNKyPOVwh         3", "G0CQZ: HB AUTO RELAY SPOT IO91"),
            ("200415 -13  0.5 1023 A  1mqQJL8Bv++u         3", "EA3ENR: CQ CQ CQ "),
        ]

        for raw_msg, expected in test_data:
            msg = Js8().parse_message(raw_msg)
            self.assertIsInstance(msg, Js8FrameHeartbeat)
            self.assertEqual(str(msg), expected)
Ejemplo n.º 7
0
    def testFrameDirected(self):
        test_data = [
            ("151615 -11  0.3 2457 A  ViZoThL+C+aL         3", "G0CQZ: DF4MJ SNR -10 "),
            ("161630 -19  0.3 1203 A  QrqjshWc6lq0         3", "DG3EK: DM5CQ ACK "),
            ("165430 -14  2.5 1697 A  Tuj1fVGGPoy0         1", "RV4CQ: @APRSIS GRID "),
            ("201915 -13  0.3  794 A  R43a8hMPfZqV         3", "EI2GYB: DF7FR ACK +00 "),
            ("183445 -24  0.3 1520 A  VkrOrOOSTgK0         1", "M0SUY: SV1GGY> ")
        ]

        for raw_msg, expected in test_data:
            msg = Js8().parse_message(raw_msg)
            self.assertIsInstance(msg, Js8FrameDirected)
            self.assertEqual(str(msg), expected)
Ejemplo n.º 8
0
    def parse(self, profile: AudioChopperProfile, freq: int, raw_msg: bytes):
        try:
            band = None
            if freq is not None:
                band = Bandplan.getSharedInstance().findBand(freq)

            msg = raw_msg.decode().rstrip()
            if Js8Parser.decoderRegex.match(msg):
                return
            if msg.startswith(" EOF on input file"):
                return

            frame = Js8().parse_message(msg)

            self.pushDecode(band)

            if (isinstance(frame, Js8FrameHeartbeat)
                    or isinstance(frame, Js8FrameCompound)) and frame.grid:
                Map.getSharedInstance().updateLocation(
                    frame.callsign, LocatorLocation(frame.grid), "JS8", band)
                ReportingEngine.getSharedInstance().spot({
                    "callsign": frame.callsign,
                    "mode": "JS8",
                    "locator": frame.grid,
                    "freq": freq + frame.freq,
                    "db": frame.db,
                    "timestamp": frame.timestamp,
                    "msg": str(frame),
                })

            out = {
                "mode": "JS8",
                "msg": str(frame),
                "timestamp": frame.timestamp,
                "db": frame.db,
                "dt": frame.dt,
                "freq": freq + frame.freq,
                "thread_type": frame.thread_type,
                "js8mode": frame.mode,
            }

            return out

        except Exception:
            logger.exception("error while parsing js8 message")