rfcap

package module
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: MIT Imports: 9 Imported by: 1

README

hz.tools/rfcap

Documentation

Index

Constants

View Source
const MimeType string = "application/x-hztools.rfcap"

MimeType is the rfcap v1 MIME type to be used.

Variables

View Source
var Size int = 48

Size is the rfcap header size in Bytes.

Functions

func ReaderSdr

func ReaderSdr(in io.Reader) (sdr.Receiver, error)

ReaderSdr will return a fake "SDR" that complies with the sdr.Sdr interface, where StartRx will provide the rfcap Reader. There are a number of read only attributes (frequency, samples per second), and calls to a number of methods will return sdr.ErrNotSupported.

func Writer

func Writer(out io.Writer, header Header) (sdr.Writer, error)

Writer will create a new sdr.Reader that writes to the underlying Stream.

Types

type Header struct {
	// Magic is 'RFCAP1'
	Magic Magic

	// CaptureTime signifies the time at which this capture was started.
	CaptureTime time.Time

	// CenterFrequency represents where the Center frequency of this capture
	// is centered.
	CenterFrequency rf.Hz

	// Number of Samples (each iq complex number is counted as a single sample)
	// per second.
	SampleRate uint

	// SampleFormat denotes what format this capture is in. It's useful to keep
	// iq information in its native capture format, and convert when required.
	SampleFormat sdr.SampleFormat

	// Compressed may only be set if the Sample Format is int16. If this is
	// true for any other Sample Format, this will result in an error being
	// returned.
	//
	// This assumes the data is actually 12 bits, and packs every 4th sample
	// into the other 3.
	Compressed bool

	// Endianness defines the ByteOrder used for the data in the rfcap
	// file.
	Endianness binary.ByteOrder
}

Header contains metadata around what the capture represents.

func HeaderFromSDR

func HeaderFromSDR(dev sdr.Sdr) (Header, error)

HeaderFromSDR will create a Header from the provided SDR

func ReadHeader added in v0.0.13

func ReadHeader(in io.Reader) (Header, error)

ReadHeader will read the rfcap Header from the io.Reader

func Reader

func Reader(in io.Reader) (sdr.Reader, Header, error)

Reader will create a new sdr.Reader from the provided io stream.

func (*Header) Marshal added in v0.0.11

func (h *Header) Marshal() ([]byte, error)

Marshal will encode a header as Bytes.

func (*Header) Unmarshal added in v0.0.11

func (h *Header) Unmarshal(b []byte) error

Unmarshal will encode a header as Bytes.

type Magic

type Magic [6]byte

Magic signifies the rfcap Magic bytes. These are prefixed to the rfcap file, and can be used to determine if the file is valid rfcap or not.

var (
	// MagicVersion1 signifies the first version of rfcap.
	MagicVersion1 Magic = Magic{'R', 'F', 'C', 'A', 'P', '1'}
)

func (Magic) String

func (magic Magic) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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