Cleaning up ISM and PAGE parsers.
This commit is contained in:
parent
2d91b3282e
commit
0acde34abf
|
|
@ -8,7 +8,8 @@ class Rtl433Module(ExecModule):
|
|||
def __init__(self, sampleRate: int = 250000, jsonOutput: bool = False):
|
||||
cmd = [
|
||||
"rtl_433", "-r", "cs16:-", "-s", str(sampleRate),
|
||||
"-M", "time:utc", "-F", "json" if jsonOutput else "kv",
|
||||
"-M", "time:unix" if jsonOutput else "time:utc",
|
||||
"-F", "json" if jsonOutput else "kv",
|
||||
"-A",
|
||||
]
|
||||
super().__init__(Format.COMPLEX_SHORT, Format.CHAR, cmd)
|
||||
|
|
|
|||
|
|
@ -630,7 +630,7 @@ IsmMessagePanel = function(el) {
|
|||
MessagePanel.call(this, el);
|
||||
this.initClearTimer();
|
||||
// These are basic message attributes
|
||||
this.basicInfo = ['mode', 'id', 'model', 'time', 'color'];
|
||||
this.basicInfo = ['mode', 'id', 'model', 'timestamp', 'freq', 'color'];
|
||||
}
|
||||
|
||||
IsmMessagePanel.prototype = Object.create(MessagePanel.prototype);
|
||||
|
|
@ -665,7 +665,7 @@ IsmMessagePanel.prototype.pushMessage = function(msg) {
|
|||
// Get basic information, assume white color if missing
|
||||
var address = msg.hasOwnProperty('id')? msg.id : '???';
|
||||
var device = msg.hasOwnProperty('model')? msg.model : '';
|
||||
var tstamp = msg.hasOwnProperty('time')? msg.time : '';
|
||||
var tstamp = msg.hasOwnProperty('timestamp')? Utils.HHMMSS(msg.timestamp) : '';
|
||||
var color = msg.hasOwnProperty('color')? msg.color : '#FFF';
|
||||
|
||||
// Append message header (address, time, etc)
|
||||
|
|
|
|||
|
|
@ -106,7 +106,6 @@ class TextParser(LineBasedModule):
|
|||
|
||||
try:
|
||||
#logger.debug("%s: %s" % (self.myName(), str(line)))
|
||||
# If running as a service with a log file...
|
||||
# Let parse() function do its thing
|
||||
out = self.parse(line)
|
||||
# If running as a service and writing to a log file...
|
||||
|
|
@ -173,6 +172,10 @@ class IsmParser(TextParser):
|
|||
out = json.loads(msg)
|
||||
# Add mode name
|
||||
out["mode"] = "ISM"
|
||||
# Convert Unix timestamps to milliseconds
|
||||
if "time" in out:
|
||||
out["timestamp"] = int(out["time"]) * 1000
|
||||
del out["time"]
|
||||
# Add frequency, if known
|
||||
if self.frequency:
|
||||
out["freq"] = self.frequency
|
||||
|
|
@ -191,7 +194,7 @@ class PageParser(TextParser):
|
|||
pm = Config.get()
|
||||
self.filtering = "paging_filter" in pm and pm["paging_filter"]
|
||||
# POCSAG<baud>: Address: <num> Function: <hex> (Certainty: <num> )?(Numeric|Alpha|Skyper): <message>
|
||||
self.rePocsag = re.compile(r"POCSAG(\d+):\s*Address:\s*(\S+)\s+Function:\s*(\S+)(\s+Certainty:.*(\d+))?(\s+(\S+):\s*(.*))?")
|
||||
self.rePocsag = re.compile(r"POCSAG(\d+):\s*Address:\s*(\S+)\s+Function:\s*(-?\d+)(\s+Certainty:\s*(-?\d+))?(\s+(\S+):\s*(.*))?")
|
||||
# FLEX|NNNN-NN-NN NN:NN:NN|<baud>/<value>/C/C|NN.NNN|NNNNNNNNN|<type>|<message>
|
||||
# FLEX|NNNN-NN-NN NN:NN:NN|<baud>/<value>/C/C|NN.NNN|NNNNNNNNN NNNNNNNNN|<type>|<message>
|
||||
self.reFlex1 = re.compile(r"FLEX\|(\d\d\d\d-\d\d-\d\d\s+\d\d:\d\d:\d\d)\|(\d+/\d+/\S/\S)\|(\d\d\.\d\d\d)\|(\d+(?:\s+\d+)?)\|(\S+)\|(.*)")
|
||||
|
|
@ -266,16 +269,17 @@ class PageParser(TextParser):
|
|||
"baud": baud,
|
||||
"timestamp": round(datetime.now().timestamp() * 1000),
|
||||
"address": capcode,
|
||||
"function": function,
|
||||
"certainty": certainty,
|
||||
"function": int(function),
|
||||
"type": msgtype,
|
||||
"message": msg
|
||||
}
|
||||
# Output type and message
|
||||
# Output type, message, and certainty
|
||||
if len(msgtype)>0:
|
||||
out["type"] = msgtype
|
||||
if len(msg)>0:
|
||||
out["message"] = msg
|
||||
if certainty is not None:
|
||||
out["certainty"] = int(certainty)
|
||||
|
||||
# Done
|
||||
return out
|
||||
|
|
|
|||
Loading…
Reference in New Issue