mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 01:55:48 -05:00
BladerRF2 input support (5). Global notification of changes to buddies
This commit is contained in:
parent
df505fcdef
commit
7dfe094364
@ -61,27 +61,18 @@ public:
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
bool getBiasTee() const { return m_biasTee; }
|
||||
bool getRxElseTx() const { return m_rxElseTx; }
|
||||
|
||||
static MsgReportBuddyChange* create(
|
||||
bool biasTee,
|
||||
bool rxElseTx)
|
||||
static MsgReportBuddyChange* create(bool rxElseTx)
|
||||
{
|
||||
return new MsgReportBuddyChange(
|
||||
biasTee,
|
||||
rxElseTx);
|
||||
return new MsgReportBuddyChange(rxElseTx);
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_biasTee;
|
||||
bool m_rxElseTx; //!< tells which side initiated the message
|
||||
bool m_rxElseTx; //!< tells which side initiated the message
|
||||
|
||||
MsgReportBuddyChange(
|
||||
bool biasTee,
|
||||
bool rxElseTx) :
|
||||
MsgReportBuddyChange(bool rxElseTx) :
|
||||
Message(),
|
||||
m_biasTee(biasTee),
|
||||
m_rxElseTx(rxElseTx)
|
||||
{ }
|
||||
};
|
||||
|
@ -434,17 +434,97 @@ bool BladeRF2Input::handleMessage(const Message& message)
|
||||
else if (DeviceBladeRF2Shared::MsgReportBuddyChange::match(message))
|
||||
{
|
||||
DeviceBladeRF2Shared::MsgReportBuddyChange& report = (DeviceBladeRF2Shared::MsgReportBuddyChange&) message;
|
||||
struct bladerf *dev = m_deviceShared.m_dev->getDev();
|
||||
BladeRF2InputSettings settings = m_settings;
|
||||
int status;
|
||||
int tmp_int;
|
||||
unsigned int tmp_uint;
|
||||
uint64_t tmp_uint64;
|
||||
bool tmp_bool;
|
||||
bladerf_gain_mode tmp_gain_mode;
|
||||
|
||||
if (report.getRxElseTx())
|
||||
{
|
||||
m_settings.m_biasTee = report.getBiasTee();
|
||||
}
|
||||
// evaluate changes that may have been introduced by changes in a buddy
|
||||
|
||||
if (getMessageQueueToGUI())
|
||||
if (dev) // The BladeRF device must have been open to do so
|
||||
{
|
||||
DeviceBladeRF2Shared::MsgReportBuddyChange *reportToGUI = DeviceBladeRF2Shared::MsgReportBuddyChange::create(
|
||||
m_settings.m_biasTee, true);
|
||||
getMessageQueueToGUI()->push(reportToGUI);
|
||||
if (report.getRxElseTx()) // Rx buddy change: check for: frequency, gain mode and value, bias tee, sample rate, bandwidth
|
||||
{
|
||||
status = bladerf_get_sample_rate(dev, BLADERF_CHANNEL_RX(m_deviceShared.m_channel), &tmp_uint);
|
||||
|
||||
if (status < 0) {
|
||||
qCritical("BladeRF2Input::handleMessage: MsgReportBuddyChange: bladerf_get_sample_rate error: %s", bladerf_strerror(status));
|
||||
} else {
|
||||
settings.m_devSampleRate = tmp_uint;
|
||||
}
|
||||
|
||||
status = bladerf_get_frequency(dev, BLADERF_CHANNEL_RX(m_deviceShared.m_channel), &tmp_uint64);
|
||||
|
||||
if (status < 0) {
|
||||
qCritical("BladeRF2Input::handleMessage: MsgReportBuddyChange: bladerf_get_frequency error: %s", bladerf_strerror(status));
|
||||
} else {
|
||||
settings.m_centerFrequency = tmp_uint64;
|
||||
}
|
||||
|
||||
status = bladerf_get_bandwidth(dev, BLADERF_CHANNEL_RX(m_deviceShared.m_channel), &tmp_uint);
|
||||
|
||||
if (status < 0) {
|
||||
qCritical("BladeRF2Input::handleMessage: MsgReportBuddyChange: bladerf_get_bandwidth error: %s", bladerf_strerror(status));
|
||||
} else {
|
||||
settings.m_bandwidth = tmp_uint;
|
||||
}
|
||||
|
||||
status = bladerf_get_gain_mode(dev, BLADERF_CHANNEL_RX(m_deviceShared.m_channel), &tmp_gain_mode);
|
||||
|
||||
if (status < 0) {
|
||||
qCritical("BladeRF2Input::handleMessage: MsgReportBuddyChange: bladerf_get_gain_mode error: %s", bladerf_strerror(status));
|
||||
} else {
|
||||
settings.m_gainMode = (int) tmp_gain_mode;
|
||||
}
|
||||
|
||||
status = bladerf_get_gain(dev, BLADERF_CHANNEL_RX(m_deviceShared.m_channel), &tmp_int);
|
||||
|
||||
if (status < 0) {
|
||||
qCritical("BladeRF2Input::handleMessage: MsgReportBuddyChange: bladerf_get_gain error: %s", bladerf_strerror(status));
|
||||
} else {
|
||||
settings.m_globalGain = tmp_int;
|
||||
}
|
||||
|
||||
status = bladerf_get_bias_tee(dev, BLADERF_CHANNEL_RX(m_deviceShared.m_channel), &tmp_bool);
|
||||
|
||||
if (status < 0) {
|
||||
qCritical("BladeRF2Input::handleMessage: MsgReportBuddyChange: bladerf_get_bias_tee error: %s", bladerf_strerror(status));
|
||||
} else {
|
||||
settings.m_biasTee = tmp_bool;
|
||||
}
|
||||
}
|
||||
else // Tx buddy change: check for sample rate change only
|
||||
{
|
||||
status = bladerf_get_sample_rate(dev, BLADERF_CHANNEL_RX(m_deviceShared.m_channel), &tmp_uint);
|
||||
|
||||
if (status < 0) {
|
||||
qCritical("BladeRF2Input::handleMessage: MsgReportBuddyChange: bladerf_get_sample_rate error: %s", bladerf_strerror(status));
|
||||
} else {
|
||||
settings.m_devSampleRate = tmp_uint;
|
||||
}
|
||||
}
|
||||
|
||||
// change DSP settings if buddy change introduced a change in center frequency or base rate
|
||||
if ((settings.m_centerFrequency != m_settings.m_centerFrequency) || (settings.m_devSampleRate != m_settings.m_devSampleRate))
|
||||
{
|
||||
int sampleRate = settings.m_devSampleRate/(1<<settings.m_log2Decim);
|
||||
DSPSignalNotification *notif = new DSPSignalNotification(sampleRate, settings.m_centerFrequency);
|
||||
m_fileSink->handleMessage(*notif); // forward to file sink
|
||||
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
||||
}
|
||||
|
||||
m_settings = settings; // acknowledge the new settings
|
||||
|
||||
// propagate settings to GUI if any
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
MsgConfigureBladeRF2 *reportToGUI = MsgConfigureBladeRF2::create(m_settings, false);
|
||||
getMessageQueueToGUI()->push(reportToGUI);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -499,8 +579,8 @@ bool BladeRF2Input::handleMessage(const Message& message)
|
||||
bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool force)
|
||||
{
|
||||
bool forwardChangeOwnDSP = false;
|
||||
bool forwardChangeRxDSP = false;
|
||||
bool forwardChangeAllDSP __attribute__((unused)) = false;
|
||||
bool forwardChangeRxBuddies = false;
|
||||
bool forwardChangeTxBuddies = false;
|
||||
|
||||
struct bladerf *dev = m_deviceShared.m_dev->getDev();
|
||||
qDebug() << "BladeRF2Input::applySettings: m_dev: " << dev;
|
||||
@ -514,6 +594,8 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo
|
||||
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force)
|
||||
{
|
||||
forwardChangeOwnDSP = true;
|
||||
forwardChangeRxBuddies = true;
|
||||
forwardChangeTxBuddies = true;
|
||||
|
||||
if (dev != 0)
|
||||
{
|
||||
@ -534,6 +616,8 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo
|
||||
|
||||
if ((m_settings.m_bandwidth != settings.m_bandwidth) || force)
|
||||
{
|
||||
forwardChangeRxBuddies = true;
|
||||
|
||||
if (dev != 0)
|
||||
{
|
||||
unsigned int actualBandwidth;
|
||||
@ -584,6 +668,7 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo
|
||||
settings.m_devSampleRate);
|
||||
|
||||
forwardChangeOwnDSP = true;
|
||||
forwardChangeRxBuddies = true;
|
||||
|
||||
if (dev != 0)
|
||||
{
|
||||
@ -600,12 +685,14 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo
|
||||
|
||||
if ((m_settings.m_biasTee != settings.m_biasTee) || force)
|
||||
{
|
||||
forwardChangeRxBuddies = true;
|
||||
m_deviceShared.m_dev->setBiasTeeRx(settings.m_biasTee);
|
||||
forwardChangeRxDSP = true;
|
||||
}
|
||||
|
||||
if ((m_settings.m_globalGain != settings.m_globalGain) || force)
|
||||
{
|
||||
forwardChangeRxBuddies = true;
|
||||
|
||||
if (dev)
|
||||
{
|
||||
int status = bladerf_set_gain(dev, BLADERF_CHANNEL_RX(m_deviceShared.m_channel), settings.m_globalGain);
|
||||
@ -621,6 +708,8 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo
|
||||
|
||||
if ((m_settings.m_gainMode != settings.m_gainMode) || force)
|
||||
{
|
||||
forwardChangeRxBuddies = true;
|
||||
|
||||
if (dev)
|
||||
{
|
||||
int status = bladerf_set_gain_mode(dev, BLADERF_CHANNEL_RX(m_deviceShared.m_channel), (bladerf_gain_mode) settings.m_gainMode);
|
||||
@ -642,7 +731,7 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo
|
||||
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
||||
}
|
||||
|
||||
if (forwardChangeRxDSP)
|
||||
if (forwardChangeRxBuddies)
|
||||
{
|
||||
// send to source buddies
|
||||
const std::vector<DeviceSourceAPI*>& sourceBuddies = m_deviceAPI->getSourceBuddies();
|
||||
@ -650,12 +739,24 @@ bool BladeRF2Input::applySettings(const BladeRF2InputSettings& settings, bool fo
|
||||
|
||||
for (; itSource != sourceBuddies.end(); ++itSource)
|
||||
{
|
||||
DeviceBladeRF2Shared::MsgReportBuddyChange *report = DeviceBladeRF2Shared::MsgReportBuddyChange::create(
|
||||
settings.m_biasTee, true);
|
||||
DeviceBladeRF2Shared::MsgReportBuddyChange *report = DeviceBladeRF2Shared::MsgReportBuddyChange::create(true);
|
||||
(*itSource)->getSampleSourceInputMessageQueue()->push(report);
|
||||
}
|
||||
}
|
||||
|
||||
if (forwardChangeTxBuddies)
|
||||
{
|
||||
// send to sink buddies
|
||||
const std::vector<DeviceSinkAPI*>& sinkBuddies = m_deviceAPI->getSinkBuddies();
|
||||
std::vector<DeviceSinkAPI*>::const_iterator itSink = sinkBuddies.begin();
|
||||
|
||||
for (; itSink != sinkBuddies.end(); ++itSink)
|
||||
{
|
||||
DeviceBladeRF2Shared::MsgReportBuddyChange *report = DeviceBladeRF2Shared::MsgReportBuddyChange::create(true);
|
||||
(*itSink)->getSampleSinkInputMessageQueue()->push(report);
|
||||
}
|
||||
}
|
||||
|
||||
m_settings = settings;
|
||||
|
||||
qDebug() << "BladeRF2Input::applySettings: "
|
||||
|
Loading…
Reference in New Issue
Block a user