Skip to content

Commit

Permalink
add bias tee support, bump version, update copyright date
Browse files Browse the repository at this point in the history
  • Loading branch information
jpoirier committed Jun 20, 2017
1 parent 716a333 commit e668aca
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 7 deletions.
2 changes: 1 addition & 1 deletion exports.go
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
12 changes: 9 additions & 3 deletions mock_test/gortlsdr/librtlsdr.c
Original file line number Diff line number Diff line change
@@ -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.
*
Expand All @@ -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)

Expand Down Expand Up @@ -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;
}
9 changes: 9 additions & 0 deletions mock_test/gortlsdr/rtl-sdr_moc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 24 additions & 1 deletion mock_test/main.go
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -505,6 +525,9 @@ func main() {
GetOffsetTuning(d, i)
SetOffsetTuning(d, i)

SetBiasTee(d, i)
SetBiasTee(d, i)

SetHwInfo(d, i)
GetHwInfo(d, i)

Expand Down
14 changes: 12 additions & 2 deletions rtlsdr.go
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e668aca

Please sign in to comment.