diff --git a/swagger/sdrangel/examples/add_channel.py b/swagger/sdrangel/examples/add_channel.py
index 4dee49d14..4de12f9cc 100644
--- a/swagger/sdrangel/examples/add_channel.py
+++ b/swagger/sdrangel/examples/add_channel.py
@@ -5,22 +5,23 @@ from optparse import OptionParser
base_url = "http://127.0.0.1:8091/sdrangel"
+
# ======================================================================
def getInputOptions():
parser = OptionParser(usage="usage: %%prog [-t]\n")
- parser.add_option("-a", "--address", dest="address", help="address and port", metavar="ADDRESS", type="string")
- parser.add_option("-d", "--device-index", dest="device_index", help="device set index", metavar="INDEX", type="int")
+ parser.add_option("-a", "--address", dest="address", help="address and port", metavar="ADDRESS", type="string")
+ parser.add_option("-d", "--device-index", dest="device_index", help="device set index", metavar="INDEX", type="int")
parser.add_option("-c", "--channel-id", dest="channel_id", help="channel ID of channel to add", metavar="ID", type="string")
(options, args) = parser.parse_args()
-
+
if options.address is None:
options.address = "127.0.0.1:8888"
-
+
if options.device_index is None or options.device_index < 0:
options.device_index = 0
-
+
if options.channel_id is None:
print("Please specify channel Id")
exit(1)
@@ -42,8 +43,8 @@ def main():
else:
print("Error adding channel. HTTP: %d" % r.status_code)
print json.dumps(r.json(), indent=4, sort_keys=True)
-
- except Exception, msg:
+
+ except Exception as ex:
tb = traceback.format_exc()
print >> sys.stderr, tb
diff --git a/swagger/sdrangel/examples/devicesets_config.py b/swagger/sdrangel/examples/devicesets_config.py
index f2bb4965d..6d797de87 100755
--- a/swagger/sdrangel/examples/devicesets_config.py
+++ b/swagger/sdrangel/examples/devicesets_config.py
@@ -73,7 +73,7 @@ def main():
print("All done!")
- except Exception, msg:
+ except Exception as ex:
tb = traceback.format_exc()
print >> sys.stderr, tb
diff --git a/swagger/sdrangel/examples/limesdr_tx.py b/swagger/sdrangel/examples/limesdr_tx.py
index 62fd8951b..fa20ab6d1 100644
--- a/swagger/sdrangel/examples/limesdr_tx.py
+++ b/swagger/sdrangel/examples/limesdr_tx.py
@@ -13,23 +13,25 @@ requests_methods = {
"DELETE": requests.delete
}
+
# ======================================================================
def getInputOptions():
parser = OptionParser(usage="usage: %%prog [-t]\n")
- parser.add_option("-a", "--address", dest="address", help="address and port", metavar="ADDRESS", type="string")
- parser.add_option("-d", "--device-index", dest="device_index", help="device set index", metavar="INDEX", type="int")
+ parser.add_option("-a", "--address", dest="address", help="address and port", metavar="ADDRESS", type="string")
+ parser.add_option("-d", "--device-index", dest="device_index", help="device set index", metavar="INDEX", type="int")
(options, args) = parser.parse_args()
-
+
if options.address == None:
options.address = "127.0.0.1:8091"
-
+
if options.device_index == None:
options.device_index = 1
-
+
return options
+
# ======================================================================
def printResponse(response):
content_type = response.headers.get("Content-Type", None)
@@ -39,38 +41,40 @@ def printResponse(response):
elif "text/plain" in content_type:
print(response.text)
+
# ======================================================================
def callAPI(url, method, params, json, text):
request_method = requests_methods.get(method, None)
if request_method is not None:
- r = request_method(url=base_url+url, params=params, json=json)
+ r = request_method(url=base_url + url, params=params, json=json)
if r.status_code / 100 == 2:
print(text + " succeeded")
printResponse(r)
- return r.json() # all 200 yield application/json response
+ return r.json() # all 200 yield application/json response
else:
print(text + " failed")
printResponse(r)
return None
+
# ======================================================================
def main():
try:
options = getInputOptions()
-
+
global base_url
base_url = "http://%s/sdrangel" % options.address
-
+
r = callAPI("/deviceset", "POST", {"tx": 1}, None, "Add Tx device set")
if r is None:
exit(-1)
-
+
deviceset_url = "/deviceset/%d" % options.device_index
-
+
r = callAPI(deviceset_url + "/device", "PUT", None, {"hwType": "LimeSDR", "tx": 1}, "setup LimeSDR on Tx device set")
if r is None:
exit(-1)
-
+
settings = callAPI(deviceset_url + "/device/settings", "GET", None, None, "Get LimeSDR Tx settings")
if settings is None:
exit(-1)
@@ -81,35 +85,35 @@ def main():
settings["limeSdrOutputSettings"]["ncoEnable"] = 1
settings["limeSdrOutputSettings"]["ncoFrequency"] = -500000
settings["limeSdrOutputSettings"]["lpfFIRBW"] = 100000
- settings["limeSdrOutputSettings"]["lpfFIREnable"] = 1
-
+ settings["limeSdrOutputSettings"]["lpfFIREnable"] = 1
+
r = callAPI(deviceset_url + "/device/settings", "PATCH", None, settings, "Patch LimeSDR Tx settings")
if r is None:
exit(-1)
-
+
r = callAPI(deviceset_url + "/channel", "POST", None, {"channelType": "NFMMod", "tx": 1}, "Create NFM mod")
if r is None:
exit(-1)
-
+
settings = callAPI(deviceset_url + "/channel/0/settings", "GET", None, None, "Get NFM mod settings")
if settings is None:
exit(-1)
-
+
settings["NFMModSettings"]["cwKeyer"]["text"] = "VVV DE F4EXB "
settings["NFMModSettings"]["cwKeyer"]["loop"] = 1
- settings["NFMModSettings"]["cwKeyer"]["mode"] = 1 # text
- settings["NFMModSettings"]["modAFInput"] = 4 # CW text
+ settings["NFMModSettings"]["cwKeyer"]["mode"] = 1 # text
+ settings["NFMModSettings"]["modAFInput"] = 4 # CW text
settings["NFMModSettings"]["toneFrequency"] = 600
-
+
r = callAPI(deviceset_url + "/channel/0/settings", "PATCH", None, settings, "Change NFM mod")
if r is None:
exit(-1)
-
+
r = callAPI(deviceset_url + "/device/run", "POST", None, None, "Start device on deviceset R1")
if r is None:
exit(-1)
-
- except Exception, msg:
+
+ except Exception as ex:
tb = traceback.format_exc()
print >> sys.stderr, tb
diff --git a/swagger/sdrangel/examples/nfm_test.py b/swagger/sdrangel/examples/nfm_test.py
index febbd1a8e..09ea421d2 100644
--- a/swagger/sdrangel/examples/nfm_test.py
+++ b/swagger/sdrangel/examples/nfm_test.py
@@ -13,19 +13,21 @@ requests_methods = {
"DELETE": requests.delete
}
+
# ======================================================================
def getInputOptions():
parser = OptionParser(usage="usage: %%prog [-t]\n")
- parser.add_option("-a", "--address", dest="address", help="address and port", metavar="ADDRESS", type="string")
+ parser.add_option("-a", "--address", dest="address", help="address and port", metavar="ADDRESS", type="string")
(options, args) = parser.parse_args()
-
+
if (options.address == None):
options.address = "127.0.0.1:8091"
-
+
return options
+
# ======================================================================
def printResponse(response):
content_type = response.headers.get("Content-Type", None)
@@ -35,58 +37,60 @@ def printResponse(response):
elif "text/plain" in content_type:
print(response.text)
+
# ======================================================================
def callAPI(url, method, params, json, text):
request_method = requests_methods.get(method, None)
if request_method is not None:
- r = request_method(url=base_url+url, params=params, json=json)
+ r = request_method(url=base_url + url, params=params, json=json)
if r.status_code / 100 == 2:
print(text + " succeeded")
printResponse(r)
- return r.json() # all 200 yield application/json response
+ return r.json() # all 200 yield application/json response
else:
print(text + " failed")
printResponse(r)
return None
+
# ======================================================================
def main():
try:
options = getInputOptions()
-
+
global base_url
base_url = "http://%s/sdrangel" % options.address
-
+
settings = callAPI("/deviceset/0/channel", "POST", None, {"channelType": "NFMDemod", "tx": 0}, "Create NFM demod")
if settings is None:
exit(-1)
settings["NFMDemodSettings"]["inputFrequencyOffset"] = 12500
settings["NFMDemodSettings"]["afBandwidth"] = 5000
-
+
r = callAPI("/deviceset/0/channel/0/settings", "PATCH", None, settings, "Change NFM demod")
if r is None:
exit(-1)
-
+
r = callAPI("/deviceset", "POST", {"tx": 1}, None, "Add Tx device set")
if r is None:
exit(-1)
-
+
settings = callAPI("/deviceset/1/channel", "POST", None, {"channelType": "NFMMod", "tx": 1}, "Create NFM mod")
if settings is None:
exit(-1)
-
+
settings["NFMModSettings"]["inputFrequencyOffset"] = 12500
settings["NFMModSettings"]["cwKeyer"]["text"] = "VVV DE F4EXB "
settings["NFMModSettings"]["cwKeyer"]["loop"] = 1
- settings["NFMModSettings"]["cwKeyer"]["mode"] = 1 # text
- settings["NFMModSettings"]["modAFInput"] = 4 # CW text
-
+ settings["NFMModSettings"]["cwKeyer"]["mode"] = 1 # text
+ settings["NFMModSettings"]["modAFInput"] = 4 # CW text
+
r = callAPI("/deviceset/1/channel/0/settings", "PATCH", None, settings, "Change NFM mod")
if r is None:
exit(-1)
-
- except Exception, msg:
+
+ except Exception as ex:
tb = traceback.format_exc()
print >> sys.stderr, tb
diff --git a/swagger/sdrangel/examples/ptt.py b/swagger/sdrangel/examples/ptt.py
index 5c1d245e0..5960f531f 100755
--- a/swagger/sdrangel/examples/ptt.py
+++ b/swagger/sdrangel/examples/ptt.py
@@ -16,27 +16,29 @@ from optparse import OptionParser
base_url = "http://127.0.0.1:8091/sdrangel"
+
# ======================================================================
def getInputOptions():
parser = OptionParser(usage="usage: %prog [-a address:port] [-d index][-t]\n")
- parser.add_option("-a", "--address", dest="address", help="address and port", metavar="ADDRESS", type="string")
+ parser.add_option("-a", "--address", dest="address", help="address and port", metavar="ADDRESS", type="string")
parser.add_option("-t", "--transmit", dest="transmit", help="transmit", metavar="TRANSMIT", action="store_true", default=False)
parser.add_option("-d", "--deviceset-index", dest="deviceset_index", help="index of currently active device set (Rx or Tx)", metavar="INDEX", type="int")
(options, args) = parser.parse_args()
-
+
if options.address == None:
options.address = "127.0.0.1:8091"
-
+
if options.deviceset_index == None:
options.deviceset_index = 0
-
+
return options
+
# ======================================================================
def startDevice(deviceIndex):
- dev_run_url = base_url+("/deviceset/%d/device/run" % deviceIndex)
+ dev_run_url = base_url + ("/deviceset/%d/device/run" % deviceIndex)
r = requests.get(url=dev_run_url)
if r.status_code / 100 == 2:
rj = r.json()
@@ -55,9 +57,10 @@ def startDevice(deviceIndex):
else:
print("Error getting device %d running state" % deviceIndex)
+
# ======================================================================
def stopDevice(deviceIndex):
- dev_run_url = base_url+("/deviceset/%d/device/run" % deviceIndex)
+ dev_run_url = base_url + ("/deviceset/%d/device/run" % deviceIndex)
r = requests.get(url=dev_run_url)
if r.status_code / 100 == 2:
rj = r.json()
@@ -75,10 +78,11 @@ def stopDevice(deviceIndex):
print("Cannot get device %d running state" % deviceIndex)
else:
print("Error getting device %d running state" % deviceIndex)
-
+
+
# ======================================================================
def setFocus(deviceIndex):
- dev_focus_url = base_url+("/deviceset/%d/focus" % deviceIndex)
+ dev_focus_url = base_url + ("/deviceset/%d/focus" % deviceIndex)
r = requests.patch(url=dev_focus_url)
if r.status_code / 100 == 2:
print("Focus set on device set %d" % deviceIndex)
@@ -86,43 +90,44 @@ def setFocus(deviceIndex):
print("Set focus on device set is not supported in a server instance")
else:
print("Error setting focus on device set %d" % deviceIndex)
-
+
+
# ======================================================================
def main():
try:
options = getInputOptions()
global base_url
base_url = "http://%s/sdrangel" % options.address
- r = requests.get(url=base_url+"/devicesets")
+ r = requests.get(url=base_url + "/devicesets")
if r.status_code / 100 == 2:
rj = r.json()
deviceSets = rj.get("deviceSets", None)
if deviceSets is not None:
if len(deviceSets) > 1:
if options.transmit:
- if deviceSets[options.deviceset_index]["samplingDevice"]["tx"] == 0 and deviceSets[options.deviceset_index+1]["samplingDevice"]["tx"] == 1:
+ if deviceSets[options.deviceset_index]["samplingDevice"]["tx"] == 0 and deviceSets[options.deviceset_index + 1]["samplingDevice"]["tx"] == 1:
stopDevice(options.deviceset_index)
time.sleep(1)
- startDevice(options.deviceset_index+1)
- setFocus(options.deviceset_index+1)
+ startDevice(options.deviceset_index + 1)
+ setFocus(options.deviceset_index + 1)
else:
- print("Incorrect configuration expecting Rx%d and Tx%d" % (options.deviceset_index, options.deviceset_index+1))
+ print("Incorrect configuration expecting Rx%d and Tx%d" % (options.deviceset_index, options.deviceset_index + 1))
else:
- if deviceSets[options.deviceset_index-1]["samplingDevice"]["tx"] == 0 and deviceSets[options.deviceset_index]["samplingDevice"]["tx"] == 1:
+ if deviceSets[options.deviceset_index - 1]["samplingDevice"]["tx"] == 0 and deviceSets[options.deviceset_index]["samplingDevice"]["tx"] == 1:
stopDevice(options.deviceset_index)
time.sleep(1)
- startDevice(options.deviceset_index-1)
- setFocus(options.deviceset_index-1)
+ startDevice(options.deviceset_index - 1)
+ setFocus(options.deviceset_index - 1)
else:
- print("Incorrect configuration expecting Rx%d and Tx%d" % (options.deviceset_index-1, options.deviceset_index))
+ print("Incorrect configuration expecting Rx%d and Tx%d" % (options.deviceset_index - 1, options.deviceset_index))
else:
print("Need at least a Rx and a Tx device set")
else:
- print("Cannot get device sets configuration")
+ print("Cannot get device sets configuration")
else:
print("Error getting device sets configuration")
-
- except Exception, msg:
+
+ except Exception as ex:
tb = traceback.format_exc()
print >> sys.stderr, tb
diff --git a/swagger/sdrangel/examples/rtlsdr_settings.py b/swagger/sdrangel/examples/rtlsdr_settings.py
index b415f9153..069c8a5a9 100644
--- a/swagger/sdrangel/examples/rtlsdr_settings.py
+++ b/swagger/sdrangel/examples/rtlsdr_settings.py
@@ -11,29 +11,32 @@ requests_methods = {
"DELETE": requests.delete
}
+
def getHwType():
- r = requests.get(url=base_url+"/deviceset/0")
- if r.status_code / 100 == 2:
+ r = requests.get(url=base_url + "/deviceset/0")
+ if r.status_code / 100 == 2:
rj = r.json()
devj = rj.get('samplingDevice', None)
if devj is not None:
- return devj.get('hwType' ,None)
+ return devj.get('hwType' , None)
else:
return None
else:
return None
-
+
+
def selectRtlSdr():
- r = requests.put(url=base_url+"/deviceset/0/device", json={"hwType": "RTLSDR"})
- if r.status_code / 100 == 2:
+ r = requests.put(url=base_url + "/deviceset/0/device", json={"hwType": "RTLSDR"})
+ if r.status_code / 100 == 2:
print json.dumps(r.json(), indent=4, sort_keys=True)
return True
else:
return False
-
+
+
def getRtlSdrSettings():
- r = requests.get(url=base_url+"/deviceset/0/device/settings")
- if r.status_code / 100 == 2:
+ r = requests.get(url=base_url + "/deviceset/0/device/settings")
+ if r.status_code / 100 == 2:
rj = r.json()
hwType = rj.get('deviceHwType', None)
if hwType is not None and hwType == "RTLSDR":
@@ -43,26 +46,28 @@ def getRtlSdrSettings():
return None
else:
return None
-
+
+
def patchRtlSdrSettings(settings):
new_settings = {"deviceHwType": "RTLSDR", "tx": 0, "rtlSdrSettings": settings}
- r = requests.patch(url=base_url+"/deviceset/0/device/settings", json=new_settings)
- if r.status_code / 100 == 2:
+ r = requests.patch(url=base_url + "/deviceset/0/device/settings", json=new_settings)
+ if r.status_code / 100 == 2:
print json.dumps(r.json(), indent=4, sort_keys=True)
else:
print "Error HTTP:", r.status_code
-
+
+
def deviceRun(run):
if run:
- r = requests.post(url=base_url+"/deviceset/0/device/run")
+ r = requests.post(url=base_url + "/deviceset/0/device/run")
else:
- r = requests.delete(url=base_url+"/deviceset/0/device/run")
- if r.status_code / 100 == 2:
+ r = requests.delete(url=base_url + "/deviceset/0/device/run")
+ if r.status_code / 100 == 2:
print json.dumps(r.json(), indent=4, sort_keys=True)
else:
print "Error HTTP:", r.status_code
-
-
+
+
def main():
hwType = getHwType()
if hwType is not None:
@@ -79,8 +84,7 @@ def main():
settings["gain"] = 445
settings["centerFrequency"] = 433900000
patchRtlSdrSettings(settings)
-
+
if __name__ == "__main__":
main()
-
\ No newline at end of file
diff --git a/swagger/sdrangel/examples/rx_test.py b/swagger/sdrangel/examples/rx_test.py
index 5152f9184..ec6957c0f 100755
--- a/swagger/sdrangel/examples/rx_test.py
+++ b/swagger/sdrangel/examples/rx_test.py
@@ -358,10 +358,7 @@ def main():
time.sleep(1)
setup_audio(options)
-# if options.channel_id == "BFMDemod":
-# channelsReport(deviceset_url)
-
- except Exception, msg:
+ except Exception as ex:
tb = traceback.format_exc()
print >> sys.stderr, tb
diff --git a/swagger/sdrangel/examples/rx_tx_test.py b/swagger/sdrangel/examples/rx_tx_test.py
index 832be0a23..621a2eb0e 100644
--- a/swagger/sdrangel/examples/rx_tx_test.py
+++ b/swagger/sdrangel/examples/rx_tx_test.py
@@ -13,52 +13,54 @@ requests_methods = {
"DELETE": requests.delete
}
+
# ======================================================================
def getInputOptions():
parser = OptionParser(usage="usage: %%prog [-t]\n")
- parser.add_option("-a", "--address", dest="address", help="address and port", metavar="ADDRESS", type="string")
- parser.add_option("-R", "--device-hwid-rx", dest="device_hwid_rx", help="device hardware id for Rx", metavar="HWID", type="string")
- parser.add_option("-T", "--device-hwid-tx", dest="device_hwid_tx", help="device hardware id for Tx", metavar="HWID", type="string")
- parser.add_option("-F", "--device-freq", dest="device_freq", help="device center frequency (kHz)", metavar="FREQ", type="int")
+ parser.add_option("-a", "--address", dest="address", help="address and port", metavar="ADDRESS", type="string")
+ parser.add_option("-R", "--device-hwid-rx", dest="device_hwid_rx", help="device hardware id for Rx", metavar="HWID", type="string")
+ parser.add_option("-T", "--device-hwid-tx", dest="device_hwid_tx", help="device hardware id for Tx", metavar="HWID", type="string")
+ parser.add_option("-F", "--device-freq", dest="device_freq", help="device center frequency (kHz)", metavar="FREQ", type="int")
parser.add_option("-f", "--channel-freq", dest="channel_freq", help="channel center frequency (Hz)", metavar="FREQ", type="int")
parser.add_option("-U", "--copy-to-udp", dest="udp_copy", help="UDP audio copy to
[:]", metavar="IP:PORT", type="string")
parser.add_option("-s", "--sample-rate-rx", dest="sample_rate_rx", help="device to host (Rx) sample rate (kS/s)", metavar="RATE", type="int")
- parser.add_option("-S", "--sample-rate-tx", dest="sample_rate_tx", help="host to device (Tx) sample rate (kS/s)", metavar="RATE", type="int")
- parser.add_option("-n", "--antenna-path-rx", dest="antenna_path_rx", help="antenna path index (Rx)", metavar="INDEX", type="int")
- parser.add_option("-N", "--antenna-path-tx", dest="antenna_path_tx", help="antenna path index (Tx)", metavar="INDEX", type="int")
+ parser.add_option("-S", "--sample-rate-tx", dest="sample_rate_tx", help="host to device (Tx) sample rate (kS/s)", metavar="RATE", type="int")
+ parser.add_option("-n", "--antenna-path-rx", dest="antenna_path_rx", help="antenna path index (Rx)", metavar="INDEX", type="int")
+ parser.add_option("-N", "--antenna-path-tx", dest="antenna_path_tx", help="antenna path index (Tx)", metavar="INDEX", type="int")
(options, args) = parser.parse_args()
-
+
if options.address == None:
options.address = "127.0.0.1:8091"
-
+
if options.device_hwid_rx == None:
options.device_hwid_rx = "FileSource"
-
+
if options.device_hwid_tx == None:
options.device_hwid_tx = "FileSink"
-
+
if options.device_freq == None:
options.device_freq = 435000
-
+
if options.channel_freq == None:
options.channel_freq = 0
-
+
if options.sample_rate_rx == None:
options.sample_rate_rx = 2600
-
+
if options.sample_rate_tx == None:
options.sample_rate_tx = 2600
-
+
if options.antenna_path_rx == None:
options.antenna_path_rx = 0
-
+
if options.antenna_path_tx == None:
options.antenna_path_tx = 0
-
+
return options
+
# ======================================================================
def printResponse(response):
content_type = response.headers.get("Content-Type", None)
@@ -68,44 +70,46 @@ def printResponse(response):
elif "text/plain" in content_type:
print(response.text)
+
# ======================================================================
def callAPI(url, method, params, json, text):
request_method = requests_methods.get(method, None)
if request_method is not None:
- r = request_method(url=base_url+url, params=params, json=json)
+ r = request_method(url=base_url + url, params=params, json=json)
if r.status_code / 100 == 2:
print(text + " succeeded")
printResponse(r)
- return r.json() # all 200 yield application/json response
+ return r.json() # all 200 yield application/json response
else:
print(text + " failed")
printResponse(r)
return None
+
# ======================================================================
def main():
try:
options = getInputOptions()
-
+
global base_url
base_url = "http://%s/sdrangel" % options.address
-
+
r = callAPI("/devicesets", "GET", None, None, "Get device set configuration")
if r is None:
exit(-1)
-
+
nb_devicesets = r['devicesetcount']
-
- if nb_devicesets == 0: # server starts without device set so add Rx device set
+
+ if nb_devicesets == 0: # server starts without device set so add Rx device set
r1 = callAPI("/deviceset", "POST", {"tx": 0}, None, "Add Rx device set")
if r1 is None:
exit(-1)
-
- ### Rx setup
-
+
+ # ## Rx setup
+
deviceset_index_rx = 0
deviceset_url = "/deviceset/%d" % deviceset_index_rx
-
+
r = callAPI(deviceset_url + "/device", "PUT", None, {"hwType": "%s" % options.device_hwid_rx, "tx": 0}, "setup device on Rx device set")
if r is None:
exit(-1)
@@ -113,13 +117,13 @@ def main():
settings = callAPI(deviceset_url + "/device/settings", "GET", None, None, "Get device settings")
if settings is None:
exit(-1)
-
+
if options.device_hwid_rx == "LimeSDR":
settings["limeSdrInputSettings"]["antennaPath"] = options.antenna_path_rx
- settings["limeSdrInputSettings"]["devSampleRate"] = options.sample_rate_rx*1000
+ settings["limeSdrInputSettings"]["devSampleRate"] = options.sample_rate_rx * 1000
settings["limeSdrInputSettings"]["log2HardDecim"] = 4
settings["limeSdrInputSettings"]["log2SoftDecim"] = 3
- settings["limeSdrInputSettings"]["centerFrequency"] = options.device_freq*1000 + 500000
+ settings["limeSdrInputSettings"]["centerFrequency"] = options.device_freq * 1000 + 500000
settings["limeSdrInputSettings"]["ncoEnable"] = 1
settings["limeSdrInputSettings"]["ncoFrequency"] = -500000
settings["limeSdrInputSettings"]["lpfBW"] = 1450000
@@ -127,34 +131,34 @@ def main():
settings["limeSdrInputSettings"]["lpfFIREnable"] = 1
settings['limeSdrInputSettings']['dcBlock'] = 1
elif options.device_hwid_rx == "RTLSDR":
- settings['rtlSdrSettings']['devSampleRate'] = options.sample_rate_rx*1000
- settings['rtlSdrSettings']['centerFrequency'] = options.device_freq*1000
+ settings['rtlSdrSettings']['devSampleRate'] = options.sample_rate_rx * 1000
+ settings['rtlSdrSettings']['centerFrequency'] = options.device_freq * 1000
settings['rtlSdrSettings']['gain'] = 496
settings['rtlSdrSettings']['log2Decim'] = 4
settings['rtlSdrSettings']['dcBlock'] = 1
settings['rtlSdrSettings']['agc'] = 1
elif options.device_hwid_rx == "HackRF":
settings['hackRFInputSettings']['LOppmTenths'] = -51
- settings['hackRFInputSettings']['centerFrequency'] = options.device_freq*1000
+ settings['hackRFInputSettings']['centerFrequency'] = options.device_freq * 1000
settings['hackRFInputSettings']['dcBlock'] = 1
- settings['hackRFInputSettings']['devSampleRate'] = options.sample_rate_rx*1000
+ settings['hackRFInputSettings']['devSampleRate'] = options.sample_rate_rx * 1000
settings['hackRFInputSettings']['lnaExt'] = 1
settings['hackRFInputSettings']['lnaGain'] = 32
settings['hackRFInputSettings']['log2Decim'] = 4
settings['hackRFInputSettings']['vgaGain'] = 24
-
+
r = callAPI(deviceset_url + "/device/settings", "PATCH", None, settings, "Patch device settings")
if r is None:
exit(-1)
-
+
r = callAPI(deviceset_url + "/channel", "POST", None, {"channelType": "NFMDemod", "tx": 0}, "Create NFM demod")
if r is None:
exit(-1)
-
+
settings = callAPI(deviceset_url + "/channel/0/settings", "GET", None, None, "Get NFM demod settings")
if settings is None:
exit(-1)
-
+
settings["NFMDemodSettings"]["title"] = "Test NFM"
settings["NFMDemodSettings"]["inputFrequencyOffset"] = options.channel_freq
settings["NFMDemodSettings"]["rfBandwidth"] = 12500
@@ -162,7 +166,7 @@ def main():
settings["NFMDemodSettings"]["afBandwidth"] = 4000
settings["NFMDemodSettings"]["squelch"] = -700
settings["NFMDemodSettings"]["volume"] = 2.0
-
+
if options.udp_copy is not None:
address_port = options.udp_copy.split(':')
if len(address_port) > 1:
@@ -170,37 +174,37 @@ def main():
if len(address_port) > 0:
settings["NFMDemodSettings"]["udpAddress"] = address_port[0]
settings["NFMDemodSettings"]["copyAudioToUDP"] = 1
-
+
r = callAPI(deviceset_url + "/channel/0/settings", "PATCH", None, settings, "Change NFM demod")
if r is None:
exit(-1)
-
+
r = callAPI(deviceset_url + "/device/run", "POST", None, None, "Start running device")
if r is None:
exit(-1)
-
- ### Tx setup
-
+
+ # ## Tx setup
+
r = callAPI("/deviceset", "POST", {"tx": 1}, None, "Add Tx device set")
if r is None:
exit(-1)
-
+
deviceset_url = "/deviceset/%d" % (deviceset_index_rx + 1)
-
+
r = callAPI(deviceset_url + "/device", "PUT", None, {"hwType": "%s" % options.device_hwid_tx, "tx": 1}, "setup device on Tx device set")
if r is None:
exit(-1)
-
+
settings = callAPI(deviceset_url + "/device/settings", "GET", None, None, "Get device settings")
if settings is None:
exit(-1)
if options.device_hwid_tx == "LimeSDR":
settings["limeSdrOutputSettings"]["antennaPath"] = options.antenna_path_tx
- settings["limeSdrOutputSettings"]["devSampleRate"] = options.sample_rate_tx*1000
+ settings["limeSdrOutputSettings"]["devSampleRate"] = options.sample_rate_tx * 1000
settings["limeSdrOutputSettings"]["log2HardInterp"] = 4
settings["limeSdrOutputSettings"]["log2SoftInterp"] = 4
- settings["limeSdrOutputSettings"]["centerFrequency"] = options.device_freq*1000 + 500000
+ settings["limeSdrOutputSettings"]["centerFrequency"] = options.device_freq * 1000 + 500000
settings["limeSdrOutputSettings"]["ncoEnable"] = 1
settings["limeSdrOutputSettings"]["ncoFrequency"] = -500000
settings["limeSdrOutputSettings"]["lpfBW"] = 4050000
@@ -208,44 +212,43 @@ def main():
settings["limeSdrOutputSettings"]["lpfFIREnable"] = 1
elif options.device_hwid_tx == "HackRF":
settings['hackRFOutputSettings']['LOppmTenths'] = -51
- settings['hackRFOutputSettings']['centerFrequency'] = options.device_freq*1000
- settings['hackRFOutputSettings']['devSampleRate'] = options.sample_rate_tx*1000
+ settings['hackRFOutputSettings']['centerFrequency'] = options.device_freq * 1000
+ settings['hackRFOutputSettings']['devSampleRate'] = options.sample_rate_tx * 1000
settings['hackRFOutputSettings']['lnaExt'] = 0
settings['hackRFOutputSettings']['log2Interp'] = 4
settings['hackRFOutputSettings']['vgaGain'] = 24
-
+
r = callAPI(deviceset_url + "/device/settings", "PATCH", None, settings, "Patch device settings")
if r is None:
exit(-1)
-
+
r = callAPI(deviceset_url + "/channel", "POST", None, {"channelType": "NFMMod", "tx": 1}, "Create NFM mod")
if r is None:
exit(-1)
-
+
settings = callAPI(deviceset_url + "/channel/0/settings", "GET", None, None, "Get NFM mod settings")
if settings is None:
exit(-1)
-
+
settings["NFMModSettings"]["title"] = "Test NFM"
settings["NFMModSettings"]["inputFrequencyOffset"] = options.channel_freq
settings["NFMModSettings"]["cwKeyer"]["text"] = "VVV DE F4EXB "
settings["NFMModSettings"]["cwKeyer"]["loop"] = 1
- settings["NFMModSettings"]["cwKeyer"]["mode"] = 1 # text
- settings["NFMModSettings"]["modAFInput"] = 4 # CW text
+ settings["NFMModSettings"]["cwKeyer"]["mode"] = 1 # text
+ settings["NFMModSettings"]["modAFInput"] = 4 # CW text
settings["NFMModSettings"]["toneFrequency"] = 600
-
+
r = callAPI(deviceset_url + "/channel/0/settings", "PATCH", None, settings, "Change NFM mod")
if r is None:
exit(-1)
-
+
deviceset_url = "/deviceset/%d" % deviceset_index_rx
-
+
r = callAPI(deviceset_url + "/focus", "PATCH", None, None, "set focus on Rx device set")
if r is None:
exit(-1)
-
-
- except Exception, msg:
+
+ except Exception as ex:
tb = traceback.format_exc()
print >> sys.stderr, tb
diff --git a/swagger/sdrangel/examples/scanner.py b/swagger/sdrangel/examples/scanner.py
index 961d8604a..597332103 100755
--- a/swagger/sdrangel/examples/scanner.py
+++ b/swagger/sdrangel/examples/scanner.py
@@ -28,41 +28,44 @@ requests_methods = {
"DELETE": requests.delete
}
+
# ======================================================================
class ScanControl:
- def __init__(self, num_channels, channel_step, start_freq, stop_freq, log2_decim):
+
+ def __init__(self, num_channels, channel_step, start_freq, stop_freq, log2_decim):
self.channel_shifts = []
if num_channels < 2:
self.channel_shifts = [0]
limit = 0
else:
- limit = ((num_channels-1)*channel_step) / 2
+ limit = ((num_channels - 1) * channel_step) / 2
self.channel_shifts = list(np.linspace(-limit, limit, num_channels))
- self.device_start_freq = start_freq + limit
+ self.device_start_freq = start_freq + limit
self.device_stop_freq = stop_freq - limit
- self.device_step_freq = 2*limit + channel_step
- self.device_sample_rate = (2*limit + channel_step)*(1< 2:
options.verbosity = 2
-
+
return options
+
# ======================================================================
def setupDevice(scan_control, options):
settings = callAPI(deviceset_url + "/device/settings", "GET", None, None, "Get device settings")
if settings is None:
exit(-1)
-
+
if options.device_hwid == "AirspyHF":
if scan_control.device_start_freq > 30000000:
settings["airspyHFSettings"]["bandIndex"] = 1
@@ -134,7 +138,7 @@ def setupDevice(scan_control, options):
settings['rtlSdrSettings']['loPpmCorrection'] = int(options.lo_ppm)
settings['rtlSdrSettings']['rfBandwidth'] = scan_control.device_step_freq + 100000
elif options.device_hwid == "HackRF":
- settings['hackRFInputSettings']['LOppmTenths'] = int(options.lo_ppm * 10) # in tenths of PPM
+ settings['hackRFInputSettings']['LOppmTenths'] = int(options.lo_ppm * 10) # in tenths of PPM
settings['hackRFInputSettings']['centerFrequency'] = scan_control.device_start_freq
settings['hackRFInputSettings']['fcPos'] = options.fc_pos
settings['hackRFInputSettings']['dcBlock'] = options.fc_pos == 2
@@ -148,7 +152,8 @@ def setupDevice(scan_control, options):
r = callAPI(deviceset_url + "/device/settings", "PATCH", None, settings, "Patch device settings")
if r is None:
exit(-1)
-
+
+
# ======================================================================
def changeDeviceFrequency(fc, options):
settings = callAPI(deviceset_url + "/device/settings", "GET", None, None, "Get device settings")
@@ -168,6 +173,7 @@ def changeDeviceFrequency(fc, options):
if r is None:
exit(-1)
+
# ======================================================================
def setupChannels(scan_control, options):
i = 0
@@ -185,8 +191,8 @@ def setupChannels(scan_control, options):
settings["NFMDemodSettings"]["afBandwidth"] = options.af_bw * 1000
settings["NFMDemodSettings"]["rfBandwidth"] = options.rf_bw
settings["NFMDemodSettings"]["volume"] = options.volume
- settings["NFMDemodSettings"]["squelch"] = options.squelch_db * 10 # centi-Bels
- settings["NFMDemodSettings"]["squelchGate"] = options.squelch_gate / 10 # 10's of ms
+ settings["NFMDemodSettings"]["squelch"] = options.squelch_db * 10 # centi-Bels
+ settings["NFMDemodSettings"]["squelchGate"] = options.squelch_gate / 10 # 10's of ms
settings["NFMDemodSettings"]["title"] = "Channel %d" % i
elif options.channel_id == "AMDemod":
settings["AMDemodSettings"]["inputFrequencyOffset"] = int(shift)
@@ -194,7 +200,7 @@ def setupChannels(scan_control, options):
settings["AMDemodSettings"]["volume"] = options.volume
settings["AMDemodSettings"]["squelch"] = options.squelch_db
settings["AMDemodSettings"]["title"] = "Channel %d" % i
- settings["AMDemodSettings"]["bandpassEnable"] = 1 # bandpass filter
+ settings["AMDemodSettings"]["bandpassEnable"] = 1 # bandpass filter
elif options.channel_id == "DSDDemod":
settings["DSDDemodSettings"]["inputFrequencyOffset"] = int(shift)
settings["DSDDemodSettings"]["rfBandwidth"] = options.rf_bw
@@ -205,13 +211,14 @@ def setupChannels(scan_control, options):
settings["DSDDemodSettings"]["enableCosineFiltering"] = 1
settings["DSDDemodSettings"]["pllLock"] = 1
settings["DSDDemodSettings"]["title"] = "Channel %d" % i
-
+
r = callAPI(deviceset_url + "/channel/%d/settings" % i, "PATCH", None, settings, "Change demod")
if r is None:
exit(-1)
-
- i += 1
-
+
+ i += 1
+
+
# ======================================================================
def checkScanning(fc, options, display_message):
reports = callAPI(deviceset_url + "/channels/report", "GET", None, None, "Get channels report")
@@ -222,19 +229,20 @@ def checkScanning(fc, options, display_message):
channel = reports["channels"][i]
if "report" in channel:
if reportKey in channel["report"]:
- if options.channel_id == "DSDDemod": # DSD is special because it only stops on voice
+ if options.channel_id == "DSDDemod": # DSD is special because it only stops on voice
stopCondition = channel["report"][reportKey]["slot1On"] == 1 or channel["report"][reportKey]["slot2On"] == 1
else:
stopCondition = channel["report"][reportKey]["squelch"] == 1
if stopCondition:
- f_channel = channel["deltaFrequency"]+fc
- f_frac = round(f_channel/options.excl_tol)
+ f_channel = channel["deltaFrequency"] + fc
+ f_frac = round(f_channel / options.excl_tol)
if f_frac not in options.excl_flist:
- if display_message: # display message only when stopping for the first time
- print("%s Stopped at %d Hz" % (datetime.datetime.now().strftime("%H:%M:%S"),f_frac*options.excl_tol))
- return False # stop scanning
- return True # continue scanning
-
+ if display_message: # display message only when stopping for the first time
+ print("%s Stopped at %d Hz" % (datetime.datetime.now().strftime("%H:%M:%S"), f_frac * options.excl_tol))
+ return False # stop scanning
+ return True # continue scanning
+
+
# ======================================================================
def printResponse(response):
content_type = response.headers.get("Content-Type", None)
@@ -244,17 +252,18 @@ def printResponse(response):
elif "text/plain" in content_type:
print(response.text)
+
# ======================================================================
def callAPI(url, method, params, json, text):
request_method = requests_methods.get(method, None)
if request_method is not None:
- r = request_method(url=base_url+url, params=params, json=json)
+ r = request_method(url=base_url + url, params=params, json=json)
if r.status_code / 100 == 2:
if verbosity >= 1:
print(text + " succeeded")
if verbosity >= 2:
printResponse(r)
- return r.json() # all 200 yield application/json response
+ return r.json() # all 200 yield application/json response
else:
if verbosity >= 1:
print(text + " failed")
@@ -262,12 +271,13 @@ def callAPI(url, method, params, json, text):
printResponse(r)
return None
+
# ======================================================================
def main():
try:
options = getInputOptions()
scan_control = ScanControl(options.num_channels, options.freq_step, options.freq_start, options.freq_stop, options.log2_decim)
-
+
# Print calculated scan parameters
print("Channel shifts: %s" % scan_control.channel_shifts)
@@ -275,43 +285,43 @@ def main():
print("Start: %d" % scan_control.device_start_freq)
print("Stop: %d" % scan_control.device_stop_freq)
print("Step: %d" % scan_control.device_step_freq)
-
+
if scan_control.device_stop_freq < scan_control.device_start_freq:
print("Frequency error")
exit(1)
-
+
freqs = []
nb_steps = 0
fc = scan_control.device_start_freq
while fc <= scan_control.device_stop_freq:
- freqs += [x+fc for x in scan_control.channel_shifts]
+ freqs += [x + fc for x in scan_control.channel_shifts]
fc += scan_control.device_step_freq
- nb_steps += 1
+ nb_steps += 1
print("Scanned frequencies: %s" % freqs)
print("Skipped frequencies: %s" % options.excl_flist)
print("In %d steps" % nb_steps)
- if options.mock: # Stop there if we are just mocking (no API access)
+ if options.mock: # Stop there if we are just mocking (no API access)
exit(0)
-
+
global base_url
base_url = "http://%s/sdrangel" % options.address
-
- # Set Rx
-
+
+ # Set Rx
+
global deviceset_url
deviceset_url = "/deviceset/%d" % options.device_index
-
- if not options.rerun: # Skip device and channels settings in re-run mode
+
+ if not options.rerun: # Skip device and channels settings in re-run mode
if options.create:
r = callAPI("/deviceset", "POST", {"tx": 0}, None, "Add Rx device set")
if r is None:
exit(-1)
-
+
r = callAPI(deviceset_url + "/device", "PUT", None, {"hwType": options.device_hwid, "tx": 0}, "setup device on Rx device set")
if r is None:
exit(-1)
-
+
# Set device and channels
setupDevice(scan_control, options)
@@ -325,7 +335,7 @@ def main():
fc = scan_control.device_start_freq
global verbosity
- verbosity = options.verbosity
+ verbosity = options.verbosity
print("Move center to %d Hz" % fc)
changeDeviceFrequency(fc, options)
@@ -335,7 +345,7 @@ def main():
resume_delay = 0
while True:
time.sleep(options.settling_time)
- scanning = checkScanning(fc, options, scanning and resume_delay == 0) # shall we move on ?
+ scanning = checkScanning(fc, options, scanning and resume_delay == 0) # shall we move on ?
if scanning:
if resume_delay > 0:
resume_delay -= 1
@@ -354,14 +364,14 @@ def main():
print("Terminated by user")
pass
finally:
- verbosity = 2
+ verbosity = 2
r = callAPI(deviceset_url + "/device/run", "DELETE", None, None, "Stop running device")
if r is None:
exit(-1)
-
+
except KeyboardInterrupt:
pass
- except Exception, msg:
+ except Exception as ex:
tb = traceback.format_exc()
print >> sys.stderr, tb
diff --git a/swagger/sdrangel/examples/start_stop.py b/swagger/sdrangel/examples/start_stop.py
index 6f266258a..8a09baa0c 100644
--- a/swagger/sdrangel/examples/start_stop.py
+++ b/swagger/sdrangel/examples/start_stop.py
@@ -5,38 +5,40 @@ from optparse import OptionParser
base_url = "http://127.0.0.1:8091/sdrangel"
+
# ======================================================================
def getInputOptions():
parser = OptionParser(usage="usage: %%prog [-t]\n")
- parser.add_option("-a", "--address", dest="address", help="address and port", metavar="ADDRESS", type="string")
- parser.add_option("-d", "--device-index", dest="device_index", help="device set index", metavar="INDEX", type="int")
+ parser.add_option("-a", "--address", dest="address", help="address and port", metavar="ADDRESS", type="string")
+ parser.add_option("-d", "--device-index", dest="device_index", help="device set index", metavar="INDEX", type="int")
parser.add_option("-t", "--stop", dest="stop", help="stop device", metavar="STOP", action="store_true", default=False)
parser.add_option("-s", "--start", dest="start", help="start device", metavar="START", action="store_true", default=False)
(options, args) = parser.parse_args()
-
+
if (options.address == None):
options.address = "127.0.0.1:8888"
-
+
if options.device_index < 0:
otions.device_index = 0
-
+
if options.start and options.stop:
print("Cannot start and stop at the same time")
exit(1)
-
+
if not options.start and not options.stop:
print("Must start or stop")
exit(1)
return options
+
# ======================================================================
def startDevice(deviceIndex):
- dev_run_url = base_url+("/deviceset/%d/device/run" % deviceIndex)
+ dev_run_url = base_url + ("/deviceset/%d/device/run" % deviceIndex)
r = requests.get(url=dev_run_url)
- if r.status_code / 100 == 2:
+ if r.status_code / 100 == 2:
rj = r.json()
state = rj.get("state", None)
if state is not None:
@@ -53,11 +55,12 @@ def startDevice(deviceIndex):
else:
print("Error getting device %d running state" % deviceIndex)
+
# ======================================================================
def stopDevice(deviceIndex):
- dev_run_url = base_url+("/deviceset/%d/device/run" % deviceIndex)
+ dev_run_url = base_url + ("/deviceset/%d/device/run" % deviceIndex)
r = requests.get(url=dev_run_url)
- if r.status_code / 100 == 2:
+ if r.status_code / 100 == 2:
rj = r.json()
state = rj.get("state", None)
if state is not None:
@@ -73,15 +76,16 @@ def stopDevice(deviceIndex):
print("Cannot get device %d running state" % deviceIndex)
else:
print("Error getting device %d running state" % deviceIndex)
-
+
+
# ======================================================================
def main():
try:
options = getInputOptions()
global base_url
base_url = "http://%s/sdrangel" % options.address
- r = requests.get(url=base_url+"/devicesets")
- if r.status_code / 100 == 2:
+ r = requests.get(url=base_url + "/devicesets")
+ if r.status_code / 100 == 2:
rj = r.json()
deviceSets = rj.get("deviceSets", None)
if deviceSets is not None:
@@ -96,8 +100,8 @@ def main():
print("Cannot get device sets configuration")
else:
print("Error getting device sets configuration")
-
- except Exception, msg:
+
+ except Exception as ex:
tb = traceback.format_exc()
print >> sys.stderr, tb
diff --git a/swagger/sdrangel/examples/stop_server.py b/swagger/sdrangel/examples/stop_server.py
index d7ff6d67a..365e7159c 100644
--- a/swagger/sdrangel/examples/stop_server.py
+++ b/swagger/sdrangel/examples/stop_server.py
@@ -13,19 +13,21 @@ requests_methods = {
"DELETE": requests.delete
}
+
# ======================================================================
def getInputOptions():
parser = OptionParser(usage="usage: %%prog [-t]\n")
- parser.add_option("-a", "--address", dest="address", help="address and port", metavar="ADDRESS", type="string")
+ parser.add_option("-a", "--address", dest="address", help="address and port", metavar="ADDRESS", type="string")
(options, args) = parser.parse_args()
-
+
if (options.address == None):
options.address = "127.0.0.1:8091"
return options
+
# ======================================================================
def printResponse(response):
content_type = response.headers.get("Content-Type", None)
@@ -35,25 +37,27 @@ def printResponse(response):
elif "text/plain" in content_type:
print(response.text)
+
# ======================================================================
def callAPI(url, method, params, json, text):
request_method = requests_methods.get(method, None)
if request_method is not None:
- r = request_method(url=base_url+url, params=params, json=json)
- if r.status_code / 100 == 2:
+ r = request_method(url=base_url + url, params=params, json=json)
+ if r.status_code / 100 == 2:
print(text + " succeeded")
printResponse(r)
- return r.json() # all 200 yield application/json response
+ return r.json() # all 200 yield application/json response
else:
print(text + " failed")
printResponse(r)
return None
+
# ======================================================================
def main():
try:
options = getInputOptions()
-
+
global base_url
base_url = "http://%s/sdrangel" % options.address
@@ -61,7 +65,7 @@ def main():
if settings is None:
exit(-1)
- except Exception, msg:
+ except Exception as ex:
tb = traceback.format_exc()
print >> sys.stderr, tb
diff --git a/swagger/sdrangel/examples/tx_test.py b/swagger/sdrangel/examples/tx_test.py
index 06fb64605..37ef3b3b4 100755
--- a/swagger/sdrangel/examples/tx_test.py
+++ b/swagger/sdrangel/examples/tx_test.py
@@ -14,15 +14,16 @@ requests_methods = {
"DELETE": requests.delete
}
+
# ======================================================================
def getInputOptions():
parser = OptionParser(usage="usage: %%prog [-t]\n")
- parser.add_option("-a", "--address", dest="address", help="address and port", metavar="ADDRESS", type="string")
- parser.add_option("-d", "--device-index", dest="device_index", help="device set index", metavar="INDEX", type="int")
- parser.add_option("-D", "--device-hwid", dest="device_hwid", help="device hardware id", metavar="HWID", type="string")
- parser.add_option("-C", "--channel-id", dest="channel_id", help="channel id", metavar="ID", type="string", default="NFMDemod")
- parser.add_option("-F", "--device-freq", dest="device_freq", help="device center frequency (kHz)", metavar="FREQ", type="int")
+ parser.add_option("-a", "--address", dest="address", help="address and port", metavar="ADDRESS", type="string")
+ parser.add_option("-d", "--device-index", dest="device_index", help="device set index", metavar="INDEX", type="int")
+ parser.add_option("-D", "--device-hwid", dest="device_hwid", help="device hardware id", metavar="HWID", type="string")
+ parser.add_option("-C", "--channel-id", dest="channel_id", help="channel id", metavar="ID", type="string", default="NFMDemod")
+ parser.add_option("-F", "--device-freq", dest="device_freq", help="device center frequency (kHz)", metavar="FREQ", type="int")
parser.add_option("-f", "--channel-freq", dest="channel_freq", help="channel center frequency (Hz)", metavar="FREQ", type="int")
parser.add_option("-s", "--sample-rate", dest="sample_rate", help="host to device sample rate (S/s)", metavar="RATE", type="int")
parser.add_option("-l", "--log2-interp", dest="log2_interp", help="log2 of interpolation factor", metavar="RATE", type="int")
@@ -34,25 +35,25 @@ def getInputOptions():
parser.add_option("--video", dest="video_file", help="video file for ATV modulator (sends video)", metavar="FILENAME", type="string")
(options, args) = parser.parse_args()
-
+
if options.address == None:
options.address = "127.0.0.1:8091"
-
+
if options.device_index == None:
options.device_index = 1
-
+
if options.device_hwid == None:
options.device_hwid = "FileSource"
-
+
if options.device_freq == None:
options.device_freq = 435000
-
+
if options.channel_freq == None:
options.channel_freq = 0
-
+
if options.sample_rate == None:
options.sample_rate = 2600000
-
+
if options.log2_interp == None:
options.log2_interp = 4
@@ -64,6 +65,7 @@ def getInputOptions():
return options
+
# ======================================================================
def printResponse(response):
content_type = response.headers.get("Content-Type", None)
@@ -73,36 +75,39 @@ def printResponse(response):
elif "text/plain" in content_type:
print(response.text)
+
# ======================================================================
def callAPI(url, method, params, json, text):
request_method = requests_methods.get(method, None)
if request_method is not None:
- r = request_method(url=base_url+url, params=params, json=json)
+ r = request_method(url=base_url + url, params=params, json=json)
if r.status_code / 100 == 2:
print(text + " succeeded")
printResponse(r)
- return r.json() # all 200 yield application/json response
+ return r.json() # all 200 yield application/json response
else:
print(text + " failed")
printResponse(r)
return None
+
# ======================================================================
def setupBladeRFXB200(fc):
if fc < 50000:
- return 5 # BLADERF_XB200_AUTO_3DB
+ return 5 # BLADERF_XB200_AUTO_3DB
elif fc < 54000:
- return 0 # BLADERF_XB200_50M
+ return 0 # BLADERF_XB200_50M
elif fc < 144000:
- return 5 # BLADERF_XB200_AUTO_3DB
+ return 5 # BLADERF_XB200_AUTO_3DB
elif fc < 148000:
- return 1 # BLADERF_XB200_144M
+ return 1 # BLADERF_XB200_144M
elif fc < 222000:
- return 5 # BLADERF_XB200_AUTO_3DB
+ return 5 # BLADERF_XB200_AUTO_3DB
elif fc < 225000:
- return 2 # BLADERF_XB200_222M
+ return 2 # BLADERF_XB200_222M
else:
- return 5 # BLADERF_XB200_AUTO_3DB
+ return 5 # BLADERF_XB200_AUTO_3DB
+
# ======================================================================
def setupDevice(options):
@@ -111,17 +116,17 @@ def setupDevice(options):
exit(-1)
# calculate RF analog and FIR optimal bandpass filters bandwidths
- lpFIRBW = options.sample_rate / (1<> sys.stderr, tb