BOSWatch 3
Python Script to receive and decode German BOS Information with rtl_fm and multimon-NG
 
Loading...
Searching...
No Matches
boswatch.inputSource.sdrInput.SdrInput Class Reference

Class for the sdr input source. More...

Protected Member Functions

def _runThread (self, dataQueue, sdrConfig, decoderConfig)
 Thread routine of the input source has to be inherit.
 
def _runThread (self, dataQueue, sdrConfig, decoderConfig)
 Thread routine of the input source has to be inherit.
 

Additional Inherited Members

- Public Member Functions inherited from boswatch.inputSource.inputBase.InputBase
def __init__ (self, inputQueue, inputConfig, decoderConfig)
 Build a new InputSource class.
 
def start (self)
 Start the input source thread.
 
def shutdown (self)
 Stop the input source thread.
 
def addToQueue (self, data)
 Decode and add alarm data to the queue for further processing during boswatch client.
 
def getDecoderInstance (self, decoderConfig, StdIn)
 
- Protected Attributes inherited from boswatch.inputSource.inputBase.InputBase
 _inputThread
 
 _isRunning
 
 _inputQueue
 
 _inputConfig
 
 _decoderConfig
 

Detailed Description

Class for the sdr input source.

Member Function Documentation

◆ _runThread()

def boswatch.inputSource.sdrInput.SdrInput._runThread (   self,
  dataQueue,
  sdrConfig,
  decoderConfig 
)
protected

Thread routine of the input source has to be inherit.

Reimplemented from boswatch.inputSource.inputBase.InputBase.

29 def _runThread(self, dataQueue, sdrConfig, decoderConfig):
30 sdrProc = None
31 mmProc = None
32 try:
33 sdrProc = ProcessManager(str(sdrConfig.get("rtlPath", default="rtl_fm")))
34 sdrProc.addArgument("-d " + str(sdrConfig.get("device", default="0"))) # device id
35 sdrProc.addArgument("-f " + str(sdrConfig.get("frequency"))) # frequencies
36 sdrProc.addArgument("-p " + str(sdrConfig.get("error", default="0"))) # frequency error in ppm
37 sdrProc.addArgument("-l " + str(sdrConfig.get("squelch", default="1"))) # squelch
38 sdrProc.addArgument("-g " + str(sdrConfig.get("gain", default="100"))) # gain
39 if (sdrConfig.get("fir_size", default=None) is not None):
40 sdrProc.addArgument("-F " + str(sdrConfig.get("fir_size"))) # fir_size
41 sdrProc.addArgument("-M fm") # set mode to fm
42 sdrProc.addArgument("-E DC") # set DC filter
43 sdrProc.addArgument("-s 22050") # bit rate of audio stream
44 sdrProc.setStderr(open(paths.LOG_PATH + "rtl_fm.log", "a"))
45 sdrProc.start()
46
47 mmProc = self.getDecoderInstance(decoderConfig, sdrProc.stdout)
48 mmProc.start()
49
50 logging.info("start decoding")
51 while self._isRunning:
52 if not sdrProc.isRunning:
53 logging.warning("rtl_fm was down - trying to restart in 10 seconds")
54 time.sleep(10)
55
56 sdrProc.start()
57 if sdrProc.isRunning:
58 logging.info("rtl_fm is back up - restarting multimon...")
59 mmProc.setStdin(sdrProc.stdout)
60 mmProc.start()
61 elif not mmProc.isRunning:
62 logging.warning("multimon was down - try to restart")
63 mmProc.start()
64 elif sdrProc.isRunning and mmProc.isRunning:
65 line = mmProc.readline()
66 if line:
67 self.addToQueue(line)
68 except:
69 logging.exception("error in sdr input routine")
70 finally:
71 mmProc.stop()
72 sdrProc.stop()