Skip to content

Commit 8185285

Browse files
authored
Merge pull request #26 from jpoirier/biastee
add bias tee support, bump version, update copyright date
2 parents 716a333 + e668aca commit 8185285

File tree

5 files changed

+55
-7
lines changed

5 files changed

+55
-7
lines changed

exports.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2012-2016 Joseph D Poirier
1+
// Copyright (c) 2012-2017 Joseph D Poirier
22
// Distributable under the terms of The New BSD License
33
// that can be found in the LICENSE file.
44

mock_test/gortlsdr/librtlsdr.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015-2016 Joseph D Poirier
2+
* Copyright (c) 2015-2017 Joseph D Poirier
33
* Distributable under the terms of The New BSD License
44
* that can be found in the LICENSE file.
55
*
@@ -22,8 +22,8 @@
2222
#define DEBVICE_CNT (3)
2323
#define DEVICE_GAIN_CNT (29)
2424
#define EEPROM_SIZE (256)
25-
#define DEFAULT_BUF_NUMBER (15)
26-
#define DEFAULT_BUF_LENGTH (16 * 32 * 512)
25+
#define DEFAULT_BUF_NUMBER (15)
26+
#define DEFAULT_BUF_LENGTH (16 * 32 * 512)
2727
#define STRINGS_OFFSET_START (9)
2828
#define MAX_RAW_STR_SZ (2*35+2)
2929

@@ -641,3 +641,9 @@ int rtlsdr_cancel_async(rtlsdr_dev_t *dev) {
641641
pthread_mutex_unlock(&dev->lock);
642642
return 0;
643643
}
644+
645+
int rtlsdr_set_bias_tee(rtlsdr_dev_t *dev, int on) {
646+
if (!dev)
647+
return -1;
648+
return 0;
649+
}

mock_test/gortlsdr/rtl-sdr_moc.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,15 @@ extern int rtlsdr_read_async(rtlsdr_dev_t *dev,
431431
*/
432432
extern int rtlsdr_cancel_async(rtlsdr_dev_t *dev);
433433

434+
/*!
435+
* Enable or disable the bias tee on GPIO PIN 0.
436+
*
437+
* \param dev the device handle given by rtlsdr_open()
438+
* \param on 1 for Bias T on. 0 for Bias T off.
439+
* \return -1 if device is not initialized. 0 otherwise.
440+
*/
441+
extern int rtlsdr_set_bias_tee(rtlsdr_dev_t *dev, int on);
442+
434443
#ifdef __cplusplus
435444
}
436445
#endif

mock_test/main.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2015-2016 Joseph D Poirier
1+
// Copyright (c) 2015-2017 Joseph D Poirier
22
// Distributable under the terms of The New BSD License
33
// that can be found in the LICENSE file.
44

@@ -369,6 +369,26 @@ func SetHwInfo(d *rtl.Context, i int) {
369369
}
370370
}
371371

372+
func SetBiasTee(d *rtl.Context, i int) {
373+
var err error
374+
375+
if err = d.SetBiasTee(true); err != nil {
376+
failed++
377+
log.Printf("--- FAILED, SetBiasTee i:%d - %s\n", i, err)
378+
} else {
379+
passed++
380+
log.Printf("--- PASSED, SetBiasTee i:%d\n", i)
381+
}
382+
383+
if err = d.SetBiasTee(false); err != nil {
384+
failed++
385+
log.Printf("--- FAILED, SetBiasTee i:%d - %s\n", i, err)
386+
} else {
387+
passed++
388+
log.Printf("--- PASSED, SetBiasTee i:%d\n", i)
389+
}
390+
}
391+
372392
var asyncReadCnt int
373393

374394
func rtlsdrCb(buf []byte) {
@@ -505,6 +525,9 @@ func main() {
505525
GetOffsetTuning(d, i)
506526
SetOffsetTuning(d, i)
507527

528+
SetBiasTee(d, i)
529+
SetBiasTee(d, i)
530+
508531
SetHwInfo(d, i)
509532
GetHwInfo(d, i)
510533

rtlsdr.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2012-2016 Joseph D Poirier
1+
// Copyright (c) 2012-2017 Joseph D Poirier
22
// Distributable under the terms of The New BSD License
33
// that can be found in the LICENSE file.
44

@@ -38,7 +38,7 @@ static inline rtlsdr_read_async_cb_t get_go_cb() {
3838
import "C"
3939

4040
// PackageVersion is the current version
41-
var PackageVersion = "v2.9.16"
41+
var PackageVersion = "v2.10.0"
4242

4343
// ReadAsyncCbT defines a user callback function type.
4444
type ReadAsyncCbT func([]byte)
@@ -587,6 +587,16 @@ func (dev *Context) CancelAsync() error {
587587
return libError(i)
588588
}
589589

590+
// SetBiasTee enables or disables bias tee.
591+
func (dev *Context) SetBiasTee(enable bool) error {
592+
mode := 0 // off
593+
if enable {
594+
mode = 1 // on
595+
}
596+
i := int(C.rtlsdr_set_bias_tee((*C.rtlsdr_dev_t)(dev), C.int(mode)))
597+
return libError(i)
598+
}
599+
590600
// GetHwInfo gets the dongle's information items.
591601
func (dev *Context) GetHwInfo() (info HwInfo, err error) {
592602
data := make([]uint8, EepromSize)

0 commit comments

Comments
 (0)