BOSWatch 3
Python Script to receive and decode German BOS Information with rtl_fm and multimon-NG
 
Loading...
Searching...
No Matches
boswatch.decoder.pocsagDecoder.PocsagDecoder Class Reference

POCSAG decoder class. More...

Static Public Member Functions

def decode (data)
 Decodes POCSAG.
 

Static Protected Member Functions

def _getBitrateRicSubric (data)
 Gets the Bitrate, Ric and Subric from data.
 

Detailed Description

POCSAG decoder class.

This class decodes POCSAG data.
First step is to validate the data and _check if the format is correct.
In the last step a valid BOSWatch packet is created and returned

Member Function Documentation

◆ decode()

def boswatch.decoder.pocsagDecoder.PocsagDecoder.decode (   data)
static

Decodes POCSAG.

    @param data: POCSAG for decoding
    @return BOSWatch POCSAG packet or None
34 def decode(data):
35 r"""!Decodes POCSAG
36
37 @param data: POCSAG for decoding
38 @return BOSWatch POCSAG packet or None"""
39 bitrate, ric, subric = PocsagDecoder._getBitrateRicSubric(data)
40
41 if re.search("[0-9]{7}", ric) and re.search("[1-4]", subric):
42 if "Alpha:" in data:
43 message = data.split('Alpha: ')[1].strip()
44 message = message.replace('<NUL>', '').replace('<NUL', '').replace('< NUL>', '').replace('<EOT>', '').strip()
45 else:
46 message = ""
47 subricText = subric.replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d")
48
49 logging.debug("found valid POCSAG")
50
51 bwPacket = Packet()
52 bwPacket.set("mode", "pocsag")
53 bwPacket.set("bitrate", bitrate)
54 bwPacket.set("ric", ric)
55 bwPacket.set("subric", subric)
56 bwPacket.set("subricText", subricText)
57 bwPacket.set("message", message)
58
59 return bwPacket
60
61 logging.warning("no valid POCSAG")
62 return None
63

◆ _getBitrateRicSubric()

def boswatch.decoder.pocsagDecoder.PocsagDecoder._getBitrateRicSubric (   data)
staticprotected

Gets the Bitrate, Ric and Subric from data.

    @param data: POCSAG data string
    @return bitrate
    @return ric
    @return subric
65 def _getBitrateRicSubric(data):
66 r"""!Gets the Bitrate, Ric and Subric from data
67
68 @param data: POCSAG data string
69 @return bitrate
70 @return ric
71 @return subric"""
72 bitrate, ric, subric = "0", "0", "0"
73
74 if "POCSAG512:" in data:
75 bitrate = "512"
76 ric = data[20:27].replace(" ", "").zfill(7)
77 subric = str(int(data[39]) + 1)
78
79 elif "POCSAG1200:" in data:
80 bitrate = "1200"
81 ric = data[21:28].replace(" ", "").zfill(7)
82 subric = str(int(data[40]) + 1)
83
84 elif "POCSAG2400:" in data:
85 bitrate = "2400"
86 ric = data[21:28].replace(" ", "").zfill(7)
87 subric = str(int(data[40]) + 1)
88
89 return bitrate, ric, subric