readsb

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2020 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ModeACMsgBytes - mode message length
	ModeACMsgBytes = int(C.MODEAC_MSG_BYTES)

	// ModeSShortMsgBytes - short msg byte length
	ModeSShortMsgBytes = int(C.MODES_SHORT_MSG_BYTES)
	// ModeSShortMsgBits - short msg bit length
	ModeSShortMsgBits = int(C.MODES_SHORT_MSG_BITS)
	// ModeSLongMsgBytes - long msg byte length
	ModeSLongMsgBytes = int(C.MODES_LONG_MSG_BYTES)
	// ModeSLongMsgBits - long msg bit length
	ModeSLongMsgBits = int(C.MODES_LONG_MSG_BITS)

	// ModeSNonIcaoAddress - Set on addresses to indicate they are not ICAO addresses
	ModeSNonIcaoAddress = int(C.MODES_NON_ICAO_ADDRESS)

	// ASCIIIntZero - '0' in ASCII
	ASCIIIntZero = 0x30

	// ModesReadsbVariant - version of readsb library
	ModesReadsbVariant = string(C.MODES_READSB_VARIANT)
)

Variables

AllNavModes contains a slice of all valid nav modes

View Source
var (
	// ErrNoData is returned when the fields data was not available
	ErrNoData = errors.New("no data for field")
)

Functions

func DebugModesMessage

func DebugModesMessage(w io.Writer, mm *C.struct_modesMessage) error

DebugModesMessage writes debug information about the message to w.

func DecodeBinMessage

func DecodeBinMessage(decoder *Decoder, m []byte, p int, withModeAC bool) (*C.struct_modesMessage, error)

DecodeBinMessage attempts to decode a single message, whose starting position in m is indicated by p. If withModeAC is true, mode AC messages will be decoded also

func DfToString

func DfToString(df uint) string

DfToString returns the description of this df value.

func IcaoFilterExpire

func IcaoFilterExpire()

IcaoFilterExpire should be called periodically so aircraft which are out of range (not seen for some TTL) are removed from our filter

func IcaoFilterInit

func IcaoFilterInit()

IcaoFilterInit calls the readsb function icaoFilterInit which initializes an internal filter data structure

func IcaoFilterInitOnce

func IcaoFilterInitOnce()

IcaoFilterInitOnce uses internal state to ensure IcaoFilterInit is only called once

func ModeACInit

func ModeACInit()

ModeACInit calls the readsb function modeACInit which initializes internal conversion tables for modeAC calculations

func ModeACInitOnce

func ModeACInitOnce()

ModeACInitOnce uses internal state to ensure ModeACInit is only called once

func ModesChecksumInit

func ModesChecksumInit(numbits int)

ModesChecksumInit calls the readsb function modesChecksumInit which precomputes data about CRC errors

func ModesChecksumInitOnce

func ModesChecksumInitOnce(numbits int)

ModesChecksumInitOnce uses internal state to ensure ModesChecksumInit is only called once

func TrackPeriodicUpdate

func TrackPeriodicUpdate(d *Decoder)

TrackPeriodicUpdate - Call periodically to remove aircraft who haven't been seen for some TTL

Types

type Aircraft

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

Aircraft simply wraps a readsb aircraft pointer so we can pass it around

func TrackUpdateFromMessage

func TrackUpdateFromMessage(d *Decoder, mm *ModesMessage) *Aircraft

TrackUpdateFromMessage - Update aircraft state with message info, and update message information with supplemental info

func (*Aircraft) GetAdsbVersion

func (a *Aircraft) GetAdsbVersion() (int64, error)

GetAdsbVersion returns the ADSB version, or ErrNoData if unknown

func (*Aircraft) GetCategory

func (a *Aircraft) GetCategory() (string, error)

GetCategory returns the ADSB emitter category, or ErrNoData if unknown

func (*Aircraft) GetNACP

func (a *Aircraft) GetNACP(recvTime time.Time) (uint32, error)

GetNACP returns the Navigation Accuracy for Position (2.2.5.1.35) or ErrNoData if not set

func (*Aircraft) GetSIL

func (a *Aircraft) GetSIL(recvTime time.Time) (uint32, SILType, error)

GetSIL returns the Source Integity Level (2.2.5.1.40), or ErrNoData if unknown

type DataSource

type DataSource int

DataSource - where the data came from

const (
	SourceInvalid      DataSource = C.SOURCE_INVALID
	SourceModeAC       DataSource = C.SOURCE_MODE_AC
	SourceMLAT         DataSource = C.SOURCE_MLAT
	SourceModeS        DataSource = C.SOURCE_MODE_S
	SourceModeSChecked DataSource = C.SOURCE_MODE_S_CHECKED
	SourceTISB         DataSource = C.SOURCE_TISB
	SourceADSR         DataSource = C.SOURCE_ADSR
	SourceADSB         DataSource = C.SOURCE_ADSB
)

Values for DataSource

func (DataSource) DataSource

func (d DataSource) DataSource() string

DataSource returns the type of data source as a string

type Decoder

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

Decoder contains a pointer to the _Modes structure that contains our aircraft state. This state is required for location decoding.

func NewDecoder

func NewDecoder() *Decoder

NewDecoder returns an initialized Decoder.

func (*Decoder) NumBitsToCorrect

func (d *Decoder) NumBitsToCorrect(nbits int)

NumBitsToCorrect sets the number of bits we should correct based on the CRC

type HeadingType

type HeadingType int

HeadingType - defines different sources for headings

const (
	HeadingInvalid        HeadingType = C.HEADING_INVALID
	HeadingGroundTrack    HeadingType = C.HEADING_GROUND_TRACK
	HeadingTrue           HeadingType = C.HEADING_TRUE
	HeadingMagnetic       HeadingType = C.HEADING_MAGNETIC
	HeadingMagneticOrTrue HeadingType = C.HEADING_MAGNETIC_OR_TRUE
	HeadingTrackOrHeading HeadingType = C.HEADING_TRACK_OR_HEADING
)

Values for HeadingType

type ModesMessage

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

ModesMessage simply wraps a modesMessage pointer so we can pass it around and expose functions to other packages

func ParseMessage

func ParseMessage(d *Decoder, b []byte) ([]*ModesMessage, int, error)

ParseMessage attempts to decode and process any messages it can find in b.

func (*ModesMessage) GetAltitudeBaro

func (m *ModesMessage) GetAltitudeBaro() (int64, error)

GetAltitudeBaro will return the barometric altitude from this message, or ErrNoData if unknown

func (*ModesMessage) GetAltitudeGeom

func (m *ModesMessage) GetAltitudeGeom() (int64, error)

GetAltitudeGeom will return the geometric altitude from this message, or ErrNoData if unknown

func (*ModesMessage) GetCallsign

func (m *ModesMessage) GetCallsign() (string, error)

GetCallsign will return the callsign from this message, or ErrNoData if unknown

func (*ModesMessage) GetCategory

func (m *ModesMessage) GetCategory() (string, error)

GetCategory returns the hex encoded category, or ErrNoData if not set

func (*ModesMessage) GetDecodeLocation

func (m *ModesMessage) GetDecodeLocation() (float64, float64, error)

GetDecodeLocation will return the position from this message, or ErrNoData if unknown. This field is only set if the message has been processed by TrackUpdateFromMessage as to successfully decode a location you need two consecutive odd + even messages.

func (*ModesMessage) GetFmsAltitude

func (m *ModesMessage) GetFmsAltitude() (int64, error)

GetFmsAltitude returns the FMS selected altitude, or ErrNoData if the data is not set. todo: units?

func (*ModesMessage) GetGroundSpeed

func (m *ModesMessage) GetGroundSpeed() (float64, error)

GetGroundSpeed returns the ground speed in knots, or ErrNoData if the data is not set.

func (*ModesMessage) GetHeading

func (m *ModesMessage) GetHeading() (float64, HeadingType, error)

GetHeading returns the heading from the message. this field is only set if the mesage has been processed by TrackUpdateFromMEssage

func (*ModesMessage) GetIcaoHex

func (m *ModesMessage) GetIcaoHex() string

GetIcaoHex returns the ICAO as a hex string in upper case

func (*ModesMessage) GetIndicatedAirSpeed

func (m *ModesMessage) GetIndicatedAirSpeed() (uint64, error)

GetIndicatedAirSpeed returns the indicated airspeed in knots, or ErrNoData if the data is not set.

func (*ModesMessage) GetMCPAltitude

func (m *ModesMessage) GetMCPAltitude() (int64, error)

GetMCPAltitude returns the MCP selected altitude, or ErrNoData if the data is not set. todo: units?

func (*ModesMessage) GetMach

func (m *ModesMessage) GetMach() (float64, error)

GetMach returns the mach speed, or ErrNoData if the data is not set

func (*ModesMessage) GetMessageType

func (m *ModesMessage) GetMessageType() int

GetMessageType returns the message type decoded from the message

func (*ModesMessage) GetMsg

func (m *ModesMessage) GetMsg() ([]byte, error)

GetMsg returns the raw message bytes

func (*ModesMessage) GetNACP

func (m *ModesMessage) GetNACP() (uint32, error)

GetNACP returns the Navigation Accuracy for Position (2.2.5.1.35), or ErrNoData if not set

func (*ModesMessage) GetNACV

func (m *ModesMessage) GetNACV() (uint32, error)

GetNACV returns the Navigation Accuracy for Velocity (2.2.5.1.19), or ErrNoData if not set

func (*ModesMessage) GetNICBaro

func (m *ModesMessage) GetNICBaro() (uint32, error)

GetNICBaro returns the Navigation Integrity Category for Barometric Altitude (2.2.5.1.35), or ErrNoData if not set

func (*ModesMessage) GetNavHeading

func (m *ModesMessage) GetNavHeading() (float64, error)

GetNavHeading returns the navigation selected heading, or ErrNoData if the data is not set

func (*ModesMessage) GetNavModes

func (m *ModesMessage) GetNavModes() (NavModes, error)

GetNavModes returns a bitmask of NavModes enabled, or ErrNoData if the data is not set

func (*ModesMessage) GetNavQNH

func (m *ModesMessage) GetNavQNH() (float64, error)

GetNavQNH returns the altimiter setting (QFE or QNH/QNE)

func (*ModesMessage) GetRateBaro

func (m *ModesMessage) GetRateBaro() (int, error)

GetRateBaro will return the barometric vertical rate from this message, or ErrNoData if unknown

func (*ModesMessage) GetRateGeom

func (m *ModesMessage) GetRateGeom() (int, error)

GetRateGeom will return the geometric vertical rate from this message, or ErrNoData if unknown

func (*ModesMessage) GetRoll

func (m *ModesMessage) GetRoll() (float64, error)

GetRoll returns the roll angle in degrees (negative is left roll), or ErrNoData if the data is not set

func (*ModesMessage) GetSIL

func (m *ModesMessage) GetSIL() (uint32, SILType, error)

GetSIL returns the Source Integity Level (2.2.5.1.40), or ErrNoData if unknown

func (*ModesMessage) GetSignalLevel

func (m *ModesMessage) GetSignalLevel() (float64, error)

GetSignalLevel returns the signal level field

func (*ModesMessage) GetSquawk

func (m *ModesMessage) GetSquawk() (string, error)

GetSquawk will return the squawk from this message, or ErrNoData if unknown

func (*ModesMessage) GetTrueAirSpeed

func (m *ModesMessage) GetTrueAirSpeed() (uint64, error)

GetTrueAirSpeed returns the true airspeed in knots, or ErrNoData if the data is not set.

func (*ModesMessage) IsOnGround

func (m *ModesMessage) IsOnGround() (bool, error)

IsOnGround will return whether the aircraft is on ground, or ErrNoData if this is unknown or otherwise uncertain.

func (*ModesMessage) SysMessageTime

func (m *ModesMessage) SysMessageTime() time.Time

SysMessageTime returns the time the message was received

type NavModes int

NavModes - bitmask of engaged automation modes.d

const (
	NavModeAutopilot NavModes = 1
	NavModeVNAV      NavModes = 2
	NavModeAltHold   NavModes = 4
	NavModeApproach  NavModes = 8
	NavModeLNAV      NavModes = 16
	NavModeTCAS      NavModes = 32
)

Values for NavModes

func (nm NavModes) NavModesList() []string

NavModesList returns the names of enabled nav modes in a list

type SILType

type SILType int

SILType - interpretation of SIL: unknown, perhour, persample.

const (
	SILInvalid   SILType = 0
	SILUnknown   SILType = 1
	SILPerSample SILType = 2
	SILPerHour   SILType = 3
)

Values for SILType

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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