Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # working cmd:
- # rtl_fm -f 153980000 -s 22050 -g 40 -p 65 | multimon-ng -a POCSAG1200 -f alpha -t raw -
- '''
- !! This requires a recent build of Multimon-NG as the old builds wont accept a piped input !!
- Change the rtl_fm string to suit your needs.. add -a POCSAG512 , 2400 etc if needed to the Multimon-ng string
- This just prints and writes to a file, you can put it in a threaded class and pass though a queue
- or whatever suits your needs.
- '''
- import time
- import sys
- import subprocess
- import os
- def curtime():
- return time.strftime("%H:%M:%S %Y-%m-%d")
- with open('error.txt','a') as file:
- file.write(('#' * 20) + '\n' + curtime() + '\n')
- multimon_ng = subprocess.Popen("rtl_fm -f 153980000 -s 22050 -g 40 -p 65 | multimon-ng -a POCSAG1200 -f alpha -t raw -",
- #stdin=rtl_fm.stdout,
- stdout=subprocess.PIPE,
- stderr=open('error.txt','a'),
- shell=True)
- try:
- while True:
- line = multimon_ng.stdout.readline()
- multimon_ng.poll()
- if line.__contains__("Alpha:"): # filter out only the alpha
- if line.startswith('POCSAG'):
- address = line[22:28].replace(" ", "").zfill(7)
- message = line.split('Alpha: ')[1].strip().rstrip('<ETB>').strip()
- output=(address+' '+curtime()+' '+ message+'\n')
- print address, curtime(), message
- with open('pocsag.txt','a') as f:
- f.write(output)
- if not "Alpha:" in line:
- with open("missed.txt","a") as missed:
- missed.write(line + '\n')
- except KeyboardInterrupt:
- os.kill(multimon_ng.pid, 9)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement