Documentation
¶
Overview ¶
This package provides a wrapper for the TCP protocol implemented by the rtl_tcp tool used with Realtek DVB-T based SDR's.
Example (SDR) ¶
var sdr SDR // Resolve address, this may be ip:port or hostname:port. addr, err := net.ResolveTCPAddr("tcp4", "127.0.0.1:1234") if err != nil { log.Fatal("Error resolving address:", err) } // Connect to address and defer close. sdr.Connect(addr) defer sdr.Close() // Print dongle info. fmt.Printf("%+v\n", sdr.Info) // Example: {Magic:"RTL0" Tuner:R820T GainCount:29} // Create an array of bytes for samples. buf := make([]byte, 16384) // Read the entire array. This is usually done in a loop. _, err = io.ReadFull(sdr, buf) if err != nil { log.Fatal("Error reading samples:", err) } // Do something with data in buf...
Output:
Index ¶
- type DongleInfo
- type Flags
- type SDR
- func (sdr *SDR) Connect(addr *net.TCPAddr) (err error)
- func (sdr SDR) HandleFlags() (err error)
- func (sdr *SDR) RegisterFlags()
- func (sdr SDR) SetAGCMode(state bool) (err error)
- func (sdr SDR) SetCenterFreq(freq uint32) (err error)
- func (sdr SDR) SetDirectSampling(state bool) (err error)
- func (sdr SDR) SetFreqCorrection(ppm uint32) (err error)
- func (sdr SDR) SetGain(gain uint32) (err error)
- func (sdr SDR) SetGainByIndex(idx uint32) (err error)
- func (sdr SDR) SetGainMode(state bool) (err error)
- func (sdr SDR) SetOffsetTuning(state bool) (err error)
- func (sdr SDR) SetRTLXtalFreq(freq uint32) (err error)
- func (sdr SDR) SetSampleRate(rate uint32) (err error)
- func (sdr SDR) SetTestMode(state bool) (err error)
- func (sdr SDR) SetTunerIfGain(stage, gain uint16) (err error)
- func (sdr SDR) SetTunerXtalFreq(freq uint32) (err error)
- type Tuner
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DongleInfo ¶
type DongleInfo struct { Magic [4]byte Tuner Tuner GainCount uint32 // Useful for setting gain by index }
Contains the Magic number, tuner information and the number of valid gain values.
func (DongleInfo) String ¶
func (d DongleInfo) String() string
func (DongleInfo) Valid ¶
func (d DongleInfo) Valid() bool
Checks that the magic number received matches the expected byte string 'RTL0'.
type SDR ¶
type SDR struct { *net.TCPConn Flags Flags Info DongleInfo }
Contains dongle information and an embedded tcp connection to the spectrum server
func (*SDR) Connect ¶
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 (SDR) HandleFlags ¶
Parses flags and executes commands associated with each flag. Should only be called once connected to rtl_tcp.
func (*SDR) RegisterFlags ¶
func (sdr *SDR) RegisterFlags()
Registers command line flags for rtltcp commands.
func (SDR) SetAGCMode ¶
Set RTL AGC mode, true for enabled.
func (SDR) SetCenterFreq ¶
Set the center frequency in Hz.
func (SDR) SetDirectSampling ¶
Set direct sampling mode.
func (SDR) SetFreqCorrection ¶
Set frequency correction in ppm.
func (SDR) SetGainByIndex ¶
Set gain by index, must be <= DongleInfo.GainCount
func (SDR) SetGainMode ¶
Set the Tuner AGC, true to enable.
func (SDR) SetOffsetTuning ¶
Set offset tuning, true for enabled.
func (SDR) SetRTLXtalFreq ¶
Set RTL xtal frequency.
func (SDR) SetSampleRate ¶
Set the sample rate in Hz.
func (SDR) SetTestMode ¶
Set test mode, true for enabled.
func (SDR) SetTunerIfGain ¶
Set tuner intermediate frequency stage and gain.
func (SDR) SetTunerXtalFreq ¶
Set tuner xtal frequency.