71 lines
2.0 KiB
Python
71 lines
2.0 KiB
Python
|
import subprocess,time, numpy as np, pandas as pd
|
||
|
|
||
|
from oscilloscope import *
|
||
|
|
||
|
def HackRF_Sweep():
|
||
|
print("deez")
|
||
|
def HackRF_CW(freq, device):
|
||
|
|
||
|
#FILE = "~/.grc_gnuradio/deez"
|
||
|
|
||
|
#process = str(subprocess.run(["hackrf_transfer", "-f", freq, "-t", FILE, "-d", DEV[device], "-H", "1", "-x", "20"], capture_output=True))
|
||
|
#process = str(subprocess.run(["hackrf_transfer", "-f", freq, "-c", "127", "-d", DEV[device], "-H", "1", "-x", "20"]))
|
||
|
p = subprocess.Popen(["hackrf_transfer", "-f", freq, "-c", "127", "-d", device, "-H", "1", "-x", "20"],stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
|
||
|
return p
|
||
|
|
||
|
|
||
|
def run_phase_meas(scope, dev, freq, avg):
|
||
|
# scope is the visa object of the oscilloscope
|
||
|
# dev[] is a list of the HackRFs (dev IDs) to test
|
||
|
# freq is the frequency to test in Hz
|
||
|
# avg is the number of averages in the phase measurement
|
||
|
|
||
|
# fill results up with placeholder values when channel not measured
|
||
|
phase_12 = ["x"] * avg
|
||
|
phase_13 = ["x"] * avg
|
||
|
phase_14 = ["x"] * avg
|
||
|
|
||
|
# set-up each HackRF to CW at a certain freq
|
||
|
hack = []
|
||
|
for device in range(len(dev)):
|
||
|
hack.append(HackRF_CW(str(freq), dev[device]))
|
||
|
|
||
|
# wait 2 seconds
|
||
|
time.sleep(2)
|
||
|
|
||
|
# make scope take the measurement
|
||
|
print("Measuring channel 2")
|
||
|
phase_12 = scope_avg_phase(scope, avg, 2)
|
||
|
print("Measuring channel 3")
|
||
|
phase_13 = scope_avg_phase(scope, avg, 3)
|
||
|
print("Measuring channel 4")
|
||
|
phase_14 = scope_avg_phase(scope, avg, 4)
|
||
|
|
||
|
# calculate averages
|
||
|
average = [0] * 3
|
||
|
average[0] = sum([float(val) for val in phase_12])/avg
|
||
|
average[1] = sum([float(val) for val in phase_13])/avg
|
||
|
average[2] = sum([float(val) for val in phase_14])/avg
|
||
|
|
||
|
|
||
|
# fill out results table
|
||
|
d = {
|
||
|
"Phase(1-2)": phase_12,
|
||
|
"Phase(1-3)": phase_13,
|
||
|
"Phase(1-4)": phase_14
|
||
|
}
|
||
|
|
||
|
i = [y for y in range(1, avg + 1)]
|
||
|
results = pd.DataFrame(data = d, index = i)
|
||
|
|
||
|
title = str(freq/1000000) + "MHz"
|
||
|
index = results.index
|
||
|
index.name = title
|
||
|
|
||
|
# terminate radios
|
||
|
for each in hack:
|
||
|
each.terminate()
|
||
|
|
||
|
# wait another 2 seconds
|
||
|
time.sleep(2)
|
||
|
return results, average # return results
|