From e668acaa3a11c18059707fcd373735cf331ab200 Mon Sep 17 00:00:00 2001 From: Joseph Poirier Date: Tue, 20 Jun 2017 11:23:02 -0500 Subject: [PATCH] add bias tee support, bump version, update copyright date --- exports.go | 2 +- mock_test/gortlsdr/librtlsdr.c | 12 +++++++++--- mock_test/gortlsdr/rtl-sdr_moc.h | 9 +++++++++ mock_test/main.go | 25 ++++++++++++++++++++++++- rtlsdr.go | 14 ++++++++++++-- 5 files changed, 55 insertions(+), 7 deletions(-) diff --git a/exports.go b/exports.go index e6ea415..1076ee7 100644 --- a/exports.go +++ b/exports.go @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2016 Joseph D Poirier +// Copyright (c) 2012-2017 Joseph D Poirier // Distributable under the terms of The New BSD License // that can be found in the LICENSE file. diff --git a/mock_test/gortlsdr/librtlsdr.c b/mock_test/gortlsdr/librtlsdr.c index 6e12e44..b399d4b 100644 --- a/mock_test/gortlsdr/librtlsdr.c +++ b/mock_test/gortlsdr/librtlsdr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016 Joseph D Poirier + * Copyright (c) 2015-2017 Joseph D Poirier * Distributable under the terms of The New BSD License * that can be found in the LICENSE file. * @@ -22,8 +22,8 @@ #define DEBVICE_CNT (3) #define DEVICE_GAIN_CNT (29) #define EEPROM_SIZE (256) -#define DEFAULT_BUF_NUMBER (15) -#define DEFAULT_BUF_LENGTH (16 * 32 * 512) +#define DEFAULT_BUF_NUMBER (15) +#define DEFAULT_BUF_LENGTH (16 * 32 * 512) #define STRINGS_OFFSET_START (9) #define MAX_RAW_STR_SZ (2*35+2) @@ -641,3 +641,9 @@ int rtlsdr_cancel_async(rtlsdr_dev_t *dev) { pthread_mutex_unlock(&dev->lock); return 0; } + +int rtlsdr_set_bias_tee(rtlsdr_dev_t *dev, int on) { + if (!dev) + return -1; + return 0; +} diff --git a/mock_test/gortlsdr/rtl-sdr_moc.h b/mock_test/gortlsdr/rtl-sdr_moc.h index 121c0ab..b3f21e1 100644 --- a/mock_test/gortlsdr/rtl-sdr_moc.h +++ b/mock_test/gortlsdr/rtl-sdr_moc.h @@ -431,6 +431,15 @@ extern int rtlsdr_read_async(rtlsdr_dev_t *dev, */ extern int rtlsdr_cancel_async(rtlsdr_dev_t *dev); +/*! + * Enable or disable the bias tee on GPIO PIN 0. + * + * \param dev the device handle given by rtlsdr_open() + * \param on 1 for Bias T on. 0 for Bias T off. + * \return -1 if device is not initialized. 0 otherwise. + */ +extern int rtlsdr_set_bias_tee(rtlsdr_dev_t *dev, int on); + #ifdef __cplusplus } #endif diff --git a/mock_test/main.go b/mock_test/main.go index a3c724b..f5e0d08 100644 --- a/mock_test/main.go +++ b/mock_test/main.go @@ -1,4 +1,4 @@ -// Copyright (c) 2015-2016 Joseph D Poirier +// Copyright (c) 2015-2017 Joseph D Poirier // Distributable under the terms of The New BSD License // that can be found in the LICENSE file. @@ -369,6 +369,26 @@ func SetHwInfo(d *rtl.Context, i int) { } } +func SetBiasTee(d *rtl.Context, i int) { + var err error + + if err = d.SetBiasTee(true); err != nil { + failed++ + log.Printf("--- FAILED, SetBiasTee i:%d - %s\n", i, err) + } else { + passed++ + log.Printf("--- PASSED, SetBiasTee i:%d\n", i) + } + + if err = d.SetBiasTee(false); err != nil { + failed++ + log.Printf("--- FAILED, SetBiasTee i:%d - %s\n", i, err) + } else { + passed++ + log.Printf("--- PASSED, SetBiasTee i:%d\n", i) + } +} + var asyncReadCnt int func rtlsdrCb(buf []byte) { @@ -505,6 +525,9 @@ func main() { GetOffsetTuning(d, i) SetOffsetTuning(d, i) + SetBiasTee(d, i) + SetBiasTee(d, i) + SetHwInfo(d, i) GetHwInfo(d, i) diff --git a/rtlsdr.go b/rtlsdr.go index 73e5f56..37792ac 100644 --- a/rtlsdr.go +++ b/rtlsdr.go @@ -1,4 +1,4 @@ -// Copyright (c) 2012-2016 Joseph D Poirier +// Copyright (c) 2012-2017 Joseph D Poirier // Distributable under the terms of The New BSD License // that can be found in the LICENSE file. @@ -38,7 +38,7 @@ static inline rtlsdr_read_async_cb_t get_go_cb() { import "C" // PackageVersion is the current version -var PackageVersion = "v2.9.16" +var PackageVersion = "v2.10.0" // ReadAsyncCbT defines a user callback function type. type ReadAsyncCbT func([]byte) @@ -587,6 +587,16 @@ func (dev *Context) CancelAsync() error { return libError(i) } +// SetBiasTee enables or disables bias tee. +func (dev *Context) SetBiasTee(enable bool) error { + mode := 0 // off + if enable { + mode = 1 // on + } + i := int(C.rtlsdr_set_bias_tee((*C.rtlsdr_dev_t)(dev), C.int(mode))) + return libError(i) +} + // GetHwInfo gets the dongle's information items. func (dev *Context) GetHwInfo() (info HwInfo, err error) { data := make([]uint8, EepromSize)