Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/bias tee #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ missing
*.pyc
.md5sums
RTL2832U
*.swp
8 changes: 7 additions & 1 deletion RTL2832U.prf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ False: Does not need control and can just attach to any currently tasked device
<kind kindtype="property"/>
<action type="external"/>
</simple>
<simple id="bias_enable" mode="readwrite" name="bias_enable" type="boolean">
<description>Since RTL v3, a bias tee is included to drive 3.3V out the antenna port to power active LNAs/antennas.</description>
<value>False</value>
<kind kindtype="property"/>
<action type="external"/>
</simple>
<struct id="FRONTEND::scanner_allocation" mode="writeonly" name="frontend_scanner_allocation">
<description>Frontend Interfaces scanner allocation structure</description>
<simple id="FRONTEND::scanner_allocation::min_freq" name="min_freq" type="double"/>
Expand All @@ -237,4 +243,4 @@ False: Does not need control and can just attach to any currently tasked device
<simple id="FRONTEND::scanner_allocation::control_limit" name="control_limit" type="double"/>
<configurationkind kindtype="allocation"/>
</struct>
</properties>
</properties>
45 changes: 29 additions & 16 deletions cpp/RTL2832U.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,6 @@ int RTL2832U_i::serviceFunction()
return NOOP;
}

/* acquires the prop_lock and the rtl_tuner.lock */
//void RTL2832U_i::initialize() throw (CF::LifeCycle::InitializeError, CORBA::SystemException)
//{
// RTL2832U_base::initialize();
//
//
//}

void RTL2832U_i::construct()
{
/***********************************************************************************
Expand All @@ -326,6 +318,7 @@ void RTL2832U_i::construct()
// set some default values that should get overwritten by correct values
group_id = "RTL_GROUP_ID_NOT_SET";
digital_agc_enable = false;
bias_enable = false;

//target_device.index = -1;

Expand All @@ -339,14 +332,23 @@ void RTL2832U_i::construct()
this function is invoked in the constructor
***********************************************************************************/

addPropertyChangeListener("target_device", this, &RTL2832U_i::targetDeviceChanged);
addPropertyChangeListener("group_id", this, &RTL2832U_i::groupIdChanged);
addPropertyChangeListener("digital_agc_enable", this, &RTL2832U_i::rtl2832uAgcEnableChanged);
addPropertyChangeListener("update_available_devices", this, &RTL2832U_i::updateAvailableDevicesChanged);
addPropertyChangeListener("frequency_correction", this, &RTL2832U_i::frequencyCorrectionChanged);

addPropertyListener(target_device, this, &RTL2832U_i::targetDeviceChanged);
addPropertyListener(group_id, this, &RTL2832U_i::groupIdChanged);
addPropertyListener(digital_agc_enable, this, &RTL2832U_i::rtl2832uAgcEnableChanged);
addPropertyListener(update_available_devices, this, &RTL2832U_i::updateAvailableDevicesChanged);
addPropertyListener(frequency_correction, this, &RTL2832U_i::frequencyCorrectionChanged);
addPropertyListener(bias_enable, this, &RTL2832U_i::biasEnableChanged);
}

LOG_INFO(RTL2832U_i, "Target Device Index " << target_device.index)
/* Developer Note: Property overrides from DCD are applied AFTER the constructor and do not trigger
* property change listeners(?). In order for property overrides from DCD to be properly applied,
* initialize the rtl device inside the 'initialize' method. */
/* acquires the prop_lock and the rtl_tuner.lock */
void RTL2832U_i::initialize() throw (CF::LifeCycle::InitializeError, CORBA::SystemException)
{
RTL2832U_base::initialize();

LOG_INFO(RTL2832U_i, "Target Device Index " << target_device.index)
{ // scope for prop_lock
exclusive_lock lock(prop_lock);

Expand Down Expand Up @@ -1108,6 +1110,14 @@ void RTL2832U_i::frequencyCorrectionChanged(const short* old_value, const short*
}
}

/* acquires the rtl_tuner.lock */
void RTL2832U_i::biasEnableChanged(const bool* old_value, const bool* new_value){
LOG_TRACE(RTL2832U_i,__PRETTY_FUNCTION__);
if(rtl_device_ptr != NULL)
scoped_tuner_lock tuner_lock(rtl_tuner.lock);
rtl_device_ptr->setBiasMode(*new_value);
}

/*************************************************************
Helper functions
*************************************************************/
Expand Down Expand Up @@ -1166,7 +1176,7 @@ void RTL2832U_i::initRtl() throw (CF::PropertySet::InvalidConfiguration) {
current_device.vendor.clear();
current_device.serial.clear();
rtl_tuner.reset();
digital_agc_enable = false;
//digital_agc_enable = false;

// update available devices
updateAvailableDevices();
Expand Down Expand Up @@ -1257,6 +1267,9 @@ void RTL2832U_i::initRtl() throw (CF::PropertySet::InvalidConfiguration) {

// set RTL2832 AGC mode according to property value
rtl_device_ptr->setAgcMode(digital_agc_enable);

// set bias mode according to property value
rtl_device_ptr->setBiasMode(bias_enable);

// start with tuner gain mode set to auto
rtl_device_ptr->setGainMode(true);
Expand Down
5 changes: 4 additions & 1 deletion cpp/RTL2832U.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class RTL2832U_i : public RTL2832U_base
int serviceFunction();

/* acquires the prop_lock and the rtl_tuner.lock */
// void initialize() throw (CF::LifeCycle::InitializeError, CORBA::SystemException);
void initialize() throw (CF::LifeCycle::InitializeError, CORBA::SystemException);

protected:

Expand Down Expand Up @@ -285,6 +285,9 @@ class RTL2832U_i : public RTL2832U_base

/* acquires the prop_lock and the rtl_tuner.lock */
void frequencyCorrectionChanged(const short* old_value, const short* new_value);

/* acquires the rtl_tuner.lock */
void biasEnableChanged(const bool* old_value, const bool* new_value);

//
// helper functions
Expand Down
9 changes: 9 additions & 0 deletions cpp/RTL2832U_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ void RTL2832U_base::loadProperties()
"ppm",
"external",
"property");

addProperty(bias_enable,
false,
"bias_enable",
"bias_enable",
"readwrite",
"",
"external",
"property");

frontend_listener_allocation = frontend::frontend_listener_allocation_struct();
frontend_tuner_allocation = frontend::frontend_tuner_allocation_struct();
Expand Down
2 changes: 2 additions & 0 deletions cpp/RTL2832U_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class RTL2832U_base : public frontend::FrontendScanningTunerDevice<frontend_tune
bool digital_agc_enable;
/// Property: frequency_correction
short frequency_correction;
/// Property: bias_enable
bool bias_enable;
/// Property: target_device
target_device_struct target_device;
/// Property: current_device
Expand Down
24 changes: 24 additions & 0 deletions cpp/RtlDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,30 @@ void RtlDevice::setAgcMode(bool enable)
}
}

/* Attempt to set the RTL2832 bias mode.
*/
void RtlDevice::setBiasMode(bool enable)
{
#ifdef HAS_RTLSDR_BIASTEE
LOG_TRACE(RtlDevice, __PRETTY_FUNCTION__);

if (m_device) {
// For error checking
int r;

if ((r = rtlsdr_set_bias_tee(m_device, (int) enable)) != 0) {
LOG_WARN(RtlDevice, "Unable to set RTL2832 bias mode to " << (enable ? "enabled" : "disabled") << " with error " << r);
} else {
LOG_INFO(RtlDevice, "RTL2832 bias mode set to " << (enable ? "enabled" : "disabled"));
}
} else {
LOG_WARN(RtlDevice, "Unable to set RTL2832 bias mode: Could not open RTL device "<<m_channelNumber);
}
#else
LOG_WARN(RtlDevice, "Unable to set RTL2832 bias mode: Device compiled with librtlsdr that does not include this function!");
#endif
}

/* Attempt to set the tuner gain mode.
*/
void RtlDevice::setGainMode(bool automatic)
Expand Down
3 changes: 2 additions & 1 deletion cpp/RtlDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ class RtlDevice

// sets AGC mode of RTL2832U chip
void setAgcMode(bool enable);

// sets bias-tee mode on RTL v3+
void setBiasMode(bool enable);
// sets gain mode (auto or manual) of the tuner chip
void setGainMode(bool enable);
// sets gain value of the tuner chip. Requires that gain mode be set to manual.
Expand Down
7 changes: 6 additions & 1 deletion cpp/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig"
PKG_CHECK_MODULES([PROJECTDEPS], [ossie >= 2.1.3 omniORB4 >= 4.1.0])
PKG_CHECK_MODULES([INTERFACEDEPS], [frontend >= 2.3, bulkio >= 2.1])
PKG_CHECK_MODULES([LIBRTLSDR], [librtlsdr = 0.5.2 libusb-1.0 >= 1.0.0 ])
PKG_CHECK_MODULES([LIBRTLSDR], [librtlsdr >= 0.5.4 libusb-1.0 >= 1.0.0 ], [HAS_RTLSDR_BIASTEE=1], [HAS_RTLSDR_BIASTEE=0])
AS_IF([test "$HAS_RTLSDR_BIASTEE" -eq 1],
[AC_DEFINE(HAS_RTLSDR_BIASTEE)],
[PKG_CHECK_MODULES([LIBRTLSDR], [librtlsdr >= 0.5.3 libusb-1.0 >= 1.0.0 ])])
AC_MSG_CHECKING(for LIBRTLSDR BIASTEE SUPPORT)
AC_MSG_RESULT($HAS_RTLSDR_BIASTEE)
PKG_CHECK_MODULES([LIBUUID], [uuid])
OSSIE_ENABLE_LOG4CXX
AX_BOOST_BASE([1.41])
Expand Down
7 changes: 3 additions & 4 deletions rh.RTL2832U.spec
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Prefix: %{_prefix}

Name: rh.RTL2832U
Version: 2.1.0
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Device %{name}

Group: REDHAWK/Devices
Expand All @@ -49,9 +49,8 @@ Requires: frontendInterfaces >= 2.3 bulkioInterfaces >= 2.1

# RTL requirements
BuildRequires: libusb1-devel >= 1.0.0
BuildRequires: librtlsdr >= 0.5.2
Requires: librtlsdr >= 0.5.2

BuildRequires: rtl-sdr-devel >= 0.5.3
Requires: rtl-sdr >= 0.5.3
Obsoletes: RTL2832U < 2.0.0


Expand Down