I am trying to run the code rtl_fm -f 162.475M -M fm -s 22050 -E dc -p 0 - | multimon-ng -t raw -a EAS
in Python, but I can't get the data from RTL_FM to pass to Multimon-ng. Am I doing something wrong?
Here is the code snippet:
def main():
args = parse_arguments()
logging.basicConfig(level=args.loglevel, format='%(levelname)s: %(message)s')
if args.msg:
same_decode(args.msg, args.lang, same_watch=args.same, event_watch=args.event, text=args.text, call=args.call,
command=args.command, jsonfile=args.json)
elif args.source:
if args.source == 'rtl':
sys.stdout.write('RTL\n')
sys.stdout.write("rtl_fm -f " + str(args.frequency[0]) + "M -M fm -s 22050 -E dc -p " + str(args.ppm[0]) + " - | multimon-ng -t raw -a EAS\n")
try:
# source_process = subprocess.call("rtl_fm -f " + str(args.frequency[0]) + "M -M fm -s 22050 -E dc -p " + str(args.ppm[0]) + " -| multimon-ng -t raw -a EAS", stdout=subprocess.PIPE, shell=True, creationflags=subprocess.CREATE_NEW_CONSOLE)
rtl_fm_cmd = ['rtl_fm', '-f', '162.475M', '-M', 'fm', '-s', '22050', '-E', 'dc', '-p', '0', '-']
multimon_ng_cmd = ['multimon-ng', '-t', 'raw', '-a', 'EAS']
time.sleep(1)
rtl_fm_process = subprocess.Popen(rtl_fm_cmd)
time.sleep(1)
multimon_ng_process = subprocess.Popen(multimon_ng_cmd, stdin=rtl_fm_process.stdout,
stdout=subprocess.PIPE)
source_process = multimon_ng_process
except Exception as detail:
logging.error(detail)
return
elif args.source == 'soundcard':
sys.stdout.write('Soundcard')
try:
source_process = subprocess.Popen('multimon-ng -a EAS', stdout=subprocess.PIPE)
except Exception as detail:
logging.error(detail)
return
else:
sys.stdout.write('ERROR')
time.sleep(10)
exit()
while True:
line = source_process.stdout.readline()
# sys.stdout.write('rtl_fm -f ' + args.frequency + 'M -M fm -s 22050 -E dc -p ' + args.ppm + ' -| multimon-ng -t raw -a EAS')
if line:
line1 = line.decode('ascii')
logging.debug(line1)
same_decode(line1, args.lang, same_watch=args.same, event_watch=args.event, text=args.text,
call=args.call, command=args.command, jsonfile=args.json)
else:
while True:
for line in sys.stdin:
logging.debug(line)
same_decode(line, args.lang, same_watch=args.same, event_watch=args.event, text=args.text,
call=args.call, command=args.command, jsonfile=args.json)
Soundcard works fine, so it's not an issue with Multimon-ng, and I ran the command in CMD and it works fine as well. It seems my Python code is the main culprit here.