mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 01:55:48 -05:00
Merge branch 'f4exb:master' into snap
This commit is contained in:
commit
7f275f2a3e
@ -2423,7 +2423,8 @@ void GLSpectrumView::peakWidth(const Real *spectrum, int center, int &left, int
|
||||
float prevRight = spectrum[center];
|
||||
left = center - 1;
|
||||
right = center + 1;
|
||||
while ((left > maxLeft) && (spectrum[left] < prevLeft) && (right < maxRight) && (spectrum[right] < prevRight))
|
||||
// Use <= as SSB spectrums have duplicated values
|
||||
while ((left > maxLeft) && (spectrum[left] <= prevLeft) && (right < maxRight) && (spectrum[right] <= prevRight))
|
||||
{
|
||||
prevLeft = spectrum[left];
|
||||
left--;
|
||||
|
@ -495,11 +495,20 @@ void MainServer::changeSampleSource(int deviceSetIndex, int selectedDeviceIndex)
|
||||
DeviceSampleSource *source = deviceSet->m_deviceAPI->getPluginInterface()->createSampleSourcePluginInstance(
|
||||
deviceSet->m_deviceAPI->getSamplingDeviceId(), deviceSet->m_deviceAPI);
|
||||
deviceSet->m_deviceAPI->setSampleSource(source);
|
||||
|
||||
deviceSet->m_deviceAPI->loadSamplingDeviceSettings(m_mainCore->m_settings.getWorkingPreset()); // load new API settings
|
||||
|
||||
// Notify
|
||||
emit m_mainCore->deviceChanged(deviceSetIndex);
|
||||
// wait for sample source to be set, before loading settings
|
||||
auto connection = new QMetaObject::Connection();
|
||||
*connection = connect(
|
||||
deviceSet->m_deviceSourceEngine,
|
||||
&DSPDeviceSourceEngine::sampleSet,
|
||||
this,
|
||||
[=]() {
|
||||
deviceSet->m_deviceAPI->loadSamplingDeviceSettings(m_mainCore->m_settings.getWorkingPreset()); // load new API settings
|
||||
// Notify
|
||||
emit m_mainCore->deviceChanged(deviceSetIndex);
|
||||
QObject::disconnect(*connection);
|
||||
delete connection;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -566,8 +575,20 @@ void MainServer::changeSampleSink(int deviceSetIndex, int selectedDeviceIndex)
|
||||
DeviceSampleSink *sink = deviceSet->m_deviceAPI->getPluginInterface()->createSampleSinkPluginInstance(
|
||||
deviceSet->m_deviceAPI->getSamplingDeviceId(), deviceSet->m_deviceAPI);
|
||||
deviceSet->m_deviceAPI->setSampleSink(sink);
|
||||
|
||||
deviceSet->m_deviceAPI->loadSamplingDeviceSettings(m_mainCore->m_settings.getWorkingPreset()); // load new API settings
|
||||
// wait for sample source to be set, before loading settings
|
||||
auto connection = new QMetaObject::Connection();
|
||||
*connection = connect(
|
||||
deviceSet->m_deviceSourceEngine,
|
||||
&DSPDeviceSourceEngine::sampleSet,
|
||||
this,
|
||||
[=]() {
|
||||
deviceSet->m_deviceAPI->loadSamplingDeviceSettings(m_mainCore->m_settings.getWorkingPreset()); // load new API settings
|
||||
// Notify
|
||||
emit m_mainCore->deviceChanged(deviceSetIndex);
|
||||
QObject::disconnect(*connection);
|
||||
delete connection;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -620,8 +641,20 @@ void MainServer::changeSampleMIMO(int deviceSetIndex, int selectedDeviceIndex)
|
||||
DeviceSampleMIMO *mimo = deviceSet->m_deviceAPI->getPluginInterface()->createSampleMIMOPluginInstance(
|
||||
deviceSet->m_deviceAPI->getSamplingDeviceId(), deviceSet->m_deviceAPI);
|
||||
deviceSet->m_deviceAPI->setSampleMIMO(mimo);
|
||||
|
||||
deviceSet->m_deviceAPI->loadSamplingDeviceSettings(m_mainCore->m_settings.getWorkingPreset()); // load new API settings
|
||||
// wait for sample source to be set, before loading settings
|
||||
auto connection = new QMetaObject::Connection();
|
||||
*connection = connect(
|
||||
deviceSet->m_deviceSourceEngine,
|
||||
&DSPDeviceSourceEngine::sampleSet,
|
||||
this,
|
||||
[=]() {
|
||||
deviceSet->m_deviceAPI->loadSamplingDeviceSettings(m_mainCore->m_settings.getWorkingPreset()); // load new API settings
|
||||
// Notify
|
||||
emit m_mainCore->deviceChanged(deviceSetIndex);
|
||||
QObject::disconnect(*connection);
|
||||
delete connection;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
12
swagger/sdrangel/examples/add_channel.py
Normal file → Executable file
12
swagger/sdrangel/examples/add_channel.py
Normal file → Executable file
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import requests, json, traceback, sys
|
||||
from optparse import OptionParser
|
||||
@ -12,12 +12,12 @@ 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("-c", "--channel-id", dest="channel_id", help="channel ID of channel to add", metavar="ID", type="string")
|
||||
parser.add_option("-c", "--channel-id", dest="channel_id", help="channel ID of channel to add (E.g. NFMDemod)", metavar="ID", type="string")
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
if options.address is None:
|
||||
options.address = "127.0.0.1:8888"
|
||||
options.address = "127.0.0.1:8091"
|
||||
|
||||
if options.device_index is None or options.device_index < 0:
|
||||
options.device_index = 0
|
||||
@ -37,12 +37,12 @@ def main():
|
||||
base_url = "http://%s/sdrangel" % options.address
|
||||
device_url = base_url + ("/deviceset/%d/channel" % options.device_index)
|
||||
r = requests.post(url=device_url, json={"direction": 0, "channelType": options.channel_id})
|
||||
if r.status_code / 100 == 2:
|
||||
if r.status_code // 100 == 2:
|
||||
print("Success")
|
||||
print json.dumps(r.json(), indent=4, sort_keys=True)
|
||||
print(json.dumps(r.json(), indent=4, sort_keys=True))
|
||||
else:
|
||||
print("Error adding channel. HTTP: %d" % r.status_code)
|
||||
print json.dumps(r.json(), indent=4, sort_keys=True)
|
||||
print(json.dumps(r.json(), indent=4, sort_keys=True))
|
||||
|
||||
except Exception as ex:
|
||||
tb = traceback.format_exc()
|
||||
|
24
swagger/sdrangel/examples/rtlsdr_settings.py
Normal file → Executable file
24
swagger/sdrangel/examples/rtlsdr_settings.py
Normal file → Executable file
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import requests, json
|
||||
|
||||
base_url = "http://127.0.0.1:8091/sdrangel"
|
||||
@ -14,7 +14,7 @@ requests_methods = {
|
||||
|
||||
def getHwType():
|
||||
r = requests.get(url=base_url + "/deviceset/0")
|
||||
if r.status_code / 100 == 2:
|
||||
if r.status_code // 100 == 2:
|
||||
rj = r.json()
|
||||
devj = rj.get('samplingDevice', None)
|
||||
if devj is not None:
|
||||
@ -27,8 +27,8 @@ def getHwType():
|
||||
|
||||
def selectRtlSdr():
|
||||
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)
|
||||
if r.status_code // 100 == 2:
|
||||
print(json.dumps(r.json(), indent=4, sort_keys=True))
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
@ -36,7 +36,7 @@ def selectRtlSdr():
|
||||
|
||||
def getRtlSdrSettings():
|
||||
r = requests.get(url=base_url + "/deviceset/0/device/settings")
|
||||
if r.status_code / 100 == 2:
|
||||
if r.status_code // 100 == 2:
|
||||
rj = r.json()
|
||||
hwType = rj.get('deviceHwType', None)
|
||||
if hwType is not None and hwType == "RTLSDR":
|
||||
@ -51,10 +51,10 @@ def getRtlSdrSettings():
|
||||
def patchRtlSdrSettings(settings):
|
||||
new_settings = {"deviceHwType": "RTLSDR", "direction": 0, "rtlSdrSettings": settings}
|
||||
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)
|
||||
if r.status_code // 100 == 2:
|
||||
print(json.dumps(r.json(), indent=4, sort_keys=True))
|
||||
else:
|
||||
print "Error HTTP:", r.status_code
|
||||
print("Error HTTP:", r.status_code)
|
||||
|
||||
|
||||
def deviceRun(run):
|
||||
@ -62,10 +62,10 @@ def deviceRun(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:
|
||||
print json.dumps(r.json(), indent=4, sort_keys=True)
|
||||
if r.status_code // 100 == 2:
|
||||
print(json.dumps(r.json(), indent=4, sort_keys=True))
|
||||
else:
|
||||
print "Error HTTP:", r.status_code
|
||||
print("Error HTTP:", r.status_code)
|
||||
|
||||
|
||||
def main():
|
||||
@ -73,8 +73,10 @@ def main():
|
||||
if hwType is not None:
|
||||
if hwType != "RTLSDR":
|
||||
if not selectRtlSdr():
|
||||
print("Device set 0 is not an RTLSDR device")
|
||||
return
|
||||
else:
|
||||
print("Device set 0 does not exist")
|
||||
return
|
||||
settings = getRtlSdrSettings()
|
||||
if settings is not None:
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import requests, json, traceback, sys, time
|
||||
from optparse import OptionParser
|
||||
|
Loading…
Reference in New Issue
Block a user