mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-10-29 20:10:22 -04:00 
			
		
		
		
	Added support for HackRF. Interim state #3
This commit is contained in:
		
							parent
							
								
									3be1a1a3e2
								
							
						
					
					
						commit
						2b092bf660
					
				| @ -71,7 +71,7 @@ The control interface is based on qthid and has been built in the software in th | |||||||
| 
 | 
 | ||||||
| <h2>HackRF</h2> | <h2>HackRF</h2> | ||||||
| 
 | 
 | ||||||
| HackRF is supported through the libhackrf library that should be installed in your system for proper build of the software and operation support. Add `libhackrf-dev` to the list of dependencies to install. | HackRF is supported through the libhackrf library that should be installed in your system for proper build of the software and operation support. Add `libhackrf-dev` to the list of dependencies to install. Please note that you will need a recent version (2015.07.2 or 2015.07.1 at least) of libhackrf that supports the sequential listing of devices so you might need to build and install the Github version: `https://github.com/mossmann/hackrf.git`. Note also that the firmware must be updated to match the library version as per instructions found in the HackRF wiki. | ||||||
| 
 | 
 | ||||||
| If you use your own location for libhackrf install directory you need to specify library and include locations. Example with `/opt/install/libhackrf` with the following defines on `cmake` command line: | If you use your own location for libhackrf install directory you need to specify library and include locations. Example with `/opt/install/libhackrf` with the following defines on `cmake` command line: | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -40,7 +40,6 @@ HackRFGui::HackRFGui(PluginAPI* pluginAPI, QWidget* parent) : | |||||||
| 
 | 
 | ||||||
| 	displaySampleRates(); | 	displaySampleRates(); | ||||||
| 	displayBandwidths(); | 	displayBandwidths(); | ||||||
| 	displayImgRejFilters(); |  | ||||||
| 
 | 
 | ||||||
| 	connect(m_sampleSource->getOutputMessageQueueToGUI(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages())); | 	connect(m_sampleSource->getOutputMessageQueueToGUI(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages())); | ||||||
| 	DSPEngine::instance()->setSource(m_sampleSource); | 	DSPEngine::instance()->setSource(m_sampleSource); | ||||||
| @ -136,7 +135,6 @@ void HackRFGui::displaySettings() | |||||||
| 	ui->lnaGainText->setText(tr("%1dB").arg(m_settings.m_lnaGain)); | 	ui->lnaGainText->setText(tr("%1dB").arg(m_settings.m_lnaGain)); | ||||||
| 	ui->lna->setValue(m_settings.m_lnaGain); | 	ui->lna->setValue(m_settings.m_lnaGain); | ||||||
| 
 | 
 | ||||||
| 	ui->rej->setCurrentIndex(m_settings.m_imjRejFilterIndex); |  | ||||||
| 	ui->bbFilter->setCurrentIndex(m_settings.m_bandwidthIndex); | 	ui->bbFilter->setCurrentIndex(m_settings.m_bandwidthIndex); | ||||||
| 
 | 
 | ||||||
| 	ui->vgaText->setText(tr("%1dB").arg(m_settings.m_vgaGain)); | 	ui->vgaText->setText(tr("%1dB").arg(m_settings.m_vgaGain)); | ||||||
| @ -151,7 +149,7 @@ void HackRFGui::displaySampleRates() | |||||||
| 
 | 
 | ||||||
| 	for (int i = 0; i < HackRFSampleRates::m_nb_rates; i++) | 	for (int i = 0; i < HackRFSampleRates::m_nb_rates; i++) | ||||||
| 	{ | 	{ | ||||||
| 		ui->sampleRate->addItem(QString("%1M").arg(QString::number(HackRFSampleRates::m_rates[i]/1000.0, 'f', 1))); | 		ui->sampleRate->addItem(QString("%1M").arg(QString::number(HackRFSampleRates::m_rates_k[i]/1000.0, 'f', 1))); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	ui->sampleRate->blockSignals(false); | 	ui->sampleRate->blockSignals(false); | ||||||
| @ -174,7 +172,7 @@ void HackRFGui::displayBandwidths() | |||||||
| 
 | 
 | ||||||
| 	for (int i = 0; i < HackRFBandwidths::m_nb_bw; i++) | 	for (int i = 0; i < HackRFBandwidths::m_nb_bw; i++) | ||||||
| 	{ | 	{ | ||||||
| 		ui->bbFilter->addItem(QString("%1M").arg(QString::number(HackRFBandwidths::m_bw[i]/1000.0, 'f', 2))); | 		ui->bbFilter->addItem(QString("%1M").arg(QString::number(HackRFBandwidths::m_bw_k[i]/1000.0, 'f', 2))); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	ui->bbFilter->blockSignals(false); | 	ui->bbFilter->blockSignals(false); | ||||||
| @ -189,29 +187,6 @@ void HackRFGui::displayBandwidths() | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void HackRFGui::displayImgRejFilters() |  | ||||||
| { |  | ||||||
| 	int savedIndex = m_settings.m_imjRejFilterIndex; |  | ||||||
| 	ui->rej->blockSignals(true); |  | ||||||
| 	ui->rej->clear(); |  | ||||||
| 
 |  | ||||||
| 	for (int i = 0; i < HackRFImageRejectFilters::m_nb_rej; i++) |  | ||||||
| 	{ |  | ||||||
| 		ui->rej->addItem(HackRFImageRejectFilters::m_rejName[i]); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	ui->rej->blockSignals(false); |  | ||||||
| 
 |  | ||||||
| 	if (savedIndex < HackRFImageRejectFilters::m_nb_rej) |  | ||||||
| 	{ |  | ||||||
| 		ui->rej->setCurrentIndex(savedIndex); |  | ||||||
| 	} |  | ||||||
| 	else |  | ||||||
| 	{ |  | ||||||
| 		ui->rej->setCurrentIndex((int) HackRFImageRejectFilters::m_nb_rej-1); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void HackRFGui::sendSettings() | void HackRFGui::sendSettings() | ||||||
| { | { | ||||||
| 	if(!m_updateTimer.isActive()) | 	if(!m_updateTimer.isActive()) | ||||||
| @ -237,12 +212,6 @@ void HackRFGui::on_sampleRate_currentIndexChanged(int index) | |||||||
| 	sendSettings(); | 	sendSettings(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void HackRFGui::on_rej_currentIndexChanged(int index) |  | ||||||
| { |  | ||||||
| 	m_settings.m_imjRejFilterIndex = index; |  | ||||||
| 	sendSettings(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void HackRFGui::on_bbFilter_currentIndexChanged(int index) | void HackRFGui::on_bbFilter_currentIndexChanged(int index) | ||||||
| { | { | ||||||
| 	m_settings.m_bandwidthIndex = index; | 	m_settings.m_bandwidthIndex = index; | ||||||
| @ -307,22 +276,22 @@ void HackRFGui::on_vga_valueChanged(int value) | |||||||
| void HackRFGui::updateHardware() | void HackRFGui::updateHardware() | ||||||
| { | { | ||||||
| 	qDebug() << "AirspyGui::updateHardware"; | 	qDebug() << "AirspyGui::updateHardware"; | ||||||
| 	HackRFInput::MsgConfigureHackRT* message = HackRFInput::MsgConfigureHackRT::create( m_settings); | 	HackRFInput::MsgConfigureHackRF* message = HackRFInput::MsgConfigureHackRF::create( m_settings); | ||||||
| 	m_sampleSource->getInputMessageQueue()->push(message); | 	m_sampleSource->getInputMessageQueue()->push(message); | ||||||
| 	m_updateTimer.stop(); | 	m_updateTimer.stop(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| unsigned int HackRFSampleRates::m_rates[] = {2400, 3200, 4800, 6400, 9680, 12800, 19200}; | unsigned int HackRFSampleRates::m_rates_k[] = {2400, 3200, 4800, 6400, 9680, 12800, 19200}; | ||||||
| 
 | 
 | ||||||
| unsigned int HackRFSampleRates::getRate(unsigned int rate_index) | unsigned int HackRFSampleRates::getRate(unsigned int rate_index) | ||||||
| { | { | ||||||
| 	if (rate_index < m_nb_rates) | 	if (rate_index < m_nb_rates) | ||||||
| 	{ | 	{ | ||||||
| 		return m_rates[rate_index]; | 		return m_rates_k[rate_index]; | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 		return m_rates[0]; | 		return m_rates_k[0]; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -330,7 +299,7 @@ unsigned int HackRFSampleRates::getRateIndex(unsigned int rate) | |||||||
| { | { | ||||||
| 	for (unsigned int i=0; i < m_nb_rates; i++) | 	for (unsigned int i=0; i < m_nb_rates; i++) | ||||||
| 	{ | 	{ | ||||||
| 		if (rate/1000 == m_rates[i]) | 		if (rate/1000 == m_rates_k[i]) | ||||||
| 		{ | 		{ | ||||||
| 			return i; | 			return i; | ||||||
| 		} | 		} | ||||||
| @ -339,17 +308,17 @@ unsigned int HackRFSampleRates::getRateIndex(unsigned int rate) | |||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| unsigned int HackRFBandwidths::m_bw[] = {1750, 2500, 3500, 5000, 5500, 6000, 7000, 8000, 9000, 10000, 12000, 14000, 15000, 20000, 24000, 28000}; | unsigned int HackRFBandwidths::m_bw_k[] = {1750, 2500, 3500, 5000, 5500, 6000, 7000, 8000, 9000, 10000, 12000, 14000, 15000, 20000, 24000, 28000}; | ||||||
| 
 | 
 | ||||||
| unsigned int HackRFBandwidths::getBandwidth(unsigned int bandwidth_index) | unsigned int HackRFBandwidths::getBandwidth(unsigned int bandwidth_index) | ||||||
| { | { | ||||||
| 	if (bandwidth_index < m_nb_bw) | 	if (bandwidth_index < m_nb_bw) | ||||||
| 	{ | 	{ | ||||||
| 		return m_bw[bandwidth_index]; | 		return m_bw_k[bandwidth_index]; | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 		return m_bw[0]; | 		return m_bw_k[0]; | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -357,7 +326,7 @@ unsigned int HackRFBandwidths::getBandwidthIndex(unsigned int bandwidth) | |||||||
| { | { | ||||||
| 	for (unsigned int i=0; i < m_nb_bw; i++) | 	for (unsigned int i=0; i < m_nb_bw; i++) | ||||||
| 	{ | 	{ | ||||||
| 		if (bandwidth == m_bw[i]) | 		if (bandwidth == m_bw_k[i]) | ||||||
| 		{ | 		{ | ||||||
| 			return i; | 			return i; | ||||||
| 		} | 		} | ||||||
| @ -365,17 +334,3 @@ unsigned int HackRFBandwidths::getBandwidthIndex(unsigned int bandwidth) | |||||||
| 
 | 
 | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
| 
 |  | ||||||
| QString HackRFImageRejectFilters::m_rejName[] = {QString("None"), QString("Low"), QString("Hi")}; |  | ||||||
| 
 |  | ||||||
| QString& HackRFImageRejectFilters::getImageRejectFilterName(unsigned int filter_index) |  | ||||||
| { |  | ||||||
| 	if (filter_index < m_nb_rej) |  | ||||||
| 	{ |  | ||||||
| 		return m_rejName[filter_index]; |  | ||||||
| 	} |  | ||||||
| 	else |  | ||||||
| 	{ |  | ||||||
| 		return m_rejName[0]; |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  | |||||||
| @ -66,7 +66,6 @@ private: | |||||||
| 	void displaySettings(); | 	void displaySettings(); | ||||||
| 	void displaySampleRates(); | 	void displaySampleRates(); | ||||||
| 	void displayBandwidths(); | 	void displayBandwidths(); | ||||||
| 	void displayImgRejFilters(); |  | ||||||
| 	void sendSettings(); | 	void sendSettings(); | ||||||
| 
 | 
 | ||||||
| private slots: | private slots: | ||||||
| @ -78,7 +77,6 @@ private slots: | |||||||
| 	void on_fcPos_currentIndexChanged(int index); | 	void on_fcPos_currentIndexChanged(int index); | ||||||
| 	void on_lnaExt_stateChanged(int state); | 	void on_lnaExt_stateChanged(int state); | ||||||
| 	void on_lna_valueChanged(int value); | 	void on_lna_valueChanged(int value); | ||||||
| 	void on_rej_currentIndexChanged(int index); |  | ||||||
| 	void on_bbFilter_currentIndexChanged(int index); | 	void on_bbFilter_currentIndexChanged(int index); | ||||||
| 	void on_vga_valueChanged(int value); | 	void on_vga_valueChanged(int value); | ||||||
| 	void updateHardware(); | 	void updateHardware(); | ||||||
| @ -90,7 +88,7 @@ public: | |||||||
| 	static unsigned int getRate(unsigned int rate_index); | 	static unsigned int getRate(unsigned int rate_index); | ||||||
| 	static unsigned int getRateIndex(unsigned int rate); | 	static unsigned int getRateIndex(unsigned int rate); | ||||||
| 	static const unsigned int m_nb_rates = 7; | 	static const unsigned int m_nb_rates = 7; | ||||||
| 	static unsigned int m_rates[m_nb_rates]; | 	static unsigned int m_rates_k[m_nb_rates]; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| class HackRFBandwidths { | class HackRFBandwidths { | ||||||
| @ -98,14 +96,7 @@ public: | |||||||
| 	static unsigned int getBandwidth(unsigned int bandwidth_index); | 	static unsigned int getBandwidth(unsigned int bandwidth_index); | ||||||
| 	static unsigned int getBandwidthIndex(unsigned int bandwidth); | 	static unsigned int getBandwidthIndex(unsigned int bandwidth); | ||||||
| 	static const unsigned int m_nb_bw = 16; | 	static const unsigned int m_nb_bw = 16; | ||||||
| 	static unsigned int m_bw[m_nb_bw]; | 	static unsigned int m_bw_k[m_nb_bw]; | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| class HackRFImageRejectFilters { |  | ||||||
| public: |  | ||||||
| 	static QString& getImageRejectFilterName(unsigned int filter_index); |  | ||||||
| 	static const unsigned int m_nb_rej = HackRFGui::HACKRF_IMGREJ_NB; |  | ||||||
| 	static QString m_rejName[m_nb_rej]; |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| #endif // INCLUDE_HACKRFGUI_H
 | #endif // INCLUDE_HACKRFGUI_H
 | ||||||
|  | |||||||
| @ -270,13 +270,13 @@ | |||||||
|      <item row="0" column="2"> |      <item row="0" column="2"> | ||||||
|       <widget class="QCheckBox" name="lnaExt"> |       <widget class="QCheckBox" name="lnaExt"> | ||||||
|        <property name="toolTip"> |        <property name="toolTip"> | ||||||
|         <string>Extra LNA</string> |         <string>Extra LNA +14dB</string> | ||||||
|        </property> |        </property> | ||||||
|        <property name="layoutDirection"> |        <property name="layoutDirection"> | ||||||
|         <enum>Qt::RightToLeft</enum> |         <enum>Qt::RightToLeft</enum> | ||||||
|        </property> |        </property> | ||||||
|        <property name="text"> |        <property name="text"> | ||||||
|         <string>LNA Ext</string> |         <string>RF Amp</string> | ||||||
|        </property> |        </property> | ||||||
|       </widget> |       </widget> | ||||||
|      </item> |      </item> | ||||||
| @ -316,10 +316,16 @@ | |||||||
|         <string>LNA gain dB</string> |         <string>LNA gain dB</string> | ||||||
|        </property> |        </property> | ||||||
|        <property name="maximum"> |        <property name="maximum"> | ||||||
|         <number>14</number> |         <number>40</number> | ||||||
|  |        </property> | ||||||
|  |        <property name="singleStep"> | ||||||
|  |         <number>8</number> | ||||||
|        </property> |        </property> | ||||||
|        <property name="pageStep"> |        <property name="pageStep"> | ||||||
|         <number>1</number> |         <number>8</number> | ||||||
|  |        </property> | ||||||
|  |        <property name="value"> | ||||||
|  |         <number>16</number> | ||||||
|        </property> |        </property> | ||||||
|        <property name="orientation"> |        <property name="orientation"> | ||||||
|         <enum>Qt::Horizontal</enum> |         <enum>Qt::Horizontal</enum> | ||||||
| @ -345,30 +351,33 @@ | |||||||
|     </layout> |     </layout> | ||||||
|    </item> |    </item> | ||||||
|    <item> |    <item> | ||||||
|     <layout class="QGridLayout" name="gridLayout_rej_bbf"> |     <layout class="QGridLayout" name="gridLayout_bbf"> | ||||||
|      <property name="spacing"> |      <property name="spacing"> | ||||||
|       <number>3</number> |       <number>3</number> | ||||||
|      </property> |      </property> | ||||||
|      <item row="0" column="1"> |  | ||||||
|       <widget class="QComboBox" name="rej"/> |  | ||||||
|      </item> |  | ||||||
|      <item row="0" column="0"> |      <item row="0" column="0"> | ||||||
|       <widget class="QLabel" name="rejLabel"> |  | ||||||
|        <property name="text"> |  | ||||||
|         <string>Rej</string> |  | ||||||
|        </property> |  | ||||||
|       </widget> |  | ||||||
|      </item> |  | ||||||
|      <item row="0" column="2"> |  | ||||||
|       <widget class="QLabel" name="bbFiltLabel"> |       <widget class="QLabel" name="bbFiltLabel"> | ||||||
|        <property name="text"> |        <property name="text"> | ||||||
|         <string>BBF</string> |         <string>BBF</string> | ||||||
|        </property> |        </property> | ||||||
|       </widget> |       </widget> | ||||||
|      </item> |      </item> | ||||||
|      <item row="0" column="3"> |      <item row="0" column="1"> | ||||||
|       <widget class="QComboBox" name="bbFilter"/> |       <widget class="QComboBox" name="bbFilter"/> | ||||||
|      </item> |      </item> | ||||||
|  |      <item row="0" column="2"> | ||||||
|  |       <spacer name="bbSpacer"> | ||||||
|  |        <property name="orientation"> | ||||||
|  |         <enum>Qt::Horizontal</enum> | ||||||
|  |        </property> | ||||||
|  |        <property name="sizeHint" stdset="0"> | ||||||
|  |         <size> | ||||||
|  |          <width>40</width> | ||||||
|  |          <height>20</height> | ||||||
|  |         </size> | ||||||
|  |        </property> | ||||||
|  |       </spacer> | ||||||
|  |      </item> | ||||||
|     </layout> |     </layout> | ||||||
|    </item> |    </item> | ||||||
|    <item> |    <item> | ||||||
| @ -389,16 +398,16 @@ | |||||||
|         <string>VGA gain dB</string> |         <string>VGA gain dB</string> | ||||||
|        </property> |        </property> | ||||||
|        <property name="maximum"> |        <property name="maximum"> | ||||||
|         <number>15</number> |         <number>62</number> | ||||||
|        </property> |        </property> | ||||||
|        <property name="singleStep"> |        <property name="singleStep"> | ||||||
|         <number>1</number> |         <number>2</number> | ||||||
|        </property> |        </property> | ||||||
|        <property name="pageStep"> |        <property name="pageStep"> | ||||||
|         <number>1</number> |         <number>2</number> | ||||||
|        </property> |        </property> | ||||||
|        <property name="value"> |        <property name="value"> | ||||||
|         <number>5</number> |         <number>16</number> | ||||||
|        </property> |        </property> | ||||||
|        <property name="orientation"> |        <property name="orientation"> | ||||||
|         <enum>Qt::Horizontal</enum> |         <enum>Qt::Horizontal</enum> | ||||||
|  | |||||||
| @ -26,7 +26,7 @@ | |||||||
| #include "hackrfserializer.h" | #include "hackrfserializer.h" | ||||||
| #include "hackrfthread.h" | #include "hackrfthread.h" | ||||||
| 
 | 
 | ||||||
| MESSAGE_CLASS_DEFINITION(HackRFInput::MsgConfigureHackRT, Message) | MESSAGE_CLASS_DEFINITION(HackRFInput::MsgConfigureHackRF, Message) | ||||||
| MESSAGE_CLASS_DEFINITION(HackRFInput::MsgReportHackRF, Message) | MESSAGE_CLASS_DEFINITION(HackRFInput::MsgReportHackRF, Message) | ||||||
| 
 | 
 | ||||||
| HackRFInput::Settings::Settings() : | HackRFInput::Settings::Settings() : | ||||||
| @ -34,7 +34,6 @@ HackRFInput::Settings::Settings() : | |||||||
| 	m_devSampleRateIndex(0), | 	m_devSampleRateIndex(0), | ||||||
| 	m_LOppmTenths(0), | 	m_LOppmTenths(0), | ||||||
| 	m_lnaGain(14), | 	m_lnaGain(14), | ||||||
| 	m_imjRejFilterIndex(0), |  | ||||||
| 	m_bandwidthIndex(0), | 	m_bandwidthIndex(0), | ||||||
| 	m_vgaGain(4), | 	m_vgaGain(4), | ||||||
| 	m_log2Decim(0), | 	m_log2Decim(0), | ||||||
| @ -50,7 +49,6 @@ void HackRFInput::Settings::resetToDefaults() | |||||||
| 	m_devSampleRateIndex = 0; | 	m_devSampleRateIndex = 0; | ||||||
| 	m_LOppmTenths = 0; | 	m_LOppmTenths = 0; | ||||||
| 	m_lnaGain = 14; | 	m_lnaGain = 14; | ||||||
| 	m_imjRejFilterIndex = 0; |  | ||||||
| 	m_bandwidthIndex = 0; | 	m_bandwidthIndex = 0; | ||||||
| 	m_vgaGain = 4; | 	m_vgaGain = 4; | ||||||
| 	m_log2Decim = 0; | 	m_log2Decim = 0; | ||||||
| @ -69,7 +67,6 @@ QByteArray HackRFInput::Settings::serialize() const | |||||||
| 	data.m_log2Decim = m_log2Decim; | 	data.m_log2Decim = m_log2Decim; | ||||||
| 	data.m_fcPos = (qint32) m_fcPos; | 	data.m_fcPos = (qint32) m_fcPos; | ||||||
| 	data.m_lnaGain = m_lnaGain; | 	data.m_lnaGain = m_lnaGain; | ||||||
| 	data.m_imjRejFilterIndex = m_imjRejFilterIndex; |  | ||||||
| 	data.m_bandwidthIndex = m_bandwidthIndex; | 	data.m_bandwidthIndex = m_bandwidthIndex; | ||||||
| 	data.m_vgaGain = m_vgaGain; | 	data.m_vgaGain = m_vgaGain; | ||||||
| 	data.m_biasT  = m_biasT; | 	data.m_biasT  = m_biasT; | ||||||
| @ -94,7 +91,6 @@ bool HackRFInput::Settings::deserialize(const QByteArray& serializedData) | |||||||
| 	m_log2Decim = data.m_log2Decim; | 	m_log2Decim = data.m_log2Decim; | ||||||
| 	m_fcPos = (fcPos_t) data.m_fcPos; | 	m_fcPos = (fcPos_t) data.m_fcPos; | ||||||
| 	m_lnaGain = data.m_lnaGain; | 	m_lnaGain = data.m_lnaGain; | ||||||
| 	m_imjRejFilterIndex = data.m_imjRejFilterIndex; |  | ||||||
| 	m_bandwidthIndex = data.m_bandwidthIndex; | 	m_bandwidthIndex = data.m_bandwidthIndex; | ||||||
| 	m_vgaGain = data.m_vgaGain; | 	m_vgaGain = data.m_vgaGain; | ||||||
| 	m_biasT = data.m_biasT; | 	m_biasT = data.m_biasT; | ||||||
| @ -106,11 +102,9 @@ bool HackRFInput::Settings::deserialize(const QByteArray& serializedData) | |||||||
| HackRFInput::HackRFInput() : | HackRFInput::HackRFInput() : | ||||||
| 	m_settings(), | 	m_settings(), | ||||||
| 	m_dev(0), | 	m_dev(0), | ||||||
| 	m_airspyThread(0), | 	m_hackRFThread(0), | ||||||
| 	m_deviceDescription("Airspy") | 	m_deviceDescription("HackRF") | ||||||
| { | { | ||||||
| 	m_sampleRates.push_back(10000000); |  | ||||||
| 	m_sampleRates.push_back(2500000); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| HackRFInput::~HackRFInput() | HackRFInput::~HackRFInput() | ||||||
| @ -126,13 +120,13 @@ bool HackRFInput::init(const Message& cmd) | |||||||
| bool HackRFInput::start(int device) | bool HackRFInput::start(int device) | ||||||
| { | { | ||||||
| 	QMutexLocker mutexLocker(&m_mutex); | 	QMutexLocker mutexLocker(&m_mutex); | ||||||
| 	airspy_error rc; | 	hackrf_error rc; | ||||||
| 
 | 
 | ||||||
| 	rc = (airspy_error) airspy_init(); | 	rc = (hackrf_error) hackrf_init(); | ||||||
| 
 | 
 | ||||||
| 	if (rc != AIRSPY_SUCCESS) | 	if (rc != HACKRF_SUCCESS) | ||||||
| 	{ | 	{ | ||||||
| 		qCritical("AirspyInput::start: failed to initiate Airspy library %s", airspy_error_name(rc)); | 		qCritical("HackRFInput::start: failed to initiate HackRF library %s", hackrf_error_name(rc)); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if (m_dev != 0) | 	if (m_dev != 0) | ||||||
| @ -142,92 +136,54 @@ bool HackRFInput::start(int device) | |||||||
| 
 | 
 | ||||||
| 	if (!m_sampleFifo.setSize(1<<19)) | 	if (!m_sampleFifo.setSize(1<<19)) | ||||||
| 	{ | 	{ | ||||||
| 		qCritical("AirspyInput::start: could not allocate SampleFifo"); | 		qCritical("HackRFInput::start: could not allocate SampleFifo"); | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if ((m_dev = open_airspy_from_sequence(device)) == 0) | 	if ((m_dev = open_hackrf_from_sequence(device)) == 0) | ||||||
| 	{ | 	{ | ||||||
| 		qCritical("AirspyInput::start: could not open Airspy #%d", device); | 		qCritical("HackRFInput::start: could not open HackRF #%d", device); | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| #ifdef LIBAIRSPY_DYN_RATES | 	if((m_hackRFThread = new HackRFThread(m_dev, &m_sampleFifo)) == 0) | ||||||
| 	uint32_t nbSampleRates; |  | ||||||
| 	uint32_t *sampleRates; |  | ||||||
| 
 |  | ||||||
| 	airspy_get_samplerates(m_dev, &nbSampleRates, 0); |  | ||||||
| 
 |  | ||||||
| 	sampleRates = new uint32_t[nbSampleRates]; |  | ||||||
| 
 |  | ||||||
| 	airspy_get_samplerates(m_dev, sampleRates, nbSampleRates); |  | ||||||
| 
 |  | ||||||
| 	if (nbSampleRates == 0) |  | ||||||
| 	{ | 	{ | ||||||
| 		qCritical("AirspyInput::start: could not obtain Airspy sample rates"); | 		qFatal("HackRFInput::start: out of memory"); | ||||||
| 		return false; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	m_sampleRates.clear(); |  | ||||||
| 
 |  | ||||||
| 	for (int i=0; i<nbSampleRates; i++) |  | ||||||
| 	{ |  | ||||||
| 		m_sampleRates.push_back(sampleRates[i]); |  | ||||||
| 		qDebug("AirspyInput::start: sampleRates[%d] = %u Hz", i, sampleRates[i]); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	delete[] sampleRates; |  | ||||||
| #endif |  | ||||||
| 
 |  | ||||||
| 	MsgReportHackRF *message = MsgReportHackRF::create(m_sampleRates); |  | ||||||
| 	getOutputMessageQueueToGUI()->push(message); |  | ||||||
| 
 |  | ||||||
| 	rc = (airspy_error) airspy_set_sample_type(m_dev, AIRSPY_SAMPLE_INT16_IQ); |  | ||||||
| 
 |  | ||||||
| 	if (rc != AIRSPY_SUCCESS) |  | ||||||
| 	{ |  | ||||||
| 		qCritical("AirspyInput::start: could not set sample type to INT16_IQ"); |  | ||||||
| 		return false; |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	if((m_airspyThread = new HackRFThread(m_dev, &m_sampleFifo)) == 0) |  | ||||||
| 	{ |  | ||||||
| 		qFatal("AirspyInput::start: out of memory"); |  | ||||||
| 		stop(); | 		stop(); | ||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	m_airspyThread->startWork(); | 	m_hackRFThread->startWork(); | ||||||
| 
 | 
 | ||||||
| 	mutexLocker.unlock(); | 	mutexLocker.unlock(); | ||||||
| 
 | 
 | ||||||
| 	applySettings(m_settings, true); | 	applySettings(m_settings, true); | ||||||
| 
 | 
 | ||||||
| 	qDebug("AirspyInput::startInput: started"); | 	qDebug("HackRFInput::startInput: started"); | ||||||
| 
 | 
 | ||||||
| 	return true; | 	return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void HackRFInput::stop() | void HackRFInput::stop() | ||||||
| { | { | ||||||
| 	qDebug("AirspyInput::stop"); | 	qDebug("HackRFInput::stop"); | ||||||
| 	QMutexLocker mutexLocker(&m_mutex); | 	QMutexLocker mutexLocker(&m_mutex); | ||||||
| 
 | 
 | ||||||
| 	if(m_airspyThread != 0) | 	if(m_hackRFThread != 0) | ||||||
| 	{ | 	{ | ||||||
| 		m_airspyThread->stopWork(); | 		m_hackRFThread->stopWork(); | ||||||
| 		delete m_airspyThread; | 		delete m_hackRFThread; | ||||||
| 		m_airspyThread = 0; | 		m_hackRFThread = 0; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if(m_dev != 0) | 	if(m_dev != 0) | ||||||
| 	{ | 	{ | ||||||
| 		airspy_stop_rx(m_dev); | 		hackrf_stop_rx(m_dev); | ||||||
| 		airspy_close(m_dev); | 		hackrf_close(m_dev); | ||||||
| 		m_dev = 0; | 		m_dev = 0; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	airspy_exit(); | 	hackrf_exit(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const QString& HackRFInput::getDeviceDescription() const | const QString& HackRFInput::getDeviceDescription() const | ||||||
| @ -237,7 +193,7 @@ const QString& HackRFInput::getDeviceDescription() const | |||||||
| 
 | 
 | ||||||
| int HackRFInput::getSampleRate() const | int HackRFInput::getSampleRate() const | ||||||
| { | { | ||||||
| 	int rate = m_sampleRates[m_settings.m_devSampleRateIndex]; | 	int rate = HackRFSampleRates::m_rates_k[m_settings.m_devSampleRateIndex] * 1000; | ||||||
| 	return (rate / (1<<m_settings.m_log2Decim)); | 	return (rate / (1<<m_settings.m_log2Decim)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -248,16 +204,16 @@ quint64 HackRFInput::getCenterFrequency() const | |||||||
| 
 | 
 | ||||||
| bool HackRFInput::handleMessage(const Message& message) | bool HackRFInput::handleMessage(const Message& message) | ||||||
| { | { | ||||||
| 	if (MsgConfigureHackRT::match(message)) | 	if (MsgConfigureHackRF::match(message)) | ||||||
| 	{ | 	{ | ||||||
| 		MsgConfigureHackRT& conf = (MsgConfigureHackRT&) message; | 		MsgConfigureHackRF& conf = (MsgConfigureHackRF&) message; | ||||||
| 		qDebug() << "AirspyInput::handleMessage: MsgConfigureAirspy"; | 		qDebug() << "HackRFInput::handleMessage: MsgConfigureHackRF"; | ||||||
| 
 | 
 | ||||||
| 		bool success = applySettings(conf.getSettings(), false); | 		bool success = applySettings(conf.getSettings(), false); | ||||||
| 
 | 
 | ||||||
| 		if (!success) | 		if (!success) | ||||||
| 		{ | 		{ | ||||||
| 			qDebug("Airspy config error"); | 			qDebug("HackRFInput::handleMessage: config error"); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		return true; | 		return true; | ||||||
| @ -272,15 +228,15 @@ void HackRFInput::setCenterFrequency(quint64 freq_hz) | |||||||
| { | { | ||||||
| 	freq_hz += (freq_hz * m_settings.m_LOppmTenths) / 10000000ULL; | 	freq_hz += (freq_hz * m_settings.m_LOppmTenths) / 10000000ULL; | ||||||
| 
 | 
 | ||||||
| 	airspy_error rc = (airspy_error) airspy_set_freq(m_dev, static_cast<uint32_t>(freq_hz)); | 	hackrf_error rc = (hackrf_error) hackrf_set_freq(m_dev, static_cast<uint64_t>(freq_hz)); | ||||||
| 
 | 
 | ||||||
| 	if (rc != AIRSPY_SUCCESS) | 	if (rc != HACKRF_SUCCESS) | ||||||
| 	{ | 	{ | ||||||
| 		qWarning("AirspyInput::setCenterFrequency: could not frequency to %llu Hz", freq_hz); | 		qWarning("HackRFInput::setCenterFrequency: could not frequency to %llu Hz", freq_hz); | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 		qWarning("AirspyInput::setCenterFrequency: frequency set to %llu Hz", freq_hz); | 		qWarning("HackRFInput::setCenterFrequency: frequency set to %llu Hz", freq_hz); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -289,35 +245,35 @@ bool HackRFInput::applySettings(const Settings& settings, bool force) | |||||||
| 	QMutexLocker mutexLocker(&m_mutex); | 	QMutexLocker mutexLocker(&m_mutex); | ||||||
| 
 | 
 | ||||||
| 	bool forwardChange = false; | 	bool forwardChange = false; | ||||||
| 	airspy_error rc; | 	hackrf_error rc; | ||||||
| 
 | 
 | ||||||
| 	qDebug() << "AirspyInput::applySettings"; | 	qDebug() << "HackRFInput::applySettings"; | ||||||
| 
 | 
 | ||||||
| 	if ((m_settings.m_devSampleRateIndex != settings.m_devSampleRateIndex) || force) | 	if ((m_settings.m_devSampleRateIndex != settings.m_devSampleRateIndex) || force) | ||||||
| 	{ | 	{ | ||||||
| 		forwardChange = true; | 		forwardChange = true; | ||||||
| 
 | 
 | ||||||
| 		if (settings.m_devSampleRateIndex < m_sampleRates.size()) | 		if (settings.m_devSampleRateIndex < HackRFSampleRates::m_nb_rates) | ||||||
| 		{ | 		{ | ||||||
| 			m_settings.m_devSampleRateIndex = settings.m_devSampleRateIndex; | 			m_settings.m_devSampleRateIndex = settings.m_devSampleRateIndex; | ||||||
| 		} | 		} | ||||||
| 		else | 		else | ||||||
| 		{ | 		{ | ||||||
| 			m_settings.m_devSampleRateIndex = m_sampleRates.size() - 1; | 			m_settings.m_devSampleRateIndex = HackRFSampleRates::m_nb_rates - 1; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		if (m_dev != 0) | 		if (m_dev != 0) | ||||||
| 		{ | 		{ | ||||||
| 			rc = (airspy_error) airspy_set_samplerate(m_dev, static_cast<airspy_samplerate_t>(m_settings.m_devSampleRateIndex)); | 			rc = (hackrf_error) hackrf_set_sample_rate_manual(m_dev, HackRFSampleRates::m_rates_k[m_settings.m_devSampleRateIndex]*1000, 1); | ||||||
| 
 | 
 | ||||||
| 			if (rc != AIRSPY_SUCCESS) | 			if (rc != HACKRF_SUCCESS) | ||||||
| 			{ | 			{ | ||||||
| 				qCritical("AirspyInput::applySettings: could not set sample rate index %u (%d S/s): %s", m_settings.m_devSampleRateIndex, m_sampleRates[m_settings.m_devSampleRateIndex], airspy_error_name(rc)); | 				qCritical("HackRFInput::applySettings: could not set sample rate index %u (%d kS/s): %s", m_settings.m_devSampleRateIndex, HackRFSampleRates::m_rates_k[m_settings.m_devSampleRateIndex], hackrf_error_name(rc)); | ||||||
| 			} | 			} | ||||||
| 			else | 			else | ||||||
| 			{ | 			{ | ||||||
| 				qDebug("AirspyInput::applySettings: sample rate set to index: %u (%d S/s)", m_settings.m_devSampleRateIndex, m_sampleRates[m_settings.m_devSampleRateIndex]); | 				qDebug("HackRFInput::applySettings: sample rate set to index: %u (%d kS/s)", m_settings.m_devSampleRateIndex, HackRFSampleRates::m_rates_k[m_settings.m_devSampleRateIndex]); | ||||||
| 				m_airspyThread->setSamplerate(m_sampleRates[m_settings.m_devSampleRateIndex]); | 				m_hackRFThread->setSamplerate(HackRFSampleRates::m_rates_k[m_settings.m_devSampleRateIndex]); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @ -329,8 +285,8 @@ bool HackRFInput::applySettings(const Settings& settings, bool force) | |||||||
| 
 | 
 | ||||||
| 		if(m_dev != 0) | 		if(m_dev != 0) | ||||||
| 		{ | 		{ | ||||||
| 			m_airspyThread->setLog2Decimation(m_settings.m_log2Decim); | 			m_hackRFThread->setLog2Decimation(m_settings.m_log2Decim); | ||||||
| 			qDebug() << "AirspyInput: set decimation to " << (1<<m_settings.m_log2Decim); | 			qDebug() << "HackRFInput: set decimation to " << (1<<m_settings.m_log2Decim); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| @ -340,14 +296,14 @@ bool HackRFInput::applySettings(const Settings& settings, bool force) | |||||||
| 
 | 
 | ||||||
| 		if(m_dev != 0) | 		if(m_dev != 0) | ||||||
| 		{ | 		{ | ||||||
| 			m_airspyThread->setFcPos((int) m_settings.m_fcPos); | 			m_hackRFThread->setFcPos((int) m_settings.m_fcPos); | ||||||
| 			qDebug() << "AirspyInput: set fc pos (enum) to " << (int) m_settings.m_fcPos; | 			qDebug() << "HackRFInput: set fc pos (enum) to " << (int) m_settings.m_fcPos; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	qint64 deviceCenterFrequency = m_settings.m_centerFrequency; | 	qint64 deviceCenterFrequency = m_settings.m_centerFrequency; | ||||||
| 	qint64 f_img = deviceCenterFrequency; | 	qint64 f_img = deviceCenterFrequency; | ||||||
| 	quint32 devSampleRate = m_sampleRates[m_settings.m_devSampleRateIndex]; | 	quint32 devSampleRate = HackRFSampleRates::m_rates_k[m_settings.m_devSampleRateIndex] * 1000; | ||||||
| 
 | 
 | ||||||
| 	if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency) || | 	if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency) || | ||||||
| 			(m_settings.m_LOppmTenths != settings.m_LOppmTenths)) | 			(m_settings.m_LOppmTenths != settings.m_LOppmTenths)) | ||||||
| @ -378,7 +334,7 @@ bool HackRFInput::applySettings(const Settings& settings, bool force) | |||||||
| 		{ | 		{ | ||||||
| 			setCenterFrequency(deviceCenterFrequency); | 			setCenterFrequency(deviceCenterFrequency); | ||||||
| 
 | 
 | ||||||
| 			qDebug() << "AirspyInput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz" | 			qDebug() << "HackRFInput::applySettings: center freq: " << m_settings.m_centerFrequency << " Hz" | ||||||
| 					<< " device center freq: " << deviceCenterFrequency << " Hz" | 					<< " device center freq: " << deviceCenterFrequency << " Hz" | ||||||
| 					<< " device sample rate: " << devSampleRate << "Hz" | 					<< " device sample rate: " << devSampleRate << "Hz" | ||||||
| 					<< " Actual sample rate: " << devSampleRate/(1<<m_settings.m_log2Decim) << "Hz" | 					<< " Actual sample rate: " << devSampleRate/(1<<m_settings.m_log2Decim) << "Hz" | ||||||
| @ -394,34 +350,15 @@ bool HackRFInput::applySettings(const Settings& settings, bool force) | |||||||
| 
 | 
 | ||||||
| 		if (m_dev != 0) | 		if (m_dev != 0) | ||||||
| 		{ | 		{ | ||||||
| 			rc = (airspy_error) airspy_set_lna_gain(m_dev, m_settings.m_lnaGain); | 			rc = (hackrf_error) hackrf_set_lna_gain(m_dev, m_settings.m_lnaGain); | ||||||
| 
 | 
 | ||||||
| 			if(rc != AIRSPY_SUCCESS) | 			if(rc != HACKRF_SUCCESS) | ||||||
| 			{ | 			{ | ||||||
| 				qDebug("AirspyInput::applySettings: airspy_set_lna_gain failed: %s", airspy_error_name(rc)); | 				qDebug("HackRFInput::applySettings: airspy_set_lna_gain failed: %s", hackrf_error_name(rc)); | ||||||
| 			} | 			} | ||||||
| 			else | 			else | ||||||
| 			{ | 			{ | ||||||
| 				qDebug() << "AirspyInput:applySettings: LNA gain set to " << m_settings.m_lnaGain; | 				qDebug() << "HackRFInput:applySettings: LNA gain set to " << m_settings.m_lnaGain; | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	if ((m_settings.m_mixerGain != settings.m_mixerGain) || force) |  | ||||||
| 	{ |  | ||||||
| 		m_settings.m_mixerGain = settings.m_mixerGain; |  | ||||||
| 
 |  | ||||||
| 		if (m_dev != 0) |  | ||||||
| 		{ |  | ||||||
| 			rc = (airspy_error) airspy_set_mixer_gain(m_dev, m_settings.m_mixerGain); |  | ||||||
| 
 |  | ||||||
| 			if(rc != AIRSPY_SUCCESS) |  | ||||||
| 			{ |  | ||||||
| 				qDebug("AirspyInput::applySettings: airspy_set_mixer_gain failed: %s", airspy_error_name(rc)); |  | ||||||
| 			} |  | ||||||
| 			else |  | ||||||
| 			{ |  | ||||||
| 				qDebug() << "AirspyInput:applySettings: mixer gain set to " << m_settings.m_mixerGain; |  | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @ -432,15 +369,43 @@ bool HackRFInput::applySettings(const Settings& settings, bool force) | |||||||
| 
 | 
 | ||||||
| 		if (m_dev != 0) | 		if (m_dev != 0) | ||||||
| 		{ | 		{ | ||||||
| 			rc = (airspy_error) airspy_set_vga_gain(m_dev, m_settings.m_vgaGain); | 			rc = (hackrf_error) hackrf_set_vga_gain(m_dev, m_settings.m_vgaGain); | ||||||
| 
 | 
 | ||||||
| 			if(rc != AIRSPY_SUCCESS) | 			if (rc != HACKRF_SUCCESS) | ||||||
| 			{ | 			{ | ||||||
| 				qDebug("AirspyInput::applySettings: airspy_set_vga_gain failed: %s", airspy_error_name(rc)); | 				qDebug("HackRFInput::applySettings: hackrf_set_vga_gain failed: %s", hackrf_error_name(rc)); | ||||||
| 			} | 			} | ||||||
| 			else | 			else | ||||||
| 			{ | 			{ | ||||||
| 				qDebug() << "AirspyInput:applySettings: VGA gain set to " << m_settings.m_vgaGain; | 				qDebug() << "HackRFInput:applySettings: VGA gain set to " << m_settings.m_vgaGain; | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	if ((m_settings.m_bandwidthIndex != settings.m_bandwidthIndex) || force) | ||||||
|  | 	{ | ||||||
|  | 
 | ||||||
|  | 		if (settings.m_bandwidthIndex < HackRFBandwidths::m_nb_bw) | ||||||
|  | 		{ | ||||||
|  | 			m_settings.m_bandwidthIndex = settings.m_bandwidthIndex; | ||||||
|  | 		} | ||||||
|  | 		else | ||||||
|  | 		{ | ||||||
|  | 			m_settings.m_bandwidthIndex = HackRFBandwidths::m_nb_bw - 1; | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		if (m_dev != 0) | ||||||
|  | 		{ | ||||||
|  | 			uint32_t bw_index = hackrf_compute_baseband_filter_bw_round_down_lt(HackRFBandwidths::m_bw_k[m_settings.m_bandwidthIndex]); | ||||||
|  | 			rc = (hackrf_error) hackrf_set_baseband_filter_bandwidth(m_dev, bw_index); | ||||||
|  | 
 | ||||||
|  | 			if (rc != HACKRF_SUCCESS) | ||||||
|  | 			{ | ||||||
|  | 				qDebug("HackRFInput::applySettings: hackrf_set_baseband_filter_bandwidth failed: %s", hackrf_error_name(rc)); | ||||||
|  | 			} | ||||||
|  | 			else | ||||||
|  | 			{ | ||||||
|  | 				qDebug() << "HackRFInput:applySettings: Baseband BW gain set to " << HackRFBandwidths::m_bw_k[m_settings.m_bandwidthIndex]; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @ -451,15 +416,15 @@ bool HackRFInput::applySettings(const Settings& settings, bool force) | |||||||
| 
 | 
 | ||||||
| 		if (m_dev != 0) | 		if (m_dev != 0) | ||||||
| 		{ | 		{ | ||||||
| 			rc = (airspy_error) airspy_set_rf_bias(m_dev, (m_settings.m_biasT ? 1 : 0)); | 			rc = (hackrf_error) hackrf_set_antenna_enable(m_dev, (m_settings.m_biasT ? 1 : 0)); | ||||||
| 
 | 
 | ||||||
| 			if(rc != AIRSPY_SUCCESS) | 			if(rc != HACKRF_SUCCESS) | ||||||
| 			{ | 			{ | ||||||
| 				qDebug("AirspyInput::applySettings: airspy_set_rf_bias failed: %s", airspy_error_name(rc)); | 				qDebug("HackRFInput::applySettings: airspy_set_rf_bias failed: %s", hackrf_error_name(rc)); | ||||||
| 			} | 			} | ||||||
| 			else | 			else | ||||||
| 			{ | 			{ | ||||||
| 				qDebug() << "AirspyInput:applySettings: bias tee set to " << m_settings.m_biasT; | 				qDebug() << "HackRFInput:applySettings: bias tee set to " << m_settings.m_biasT; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @ -474,31 +439,20 @@ bool HackRFInput::applySettings(const Settings& settings, bool force) | |||||||
| 	return true; | 	return true; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| struct airspy_device *HackRFInput::open_airspy_from_sequence(int sequence) | hackrf_device *HackRFInput::open_hackrf_from_sequence(int sequence) | ||||||
| { | { | ||||||
| 	airspy_read_partid_serialno_t read_partid_serialno; | 	hackrf_device_list_t *hackrf_devices = hackrf_device_list(); | ||||||
| 	struct airspy_device *devinfo, *retdev = 0; | 	hackrf_device *hackrf_ptr; | ||||||
| 	uint32_t serial_msb = 0; | 	hackrf_error rc; | ||||||
| 	uint32_t serial_lsb = 0; |  | ||||||
| 	airspy_error rc; |  | ||||||
| 	int i; |  | ||||||
| 
 | 
 | ||||||
| 	for (int i = 0; i < AIRSPY_MAX_DEVICE; i++) | 	rc = (hackrf_error) hackrf_device_list_open(hackrf_devices, sequence, &hackrf_ptr); | ||||||
| 	{ |  | ||||||
| 		rc = (airspy_error) airspy_open(&devinfo); |  | ||||||
| 
 | 
 | ||||||
| 		if (rc == AIRSPY_SUCCESS) | 	if (rc == HACKRF_SUCCESS) | ||||||
| 	{ | 	{ | ||||||
| 			if (i == sequence) | 		return hackrf_ptr; | ||||||
| 			{ |  | ||||||
| 				return devinfo; |  | ||||||
| 			} |  | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 			break; |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 		return 0; | 		return 0; | ||||||
| 	} | 	} | ||||||
|  | } | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ | |||||||
| #define INCLUDE_HACKRFINPUT_H | #define INCLUDE_HACKRFINPUT_H | ||||||
| 
 | 
 | ||||||
| #include "dsp/samplesource.h" | #include "dsp/samplesource.h" | ||||||
| #include <libhackrf/hackrf.h> | #include "libhackrf/hackrf.h" | ||||||
| #include <QString> | #include <QString> | ||||||
| 
 | 
 | ||||||
| class HackRFThread; | class HackRFThread; | ||||||
| @ -36,7 +36,6 @@ public: | |||||||
| 		qint32  m_LOppmTenths; | 		qint32  m_LOppmTenths; | ||||||
| 		quint32 m_devSampleRateIndex; | 		quint32 m_devSampleRateIndex; | ||||||
| 		quint32 m_bandwidthIndex; | 		quint32 m_bandwidthIndex; | ||||||
| 		quint32 m_imjRejFilterIndex; |  | ||||||
| 		quint32 m_lnaGain; | 		quint32 m_lnaGain; | ||||||
| 		quint32 m_vgaGain; | 		quint32 m_vgaGain; | ||||||
| 		quint32 m_log2Decim; | 		quint32 m_log2Decim; | ||||||
| @ -50,21 +49,21 @@ public: | |||||||
| 		bool deserialize(const QByteArray& data); | 		bool deserialize(const QByteArray& data); | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
| 	class MsgConfigureHackRT : public Message { | 	class MsgConfigureHackRF : public Message { | ||||||
| 		MESSAGE_CLASS_DECLARATION | 		MESSAGE_CLASS_DECLARATION | ||||||
| 
 | 
 | ||||||
| 	public: | 	public: | ||||||
| 		const Settings& getSettings() const { return m_settings; } | 		const Settings& getSettings() const { return m_settings; } | ||||||
| 
 | 
 | ||||||
| 		static MsgConfigureHackRT* create(const Settings& settings) | 		static MsgConfigureHackRF* create(const Settings& settings) | ||||||
| 		{ | 		{ | ||||||
| 			return new MsgConfigureHackRT(settings); | 			return new MsgConfigureHackRF(settings); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 	private: | 	private: | ||||||
| 		Settings m_settings; | 		Settings m_settings; | ||||||
| 
 | 
 | ||||||
| 		MsgConfigureHackRT(const Settings& settings) : | 		MsgConfigureHackRF(const Settings& settings) : | ||||||
| 			Message(), | 			Message(), | ||||||
| 			m_settings(settings) | 			m_settings(settings) | ||||||
| 		{ } | 		{ } | ||||||
| @ -74,19 +73,16 @@ public: | |||||||
| 		MESSAGE_CLASS_DECLARATION | 		MESSAGE_CLASS_DECLARATION | ||||||
| 
 | 
 | ||||||
| 	public: | 	public: | ||||||
| 		const std::vector<uint32_t>& getSampleRates() const { return m_sampleRates; } |  | ||||||
| 
 | 
 | ||||||
| 		static MsgReportHackRF* create(const std::vector<uint32_t>& sampleRates) | 		static MsgReportHackRF* create() | ||||||
| 		{ | 		{ | ||||||
| 			return new MsgReportHackRF(sampleRates); | 			return new MsgReportHackRF(); | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 	protected: | 	protected: | ||||||
| 		std::vector<uint32_t> m_sampleRates; |  | ||||||
| 
 | 
 | ||||||
| 		MsgReportHackRF(const std::vector<uint32_t>& sampleRates) : | 		MsgReportHackRF() : | ||||||
| 			Message(), | 			Message() | ||||||
| 			m_sampleRates(sampleRates) |  | ||||||
| 		{ } | 		{ } | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
| @ -100,21 +96,19 @@ public: | |||||||
| 	virtual const QString& getDeviceDescription() const; | 	virtual const QString& getDeviceDescription() const; | ||||||
| 	virtual int getSampleRate() const; | 	virtual int getSampleRate() const; | ||||||
| 	virtual quint64 getCenterFrequency() const; | 	virtual quint64 getCenterFrequency() const; | ||||||
| 	const std::vector<uint32_t>& getSampleRates() const { return m_sampleRates; } |  | ||||||
| 
 | 
 | ||||||
| 	virtual bool handleMessage(const Message& message); | 	virtual bool handleMessage(const Message& message); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
| 	bool applySettings(const Settings& settings, bool force); | 	bool applySettings(const Settings& settings, bool force); | ||||||
| 	struct airspy_device *open_airspy_from_sequence(int sequence); | 	hackrf_device *open_hackrf_from_sequence(int sequence); | ||||||
| 	void setCenterFrequency(quint64 freq); | 	void setCenterFrequency(quint64 freq); | ||||||
| 
 | 
 | ||||||
| 	QMutex m_mutex; | 	QMutex m_mutex; | ||||||
| 	Settings m_settings; | 	Settings m_settings; | ||||||
| 	struct airspy_device* m_dev; | 	struct hackrf_device* m_dev; | ||||||
| 	HackRFThread* m_airspyThread; | 	HackRFThread* m_hackRFThread; | ||||||
| 	QString m_deviceDescription; | 	QString m_deviceDescription; | ||||||
| 	std::vector<uint32_t> m_sampleRates; |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| #endif // INCLUDE_HACKRFINPUT_H
 | #endif // INCLUDE_HACKRFINPUT_H
 | ||||||
|  | |||||||
| @ -16,7 +16,7 @@ | |||||||
| 
 | 
 | ||||||
| #include <QtPlugin> | #include <QtPlugin> | ||||||
| #include <QAction> | #include <QAction> | ||||||
| #include <libhackrf/hackrf.h> | #include "libhackrf/hackrf.h" | ||||||
| 
 | 
 | ||||||
| #include "hackrfplugin.h" | #include "hackrfplugin.h" | ||||||
| 
 | 
 | ||||||
| @ -25,7 +25,7 @@ | |||||||
| #include "util/simpleserializer.h" | #include "util/simpleserializer.h" | ||||||
| 
 | 
 | ||||||
| const PluginDescriptor HackRFPlugin::m_pluginDescriptor = { | const PluginDescriptor HackRFPlugin::m_pluginDescriptor = { | ||||||
| 	QString("Airspy Input"), | 	QString("HackRF Input"), | ||||||
| 	QString("---"), | 	QString("---"), | ||||||
| 	QString("(c) Edouard Griffiths, F4EXB"), | 	QString("(c) Edouard Griffiths, F4EXB"), | ||||||
| 	QString("https://github.com/f4exb/sdrangel"), | 	QString("https://github.com/f4exb/sdrangel"), | ||||||
| @ -47,70 +47,68 @@ const PluginDescriptor& HackRFPlugin::getPluginDescriptor() const | |||||||
| void HackRFPlugin::initPlugin(PluginAPI* pluginAPI) | void HackRFPlugin::initPlugin(PluginAPI* pluginAPI) | ||||||
| { | { | ||||||
| 	m_pluginAPI = pluginAPI; | 	m_pluginAPI = pluginAPI; | ||||||
| 	m_pluginAPI->registerSampleSource("org.osmocom.sdr.samplesource.airspy", this); | 	m_pluginAPI->registerSampleSource("org.osmocom.sdr.samplesource.hackrf", this); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| PluginInterface::SampleSourceDevices HackRFPlugin::enumSampleSources() | PluginInterface::SampleSourceDevices HackRFPlugin::enumSampleSources() | ||||||
| { | { | ||||||
| 	SampleSourceDevices result; | 	SampleSourceDevices result; | ||||||
| 	airspy_read_partid_serialno_t read_partid_serialno; | 	hackrf_device_list_t *hackrf_devices = hackrf_device_list(); | ||||||
| 	struct airspy_device *devinfo; | 	hackrf_device *hackrf_ptr; | ||||||
| 	uint32_t serial_msb = 0; | 	read_partid_serialno_t read_partid_serialno; | ||||||
| 	uint32_t serial_lsb = 0; | 	hackrf_error rc; | ||||||
| 	airspy_error rc; |  | ||||||
| 	int i; | 	int i; | ||||||
| 
 | 
 | ||||||
| 	rc = (airspy_error) airspy_init(); | 	rc = (hackrf_error) hackrf_init(); | ||||||
| 
 | 
 | ||||||
| 	if (rc != AIRSPY_SUCCESS) | 	if (rc != HACKRF_SUCCESS) | ||||||
| 	{ | 	{ | ||||||
| 		qCritical("AirspyPlugin::enumSampleSources: failed to initiate Airspy library: %s", airspy_error_name(rc)); | 		qCritical("HackRFPlugin::SampleSourceDevices: failed to initiate HackRF library: %s", hackrf_error_name(rc)); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	for (i=0; i < AIRSPY_MAX_DEVICE; i++) |  | ||||||
| 	{ |  | ||||||
| 		rc = (airspy_error) airspy_open(&devinfo); |  | ||||||
| 
 | 
 | ||||||
| 		if (rc == AIRSPY_SUCCESS) |  | ||||||
| 		{ |  | ||||||
| 			qDebug("AirspyPlugin::enumSampleSources: try to enumerate Airspy device #%d", i); |  | ||||||
| 
 | 
 | ||||||
| 			rc = (airspy_error) airspy_board_partid_serialno_read(devinfo, &read_partid_serialno); |  | ||||||
| 
 | 
 | ||||||
| 			if (rc != AIRSPY_SUCCESS) | 	for (i=0; i < hackrf_devices->devicecount; i++) | ||||||
| 	{ | 	{ | ||||||
| 				qDebug("AirspyPlugin::enumSampleSources: failed to read serial no: %s", airspy_error_name(rc)); | 		rc = (hackrf_error) hackrf_device_list_open(hackrf_devices, i, &hackrf_ptr); | ||||||
| 				airspy_close(devinfo); | 
 | ||||||
|  | 		if (rc == HACKRF_SUCCESS) | ||||||
|  | 		{ | ||||||
|  | 			qDebug("HackRFPlugin::enumSampleSources: try to enumerate HackRF device #%d", i); | ||||||
|  | 
 | ||||||
|  | 			rc = (hackrf_error) hackrf_board_partid_serialno_read(hackrf_ptr, &read_partid_serialno); | ||||||
|  | 
 | ||||||
|  | 			if (rc != HACKRF_SUCCESS) | ||||||
|  | 			{ | ||||||
|  | 				qDebug("HackRFPlugin::enumSampleSources: failed to read serial no: %s", hackrf_error_name(rc)); | ||||||
|  | 				hackrf_close(hackrf_ptr); | ||||||
| 				continue; // next
 | 				continue; // next
 | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			if ((read_partid_serialno.serial_no[2] != serial_msb) && (read_partid_serialno.serial_no[3] != serial_lsb)) | 			uint32_t serial_msb = read_partid_serialno.serial_no[2]; | ||||||
| 			{ | 			uint32_t serial_lsb = read_partid_serialno.serial_no[3]; | ||||||
| 				serial_msb = read_partid_serialno.serial_no[2]; |  | ||||||
| 				serial_lsb = read_partid_serialno.serial_no[3]; |  | ||||||
| 
 | 
 | ||||||
| 			QString serial_str = QString::number(serial_msb, 16) + QString::number(serial_lsb, 16); | 			QString serial_str = QString::number(serial_msb, 16) + QString::number(serial_lsb, 16); | ||||||
| 			uint64_t serial_num = (((uint64_t) serial_msb)<<32) + serial_lsb; | 			uint64_t serial_num = (((uint64_t) serial_msb)<<32) + serial_lsb; | ||||||
| 				QString displayedName(QString("Airspy #%1 0x%2").arg(i).arg(serial_str)); | 			QString displayedName(QString("HackRF #%1 0x%2").arg(i).arg(serial_str)); | ||||||
| 			SimpleSerializer s(1); | 			SimpleSerializer s(1); | ||||||
| 			s.writeS32(1, i); | 			s.writeS32(1, i); | ||||||
| 			s.writeString(2, serial_str); | 			s.writeString(2, serial_str); | ||||||
| 			s.writeU64(3, serial_num); | 			s.writeU64(3, serial_num); | ||||||
| 				result.append(SampleSourceDevice(displayedName, "org.osmocom.sdr.samplesource.airspy", s.final())); | 			result.append(SampleSourceDevice(displayedName, "org.osmocom.sdr.samplesource.hackrf", s.final())); | ||||||
| 				qDebug("AirspyPlugin::enumSampleSources: enumerated Airspy device #%d", i); | 			qDebug("HackRFPlugin::enumSampleSources: enumerated HackRF device #%d", i); | ||||||
| 			} |  | ||||||
| 
 | 
 | ||||||
| 			airspy_close(devinfo); | 			hackrf_close(hackrf_ptr); | ||||||
| 		} | 		} | ||||||
| 		else | 		else | ||||||
| 		{ | 		{ | ||||||
| 			qDebug("AirspyPlugin::enumSampleSources: enumerated %d Airspy devices %s", i, airspy_error_name(rc)); | 			qDebug("HackRFPlugin::enumSampleSources: failed to enumerate HackRF device #%d: %s", i, hackrf_error_name(rc)); | ||||||
| 			break; // finished
 |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	rc = (airspy_error) airspy_exit(); | 	rc = (hackrf_error) hackrf_exit(); | ||||||
| 	qDebug("AirspyPlugin::enumSampleSources: airspy_exit: %s", airspy_error_name(rc)); | 	qDebug("HackRFPlugin::enumSampleSources: hackrf_exit: %s", hackrf_error_name(rc)); | ||||||
| 
 | 
 | ||||||
| 	return result; | 	return result; | ||||||
| } | } | ||||||
| @ -122,7 +120,7 @@ PluginGUI* HackRFPlugin::createSampleSourcePluginGUI(const QString& sourceName, | |||||||
| 		return 0; | 		return 0; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if(sourceName == "org.osmocom.sdr.samplesource.airspy") | 	if(sourceName == "org.osmocom.sdr.samplesource.hackrf") | ||||||
| 	{ | 	{ | ||||||
| 		HackRFGui* gui = new HackRFGui(m_pluginAPI); | 		HackRFGui* gui = new HackRFGui(m_pluginAPI); | ||||||
| 		m_pluginAPI->setInputGUI(gui); | 		m_pluginAPI->setInputGUI(gui); | ||||||
|  | |||||||
| @ -29,11 +29,10 @@ void HackRFSerializer::writeSerializedData(const AirspyData& data, QByteArray& s | |||||||
| 	s.writeU32(4, data.m_log2Decim); | 	s.writeU32(4, data.m_log2Decim); | ||||||
| 	s.writeS32(5, data.m_fcPos); | 	s.writeS32(5, data.m_fcPos); | ||||||
| 	s.writeU32(6, data.m_lnaGain); | 	s.writeU32(6, data.m_lnaGain); | ||||||
| 	s.writeU32(7, data.m_imjRejFilterIndex); | 	s.writeU32(7, data.m_bandwidthIndex); | ||||||
| 	s.writeU32(8, data.m_bandwidthIndex); | 	s.writeU32(8, data.m_vgaGain); | ||||||
| 	s.writeU32(9, data.m_vgaGain); | 	s.writeBool(9, data.m_biasT); | ||||||
| 	s.writeBool(10, data.m_biasT); | 	s.writeBool(10, data.m_lnaExt); | ||||||
| 	s.writeBool(11, data.m_lnaExt); |  | ||||||
| 
 | 
 | ||||||
| 	serializedData = s.final(); | 	serializedData = s.final(); | ||||||
| } | } | ||||||
| @ -61,12 +60,11 @@ bool HackRFSerializer::readSerializedData(const QByteArray& serializedData, Airs | |||||||
| 		d.readU32(3, &data.m_sampleRateIndex, 0); | 		d.readU32(3, &data.m_sampleRateIndex, 0); | ||||||
| 		d.readU32(4, &data.m_log2Decim, 0); | 		d.readU32(4, &data.m_log2Decim, 0); | ||||||
| 		d.readS32(5, &data.m_fcPos, 0); | 		d.readS32(5, &data.m_fcPos, 0); | ||||||
| 		d.readU32(6, &data.m_lnaGain, 14); | 		d.readU32(6, &data.m_lnaGain, 16); | ||||||
| 		d.readU32(7, &data.m_imjRejFilterIndex, 0); | 		d.readU32(7, &data.m_bandwidthIndex, 0); | ||||||
| 		d.readU32(8, &data.m_bandwidthIndex, 0); | 		d.readU32(8, &data.m_vgaGain, 16); | ||||||
| 		d.readU32(9, &data.m_vgaGain, 4); | 		d.readBool(9, &data.m_biasT, false); | ||||||
| 		d.readBool(10, &data.m_biasT, false); | 		d.readBool(10, &data.m_lnaExt, false); | ||||||
| 		d.readBool(11, &data.m_lnaExt, false); |  | ||||||
| 
 | 
 | ||||||
| 		return SampleSourceSerializer::readSerializedData(sampleSourceSerialized, data.m_data); | 		return SampleSourceSerializer::readSerializedData(sampleSourceSerialized, data.m_data); | ||||||
| 	} | 	} | ||||||
| @ -83,10 +81,9 @@ void HackRFSerializer::setDefaults(AirspyData& data) | |||||||
| 	data.m_sampleRateIndex = 0; | 	data.m_sampleRateIndex = 0; | ||||||
| 	data.m_log2Decim = 0; | 	data.m_log2Decim = 0; | ||||||
| 	data.m_fcPos = 0; | 	data.m_fcPos = 0; | ||||||
| 	data.m_lnaGain = 14; | 	data.m_lnaGain = 16; | ||||||
| 	data.m_imjRejFilterIndex = 0; |  | ||||||
| 	data.m_bandwidthIndex = 0; | 	data.m_bandwidthIndex = 0; | ||||||
| 	data.m_vgaGain = 4; | 	data.m_vgaGain = 16; | ||||||
| 	data.m_biasT = false; | 	data.m_biasT = false; | ||||||
| 	data.m_lnaExt = false; | 	data.m_lnaExt = false; | ||||||
| } | } | ||||||
|  | |||||||
| @ -30,7 +30,6 @@ public: | |||||||
| 		quint32 m_log2Decim; | 		quint32 m_log2Decim; | ||||||
| 		qint32 m_fcPos; | 		qint32 m_fcPos; | ||||||
| 		quint32 m_lnaGain; | 		quint32 m_lnaGain; | ||||||
| 		quint32 m_imjRejFilterIndex; |  | ||||||
| 		quint32 m_bandwidthIndex; | 		quint32 m_bandwidthIndex; | ||||||
| 		quint32 m_vgaGain; | 		quint32 m_vgaGain; | ||||||
| 		bool m_biasT; | 		bool m_biasT; | ||||||
|  | |||||||
| @ -22,11 +22,11 @@ | |||||||
| 
 | 
 | ||||||
| HackRFThread *HackRFThread::m_this = 0; | HackRFThread *HackRFThread::m_this = 0; | ||||||
| 
 | 
 | ||||||
| HackRFThread::HackRFThread(struct airspy_device* dev, SampleFifo* sampleFifo, QObject* parent) : | HackRFThread::HackRFThread(hackrf_device* dev, SampleFifo* sampleFifo, QObject* parent) : | ||||||
| 	QThread(parent), | 	QThread(parent), | ||||||
| 	m_running(false), | 	m_running(false), | ||||||
| 	m_dev(dev), | 	m_dev(dev), | ||||||
| 	m_convertBuffer(AIRSPY_BLOCKSIZE), | 	m_convertBuffer(HACKRF_BLOCKSIZE), | ||||||
| 	m_sampleFifo(sampleFifo), | 	m_sampleFifo(sampleFifo), | ||||||
| 	m_samplerate(10), | 	m_samplerate(10), | ||||||
| 	m_log2Decim(0), | 	m_log2Decim(0), | ||||||
| @ -74,41 +74,41 @@ void HackRFThread::setFcPos(int fcPos) | |||||||
| 
 | 
 | ||||||
| void HackRFThread::run() | void HackRFThread::run() | ||||||
| { | { | ||||||
| 	airspy_error rc; | 	hackrf_error rc; | ||||||
| 
 | 
 | ||||||
| 	m_running = true; | 	m_running = true; | ||||||
| 	m_startWaiter.wakeAll(); | 	m_startWaiter.wakeAll(); | ||||||
| 
 | 
 | ||||||
| 	rc = (airspy_error) airspy_start_rx(m_dev, rx_callback, NULL); | 	rc = (hackrf_error) hackrf_start_rx(m_dev, rx_callback, NULL); | ||||||
| 
 | 
 | ||||||
| 	if (rc != AIRSPY_SUCCESS) | 	if (rc != HACKRF_SUCCESS) | ||||||
| 	{ | 	{ | ||||||
| 		qCritical("AirspyInput::run: failed to start Airspy Rx: %s", airspy_error_name(rc)); | 		qCritical("HackRFThread::run: failed to start HackRF Rx: %s", hackrf_error_name(rc)); | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 		while ((m_running) && (airspy_is_streaming(m_dev) == AIRSPY_TRUE)) | 		while ((m_running) && (hackrf_is_streaming(m_dev) == HACKRF_TRUE)) | ||||||
| 		{ | 		{ | ||||||
| 			sleep(1); | 			sleep(1); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	rc = (airspy_error) airspy_stop_rx(m_dev); | 	rc = (hackrf_error) hackrf_stop_rx(m_dev); | ||||||
| 
 | 
 | ||||||
| 	if (rc == AIRSPY_SUCCESS) | 	if (rc == HACKRF_SUCCESS) | ||||||
| 	{ | 	{ | ||||||
| 		qDebug("AirspyInput::run: stopped Airspy Rx"); | 		qDebug("HackRFThread::run: stopped HackRF Rx"); | ||||||
| 	} | 	} | ||||||
| 	else | 	else | ||||||
| 	{ | 	{ | ||||||
| 		qDebug("AirspyInput::run: failed to stop Airspy Rx: %s", airspy_error_name(rc)); | 		qDebug("HackRFThread::run: failed to stop HackRF Rx: %s", hackrf_error_name(rc)); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	m_running = false; | 	m_running = false; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| //  Decimate according to specified log2 (ex: log2=4 => decim=16)
 | //  Decimate according to specified log2 (ex: log2=4 => decim=16)
 | ||||||
| void HackRFThread::callback(const qint16* buf, qint32 len) | void HackRFThread::callback(const qint8* buf, qint32 len) | ||||||
| { | { | ||||||
| 	SampleVector::iterator it = m_convertBuffer.begin(); | 	SampleVector::iterator it = m_convertBuffer.begin(); | ||||||
| 
 | 
 | ||||||
| @ -202,9 +202,9 @@ void HackRFThread::callback(const qint16* buf, qint32 len) | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| int HackRFThread::rx_callback(airspy_transfer_t* transfer) | int HackRFThread::rx_callback(hackrf_transfer* transfer) | ||||||
| { | { | ||||||
| 	qint32 bytes_to_write = transfer->sample_count * sizeof(qint16); | 	qint32 bytes_to_write = transfer->valid_length; | ||||||
| 	m_this->callback((qint16 *) transfer->samples, bytes_to_write); | 	m_this->callback((qint8 *) transfer->buffer, bytes_to_write); | ||||||
| 	return 0; | 	return 0; | ||||||
| } | } | ||||||
|  | |||||||
| @ -30,7 +30,7 @@ class HackRFThread : public QThread { | |||||||
| 	Q_OBJECT | 	Q_OBJECT | ||||||
| 
 | 
 | ||||||
| public: | public: | ||||||
| 	HackRFThread(struct airspy_device* dev, SampleFifo* sampleFifo, QObject* parent = NULL); | 	HackRFThread(hackrf_device* dev, SampleFifo* sampleFifo, QObject* parent = NULL); | ||||||
| 	~HackRFThread(); | 	~HackRFThread(); | ||||||
| 
 | 
 | ||||||
| 	void startWork(); | 	void startWork(); | ||||||
| @ -44,7 +44,7 @@ private: | |||||||
| 	QWaitCondition m_startWaiter; | 	QWaitCondition m_startWaiter; | ||||||
| 	bool m_running; | 	bool m_running; | ||||||
| 
 | 
 | ||||||
| 	struct airspy_device* m_dev; | 	hackrf_device* m_dev; | ||||||
| 	qint16 m_buf[2*HACKRF_BLOCKSIZE]; | 	qint16 m_buf[2*HACKRF_BLOCKSIZE]; | ||||||
| 	SampleVector m_convertBuffer; | 	SampleVector m_convertBuffer; | ||||||
| 	SampleFifo* m_sampleFifo; | 	SampleFifo* m_sampleFifo; | ||||||
| @ -54,11 +54,11 @@ private: | |||||||
| 	int m_fcPos; | 	int m_fcPos; | ||||||
| 	static HackRFThread *m_this; | 	static HackRFThread *m_this; | ||||||
| 
 | 
 | ||||||
| 	Decimators<qint16, SDR_SAMP_SZ, 12> m_decimators; | 	Decimators<qint8, SDR_SAMP_SZ, 8> m_decimators; | ||||||
| 
 | 
 | ||||||
| 	void run(); | 	void run(); | ||||||
| 	void callback(const qint16* buf, qint32 len); | 	void callback(const qint8* buf, qint32 len); | ||||||
| 	static int rx_callback(airspy_transfer_t* transfer); | 	static int rx_callback(hackrf_transfer* transfer); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| #endif // INCLUDE_HACKRFTHREAD_H
 | #endif // INCLUDE_HACKRFTHREAD_H
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user