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() <<
"FCDProInput::openDevice with device #" << device;
91 qCritical(
"FCDProInput::start: could not open FCD");
97 qCritical(
"FCDProInput::start: could not open FCD audio source");
102 qDebug(
"FCDProInput::start: FCD audio source opened");
115 qDebug() <<
"FCDProInput::start";
134 qCritical(
"Could not allocate SampleFifo");
144 qDebug(
"FCDProInput::started");
165 const QList<QAudioDeviceInfo>& audioList = audioDeviceManager->
getInputDevices();
167 for (
const auto &itAudio : audioList)
169 if (itAudio.deviceName().contains(QString(cardname)))
174 qDebug(
"FCDProPlusInput::openFCDAudio: %s index %d at %d S/s",
175 itAudio.deviceName().toStdString().c_str(), fcdDeviceIndex, fcdSampleRate);
181 qCritical(
"FCDProInput::openFCDAudio: device with name %s not found", cardname);
267 qDebug() <<
"FCDProInput::handleMessage: MsgConfigureFCD";
275 qDebug() <<
"FCDProInput::handleMessage: MsgStartStop: " << (cmd.
getStartStop() ?
"start" :
"stop");
298 qDebug() <<
"FCDProInput::handleMessage: MsgFileRecord: " << conf.
getStartStop();
325 bool forwardChange =
false;
326 QList<QString> reverseAPIKeys;
329 reverseAPIKeys.append(
"centerFrequency");
332 reverseAPIKeys.append(
"transverterMode");
335 reverseAPIKeys.append(
"transverterDeltaFrequency");
338 reverseAPIKeys.append(
"LOppmTenths");
354 DeviceSampleSource::FrequencyShiftScheme::FSHIFT_STD,
362 qDebug() <<
"FCDProInput::applySettings: center freq: " << settings.
m_centerFrequency <<
" Hz" 363 <<
" device center freq: " << deviceCenterFrequency <<
" Hz";
372 reverseAPIKeys.append(
"log2Decim");
373 forwardChange =
true;
378 qDebug() <<
"FCDProInput::applySettings: set decimation to " << (1<<settings.
m_log2Decim);
384 reverseAPIKeys.append(
"fcPos");
390 qDebug() <<
"FCDProInput::applySettings: set fc pos (enum) to " << (int) settings.
m_fcPos;
395 reverseAPIKeys.append(
"lnaGainIndex");
404 reverseAPIKeys.append(
"rfFilterIndex");
413 reverseAPIKeys.append(
"lnaEnhanceIndex");
422 reverseAPIKeys.append(
"bandIndex");
431 reverseAPIKeys.append(
"mixerGainIndex");
440 reverseAPIKeys.append(
"mixerFilterIndex");
449 reverseAPIKeys.append(
"biasCurrentIndex");
458 reverseAPIKeys.append(
"modeIndex");
467 reverseAPIKeys.append(
"gain1Index");
476 reverseAPIKeys.append(
"rcFilterIndex");
485 reverseAPIKeys.append(
"gain2Index");
494 reverseAPIKeys.append(
"gain3Index");
503 reverseAPIKeys.append(
"gain4Index");
512 reverseAPIKeys.append(
"ifFilterIndex");
521 reverseAPIKeys.append(
"gain5Index");
530 reverseAPIKeys.append(
"gain6Index");
539 reverseAPIKeys.append(
"dcBlock");
545 reverseAPIKeys.append(
"iqCorrection");
574 qDebug(
"No FCD HID found for frquency change");
599 qWarning() <<
"FCDProPlusInput::set_lnaGain: failed to set at " << cmd_value;
614 qWarning() <<
"FCDProPlusInput::set_rfFilter: failed to set at " << cmd_value;
629 qWarning() <<
"FCDProPlusInput::set_lnaEnhance: failed to set at " << cmd_value;
644 qWarning() <<
"FCDProPlusInput::set_band: failed to set at " << cmd_value;
659 qWarning() <<
"FCDProPlusInput::set_mixerGain: failed to set at " << cmd_value;
674 qWarning() <<
"FCDProPlusInput::set_mixerFilter: failed to set at " << cmd_value;
689 qWarning() <<
"FCDProPlusInput::set_biasCurrent: failed to set at " << cmd_value;
704 qWarning() <<
"FCDProPlusInput::set_mode: failed to set at " << cmd_value;
719 qWarning() <<
"FCDProPlusInput::set_gain1: failed to set at " << cmd_value;
734 qWarning() <<
"FCDProPlusInput::set_rcFilter: failed to set at " << cmd_value;
749 qWarning() <<
"FCDProPlusInput::set_gain2: failed to set at " << cmd_value;
764 qWarning() <<
"FCDProPlusInput::set_gain3: failed to set at " << cmd_value;
779 qWarning() <<
"FCDProPlusInput::set_gain4: failed to set at " << cmd_value;
794 qWarning() <<
"FCDProPlusInput::set_ifFilter: failed to set at " << cmd_value;
810 qWarning() <<
"FCDProPlusInput::set_gain5: failed to set at " << cmd_value;
825 qWarning() <<
"FCDProPlusInput::set_gain6: failed to set at " << cmd_value;
831 QString& errorMessage)
841 QString& errorMessage)
859 QString& errorMessage)
870 const QStringList& deviceSettingsKeys,
872 QString& errorMessage)
877 if (deviceSettingsKeys.contains(
"centerFrequency")) {
880 if (deviceSettingsKeys.contains(
"LOppmTenths")) {
883 if (deviceSettingsKeys.contains(
"lnaGainIndex")) {
886 if (deviceSettingsKeys.contains(
"rfFilterIndex")) {
889 if (deviceSettingsKeys.contains(
"lnaEnhanceIndex")) {
892 if (deviceSettingsKeys.contains(
"bandIndex")) {
895 if (deviceSettingsKeys.contains(
"mixerGainIndex")) {
898 if (deviceSettingsKeys.contains(
"mixerFilterIndex")) {
901 if (deviceSettingsKeys.contains(
"biasCurrentIndex")) {
904 if (deviceSettingsKeys.contains(
"modeIndex")) {
907 if (deviceSettingsKeys.contains(
"gain1Index")) {
910 if (deviceSettingsKeys.contains(
"gain2Index")) {
913 if (deviceSettingsKeys.contains(
"gain3Index")) {
916 if (deviceSettingsKeys.contains(
"gain4Index")) {
919 if (deviceSettingsKeys.contains(
"gain5Index")) {
922 if (deviceSettingsKeys.contains(
"gain6Index")) {
925 if (deviceSettingsKeys.contains(
"log2Decim")) {
928 if (deviceSettingsKeys.contains(
"fcPos")) {
931 if (deviceSettingsKeys.contains(
"rcFilterIndex")) {
934 if (deviceSettingsKeys.contains(
"ifFilterIndex")) {
937 if (deviceSettingsKeys.contains(
"dcBlock")) {
940 if (deviceSettingsKeys.contains(
"iqCorrection")) {
943 if (deviceSettingsKeys.contains(
"transverterDeltaFrequency")) {
946 if (deviceSettingsKeys.contains(
"transverterMode")) {
949 if (deviceSettingsKeys.contains(
"fileRecordName")) {
952 if (deviceSettingsKeys.contains(
"useReverseAPI")) {
955 if (deviceSettingsKeys.contains(
"reverseAPIAddress")) {
958 if (deviceSettingsKeys.contains(
"reverseAPIPort")) {
961 if (deviceSettingsKeys.contains(
"reverseAPIDeviceIndex")) {
1034 if (deviceSettingsKeys.contains(
"centerFrequency") || force) {
1037 if (deviceSettingsKeys.contains(
"LOppmTenths") || force) {
1040 if (deviceSettingsKeys.contains(
"lnaGainIndex") || force) {
1043 if (deviceSettingsKeys.contains(
"rfFilterIndex") || force) {
1046 if (deviceSettingsKeys.contains(
"lnaEnhanceIndex") || force) {
1049 if (deviceSettingsKeys.contains(
"bandIndex") || force) {
1052 if (deviceSettingsKeys.contains(
"mixerGainIndex") || force) {
1055 if (deviceSettingsKeys.contains(
"mixerFilterIndex") || force) {
1058 if (deviceSettingsKeys.contains(
"biasCurrentIndex") || force) {
1061 if (deviceSettingsKeys.contains(
"modeIndex") || force) {
1064 if (deviceSettingsKeys.contains(
"gain1Index") || force) {
1067 if (deviceSettingsKeys.contains(
"gain2Index") || force) {
1070 if (deviceSettingsKeys.contains(
"gain3Index") || force) {
1073 if (deviceSettingsKeys.contains(
"gain4Index") || force) {
1076 if (deviceSettingsKeys.contains(
"gain5Index") || force) {
1079 if (deviceSettingsKeys.contains(
"gain6Index") || force) {
1082 if (deviceSettingsKeys.contains(
"log2Decim") || force) {
1085 if (deviceSettingsKeys.contains(
"fcPos") || force) {
1088 if (deviceSettingsKeys.contains(
"rcFilterIndex") || force) {
1091 if (deviceSettingsKeys.contains(
"ifFilterIndex") || force) {
1094 if (deviceSettingsKeys.contains(
"dcBlock") || force) {
1097 if (deviceSettingsKeys.contains(
"iqCorrection") || force) {
1100 if (deviceSettingsKeys.contains(
"transverterDeltaFrequency") || force) {
1103 if (deviceSettingsKeys.contains(
"transverterMode") || force) {
1106 if (deviceSettingsKeys.contains(
"fileRecordName") || force) {
1110 QString deviceSettingsURL = QString(
"http://%1:%2/sdrangel/deviceset/%3/device/settings")
1115 m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader,
"application/json");
1117 QBuffer *buffer=
new QBuffer();
1118 buffer->open((QBuffer::ReadWrite));
1119 buffer->write(swgDeviceSettings->
asJson().toUtf8());
1125 delete swgDeviceSettings;
1135 QString deviceSettingsURL = QString(
"http://%1:%2/sdrangel/deviceset/%3/device/run")
1140 m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader,
"application/json");
1142 QBuffer *buffer=
new QBuffer();
1143 buffer->open((QBuffer::ReadWrite));
1144 buffer->write(swgDeviceSettings->
asJson().toUtf8());
1153 delete swgDeviceSettings;
1158 QNetworkReply::NetworkError replyError = reply->error();
1162 qWarning() <<
"FCDProInput::networkManagerFinished:" 1163 <<
" error(" << (int) replyError
1164 <<
"): " << replyError
1165 <<
": " << reply->errorString();
1169 QString answer = reply->readAll();
1171 qDebug(
"FCDProInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
void setGain1Index(qint32 gain1_index)
void setLog2Decimation(unsigned int log2_decim)
uint16_t m_reverseAPIPort
fcdpro_if_gain1_value value
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)
qint32 getRfFilterIndex()
#define FCDPRO_HID_CMD_SET_IF_FILTER
#define FCDPRO_HID_CMD_SET_MIXER_FILTER
SWGFCDProSettings * getFcdProSettings()
qint32 getLnaEnhanceIndex()
fcdpro_if_gain5_value value
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.
fcdpro_if_rc_filter_value value
QString * getFileRecordName()
void setMixerFilterIndex(qint32 mixer_filter_index)
void setGain6Index(qint32 gain6_index)
static int fcdpro_if_filter_nb_values()
void stopDeviceEngine()
Stop the device engine corresponding to the stream type.
static int fcdpro_rf_filter_nb_values()
static const fcdpro_if_gain3 if_gains3[]
static const fcdpro_bias_current bias_currents[]
void setFileName(const QString &filename)
uint getDeviceUID() const
Return the current device engine unique ID.
void setFcPos(qint32 fc_pos)
FCD_MODE_ENUM fcdAppSetFreq(hid_device *phd, int nFreq)
Set FCD frequency with Hz resolution.
static const fcdpro_if_gain1 if_gains1[]
MessageQueue m_inputMessageQueue
Input queue to the source.
void setIqCorrection(qint32 iq_correction)
static int fcdpro_mixer_gain_nb_values()
virtual QString asJson() override
static const fcdpro_if_gain_mode if_gain_modes[]
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
fcdpro_mixer_filter_value value
void setGain5Index(qint32 gain5_index)
void setLOppmTenths(qint32 l_oppm_tenths)
qint32 getReverseApiDeviceIndex()
static int fcdpro_if_gain3_nb_values()
qint32 getReverseApiPort()
static int fcdpro_bias_current_nb_values()
qint32 getRcFilterIndex()
bool initDeviceEngine()
Init the device engine corresponding to the stream type.
static const fcdpro_if_gain6 if_gains6[]
void setTransverterDeltaFrequency(qint64 transverter_delta_frequency)
qint64 getTransverterDeltaFrequency()
static const fcdpro_lna_gain lna_gains[]
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void setOriginatorIndex(qint32 originator_index)
void setRfFilterIndex(qint32 rf_filter_index)
static const fcdpro_if_gain2 if_gains2[]
#define FCDPRO_HID_CMD_SET_BAND
#define FCDPRO_HID_CMD_SET_IF_GAIN2
SampleSinkFifo m_sampleFifo
#define FCDPRO_HID_CMD_SET_BIAS_CURRENT
qint32 getTransverterMode()
#define FCDPRO_HID_CMD_SET_IF_GAIN5
qint32 getMixerGainIndex()
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.
void setCenterFrequency(qint64 center_frequency)
static int fcdpro_if_gain2_nb_values()
void setBandIndex(qint32 band_index)
qint64 m_transverterDeltaFrequency
void setGain2Index(qint32 gain2_index)
int getDeviceSetIndex() const
#define FCDPRO_HID_CMD_SET_MIXER_GAIN
void setGain4Index(qint32 gain4_index)
uint16_t m_reverseAPIDeviceIndex
#define FCDPRO_HID_CMD_SET_IF_GAIN3
void setModeIndex(qint32 mode_index)
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)
static DSPEngine * instance()
QByteArray serialize() const
void setRcFilterIndex(qint32 rc_filter_index)
static int fcdpro_lna_enhance_nb_values()
void setBiasCurrentIndex(qint32 bias_current_index)
fcdpro_if_gain_mode_value value
void setGain3Index(qint32 gain3_index)
#define FCDPRO_HID_CMD_SET_IF_RC_FILTER
static int fcdpro_lna_gain_nb_values()
qint64 getCenterFrequency()
static int fcdpro_band_nb_values()
void setLnaGainIndex(qint32 lna_gain_index)
fcdpro_bias_current_value value
static bool match(const Message *message)
static int fcdpro_if_rc_filter_nb_values()
static int fcdpro_if_gain1_nb_values()
fcdpro_if_gain4_value value
void removeAncillarySink(BasebandSampleSink *sink, unsigned int index=0)
Removes it.
void setMixerGainIndex(qint32 mixer_gain_index)
#define FCDPRO_HID_CMD_SET_LNA_ENHANCE
qint32 getMixerFilterIndex()
static const fcdpro_rf_filter rf_filters[]
#define FCDPRO_HID_CMD_SET_RF_FILTER
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
static int fcdpro_if_gain6_nb_values()
qint32 m_mixerFilterIndex
fcdpro_if_filter_value value
static const fcdpro_if_filter if_filters[]
void setFcdProSettings(SWGFCDProSettings *fcd_pro_settings)
void getDeviceEngineStateStr(QString &state)
fcdpro_if_gain6_value value
fcdpro_if_gain2_value value
void setUseReverseApi(qint32 use_reverse_api)
#define FCDPRO_HID_CMD_SET_LNA_GAIN
void setLnaEnhanceIndex(qint32 lna_enhance_index)
AudioDeviceManager * getAudioDeviceManager()
fcdpro_if_gain3_value value
void setFileRecordName(QString *file_record_name)
void setTransverterMode(qint32 transverter_mode)
void setReverseApiPort(qint32 reverse_api_port)
QString m_reverseAPIAddress
QString * getReverseApiAddress()
qint32 getIfFilterIndex()
void setReverseApiAddress(QString *reverse_api_address)
fcdpro_mixer_gain_value value
static int fcdpro_if_gain_mode_nb_values()
void setLog2Decim(qint32 log2_decim)
void setDcBlock(qint32 dc_block)
static const fcdpro_if_gain4 if_gains4[]
int getInputDeviceIndex(const QString &deviceName) const
fcdpro_rf_filter_value value
#define FCDPRO_HID_CMD_SET_IF_GAIN6
static const fcdpro_mixer_filter mixer_filters[]
qint32 getBiasCurrentIndex()
bool deserialize(const QByteArray &data)
fcdpro_lna_gain_value value
#define FCDPRO_HID_CMD_SET_IF_GAIN4
qint32 getUseReverseApi()
static const fcdpro_band bands[]
static int fcdpro_if_gain4_nb_values()
void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection, int streamIndex=0)
Configure current device engine DSP corrections (Rx)
uint32_t getSamplingDeviceSequence() const
void setDirection(qint32 direction)
fcdpro_lna_enhance_value value
static const fcdpro_if_gain5 if_gains5[]
quint64 m_centerFrequency
static const fcdpro_lna_enhance lna_enhances[]
#define FCDPRO_HID_CMD_SET_IF_GAIN_MODE
static int fcdpro_if_gain5_nb_values()
void setDeviceHwType(QString *device_hw_type)
static const fcdpro_mixer_gain mixer_gains[]
qint32 m_biasCurrentIndex
#define FCDPRO_HID_CMD_SET_IF_GAIN1
static const fcdpro_if_rc_filter if_rc_filters[]
static int fcdpro_mixer_filter_nb_values()
void setIfFilterIndex(qint32 if_filter_index)