[hamradio-commits] [soapyhackrf] 01/05: New upstream version 0.3.2
Andreas E. Bombe
aeb at moszumanska.debian.org
Thu Nov 23 23:43:42 UTC 2017
This is an automated email from the git hooks/post-receive script.
aeb pushed a commit to annotated tag debian/0.3.2-1
in repository soapyhackrf.
commit 74cf8e7ff86971ee4d5eb7927a3e2b1ded7b6b60
Author: Andreas Bombe <aeb at debian.org>
Date: Fri Nov 24 00:22:12 2017 +0100
New upstream version 0.3.2
---
CMakeLists.txt | 4 +--
Changelog.txt | 9 +++++
FindLIBHACKRF.cmake | 82 +++++++++++++++++-----------------------------
HackRF_Settings.cpp | 18 ++++++++--
HackRF_Streaming.cpp | 92 ++++++++++++++++++++++++++++++++++++++++++++--------
debian/changelog | 6 ++++
6 files changed, 141 insertions(+), 70 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8590d90..b4affb4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,12 +16,12 @@ find_package(LIBHACKRF)
if (NOT LIBHACKRF_FOUND)
message(FATAL_ERROR "HackRF development files not found...")
endif ()
-message(STATUS "LIBHACKRF_INCLUDE_DIR - ${LIBHACKRF_INCLUDE_DIR}")
+message(STATUS "LIBHACKRF_INCLUDE_DIRS - ${LIBHACKRF_INCLUDE_DIRS}")
message(STATUS "LIBHACKRF_LIBRARIES - ${LIBHACKRF_LIBRARIES}")
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
-include_directories(${LIBHACKRF_INCLUDE_DIR})
+include_directories(${LIBHACKRF_INCLUDE_DIRS})
#enable c++11 features
if(CMAKE_COMPILER_IS_GNUCXX)
diff --git a/Changelog.txt b/Changelog.txt
index 31b4fc8..4cda0b5 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -1,3 +1,12 @@
+Release 0.3.2 (2017-11-19)
+==========================
+
+- Corrected order of gain elements in the Rx direction
+- Track settings during TX/RX switch for TRX switching
+- Prevent spin loop in SoapyHackRF::acquireReadBuffer()
+- Fix edge case in SoapyHackRF::releaseReadBuffer()
+- Standard style find script for FindLIBHACKRF.cmake
+
Release 0.3.1 (2017-06-19)
==========================
diff --git a/FindLIBHACKRF.cmake b/FindLIBHACKRF.cmake
index a97fec5..7188b67 100644
--- a/FindLIBHACKRF.cmake
+++ b/FindLIBHACKRF.cmake
@@ -1,55 +1,33 @@
-# - Try to find the libhackrf library
-# Once done this defines
-#
-# LIBHACKRF_FOUND - system has libhackrf
-# LIBHACKRF_INCLUDE_DIR - the libhackrf include directory
-# LIBHACKRF_LIBRARIES - Link these to use libhackrf
+# - Try to find libhackrf
+# Once done this will define
+# LIBHACKRF_FOUND - System has libhackrf
+# LIBHACKRF_INCLUDE_DIRS - The libhackrf include directories
+# LIBHACKRF_LIBRARIES - The libraries needed to use libhackrf
-# Copyright (c) 2013 Benjamin Vernoux
-#
+find_package(PkgConfig)
+pkg_check_modules(PC_LIBHACKRF QUIET libhackrf)
-
-if (LIBHACKRF_INCLUDE_DIR AND LIBHACKRF_LIBRARIES)
-
- # in cache already
- set(LIBHACKRF_FOUND TRUE)
-
-else (LIBHACKRF_INCLUDE_DIR AND LIBHACKRF_LIBRARIES)
- IF (NOT WIN32)
- # use pkg-config to get the directories and then use these values
- # in the FIND_PATH() and FIND_LIBRARY() calls
- find_package(PkgConfig)
- pkg_check_modules(PC_LIBHACKRF QUIET libhackrf)
- ENDIF(NOT WIN32)
-
- FIND_PATH(LIBHACKRF_INCLUDE_DIR
+find_path(LIBHACKRF_INCLUDE_DIR
NAMES hackrf.h
- HINTS $ENV{LIBHACKRF_DIR}/include ${PC_LIBHACKRF_INCLUDEDIR}
- PATHS /usr/local/include/libhackrf /usr/include/libhackrf /usr/local/include
- /usr/include ${CMAKE_SOURCE_DIR}/../libhackrf/src
- /opt/local/include/libhackrf
- ${LIBHACKRF_INCLUDE_DIR}
- )
-
- set(libhackrf_library_names hackrf)
-
- FIND_LIBRARY(LIBHACKRF_LIBRARIES
- NAMES ${libhackrf_library_names}
- HINTS $ENV{LIBHACKRF_DIR}/lib ${PC_LIBHACKRF_LIBDIR}
- PATHS /usr/local/lib /usr/lib /opt/local/lib ${PC_LIBHACKRF_LIBDIR} ${PC_LIBHACKRF_LIBRARY_DIRS} ${CMAKE_SOURCE_DIR}/../libhackrf/src
- )
-
- if(LIBHACKRF_INCLUDE_DIR)
- set(CMAKE_REQUIRED_INCLUDES ${LIBHACKRF_INCLUDE_DIR})
- endif()
-
- if(LIBHACKRF_LIBRARIES)
- set(CMAKE_REQUIRED_LIBRARIES ${LIBHACKRF_LIBRARIES})
- endif()
-
- include(FindPackageHandleStandardArgs)
- FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBHACKRF DEFAULT_MSG LIBHACKRF_LIBRARIES LIBHACKRF_INCLUDE_DIR)
-
- MARK_AS_ADVANCED(LIBHACKRF_INCLUDE_DIR LIBHACKRF_LIBRARIES)
-
-endif (LIBHACKRF_INCLUDE_DIR AND LIBHACKRF_LIBRARIES)
\ No newline at end of file
+ HINTS
+ $ENV{LIBHACKRF_DIR}/include
+ ${PC_LIBHACKRF_INCLUDEDIR}
+ ${PC_LIBHACKRF_INCLUDE_DIRS}
+ PATH_SUFFIXES libhackrf
+)
+
+find_library(LIBHACKRF_LIBRARY
+ NAMES hackrf
+ HINTS
+ $ENV{LIBHACKRF_DIR}/lib
+ ${PC_LIBHACKRF_LIBDIR}
+ ${PC_LIBHACKRF_LIBRARY_DIRS}
+)
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBHACKRF DEFAULT_MSG LIBHACKRF_LIBRARY LIBHACKRF_INCLUDE_DIR)
+
+mark_as_advanced(LIBHACKRF_INCLUDE_DIR LIBHACKRF_LIBRARY)
+
+set(LIBHACKRF_INCLUDE_DIRS ${LIBHACKRF_INCLUDE_DIR})
+set(LIBHACKRF_LIBRARIES ${LIBHACKRF_LIBRARY})
diff --git a/HackRF_Settings.cpp b/HackRF_Settings.cpp
index 4a8f1a6..4fb8bdd 100644
--- a/HackRF_Settings.cpp
+++ b/HackRF_Settings.cpp
@@ -251,10 +251,16 @@ std::vector<std::string> SoapyHackRF::listGains( const int direction, const size
std::vector<std::string> options;
if ( direction == SOAPY_SDR_RX )
{
- options.push_back( "LNA" );
+ // in gr-osmosdr/lib/soapy/ soapy_sink_c.cc and soapy_source_c.cc expect if_gain at front and bb_gain at back
+ options.push_back( "LNA" ); // RX: if_gain
+ options.push_back( "AMP" ); // RX: rf_gain
+ options.push_back( "VGA" ); // RX: bb_gain
+ }
+ else
+ {
+ options.push_back( "VGA" ); // TX: if_gain
+ options.push_back( "AMP" ); // TX: rf_gain
}
- options.push_back( "VGA" );
- options.push_back( "AMP" );
return(options);
/*
@@ -282,6 +288,7 @@ void SoapyHackRF::setGain( const int direction, const size_t channel, const doub
std::lock_guard<std::mutex> lock(_device_mutex);
int32_t ret(0), gain(0);
gain = value;
+ SoapySDR_logf(SOAPY_SDR_DEBUG,"setGain RF %s, channel %d, gain %d", direction == SOAPY_SDR_RX ? "RX" : "TX", channel, gain);
if ( direction == SOAPY_SDR_RX )
{
@@ -343,6 +350,7 @@ void SoapyHackRF::setGain( const int direction, const size_t channel, const doub
void SoapyHackRF::setGain( const int direction, const size_t channel, const std::string &name, const double value )
{
std::lock_guard<std::mutex> lock(_device_mutex);
+ SoapySDR_logf(SOAPY_SDR_DEBUG,"setGain %s %s, channel %d, gain %d", name.c_str(), direction == SOAPY_SDR_RX ? "RX" : "TX", channel, (int)value);
if ( name == "AMP" )
{
_current_amp = value;
@@ -354,6 +362,9 @@ void SoapyHackRF::setGain( const int direction, const size_t channel, const std:
_tx_stream.amp_gain=_current_amp;
}
+ if( ((direction == SOAPY_SDR_RX) && (_current_mode == HACKRF_TRANSCEIVER_MODE_RX))
+ || ((direction == SOAPY_SDR_TX) && (_current_mode == HACKRF_TRANSCEIVER_MODE_TX)) )
+ {
if ( _dev != NULL )
{
int ret = hackrf_set_amp_enable( _dev, (_current_amp > 0)?1 : 0 );
@@ -362,6 +373,7 @@ void SoapyHackRF::setGain( const int direction, const size_t channel, const std:
SoapySDR::logf( SOAPY_SDR_ERROR, "hackrf_set_amp_enable(%f) returned %s", _current_amp, hackrf_error_name( (hackrf_error) ret ) );
}
}
+ }
}else if ( direction == SOAPY_SDR_RX and name == "LNA" )
{
_rx_stream.lna_gain = value;
diff --git a/HackRF_Streaming.cpp b/HackRF_Streaming.cpp
index a331e64..e508953 100644
--- a/HackRF_Streaming.cpp
+++ b/HackRF_Streaming.cpp
@@ -300,6 +300,42 @@ int SoapyHackRF::activateStream(
}
hackrf_stop_tx(_dev);
+
+ // determine what (if any) settings need to be changed for RX; only applicable if there is both a source and sink block
+ // sample_rate
+ if(_current_samplerate != _rx_stream.samplerate) {
+ _current_samplerate = _rx_stream.samplerate;
+ SoapySDR_logf(SOAPY_SDR_DEBUG, "activateStream - Set RX samplerate to %f", _current_samplerate);
+ hackrf_set_sample_rate(_dev,_current_samplerate);
+ }
+
+ // frequency
+ if(_current_frequency != _rx_stream.frequency) {
+ _current_frequency = _rx_stream.frequency;
+ SoapySDR_logf(SOAPY_SDR_DEBUG, "activateStream - Set RX frequency to %lu", _current_frequency);
+ hackrf_set_freq(_dev,_current_frequency);
+ }
+
+ // frequency_correction; assume RX and TX use the same correction
+ // This will be the setting of whichever block was last added to the flow graph
+
+ // RF Gain (RF Amp for TX & RX)
+ if(_current_amp != _rx_stream.amp_gain) {
+ _current_amp = _rx_stream.amp_gain;
+ SoapySDR_logf(SOAPY_SDR_DEBUG, "activateStream - Set RX amp gain to %d", _current_amp);
+ hackrf_set_amp_enable(_dev,(_current_amp > 0)?1 : 0 );
+ }
+
+ // IF Gain (LNA for RX; VGA_TX for TX)
+ // BB Gain (VGA for RX; n/a for TX)
+ // These are independant values in the hackrf, so no need to change
+
+ // Bandwidth
+ if(_current_bandwidth !=_rx_stream.bandwidth) {
+ _current_bandwidth =_rx_stream.bandwidth;
+ SoapySDR_logf(SOAPY_SDR_DEBUG, "activateStream - Set RX bandwidth to %d", _current_bandwidth);
+ hackrf_set_baseband_filter_bandwidth(_dev,_current_bandwidth);
+ }
}
SoapySDR_logf(SOAPY_SDR_DEBUG, "Start RX");
@@ -329,7 +365,7 @@ int SoapyHackRF::activateStream(
_current_bandwidth=_rx_stream.bandwidth;
hackrf_set_baseband_filter_bandwidth(_dev,_current_bandwidth);
_current_amp=_rx_stream.amp_gain;
- hackrf_set_amp_enable(_dev,_current_amp);
+ hackrf_set_amp_enable(_dev,(_current_amp > 0)?1 : 0 );
hackrf_set_lna_gain(_dev,_rx_stream.lna_gain);
hackrf_set_vga_gain(_dev,_rx_stream.vga_gain);
hackrf_start_rx(_dev,_hackrf_rx_callback,(void *) this);
@@ -361,6 +397,43 @@ int SoapyHackRF::activateStream(
if(_current_mode==HACKRF_TRANSCEIVER_MODE_RX){
hackrf_stop_rx(_dev);
+
+ // determine what (if any) settings need to be changed for TX; only applicable if there is both a source and sink block
+ // sample_rate
+ if(_current_samplerate != _tx_stream.samplerate) {
+ _current_samplerate=_tx_stream.samplerate;
+ SoapySDR_logf(SOAPY_SDR_DEBUG, "activateStream - Set TX samplerate to %f", _current_samplerate);
+ hackrf_set_sample_rate(_dev,_current_samplerate);
+ }
+
+ // frequency
+ if(_current_frequency != _tx_stream.frequency) {
+ _current_frequency=_tx_stream.frequency;
+ SoapySDR_logf(SOAPY_SDR_DEBUG, "activateStream - Set TX frequency to %lu", _current_frequency);
+ hackrf_set_freq(_dev,_current_frequency);
+ }
+
+ // frequency_correction; assume RX and TX use the same correction
+ // This will be the setting of whichever block was last added to the flow graph
+
+ // RF Gain (RF Amp for TX & RX)
+ if(_current_amp != _tx_stream.amp_gain) {
+ _current_amp=_tx_stream.amp_gain;
+ SoapySDR_logf(SOAPY_SDR_DEBUG, "activateStream - Set TX amp gain to %d", _current_amp);
+ hackrf_set_amp_enable(_dev,(_current_amp > 0)?1 : 0 );
+ }
+
+ // IF Gain (LNA for RX, VGA_TX for TX)
+ // BB Gain (VGA for RX, n/a for TX)
+ // These are independant values in the hackrf, so no need to change
+
+ // Bandwidth
+ if(_current_bandwidth !=_tx_stream.bandwidth) {
+ _current_bandwidth =_tx_stream.bandwidth;
+ SoapySDR_logf(SOAPY_SDR_DEBUG, "activateStream - Set RX bandwidth to %d", _current_bandwidth);
+ hackrf_set_baseband_filter_bandwidth(_dev,_current_bandwidth);
+ }
+
}
SoapySDR_logf( SOAPY_SDR_DEBUG, "Start TX" );
@@ -385,7 +458,7 @@ int SoapyHackRF::activateStream(
_current_bandwidth=_tx_stream.bandwidth;
hackrf_set_baseband_filter_bandwidth(_dev,_current_bandwidth);
_current_amp=_rx_stream.amp_gain;
- hackrf_set_amp_enable(_dev,_current_amp);
+ hackrf_set_amp_enable(_dev,(_current_amp > 0)?1 : 0 );
hackrf_set_txvga_gain(_dev,_tx_stream.vga_gain);
hackrf_set_antenna_enable(_dev,_tx_stream.bias);
hackrf_start_tx(_dev,_hackrf_tx_callback,(void *) this);
@@ -688,12 +761,10 @@ int SoapyHackRF::acquireReadBuffer(
if ( _current_mode!=HACKRF_TRANSCEIVER_MODE_RX ) {
//wait for tx to be consumed before switching
- const auto exitTime = std::chrono::high_resolution_clock::now() + std::chrono::microseconds(timeoutUs);
- while (true)
{
std::unique_lock <std::mutex> lock( _buf_mutex );
- if (_tx_stream.buf_count == 0) break;
- if (std::chrono::high_resolution_clock::now() > exitTime) return SOAPY_SDR_TIMEOUT;
+ if (not _buf_cond.wait_for(lock, std::chrono::microseconds(timeoutUs),
+ [this]{return this->_tx_stream.buf_count == 0;})) return SOAPY_SDR_TIMEOUT;
}
int ret=this->activateStream(stream);
@@ -730,13 +801,8 @@ void SoapyHackRF::releaseReadBuffer(
throw std::runtime_error("Invalid stream");
}
- if(!_tx_stream.burst_end){
-
- std::unique_lock <std::mutex> lock( _buf_mutex );
-
- _rx_stream.buf_count--;
- }
-
+ std::unique_lock <std::mutex> lock( _buf_mutex );
+ _rx_stream.buf_count--;
}
int SoapyHackRF::acquireWriteBuffer(
diff --git a/debian/changelog b/debian/changelog
index 4381ccb..120420f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+soapyhackrf (0.3.2-1) unstable; urgency=low
+
+ * Release 0.3.2 (2017-11-19)
+
+ -- Josh Blum <josh at pothosware.com> Sun, 19 Nov 2017 15:39:14 -0000
+
soapyhackrf (0.3.1-1) unstable; urgency=low
* Release 0.3.1 (2017-06-19)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/soapyhackrf.git
More information about the pkg-hamradio-commits
mailing list