radio

package
v0.0.0-...-065a330 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2020 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBadSampleRate = errors.New("bad sample rate")
View Source
var ErrFrequencyOutOfRange = errors.New("frequency out of range")
View Source
var ErrRateOutOfRange = errors.New("sample rate out of range")

Functions

func Calibrate

func Calibrate(s SDR) error

func FindPPM

func FindPPM(sdr SDR) (float64, error)

Types

type Bands

type Bands []FreqBand

func (Bands) Len

func (a Bands) Len() int

func (Bands) Less

func (a Bands) Less(i, j int) bool

func (Bands) Swap

func (a Bands) Swap(i, j int)

type DongleInfo

type DongleInfo struct {
	Magic     [4]byte
	Tuner     uint32
	GainCount uint32 // Useful for setting gain by index
}

DongleInfo is data pulled from the RTLTCPSDR on connection.

func (DongleInfo) Valid

func (d DongleInfo) Valid() bool

Valid checks the received magic number matches the expected byte string 'RTL0'.

type FreqBand

type FreqBand struct {
	Center float64
	Width  float64
}

TODO: replace with HzBand

func BandMerge

func BandMerge(fbs []FreqBand) (ret []FreqBand)

func BandRange

func BandRange(fb []FreqBand) FreqBand

func NewFreqRange

func NewFreqRange(loMHz, hiMHz float64) FreqBand

func Scan

func Scan(sdr SDR, cfg ScanConfig) (ret []FreqBand)

func ScanIQReader

func ScanIQReader(iqr *MixerIQReader, minWidthHz float64) (ret []FreqBand, err error)

func (FreqBand) BandwidthKHz

func (f FreqBand) BandwidthKHz() float64

func (FreqBand) BeginMHz

func (f FreqBand) BeginMHz() float64

func (FreqBand) EndMHz

func (f FreqBand) EndMHz() float64

func (FreqBand) Overlaps

func (fb1 FreqBand) Overlaps(fb2 FreqBand) bool

func (FreqBand) ToHzBand

func (f FreqBand) ToHzBand() HzBand

type HzBand

type HzBand struct {
	Center uint64 `json:"center_hz"`
	Width  uint64 `json:"width_hz"`
}

func HzBandRange

func HzBandRange(lo, hi int64) HzBand

func (HzBand) Overlaps

func (hzb HzBand) Overlaps(hz2 HzBand) bool

func (HzBand) ToMHz

func (hzb HzBand) ToMHz() FreqBand

type IQReader

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

func NewIQReader

func NewIQReader(r io.Reader) *IQReader

NewIQReader takes a reader that uses u8 I/Q samples.

func (*IQReader) Batch64

func (iq *IQReader) Batch64(batch, limit int) <-chan []complex64

func (*IQReader) BatchStream64

func (iq *IQReader) BatchStream64(ctx context.Context, batch, limit int) <-chan []complex64

func (*IQReader) ToMixer

func (iqr *IQReader) ToMixer(hzb HzBand) *MixerIQReader

type IQWriter

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

func NewIQWriter

func NewIQWriter(w io.Writer) *IQWriter

func (*IQWriter) Write64

func (iq *IQWriter) Write64(out []complex64) error

type MixerIQReader

type MixerIQReader struct {
	HzBand
	*IQReader
}

func NewMixerIQReader

func NewMixerIQReader(r io.Reader, hzb HzBand) *MixerIQReader

type RTLTCPSDR

type RTLTCPSDR struct {
	*net.TCPConn
	Info DongleInfo
}

RTLTCPSDR contains dongle information and an embedded tcp connection to the spectrum server.

func (*RTLTCPSDR) Connect

func (sdr *RTLTCPSDR) Connect(addr *net.TCPAddr) (err error)

Give an address of the form "127.0.0.1:1234" connects to the spectrum server at the given address or returns an error. The user is responsible for closing this connection. If addr is nil, use "127.0.0.1:1234" or command line flag value.

func (*RTLTCPSDR) SetAGCMode

func (sdr *RTLTCPSDR) SetAGCMode(state bool) error

Set RTL AGC mode, true for enabled.

func (*RTLTCPSDR) SetCenterFreq

func (sdr *RTLTCPSDR) SetCenterFreq(freq uint32) error

Set the center frequency in Hz.

func (*RTLTCPSDR) SetDirectSampling

func (sdr *RTLTCPSDR) SetDirectSampling(state uint32) error

Set direct sampling mode. 0 = disabled, 1 = i-branch, 2 = q-branch, 3 = direct mod.

func (*RTLTCPSDR) SetFreqCorrection

func (sdr *RTLTCPSDR) SetFreqCorrection(ppm uint32) error

Set frequency correction in ppm.

func (*RTLTCPSDR) SetGain

func (sdr *RTLTCPSDR) SetGain(gain uint32) error

Set gain in tenths of dB. (197 => 19.7dB)

func (*RTLTCPSDR) SetGainByIndex

func (sdr *RTLTCPSDR) SetGainByIndex(idx uint32) error

Set gain by index, must be <= DongleInfo.GainCount

func (*RTLTCPSDR) SetGainMode

func (sdr *RTLTCPSDR) SetGainMode(state bool) error

Set the Tuner AGC, true to enable.

func (*RTLTCPSDR) SetOffsetTuning

func (sdr *RTLTCPSDR) SetOffsetTuning(state bool) error

Set offset tuning, true for enabled.

func (*RTLTCPSDR) SetRTLXtalFreq

func (sdr *RTLTCPSDR) SetRTLXtalFreq(freq uint32) error

Set RTL xtal frequency.

func (*RTLTCPSDR) SetSampleRate

func (sdr *RTLTCPSDR) SetSampleRate(rate uint32) error

Set the sample rate in Hz.

func (*RTLTCPSDR) SetTestMode

func (sdr *RTLTCPSDR) SetTestMode(state bool) error

Set test mode, true for enabled.

func (*RTLTCPSDR) SetTunerIfGain

func (sdr *RTLTCPSDR) SetTunerIfGain(stage, gain uint16) error

Set tuner intermediate frequency stage and gain.

func (*RTLTCPSDR) SetTunerXtalFreq

func (sdr *RTLTCPSDR) SetTunerXtalFreq(freq uint32) error

Set tuner xtal frequency.

type SDR

type SDR interface {
	SetBand(b HzBand) error
	SetFreqCorrection(ppm uint32) error
	Info() SDRHWInfo
	Close() error
	Reader() *MixerIQReader
}

func NewSDR

func NewSDR(ctx context.Context) (SDR, error)

func NewSDRWithSerial

func NewSDRWithSerial(ctx context.Context, ser string) (SDR, error)

type SDRFormat

type SDRFormat struct {
	BitDepth   uint   `json:"bit_depth"`
	CenterHz   uint64 `json:"center_hz"`
	SampleRate uint32 `json:"sample_rate"`
}

func (*SDRFormat) HzBand

func (s *SDRFormat) HzBand() HzBand

type SDRHWInfo

type SDRHWInfo struct {
	Id string `json:"id"`

	MinHz         uint64 `json:"min_hz"`
	MaxHz         uint64 `json:"max_hz"`
	MinSampleRate uint32 `json:"min_sample_rate"`
	MaxSampleRate uint32 `json:"max_sample_rate"`

	SDRFormat
}

func SDRList

func SDRList(ctx context.Context) ([]SDRHWInfo, error)

type ScanConfig

type ScanConfig struct {
	CenterMHz   float64
	MinWidthMHz float64
}

type SpectralPower

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

func NewSpectralPower

func NewSpectralPower(band FreqBand, bins, ffts int) *SpectralPower

func (*SpectralPower) Average

func (sp *SpectralPower) Average() []float64

func (*SpectralPower) BandPower

func (sp *SpectralPower) BandPower(fb FreqBand, samps int) float64

func (*SpectralPower) Bands

func (sp *SpectralPower) Bands() (ret []FreqBand)

func (*SpectralPower) Measure

func (sp *SpectralPower) Measure(ch <-chan []complex64) error

func (*SpectralPower) NoiseFloor

func (sp *SpectralPower) NoiseFloor() float64

func (*SpectralPower) Spread

func (sp *SpectralPower) Spread() float64

func (*SpectralPower) Spurs

func (sp *SpectralPower) Spurs() (ret []FreqBand)

func (*SpectralPower) Stddev

func (sp *SpectralPower) Stddev() float64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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