diff options
-rwxr-xr-x | cir_measure.py | 21 | ||||
-rwxr-xr-x | correlate_with_ref.py | 5 | ||||
-rw-r--r-- | views/index.tpl | 4 |
3 files changed, 21 insertions, 9 deletions
diff --git a/cir_measure.py b/cir_measure.py index 03d742c..5ec3f12 100755 --- a/cir_measure.py +++ b/cir_measure.py @@ -15,6 +15,7 @@ import sys from bottle import route, run, template, static_file, request import subprocess import time +import datetime import multiprocessing as mp import correlate_with_ref import shlex @@ -35,9 +36,10 @@ class RTLSDR_CIR_Runner(mp.Process): self.events = mp.Queue() - self.freq = options.freq - self.rate = options.rate - self.samps = options.samps + self.freq = float(options.freq) + self.rate = int(options.rate) + self.samps = int(options.samps) + self.gain = float(options.gain) self.iq_file = iq_file self.fig_file = fig_file @@ -62,7 +64,7 @@ class RTLSDR_CIR_Runner(mp.Process): def do_one_cir_run(self): # Build the rtl_sdr command line from the settings in config - rtl_sdr_cmdline = shlex.split("rtl_sdr -f {} -s {} -g 20 -S -".format(self.freq, self.rate)) + rtl_sdr_cmdline = shlex.split("rtl_sdr -f {} -s {} -g {} -S -".format(self.freq, self.rate, self.gain)) dd_cmdline = shlex.split("dd of={} bs=2 count={}".format(self.iq_file, self.samps)) # To avoid calling the shell, we do the pipe between rtlsdr and dd using Popen @@ -79,12 +81,18 @@ class RTLSDR_CIR_Runner(mp.Process): # The RTLSDR outputs u8 format print("Starting correlation") cir_corr = correlate_with_ref.CIR_Correlate(self.iq_file, "u8") - cir_corr.plot(self.fig_file) + + title = "Correlation on {}kHz done at {}".format( + int(self.freq / 1000), + datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S")) + cir_corr.plot(self.fig_file, title) @route('/') def index(): return template('index', - rtl_sdr_cmdline = "rtl_sdr", + freq = cli_args.freq, + rate = cli_args.rate, + gain = cli_args.gain, fig_file = FIG_FILE) @route('/static/<filename:path>') @@ -104,6 +112,7 @@ if __name__ == '__main__': default=10*196608, help='Number of samples to analyse in one run, one transmission frame at 2048000 samples per second is 196608 samples', required=False) + parser.add_argument('--gain', default=20, help='Gain setting for rtl_sdr', required=False) parser.add_argument('--rate', default='2048000', help='Samplerate for RTLSDR receiver (2048000)', required=False) diff --git a/correlate_with_ref.py b/correlate_with_ref.py index 31e9710..ae783a6 100755 --- a/correlate_with_ref.py +++ b/correlate_with_ref.py @@ -108,7 +108,7 @@ class CIR_Correlate: return cir / channel_power - def plot(self, plot_file): + def plot(self, plot_file, title): num_correlations = int(len(self.channel_out) / T_TF) self.null_symbol_ixs = [] @@ -118,6 +118,7 @@ class CIR_Correlate: for i in range(num_correlations) ]) fig = pp.figure() + fig.suptitle(title) ax1 = fig.add_subplot(211) ax1.plot(cirs.sum(axis=0)) ax2 = fig.add_subplot(212) @@ -150,7 +151,7 @@ if __name__ == "__main__": cir_corr = CIR_Correlate(file_in, file_format) - cir_corr.plot(file_figure) + cir_corr.plot(file_figure, "Correlation") print("Null symbols at:") print(" " + " ".join("{}".format(t_null) diff --git a/views/index.tpl b/views/index.tpl index db20f49..c620fa8 100644 --- a/views/index.tpl +++ b/views/index.tpl @@ -15,7 +15,9 @@ <div id="general"> <p>General Options</p> <ul> - <li>rtl_sdr command line: {{rtl_sdr_cmdline}}</li> + <li>frequency: {{freq}}</li> + <li>gain: {{gain}}</li> + <li>rate: {{rate}}</li> </ul> </div> |