Coder Social home page Coder Social logo

gortlsdr's Introduction

gortlsdr version Build Status Godoc reference Go Report Card BSD3 License

Description

gortlsdr is a simple Go interface to devices supported by the RTL-SDR project, which turns certain USB DVB-T dongles employing the Realtek RTL2832U chipset into a low-cost, general purpose software-defined radio receiver. It wraps all the functions in the librtlsdr library (including asynchronous read support).

Supported Platforms:

  • Linux
  • OS X
  • Windows (with a little work)

Installation

Dependencies

Usage

All functions in librtlsdr are accessible from the gortlsdr package:

go get -u github.com/jpoirier/gortlsdr

Example

See the eample.go file:

go run example.go

Windows

If you don't want to build the librtlsdr and libusb dependencies from source you can use the librtlsdr pre-built package, which includes libusb, but you're restricted to building a 32-bit gortlsdr library.

Building gortlsdr on Windows:

  • Download and install git.

  • Download and install the Go tools. Create a "go-pkgs" directory-your user folder is a good location-and add a GOPATH variable to your system environment, where GOPATH is set to the go-pkgs path, e.g. GOPATH=c:\users\jpoirier\go-pkgs.

  • Download the pre-built rtl-sdr library and unzip it, e.g. to your user folder. Note the path to the header files and the *.dll files in the x32 folder.

  • Download gortlsdr, but don't install the package:

        go get -d github.com/jpoirier/gortlsdr
    
  • Set CFLAGS and LDFLAGS in rtlsdr.go. Open the rtlsdr.go file in an editor, it'll be in go-pkgs\src\github.com\jpoirier\gortlsdr, and set the following two windows specific flags shown below, but with the correct paths from your system. CFLAGS points to the header files and LDFLAGS to the *.dll files:

        cgo windows CFLAGS: -IC:/Users/jpoirier/rtlsdr
        cgo windows LDFLAGS: -lrtlsdr -LC:/Users/jpoirier/rtlsdr/x32
    
  • Build gortlsdr:

        go install github.com/jpoirier/gortlsdr
    
  • Insert the DVB-T/DAB/FM dongle into a USB port, open a shell window in go-pkgs\src\github.com\jpoirier\gortlsdr and run the example program: go run example.go. Note, the pre-built rtl-sdr package contains several test executables as well.

Credit

Todo

-joe

gortlsdr's People

Contributors

9nut avatar cyoung avatar josephlewis42 avatar jpoirier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gortlsdr's Issues

Go errors

It would be nice to hide the C-isms as much as possible e.g. rather than returning ints, return Go errors

To this end I've created a branch which includes:

  • return Go error type where appropriate.
  • Tidy up function comments. Hide C function signatures
  • Use bool instead of int 0/1

Possibly a candidate for v2.0 ๐Ÿ˜€

cgo question

I'm trying to understand how gortlsdr uses cgo to interface with the C library, in particular the callback function used in the async read. clientCb is set inside ReadAsync() yet doesn't get passed to a C function or referenced from the C preamble!?

The Go docs http://golang.org/cmd/cgo/ talk about using //export before the Go function to be exported...yet gortlsdr doesn't do this. Could you explain how this works?

rtlsdr_set_tuner_bandwidth

function rtlsdr_set_tuner_bandwidth() is not present in Linux distro releases of rtl-sdr package. Go packages that have gortlsdr as a depencency will fail to compile when using distro packaged librtlsdr.

I've confirmed this on Fedora 23 and Ubuntu 14.04.

Could SetTunerBw() be modified to return an error if rtlsdr_set_tuner_bandwidth() can't be found?

libusb

-lusb here appears to be redundant and removing it makes no difference to compilation on Linux.

I found that having the flag there actually causes compilation to fail if legacy libusb is not installed. For example Arch linux uses the current 1.0 library which is referenced by -lusb-1.0

@jpoirier do you foresee see any issues in removing this flag?

Support for older versions of rtl-sdr


Please add here:

#ifdef rtlsdr_set_bias_tee
static int rtlsdr_set_bias_tee_wrap(rtlsdr_dev_t* d, int i) { return rtlsdr_set_bias_tee(d,i); }
#else
static int rtlsdr_set_bias_tee_wrap(rtlsdr_dev_t* d, int i) { return -12; }
#endif

And call rtlsdr_set_bias_tee_wrap instead of rtlsdr_set_bias_tee
Thanks.

error

when i run "go get -u github.com/jpoirier/gortlsdr" i get this error does anyone know how to fix it?

# github.com/jpoirier/gortlsdr /tmp/go-build505426775/github.com/jpoirier/gortlsdr/_obj/rtlsdr.cgo2.o: In function _cgo_1debe9789e24_Cfunc_rtlsdr_set_bias_tee':
go/src/github.com/jpoirier/gortlsdr/rtlsdr.go:355: undefined reference to rtlsdr_set_bias_tee' /tmp/go-build505426775/github.com/jpoirier/gortlsdr/_obj/rtlsdr.cgo2.o: In function _cgo_1debe9789e24_Cfunc_rtlsdr_set_tuner_bandwidth':
go/src/github.com/jpoirier/gortlsdr/rtlsdr.go:446: undefined reference to rtlsdr_set_tuner_bandwidth' collect2: error: ld returned 1 exit status

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.