rtl

package
v0.0.0-...-9809d57 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2023 License: MIT Imports: 9 Imported by: 1

README

RTL-SDR hz.tools/sdr driver

The rtl-sdr driver was the first driver that was written in early 2020. It's kept up with best practice and is very stable on RX. A lot of work has gone into keeping this code fast enough to work on constrained platforms.

Format Type U8
Receiver
Transmitter

Documentation

Overview

Package rtl contains an sdr.Sdr implementation for rtlsdr based SDRs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeviceCount

func DeviceCount() uint

DeviceCount will return the number of rtlsdr devices present on the system.

func DeviceIndexBySerial

func DeviceIndexBySerial(serial string) (uint, error)

DeviceIndexBySerial will get the device index that has the Serial provided.

func InfoByDeviceIndex

func InfoByDeviceIndex(index uint) (*sdr.HardwareInfo, error)

InfoByDeviceIndex will return a HardwareInfo struct by a device index.

Types

type Sdr

type Sdr struct {
	// contains filtered or unexported fields
}

Sdr is a handle to internal rtlsdr state used by the underlying C library.

func New

func New(index uint, windowSize uint) (*Sdr, error)

New will create a new Sdr struct, and initialize the internal handles as required.

index corresponds to the index into the number of devices (as seen by

DeviceCount) to open.

windowSize instructs the rtlsdr library as to how many iq samples to deliver

per callback.

func (Sdr) Close

func (r Sdr) Close() error

Close will call the underlying rtlsdr library to close the handle that we opened when creating this object. This should always be called when finished with the sdr.

func (Sdr) GetCenterFrequency

func (r Sdr) GetCenterFrequency() (rf.Hz, error)

GetCenterFrequency will return the center frequency that the rtlsdr is tuned to.

func (Sdr) GetGain

func (r Sdr) GetGain(gainStage sdr.GainStage) (float32, error)

GetGain implements the sdr.Sdr interface.

func (Sdr) GetGainStages

func (r Sdr) GetGainStages() (sdr.GainStages, error)

GetGainStages implements the sdr.Sdr interface.

func (Sdr) GetPPM

func (r Sdr) GetPPM() int

GetPPM will get the PPM skew.

func (Sdr) GetSampleRate

func (r Sdr) GetSampleRate() (uint, error)

GetSampleRate will get the number of samples per second.

func (Sdr) GetSamplesPerWindow

func (r Sdr) GetSamplesPerWindow() (uint, error)

GetSamplesPerWindow will return the number of samples contained in one windows-worth of iq data.

func (Sdr) HardwareInfo

func (r Sdr) HardwareInfo() sdr.HardwareInfo

HardwareInfo implements the sdr.Sdr interface

func (Sdr) ResetBuffer

func (r Sdr) ResetBuffer() error

ResetBuffer will reset the internal rtlsdr buffer(s).

func (Sdr) SampleFormat

func (r Sdr) SampleFormat() sdr.SampleFormat

SampleFormat will return the IQ sample format. For the rtlsdr this is always SampleFormatU8.

func (Sdr) SetAutomaticGain

func (r Sdr) SetAutomaticGain(automatic bool) error

SetAutomaticGain will set the tuner mode to use AGC.

func (Sdr) SetBiasT

func (r Sdr) SetBiasT(on bool) error

SetBiasT will enable or disable the bias tee.

func (Sdr) SetBiasTGPIO

func (r Sdr) SetBiasTGPIO(pin int, on bool) error

SetBiasTGPIO will enable or disable the bias tee.

func (Sdr) SetCenterFrequency

func (r Sdr) SetCenterFrequency(freq rf.Hz) error

SetCenterFrequency will set the center frequency that the rtlsdr will tune to.

func (Sdr) SetGain

func (r Sdr) SetGain(gainStage sdr.GainStage, gain float32) error

SetGain implements the sdr.Sdr interface.

func (Sdr) SetPPM

func (r Sdr) SetPPM(ppm int) error

SetPPM will set the PPM skew.

func (Sdr) SetSampleRate

func (r Sdr) SetSampleRate(sps uint) error

SetSampleRate will set the number of samples per second. This will not change the window size.

func (Sdr) SetTestMode

func (r Sdr) SetTestMode(on bool) error

SetTestMode will turn on and off test mode.

Test mode will cause every byte to be the one larger than the next byte, and on overflow, return to 0. This is useful to detect cases where you're dropping packets, or to ensure that your code can fully process the data end-to-end in real-time.

func (Sdr) StartRx

func (r Sdr) StartRx() (sdr.ReadCloser, error)

StartRx will start to receive IQ samples, ready for consumption from the returned ReadCloser.

func (Sdr) Tuner

func (r Sdr) Tuner() Tuner

Tuner will return the rtlsdr Tuner type. This can be used to determine the behavior of some of the Gain options, as well as well as performance.

type Tuner

type Tuner uint8

Tuner is an enum that represents an rtlsdr Tuner chipset.

var (
	// TunerUnknown is used when the underlying rtlsdr Tuner is not known
	// by the underlying rtlsdr library.
	TunerUnknown Tuner = C.RTLSDR_TUNER_UNKNOWN

	// TunerE4000 represents the rtlsdr E4000 tuner type.
	TunerE4000 Tuner = C.RTLSDR_TUNER_E4000

	// TunerFC0012 represents the rtlsdr FC0012 tuner type.
	TunerFC0012 Tuner = C.RTLSDR_TUNER_FC0012

	// TunerFC0013 represents the rtlsdr FC0013 tuner type.
	TunerFC0013 Tuner = C.RTLSDR_TUNER_FC0013

	// TunerFC2580 represents the rtlsdr FC2580 tuner type.
	TunerFC2580 Tuner = C.RTLSDR_TUNER_FC2580

	// TunerR820T represents the rtlsdr R820T tuner type.
	TunerR820T Tuner = C.RTLSDR_TUNER_R820T

	// TunerR828D represents the rtlsdr R828D tuner type.
	TunerR828D Tuner = C.RTLSDR_TUNER_R828D
)

func (Tuner) GetGainStages

func (tuner Tuner) GetGainStages() (sdr.GainStages, error)

GetGainStages will return the GainStages for the specific Tuner. The Sdr.GetGainStages function will implement the sdr.Sdr interface, but will call this function to get the underlying gains.

This does not make dynamic calls, since other libraries (such as rtltcp) may need the GainStage values for a Tuner without it being plugged in, preventing the use of rtlsdr_get_tuner_gains.

func (Tuner) String

func (t Tuner) String() string

String will return the human readable name for the Tuner type.

Directories

Path Synopsis
Package e4k contains code to translate gains in dB to values to be sent to the e4k's 6-stage IF gain controls.
Package e4k contains code to translate gains in dB to values to be sent to the e4k's 6-stage IF gain controls.
Package kerberos contains the KerberosSDR driver for hz.tools/sdr
Package kerberos contains the KerberosSDR driver for hz.tools/sdr
internal
Package internal contains kerberos specific internal bits of API.
Package internal contains kerberos specific internal bits of API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL