mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-10 10:33:29 -05:00
SDRDaemonSource: sample bit size conversion 16 / 24 bits bidirectional
This commit is contained in:
parent
0ae5955b76
commit
7e97f62615
@ -38,8 +38,8 @@ QByteArray SDRdaemonSourceSettings::serialize() const
|
||||
SimpleSerializer s(1);
|
||||
|
||||
s.writeString(5, m_apiAddress);
|
||||
s.writeU32(6, m_dataPort);
|
||||
s.writeU32(7, m_apiPort);
|
||||
s.writeU32(6, m_apiPort);
|
||||
s.writeU32(7, m_dataPort);
|
||||
s.writeString(8, m_dataAddress);
|
||||
s.writeBool(9, m_dcBlock);
|
||||
s.writeBool(10, m_iqCorrection);
|
||||
@ -62,7 +62,7 @@ bool SDRdaemonSourceSettings::deserialize(const QByteArray& data)
|
||||
quint32 uintval;
|
||||
d.readString(5, &m_apiAddress, "127.0.0.1");
|
||||
d.readU32(6, &uintval, 9090);
|
||||
m_dataPort = uintval % (1<<16);
|
||||
m_apiPort = uintval % (1<<16);
|
||||
d.readU32(7, &uintval, 9091);
|
||||
m_dataPort = uintval % (1<<16);
|
||||
d.readString(8, &m_dataAddress, "127.0.0.1");
|
||||
|
@ -264,14 +264,15 @@ void SDRdaemonSourceUDPHandler::tick()
|
||||
}
|
||||
|
||||
m_readLength = m_readLengthSamples * SDRdaemonSourceBuffer::m_iqSampleSize;
|
||||
const SDRdaemonSourceBuffer::MetaDataFEC& metaData = m_sdrDaemonBuffer.getCurrentMeta();
|
||||
|
||||
if (SDR_RX_SAMP_SZ == 16)
|
||||
if (SDR_RX_SAMP_SZ == metaData.m_sampleBits) // same sample size
|
||||
{
|
||||
// read samples directly feeding the SampleFifo (no callback)
|
||||
m_sampleFifo->write(reinterpret_cast<quint8*>(m_sdrDaemonBuffer.readData(m_readLength)), m_readLength);
|
||||
m_samplesCount += m_readLengthSamples;
|
||||
}
|
||||
else if (SDR_RX_SAMP_SZ == 24)
|
||||
else if (metaData.m_sampleBits == 16) // 16 -> 24 bits
|
||||
{
|
||||
if (m_readLengthSamples > m_converterBufferNbSamples)
|
||||
{
|
||||
@ -283,14 +284,37 @@ void SDRdaemonSourceUDPHandler::tick()
|
||||
|
||||
for (unsigned int is = 0; is < m_readLengthSamples; is++)
|
||||
{
|
||||
m_converterBuffer[2*is] = ((int16_t*)buf)[2*is];
|
||||
m_converterBuffer[2*is] = ((int16_t*)buf)[2*is]; // I
|
||||
m_converterBuffer[2*is]<<=8;
|
||||
m_converterBuffer[2*is+1] = ((int16_t*)buf)[2*is+1];
|
||||
m_converterBuffer[2*is+1] = ((int16_t*)buf)[2*is+1]; // Q
|
||||
m_converterBuffer[2*is+1]<<=8;
|
||||
}
|
||||
|
||||
m_sampleFifo->write(reinterpret_cast<quint8*>(m_converterBuffer), m_readLengthSamples*sizeof(Sample));
|
||||
}
|
||||
else if (metaData.m_sampleBits == 24) // 24 -> 16 bits
|
||||
{
|
||||
if (m_readLengthSamples > m_converterBufferNbSamples)
|
||||
{
|
||||
if (m_converterBuffer) { delete[] m_converterBuffer; }
|
||||
m_converterBuffer = new int32_t[m_readLengthSamples];
|
||||
}
|
||||
|
||||
uint8_t *buf = m_sdrDaemonBuffer.readData(m_readLength);
|
||||
|
||||
for (unsigned int is = 0; is < m_readLengthSamples; is++)
|
||||
{
|
||||
m_converterBuffer[is] = ((int32_t *)buf)[2*is]>>8; // I -> MSB
|
||||
m_converterBuffer[is] <<=16;
|
||||
m_converterBuffer[is] += ((int32_t *)buf)[2*is+1]>>8; // Q -> LSB
|
||||
}
|
||||
|
||||
m_sampleFifo->write(reinterpret_cast<quint8*>(m_converterBuffer), m_readLengthSamples*sizeof(Sample));
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning("SDRdaemonSourceUDPHandler::tick: unexpected sample size in stream: %d bits", (int) metaData.m_sampleBits);
|
||||
}
|
||||
|
||||
if (m_tickCount < m_rateDivider)
|
||||
{
|
||||
|
@ -13,26 +13,28 @@ 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("-U", "--copy-to-udp", dest="udp_copy", help="UDP audio copy to <address>[:<port>]", metavar="IP:PORT", type="string")
|
||||
parser.add_option("-A", "--antenna-path", dest="antenna_path", help="antenna path index", metavar="INDEX", type="int")
|
||||
parser.add_option("-U", "--copy-to-udp", dest="udp_copy", help="UDP audio copy to <address>[:<port>]", metavar="IP:PORT", type="string")
|
||||
parser.add_option("-A", "--antenna-path", dest="antenna_path", help="antenna path index", metavar="INDEX", type="int")
|
||||
parser.add_option("-s", "--sample-rate", dest="sample_rate", help="device to host sample rate (kS/s)", metavar="RATE", type="int")
|
||||
parser.add_option("-l", "--log2-decim", dest="log2_decim", help="log2 of the desired software decimation factor", metavar="LOG2", type="int", default=4)
|
||||
parser.add_option("-b", "--af-bw", dest="af_bw", help="audio babdwidth (kHz)", metavar="FREQUENCY_KHZ", type="int" ,default=3)
|
||||
parser.add_option("-r", "--rf-bw", dest="rf_bw", help="RF babdwidth (Hz). Sets to nearest available", metavar="FREQUENCY", type="int", default=10000)
|
||||
parser.add_option("-l", "--log2-decim", dest="log2_decim", help="log2 of the desired software decimation factor", metavar="LOG2", type="int", default=4)
|
||||
parser.add_option("--device-rfbw", dest="device_rfbw", help="Device RF bandwidth in kHz", metavar="FREQUENCY_KHZ", type="int")
|
||||
parser.add_option("-b", "--channel-afbw", dest="af_bw", help="Channel audio babdwidth (kHz)", metavar="FREQUENCY_KHZ", type="int" , default=3)
|
||||
parser.add_option("-r", "--channel-rfbw", dest="rf_bw", help="Channel RF bandwidth (Hz). Sets to nearest available", metavar="FREQUENCY", type="int", default=10000)
|
||||
parser.add_option("--vol", dest="volume", help="audio volume", metavar="VOLUME", type="float", default=1.0)
|
||||
parser.add_option("-c", "--create", dest="create", help="create a new device set", metavar="CREATE", action="store_true", default=False)
|
||||
parser.add_option("--ppm", dest="lo_ppm", help="LO correction in PPM", metavar="PPM", type="float", default=0.0)
|
||||
parser.add_option("--fc-pos", dest="fc_pos", help="Center frequency position 0:inf 1:sup 2:cen", metavar="ENUM", type="int", default=2)
|
||||
parser.add_option("--ppm", dest="lo_ppm", help="LO correction in PPM", metavar="PPM", type="float", default=0.0)
|
||||
parser.add_option("--fc-pos", dest="fc_pos", help="Center frequency position 0:inf 1:sup 2:cen", metavar="ENUM", type="int", default=2)
|
||||
parser.add_option("--sq", dest="squelch_db", help="Squelsch threshold in dB", metavar="DECIBEL", type="float", default=-50.0)
|
||||
parser.add_option("--sq-gate", dest="squelch_gate", help="Squelsch gate in ms", metavar="MILLISECONDS", type="int", default=50)
|
||||
parser.add_option("--stereo", dest="stereo", help="Broadcast FM stereo", metavar="BOOL", action="store_true", default=False)
|
||||
@ -50,32 +52,33 @@ def getInputOptions():
|
||||
parser.add_option("--dmn-port", dest="daemon_port", help="DaemonSink: destination data port", metavar="PORT", type="int")
|
||||
parser.add_option("--dmn-fec", dest="daemon_fec", help="DaemonSink: number of FEC blocks per frame", metavar="NUMBER", type="int")
|
||||
parser.add_option("--dmn-tx-delay", dest="daemon_tx_delay", help="DaemonSink: inter block UDP Tx delay percentage", metavar="PERCENT", 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 = 0
|
||||
|
||||
|
||||
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.antenna_path == None:
|
||||
options.antenna_path = 0
|
||||
|
||||
|
||||
if options.sample_rate == None:
|
||||
options.sample_rate = 2600
|
||||
|
||||
|
||||
return options
|
||||
|
||||
|
||||
# ======================================================================
|
||||
def printResponse(response):
|
||||
content_type = response.headers.get("Content-Type", None)
|
||||
@ -85,25 +88,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:
|
||||
#print(base_url, url, json)
|
||||
r = request_method(url=base_url+url, params=params, json=json)
|
||||
# print(base_url, url, 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 setup_audio(options):
|
||||
audio_dict = {}
|
||||
if options.audio_name: # must not be None and reference a valid audio device
|
||||
if options.audio_name: # must not be None and reference a valid audio device
|
||||
audio_dict["name"] = options.audio_name
|
||||
if options.audio_udp:
|
||||
audio_dict["copyToUDP"] = 0 if options.audio_udp == 0 else 1
|
||||
@ -114,39 +119,40 @@ def setup_audio(options):
|
||||
if options.audio_port:
|
||||
audio_dict["udpPort"] = options.audio_port
|
||||
if options.audio_channels:
|
||||
audio_dict["udpChannelMode"] = 0 if options.audio_channels < 0 else 3 if options.audio_channels > 3 else options.audio_channels
|
||||
|
||||
audio_dict["udpChannelMode"] = 0 if options.audio_channels < 0 else 3 if options.audio_channels > 3 else options.audio_channels
|
||||
|
||||
r = callAPI('/audio/output/parameters', "PATCH", None, audio_dict, "setup audio {}".format(options.audio_name))
|
||||
if r is None:
|
||||
exit(-1)
|
||||
|
||||
|
||||
# ======================================================================
|
||||
def setupDevice(deviceset_url, options):
|
||||
r = callAPI(deviceset_url + "/device", "PUT", None, {"hwType": "%s" % options.device_hwid, "tx": 0}, "setup device on Rx 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)
|
||||
|
||||
# calculate RF analog and FIR optimal bandpass filters bandwidths
|
||||
lpFIRBW = options.sample_rate*1000 / (1<<options.log2_decim)
|
||||
if options.fc_pos == 2: # center of passband
|
||||
lpfBW = options.sample_rate*1000 / (1<<options.log2_decim)
|
||||
else: # side of passband
|
||||
lpFIRBW = options.sample_rate * 1000 / (1 << options.log2_decim)
|
||||
if options.fc_pos == 2: # center of passband
|
||||
lpfBW = options.sample_rate * 1000 / (1 << options.log2_decim)
|
||||
else: # side of passband
|
||||
if options.log2_decim == 0:
|
||||
lpfBW = options.sample_rate*1000
|
||||
lpfBW = options.sample_rate * 1000
|
||||
elif options.log2_decim == 1:
|
||||
lpfBW = options.sample_rate*1000
|
||||
lpfBW = options.sample_rate * 1000
|
||||
elif options.log2_decim == 2:
|
||||
lpfBW = options.sample_rate*500
|
||||
lpfBW = options.sample_rate * 500
|
||||
else:
|
||||
lpfBW = options.sample_rate*750
|
||||
lpfBW = options.sample_rate * 750
|
||||
|
||||
if options.device_hwid == "Airspy":
|
||||
settings['airspySettings']['LOppmTenths'] = int(options.lo_ppm * 10) # in tenths of PPM
|
||||
settings["airspySettings"]["centerFrequency"] = options.device_freq*1000
|
||||
settings['airspySettings']['LOppmTenths'] = int(options.lo_ppm * 10) # in tenths of PPM
|
||||
settings["airspySettings"]["centerFrequency"] = options.device_freq * 1000
|
||||
settings["airspySettings"]["devSampleRateIndex"] = 1
|
||||
settings['airspySettings']['log2Decim'] = options.log2_decim
|
||||
settings['airspySettings']['fcPos'] = options.fc_pos
|
||||
@ -162,16 +168,16 @@ def setupDevice(deviceset_url, options):
|
||||
settings["airspyHFSettings"]["bandIndex"] = 1
|
||||
else:
|
||||
settings["airspyHFSettings"]["bandIndex"] = 0
|
||||
settings["airspyHFSettings"]["centerFrequency"] = options.device_freq*1000
|
||||
settings["airspyHFSettings"]["centerFrequency"] = options.device_freq * 1000
|
||||
settings["airspyHFSettings"]["devSampleRateIndex"] = 0
|
||||
settings['airspyHFSettings']['log2Decim'] = options.log2_decim
|
||||
settings['airspyHFSettings']['LOppmTenths'] = int(options.lo_ppm * 10) # in tenths of PPM
|
||||
elif options.device_hwid == "LimeSDR":
|
||||
settings["limeSdrInputSettings"]["antennaPath"] = options.antenna_path
|
||||
settings["limeSdrInputSettings"]["devSampleRate"] = options.sample_rate*1000
|
||||
settings["limeSdrInputSettings"]["devSampleRate"] = options.sample_rate * 1000
|
||||
settings["limeSdrInputSettings"]["log2HardDecim"] = 4
|
||||
settings["limeSdrInputSettings"]["log2SoftDecim"] = options.log2_decim
|
||||
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"] = lpfBW
|
||||
@ -180,10 +186,10 @@ def setupDevice(deviceset_url, options):
|
||||
settings['limeSdrInputSettings']['dcBlock'] = 1
|
||||
elif options.device_hwid == "PlutoSDR":
|
||||
settings["plutoSdrInputSettings"]["antennaPath"] = options.antenna_path
|
||||
settings["plutoSdrInputSettings"]["devSampleRate"] = options.sample_rate*1000
|
||||
settings["plutoSdrInputSettings"]["devSampleRate"] = options.sample_rate * 1000
|
||||
settings["plutoSdrInputSettings"]["lpfFIRlog2Decim"] = 1
|
||||
settings["plutoSdrInputSettings"]["log2Decim"] = options.log2_decim
|
||||
settings["plutoSdrInputSettings"]["centerFrequency"] = options.device_freq*1000
|
||||
settings["plutoSdrInputSettings"]["centerFrequency"] = options.device_freq * 1000
|
||||
settings["plutoSdrInputSettings"]["lpfBW"] = lpfBW
|
||||
settings["plutoSdrInputSettings"]["lpfFIRBW"] = lpFIRBW
|
||||
settings["plutoSdrInputSettings"]["lpfFIREnable"] = 1
|
||||
@ -192,8 +198,8 @@ def setupDevice(deviceset_url, options):
|
||||
settings['plutoSdrInputSettings']['iqImbalance'] = options.fc_pos == 2
|
||||
settings['plutoSdrInputSettings']['LOppmTenths'] = int(options.lo_ppm * 10) # in tenths of PPM
|
||||
elif options.device_hwid == "RTLSDR":
|
||||
settings['rtlSdrSettings']['devSampleRate'] = options.sample_rate*1000
|
||||
settings['rtlSdrSettings']['centerFrequency'] = options.device_freq*1000
|
||||
settings['rtlSdrSettings']['devSampleRate'] = options.sample_rate * 1000
|
||||
settings['rtlSdrSettings']['centerFrequency'] = options.device_freq * 1000
|
||||
settings['rtlSdrSettings']['gain'] = 496
|
||||
settings['rtlSdrSettings']['log2Decim'] = options.log2_decim
|
||||
settings['rtlSdrSettings']['fcPos'] = options.fc_pos
|
||||
@ -201,35 +207,38 @@ def setupDevice(deviceset_url, options):
|
||||
settings['rtlSdrSettings']['iqImbalance'] = options.fc_pos == 2
|
||||
settings['rtlSdrSettings']['agc'] = 1
|
||||
settings['rtlSdrSettings']['loPpmCorrection'] = int(options.lo_ppm)
|
||||
if options.device_rfbw:
|
||||
settings['rtlSdrSettings']['rfBandwidth'] = options.device_rfbw * 1000
|
||||
elif options.device_hwid == "HackRF":
|
||||
settings['hackRFInputSettings']['LOppmTenths'] = int(options.lo_ppm * 10) # in tenths of PPM
|
||||
settings['hackRFInputSettings']['centerFrequency'] = options.device_freq*1000
|
||||
settings['hackRFInputSettings']['fcPos'] = options.fc_pos
|
||||
settings['hackRFInputSettings']['LOppmTenths'] = int(options.lo_ppm * 10) # in tenths of PPM
|
||||
settings['hackRFInputSettings']['centerFrequency'] = options.device_freq * 1000
|
||||
settings['hackRFInputSettings']['fcPos'] = options.fc_pos
|
||||
settings['hackRFInputSettings']['dcBlock'] = options.fc_pos == 2
|
||||
settings['hackRFInputSettings']['iqImbalance'] = options.fc_pos == 2
|
||||
settings['hackRFInputSettings']['devSampleRate'] = options.sample_rate*1000
|
||||
settings['hackRFInputSettings']['devSampleRate'] = options.sample_rate * 1000
|
||||
settings['hackRFInputSettings']['lnaExt'] = 1
|
||||
settings['hackRFInputSettings']['lnaGain'] = 32
|
||||
settings['hackRFInputSettings']['log2Decim'] = options.log2_decim
|
||||
settings['hackRFInputSettings']['vgaGain'] = 24
|
||||
elif options.device_hwid == "Perseus":
|
||||
settings['perseusSettings']['LOppmTenths'] = int(options.lo_ppm * 10) # in tenths of PPM
|
||||
settings['perseusSettings']['centerFrequency'] = options.device_freq*1000
|
||||
settings['perseusSettings']['LOppmTenths'] = int(options.lo_ppm * 10) # in tenths of PPM
|
||||
settings['perseusSettings']['centerFrequency'] = options.device_freq * 1000
|
||||
settings["perseusSettings"]["devSampleRateIndex"] = 0
|
||||
settings['perseusSettings']['log2Decim'] = options.log2_decim
|
||||
settings['perseusSettings']['adcDither'] = 0
|
||||
settings['perseusSettings']['adcPreamp'] = 0
|
||||
settings['perseusSettings']['wideBand'] = 0
|
||||
settings['perseusSettings']['attenuator'] = 0
|
||||
|
||||
|
||||
r = callAPI(deviceset_url + "/device/settings", "PATCH", None, settings, "Patch device settings")
|
||||
if r is None:
|
||||
exit(-1)
|
||||
|
||||
|
||||
# ======================================================================
|
||||
def setupChannel(deviceset_url, options):
|
||||
i = 0
|
||||
|
||||
|
||||
settings = callAPI(deviceset_url + "/channel", "POST", None, {"channelType": options.channel_id, "tx": 0}, "Create demod")
|
||||
if settings is None:
|
||||
exit(-1)
|
||||
@ -243,15 +252,15 @@ def setupChannel(deviceset_url, 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 == "BFMDemod":
|
||||
settings["BFMDemodSettings"]["inputFrequencyOffset"] = options.channel_freq
|
||||
settings["BFMDemodSettings"]["afBandwidth"] = options.af_bw * 1000
|
||||
settings["BFMDemodSettings"]["rfBandwidth"] = options.rf_bw
|
||||
settings["BFMDemodSettings"]["volume"] = options.volume
|
||||
settings["BFMDemodSettings"]["squelch"] = options.squelch_db # dB
|
||||
settings["BFMDemodSettings"]["squelch"] = options.squelch_db # dB
|
||||
settings["BFMDemodSettings"]["audioStereo"] = 1 if options.stereo else 0
|
||||
settings["BFMDemodSettings"]["lsbStereo"] = 1 if options.lsb_stereo else 0
|
||||
settings["BFMDemodSettings"]["rdsActive"] = 1 if options.rds else 0
|
||||
@ -261,7 +270,7 @@ def setupChannel(deviceset_url, options):
|
||||
settings["WFMDemodSettings"]["afBandwidth"] = options.af_bw * 1000
|
||||
settings["WFMDemodSettings"]["rfBandwidth"] = options.rf_bw
|
||||
settings["WFMDemodSettings"]["volume"] = options.volume
|
||||
settings["WFMDemodSettings"]["squelch"] = options.squelch_db # dB
|
||||
settings["WFMDemodSettings"]["squelch"] = options.squelch_db # dB
|
||||
settings["WFMDemodSettings"]["audioMute"] = 0
|
||||
settings["WFMDemodSettings"]["title"] = "Channel %d" % i
|
||||
elif options.channel_id == "AMDemod":
|
||||
@ -270,7 +279,7 @@ def setupChannel(deviceset_url, 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 == "SSBDemod":
|
||||
settings["SSBDemodSettings"]["inputFrequencyOffset"] = options.channel_freq
|
||||
settings["SSBDemodSettings"]["rfBandwidth"] = options.rf_bw
|
||||
@ -313,11 +322,12 @@ def setupChannel(deviceset_url, options):
|
||||
settings["DaemonSinkSettings"]["nbFECBlocks"] = options.daemon_fec
|
||||
if options.daemon_tx_delay:
|
||||
settings["DaemonSinkSettings"]["txDelay"] = options.daemon_tx_delay
|
||||
|
||||
|
||||
r = callAPI(deviceset_url + "/channel/%d/settings" % i, "PATCH", None, settings, "Change demod")
|
||||
if r is None:
|
||||
exit(-1)
|
||||
|
||||
|
||||
# ======================================================================
|
||||
def channelsReport(deviceset_url):
|
||||
report = callAPI(deviceset_url + "/channels/report", "GET", None, None, "Get channels report")
|
||||
@ -327,30 +337,30 @@ def channelsReport(deviceset_url):
|
||||
def main():
|
||||
try:
|
||||
options = getInputOptions()
|
||||
|
||||
|
||||
global base_url
|
||||
base_url = "http://%s/sdrangel" % options.address
|
||||
deviceset_url = "/deviceset/%d" % options.device_index
|
||||
|
||||
|
||||
if options.create:
|
||||
r = callAPI("/deviceset", "POST", {"tx": 0}, None, "Add Rx device set")
|
||||
if r is None:
|
||||
exit(-1)
|
||||
|
||||
setupDevice(deviceset_url, options)
|
||||
|
||||
setupDevice(deviceset_url, options)
|
||||
setupChannel(deviceset_url, options)
|
||||
|
||||
|
||||
r = callAPI(deviceset_url + "/device/run", "POST", None, None, "Start running device")
|
||||
if r is None:
|
||||
exit(-1)
|
||||
|
||||
|
||||
if options.audio_name:
|
||||
time.sleep(1)
|
||||
setup_audio(options)
|
||||
|
||||
|
||||
# if options.channel_id == "BFMDemod":
|
||||
# channelsReport(deviceset_url)
|
||||
|
||||
|
||||
except Exception, msg:
|
||||
tb = traceback.format_exc()
|
||||
print >> sys.stderr, tb
|
||||
|
Loading…
Reference in New Issue
Block a user