22 #include <QNetworkReply> 43 m_deviceAPI(deviceAPI),
52 m_fileSink =
new FileRecord(QString(
"test_%1.sdriq").
arg(m_deviceAPI->getDeviceUID()));
53 m_deviceAPI->setNbSourceStreams(1);
54 m_deviceAPI->addAncillarySink(m_fileSink);
55 m_networkManager =
new QNetworkAccessManager();
56 connect(m_networkManager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(networkManagerFinished(QNetworkReply*)));
86 qDebug() <<
"FCDProPlusInput::openDevice with device #" << device;
91 qCritical(
"FCDProPlusInput::start: could not open FCD");
97 qCritical(
"FCDProPlusInput::start: could not open FCD audio source");
102 qDebug(
"FCDProPlusInput::start: FCD audio source opened");
125 qDebug() <<
"FCDProPlusInput::start";
136 qCritical(
"FCDProPlusInput::start: could not allocate SampleFifo");
146 qDebug(
"FCDProPlusInput::started");
167 const QList<QAudioDeviceInfo>& audioList = audioDeviceManager->
getInputDevices();
169 for (
const auto &itAudio : audioList)
171 if (itAudio.deviceName().contains(QString(cardname)))
176 qDebug(
"FCDProPlusInput::openFCDAudio: %s index %d at %d S/s",
177 itAudio.deviceName().toStdString().c_str(), fcdDeviceIndex, fcdSampleRate);
183 qCritical(
"FCDProPlusInput::openFCDAudio: device with name %s not found", cardname);
195 QMutexLocker mutexLocker(&
m_mutex);
269 qDebug() <<
"FCDProPlusInput::handleMessage: MsgConfigureFCD";
277 qDebug() <<
"FCDProPlusInput::handleMessage: MsgStartStop: " << (cmd.
getStartStop() ?
"start" :
"stop");
300 qDebug() <<
"FCDProPlusInput::handleMessage: MsgFileRecord: " << conf.
getStartStop();
327 bool forwardChange =
false;
328 QList<QString> reverseAPIKeys;
331 reverseAPIKeys.append(
"centerFrequency");
334 reverseAPIKeys.append(
"transverterMode");
337 reverseAPIKeys.append(
"transverterDeltaFrequency");
340 reverseAPIKeys.append(
"LOppmTenths");
356 DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
363 qDebug() <<
"FCDProPlusInput::applySettings: center freq: " << settings.
m_centerFrequency <<
" Hz" 364 <<
" device center freq: " << deviceCenterFrequency <<
" Hz";
373 reverseAPIKeys.append(
"log2Decim");
374 forwardChange =
true;
379 qDebug() <<
"FCDProPlusInput::applySettings: set decimation to " << (1<<settings.
m_log2Decim);
385 reverseAPIKeys.append(
"fcPos");
391 qDebug() <<
"FCDProPlusInput::applySettings: set fc pos (enum) to " << (int) settings.
m_fcPos;
396 reverseAPIKeys.append(
"lnaGain");
405 reverseAPIKeys.append(
"biasT");
414 reverseAPIKeys.append(
"mixGain");
423 reverseAPIKeys.append(
"ifGain");
432 reverseAPIKeys.append(
"ifFilterIndex");
441 reverseAPIKeys.append(
"rfFilterIndex");
450 reverseAPIKeys.append(
"dcBlock");
456 reverseAPIKeys.append(
"iqImbalance");
485 qDebug(
"No FCD HID found for frquency change");
491 quint8 cmd = on ? 1 : 0;
498 quint8 cmd = on ? 1 : 0;
505 quint8 cmd = on ? 1 : 0;
517 quint8 cmd_value = gain;
521 qWarning() <<
"FCDProPlusInput::set_if_gain: failed to set at " << cmd_value;
536 qWarning() <<
"FCDProPlusInput::set_if_filter: failed to set at " << cmd_value;
552 qWarning() <<
"FCDProPlusInput::set_rf_filter: failed to set at " << cmd_value;
558 QString& errorMessage)
568 QString& errorMessage)
586 QString& errorMessage)
597 const QStringList& deviceSettingsKeys,
599 QString& errorMessage)
604 if (deviceSettingsKeys.contains(
"centerFrequency")) {
607 if (deviceSettingsKeys.contains(
"log2Decim")) {
610 if (deviceSettingsKeys.contains(
"fcPos")) {
613 if (deviceSettingsKeys.contains(
"rangeLow")) {
616 if (deviceSettingsKeys.contains(
"lnaGain")) {
619 if (deviceSettingsKeys.contains(
"mixGain")) {
622 if (deviceSettingsKeys.contains(
"biasT")) {
625 if (deviceSettingsKeys.contains(
"ifGain")) {
628 if (deviceSettingsKeys.contains(
"ifFilterIndex")) {
631 if (deviceSettingsKeys.contains(
"rfFilterIndex")) {
634 if (deviceSettingsKeys.contains(
"LOppmTenths")) {
637 if (deviceSettingsKeys.contains(
"dcBlock")) {
640 if (deviceSettingsKeys.contains(
"iqImbalance")) {
643 if (deviceSettingsKeys.contains(
"transverterDeltaFrequency")) {
646 if (deviceSettingsKeys.contains(
"transverterMode")) {
649 if (deviceSettingsKeys.contains(
"fileRecordName")) {
652 if (deviceSettingsKeys.contains(
"useReverseAPI")) {
655 if (deviceSettingsKeys.contains(
"reverseAPIAddress")) {
658 if (deviceSettingsKeys.contains(
"reverseAPIPort")) {
661 if (deviceSettingsKeys.contains(
"reverseAPIDeviceIndex")) {
725 if (deviceSettingsKeys.contains(
"centerFrequency") || force) {
728 if (deviceSettingsKeys.contains(
"log2Decim") || force) {
731 if (deviceSettingsKeys.contains(
"fcPos") || force) {
734 if (deviceSettingsKeys.contains(
"rangeLow") || force) {
737 if (deviceSettingsKeys.contains(
"lnaGain") || force) {
740 if (deviceSettingsKeys.contains(
"mixGain") || force) {
743 if (deviceSettingsKeys.contains(
"biasT") || force) {
746 if (deviceSettingsKeys.contains(
"ifGain") || force) {
749 if (deviceSettingsKeys.contains(
"ifFilterIndex") || force) {
752 if (deviceSettingsKeys.contains(
"rfFilterIndex") || force) {
755 if (deviceSettingsKeys.contains(
"LOppmTenths") || force) {
758 if (deviceSettingsKeys.contains(
"dcBlock") || force) {
761 if (deviceSettingsKeys.contains(
"iqImbalance") || force) {
764 if (deviceSettingsKeys.contains(
"transverterDeltaFrequency") || force) {
767 if (deviceSettingsKeys.contains(
"transverterMode") || force) {
770 if (deviceSettingsKeys.contains(
"fileRecordName") || force) {
774 QString deviceSettingsURL = QString(
"http://%1:%2/sdrangel/deviceset/%3/device/settings")
779 m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader,
"application/json");
781 QBuffer *buffer=
new QBuffer();
782 buffer->open((QBuffer::ReadWrite));
783 buffer->write(swgDeviceSettings->
asJson().toUtf8());
789 delete swgDeviceSettings;
799 QString deviceSettingsURL = QString(
"http://%1:%2/sdrangel/deviceset/%3/device/run")
804 m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader,
"application/json");
806 QBuffer *buffer=
new QBuffer();
807 buffer->open((QBuffer::ReadWrite));
808 buffer->write(swgDeviceSettings->
asJson().toUtf8());
817 delete swgDeviceSettings;
822 QNetworkReply::NetworkError replyError = reply->error();
826 qWarning() <<
"FCDProPlusInput::networkManagerFinished:" 827 <<
" error(" << (int) replyError
828 <<
"): " << replyError
829 <<
": " << reply->errorString();
833 QString answer = reply->readAll();
835 qDebug(
"FCDProPlusInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
const QList< QAudioDeviceInfo > & getInputDevices() const
bool startDeviceEngine()
Start the device engine corresponding to the stream type.
FCD_MODE_ENUM fcdAppSetParam(hid_device *phd, uint8_t u8Cmd, uint8_t *pu8Data, uint8_t u8len)
Write FCD parameter (e.g. gain or filter)
void setRangeLow(qint32 range_low)
static qint64 calculateDeviceCenterFrequency(quint64 centerFrequency, qint64 transverterDeltaFrequency, int log2Decim, fcPos_t fcPos, quint32 devSampleRate, FrequencyShiftScheme frequencyShiftScheme, bool transverterMode=false)
void fcdClose(hid_device *phd)
Close FCD HID device.
void push(Message *message, bool emitSignal=true)
Push message onto queue.
void stopDeviceEngine()
Stop the device engine corresponding to the stream type.
qint64 getCenterFrequency()
void setRfFilterIndex(qint32 rf_filter_index)
static const fcdproplus_rf_filter rf_filters[]
void setFileName(const QString &filename)
uint getDeviceUID() const
Return the current device engine unique ID.
qint64 m_transverterDeltaFrequency
FCD_MODE_ENUM fcdAppSetFreq(hid_device *phd, int nFreq)
Set FCD frequency with Hz resolution.
qint64 getTransverterDeltaFrequency()
MessageQueue m_inputMessageQueue
Input queue to the source.
virtual QString asJson() override
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
#define FCDPROPLUS_HID_CMD_SET_LNA_GAIN
void setDcBlock(qint32 dc_block)
qint32 getReverseApiDeviceIndex()
QString m_reverseAPIAddress
#define FCDPROPLUS_HID_CMD_SET_IF_GAIN
static const fcdproplus_if_filter if_filters[]
QByteArray serialize() const
bool initDeviceEngine()
Init the device engine corresponding to the stream type.
void setIfGain(qint32 if_gain)
#define FCDPROPLUS_HID_CMD_SET_RF_FILTER
static int fcdproplus_rf_filter_nb_values()
void setOriginatorIndex(qint32 originator_index)
void setReverseApiPort(qint32 reverse_api_port)
quint64 m_centerFrequency
SampleSinkFifo m_sampleFifo
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
virtual bool handleMessage(const Message &message)
Processing of a message. Returns true if message has actually been processed.
#define FCDPROPLUS_HID_CMD_SET_BIAS_TEE
fcdproplus_rf_filter_value value
void setCenterFrequency(qint64 center_frequency)
void setIfFilterIndex(qint32 if_filter_index)
void setLog2Decim(qint32 log2_decim)
int getDeviceSetIndex() const
void setTransverterMode(qint32 transverter_mode)
hid_device * fcdOpen(uint16_t usVID, uint16_t usPID, int whichdongle)
Open FCD device.
#define MESSAGE_CLASS_DEFINITION(Name, BaseClass)
void genUniqueFileName(uint deviceUID, int istream=-1)
qint32 getIfFilterIndex()
QString * getFileRecordName()
void setLog2Decimation(unsigned int log2_decim)
static DSPEngine * instance()
QString * getReverseApiAddress()
void setFileRecordName(QString *file_record_name)
static int fcdproplus_if_filter_nb_values()
static bool match(const Message *message)
void setIqImbalance(qint32 iq_imbalance)
void setLOppmTenths(qint32 l_oppm_tenths)
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void removeAncillarySink(BasebandSampleSink *sink, unsigned int index=0)
Removes it.
SWGFCDProPlusSettings * getFcdProPlusSettings()
bool deserialize(const QByteArray &data)
void setBiasT(qint32 bias_t)
qint32 getUseReverseApi()
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
void setLnaGain(qint32 lna_gain)
#define FCDPROPLUS_HID_CMD_SET_MIXER_GAIN
void setTransverterDeltaFrequency(qint64 transverter_delta_frequency)
void getDeviceEngineStateStr(QString &state)
void setFcdProPlusSettings(SWGFCDProPlusSettings *fcd_pro_plus_settings)
fcdproplus_if_filter_value value
AudioDeviceManager * getAudioDeviceManager()
#define FCDPROPLUS_HID_CMD_SET_IF_FILTER
qint32 getTransverterMode()
int getInputDeviceIndex(const QString &deviceName) const
void setUseReverseApi(qint32 use_reverse_api)
void setFcPos(qint32 fc_pos)
qint32 getRfFilterIndex()
void setMixGain(qint32 mix_gain)
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection, int streamIndex=0)
Configure current device engine DSP corrections (Rx)
uint32_t getSamplingDeviceSequence() const
void setDirection(qint32 direction)
uint16_t m_reverseAPIDeviceIndex
qint32 getReverseApiPort()
void setDeviceHwType(QString *device_hw_type)
void setReverseApiAddress(QString *reverse_api_address)
uint16_t m_reverseAPIPort