little edits on decoder

This commit is contained in:
Bastian Schroll 2018-01-08 07:56:10 +01:00
parent 9a7dbaeade
commit 881615dcce
3 changed files with 31 additions and 18 deletions

View file

@ -34,6 +34,7 @@ class Fms:
"""!Create a new instance"""
logging.debug("FMS decoder started")
@staticmethod
def decode(self, data):
"""!Decodes FMS

View file

@ -34,29 +34,13 @@ class Pocsag:
"""!Create a new instance"""
logging.debug("POCSAG decoder started")
@staticmethod
def decode(self, data):
"""!Decodes POCSAG
@param data: POCSAG for decoding
@return BOSWatch POCSAG packet or None"""
bitrate = None
ric = None
subric = None
if "POCSAG512:" in data:
bitrate = 512
ric = data[20:27].replace(" ", "").zfill(7)
subric = str(int(data[39]) + 1)
elif "POCSAG1200:" in data:
bitrate = 1200
ric = data[21:28].replace(" ", "").zfill(7)
subric = str(int(data[40]) + 1)
elif "POCSAG2400:" in data:
bitrate = 2400
ric = data[21:28].replace(" ", "").zfill(7)
subric = str(int(data[40]) + 1)
bitrate, ric, subric = Pocsag._getBitrateRicSubric(data)
if re.search("[0-9]{7}", ric) and re.search("[1-4]{1}", subric):
if "Alpha:" in data:
@ -81,3 +65,30 @@ class Pocsag:
logging.warning("no valid data")
return None
@staticmethod
def _getBitrateRicSubric(data):
"""!Gets the Bitrate, Ric and Subric from data
@param data: POCSAG data string
@return bitrate
@return ric
@return subric"""
bitrate, ric, subric = 0, 0, 0
if "POCSAG512:" in data:
bitrate = 512
ric = data[20:27].replace(" ", "").zfill(7)
subric = str(int(data[39]) + 1)
elif "POCSAG1200:" in data:
bitrate = 1200
ric = data[21:28].replace(" ", "").zfill(7)
subric = str(int(data[40]) + 1)
elif "POCSAG2400:" in data:
bitrate = 2400
ric = data[21:28].replace(" ", "").zfill(7)
subric = str(int(data[40]) + 1)
return bitrate, ric, subric

View file

@ -35,6 +35,7 @@ class Zvei:
"""!Create a new instance"""
logging.debug("ZVEI decoder started")
@staticmethod
def decode(self, data):
"""!Decodes ZVEI