Open paulvanderheijden90 opened 5 years ago
I made some software to receive some P2000 messages.
I would like to get the stdout. write message also to a telegram bot
i heave made a bot so that's fine. But please let me know.
import time import sys import subprocess import os import re import paho.mqtt.publish as publish from datetime import datetime from dateutil import tz from termcolor import colored MQTT_SERVER = "localhost" MQTT_PATH1 = "P2000_Steenbergen" MQTT_PATH2 = "P2000_ProvincieWeg" capcode_Steenbergen= "001200768" capcodeToFind_List= ["001200768","001220499","001420999"] ProvincieToFind_List= ["N257","N262","N268","N285","N286","N289","N389","N640","N656","N659","N638","N394","N639","N260","N282","N631","N629","N632","N261","N267","N283","N322"] def curtime(): return time.strftime("%H:%M %m-%d") with open('error.txt','a') as file: file.write(('#' * 20) + '\n' + curtime() + '\n') sys.stdout.write("P2000 Monitor gestart") sys.stdout.flush() multimon_ng = subprocess.Popen("rtl_fm -f 169.65M -M fm -s 22050 | multimon-ng -a FLEX -t raw -", stdout=subprocess.PIPE, stderr=open('error.txt','a'), shell=True) try: while True: line=multimon_ng.stdout.readline() multimon_ng.poll() time.sleep(.500) if line.__contains__("ALN"): if line.startswith('FLEX'): flex = line[0:5] timestamp = line[6:25] melding = line[59:] groupid = line[35:41] capcode = line[45:54] if any(c in melding for c in ProvincieToFind_List): publish.single(MQTT_PATH2, melding, hostname=MQTT_SERVER) if capcode_Steenbergen in (str(capcode)): sys.stdout.write(curtime() + melding) sys.stdout.flush() publish.single(MQTT_PATH1, melding, hostname=MQTT_SERVER) except KeyboardInterrupt: os.kill(multimon_ng.pid, 9)
I made some software to receive some P2000 messages.
I would like to get the stdout. write message also to a telegram bot
i heave made a bot so that's fine. But please let me know.