mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2025-12-06 07:12:04 +01:00
edit processManager demo
This commit is contained in:
parent
2da9bfbe0c
commit
c4b9f54df6
|
|
@ -13,26 +13,32 @@
|
||||||
from boswatch.processManager import ProcessManager
|
from boswatch.processManager import ProcessManager
|
||||||
from boswatch.decoder.decoder import Decoder
|
from boswatch.decoder.decoder import Decoder
|
||||||
import logging.config
|
import logging.config
|
||||||
|
import subprocess
|
||||||
logging.config.fileConfig("config/logger_client.ini")
|
logging.config.fileConfig("config/logger_client.ini")
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
sdrProc = ProcessManager("/usr/bin/rtl_fm")
|
sdrProc = ProcessManager("/usr/bin/rtl_fm")
|
||||||
sdrProc.addArgument("-f 85M")
|
sdrProc.addArgument("-f 85M")
|
||||||
sdrProc.addArgument("-m fm")
|
# sdrProc.addArgument("-M fm")
|
||||||
sdrProc.start(True)
|
if not sdrProc.start():
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
sdrProc.skipLines(20)
|
||||||
|
|
||||||
mmProc = ProcessManager("/opt/multimon/multimon-ng", textMode=True)
|
mmProc = ProcessManager("/opt/multimon/multimon-ng", textMode=True)
|
||||||
# mmProc.addArgument("-i")
|
# mmProc.addArgument("-i")
|
||||||
# mmProc.addArgument("-a POCSAG1200 -a FMSFSK -a ZVEI1")
|
mmProc.addArgument("-a FMSFSK -a POCSAG512 -a POCSAG1200 -a POCSAG2400")
|
||||||
mmProc.addArgument("-f alpha")
|
# mmProc.addArgument("-f alpha")
|
||||||
mmProc.addArgument("-t raw /dev/stdin -")
|
mmProc.addArgument("-t raw -")
|
||||||
mmProc.setStdin(sdrProc.stdout)
|
mmProc.setStdin(sdrProc.stdout)
|
||||||
mmProc.start(True)
|
mmProc.start()
|
||||||
mmProc.skipLines(5)
|
# mmProc.skipLines(5)
|
||||||
while 1:
|
while 1:
|
||||||
if not mmProc.isRunning:
|
if not mmProc.isRunning:
|
||||||
logging.warning("multimon was down - try to restart")
|
logging.warning("multimon was down - try to restart")
|
||||||
mmProc.start()
|
mmProc.start()
|
||||||
mmProc.skipLines(5)
|
# mmProc.skipLines(5)
|
||||||
line = mmProc.readline()
|
line = mmProc.readline()
|
||||||
if line:
|
if line:
|
||||||
print(line)
|
print(line)
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,9 @@ class ProcessManager:
|
||||||
self._processHandle = None
|
self._processHandle = None
|
||||||
self._textMode = textMode
|
self._textMode = textMode
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
self.stop()
|
||||||
|
|
||||||
def addArgument(self, arg):
|
def addArgument(self, arg):
|
||||||
"""!add a new argument
|
"""!add a new argument
|
||||||
|
|
||||||
|
|
@ -44,7 +47,7 @@ class ProcessManager:
|
||||||
"""!clear all arguments"""
|
"""!clear all arguments"""
|
||||||
self._args = self._args[0:1] # kept first element (process name)
|
self._args = self._args[0:1] # kept first element (process name)
|
||||||
|
|
||||||
def start(self, startAsShell=False):
|
def start(self):
|
||||||
"""!start the new process
|
"""!start the new process
|
||||||
|
|
||||||
@return: True or False"""
|
@return: True or False"""
|
||||||
|
|
@ -55,7 +58,7 @@ class ProcessManager:
|
||||||
stdout=self._stdout,
|
stdout=self._stdout,
|
||||||
stderr=self._stderr,
|
stderr=self._stderr,
|
||||||
universal_newlines=self._textMode,
|
universal_newlines=self._textMode,
|
||||||
shell=startAsShell)
|
shell=False)
|
||||||
if not self.isRunning:
|
if not self.isRunning:
|
||||||
logging.error("cannot start")
|
logging.error("cannot start")
|
||||||
return False
|
return False
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue