adsb

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package adsb provides objects and methods for decoding and managing raw ADS-B messages.

Index

Constants

View Source
const (
	KNOT_TO_MPS         = 0.514444444 // factor to convert from knot to m/s
	FEET_PER_MIN_TO_MPS = 0.00508     // factor to convert from feet/min to m/s
)

Variables

View Source
var (

	// ErrNotAvailable is used to indicate that a field is not part of the
	// specification for the message format received. Each field error wraps
	// ErrNotAvailable, making it accessible by calling
	// errors.Is(err, adsb.ErrNotAvailable).
	ErrNotAvailable = errNotAvailable

	// ErrUnsupported is returned when the Downlink Format of a message
	// is not supported by Message. The error may be wrapped and should be
	// checked with errors.Is().
	ErrUnsupported = errUnsupported
)

Public error variables.

Functions

func DecodeGlobalPosition

func DecodeGlobalPosition(c1 *CPR, c2 *CPR) ([]float64, error)

DecodeGlobalPosition decodes an encoded position to a globally unabmiguous latitude and longitude by combining two CPR messages. The two messages must have different formats (CPR.F) and must have a time difference of less than 10 seconds (3 NM distance). The return value is in the format [latitude, longitude].

Types

type CPR

type CPR struct {
	Nb  uint8  // number of encoded bits (17, 19, 14 or 12)
	T   uint8  // time bit
	F   uint8  // format bit
	Lat uint32 // encoded latitude
	Lon uint32 // encoded longitude
}

CPR is an extended squitter compact position report.

func (*CPR) DecodeLocal

func (c *CPR) DecodeLocal(rp []float64) ([]float64, error)

DecodeLocal decodes an encoded position to a global latitude and longitude by comparing the position to a known reference point. Argument and return value is in the format [latitude, longitude].

type Message

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

Message provides a high-level abstraction for ADS-B messages. The methods of Message provide convenient access to common data values. Use RawMessage to obtain direct access to the underlying binary data.

func NewMessage

func NewMessage(r *RawMessage) (*Message, error)

NewMessage wraps a RawMessage and returns the new Message.

func (*Message) Alt

func (m *Message) Alt() (int64, error)

Alt returns the altitude.

func (*Message) CPR

func (m *Message) CPR() (*CPR, error)

CPR returns the compact position report.

func (*Message) Call

func (m *Message) Call() (string, error)

Call returns the callsign.

func (*Message) GroundSpeed

func (m *Message) GroundSpeed() (velocity, heading float64, err error)

Ground speed decoding with GNSS information, in m/s. velocity: in m/s. heading: in degrees with range (-180, 180], where the north is 0, east is 90, south is 180, west is -90.

func (*Message) ICAO

func (m *Message) ICAO() (uint64, error)

ICAO returns the ICAO address as an unsigned integer.

Since the ICAO address is often extracted from the parity field, additional validation against a list of known addresses may be warranted.

func (*Message) Raw

func (m *Message) Raw() *RawMessage

Raw returns the underlying RawMessage. The content of the RawMessage will be overwritten by a subsequent call to UnmarsahalBinary.

func (*Message) Sqk

func (m *Message) Sqk() ([]byte, error)

Sqk returns the squawk code.

func (*Message) UnmarshalBinary

func (m *Message) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the BinaryUnmarshaler interface, storing the supplied data in the Message.

If an error is returned that wraps ErrUnsupported, the data was successfully Unmarshalled and the Raw() method will still return the RawMessage for further inspection.

func (*Message) VerticalSpeed

func (m *Message) VerticalSpeed() (float64, error)

Vertical speed, in m/s.

type RawMessage

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

RawMessage is a raw binary ADS-B message with helper methods for retrieving message fields and arbitrary bit sequences.

func (*RawMessage) AA

func (r *RawMessage) AA() (uint64, error)

AA returns the Address Announced field.

func (*RawMessage) AC

func (r *RawMessage) AC() (uint64, error)

AC returns the Altitude Code field.

func (*RawMessage) AF

func (r *RawMessage) AF() (uint64, error)

AF returns the Application Field.

func (*RawMessage) AP

func (r *RawMessage) AP() (uint64, error)

AP returns the Address / Parity field.

func (*RawMessage) Bit

func (r *RawMessage) Bit(n int) uint8

Bit returns the n-th bit of the RawMessage, where the first bit is numbered 1. Bit will panic if n is out of range.

func (*RawMessage) Bits

func (r *RawMessage) Bits(n int, z int) (bits uint64)

Bits returns bits n through z of the RawMessage, where the first bit is numbered 1. Bits will panic if n or z are out of range, or if the result is greater than 64 bits.

func (*RawMessage) CA

func (r *RawMessage) CA() (uint64, error)

CA returns the Capability field.

func (*RawMessage) CC

func (r *RawMessage) CC() (uint64, error)

CC returns the Cross-link Capability field.

func (*RawMessage) CF

func (r *RawMessage) CF() (uint64, error)

CF returns the Control Field.

func (*RawMessage) DF

func (r *RawMessage) DF() (uint64, error)

DF returns the Downlink Format field.

func (*RawMessage) DP

func (r *RawMessage) DP() (uint64, error)

DP returns the Data Parity field.

func (*RawMessage) DR

func (r *RawMessage) DR() (uint64, error)

DR returns the Downlink Request field.

func (*RawMessage) ESAltitude

func (r *RawMessage) ESAltitude() (uint64, error)

ESAltitude returns the extended squitter altitude field.

func (*RawMessage) ESType

func (r *RawMessage) ESType() (uint64, error)

ESType returns the extended squitter type code.

func (*RawMessage) FS

func (r *RawMessage) FS() (uint64, error)

FS returns the Flight Status field.

func (*RawMessage) ID

func (r *RawMessage) ID() (uint64, error)

ID returns the Identity field.

func (*RawMessage) KE

func (r *RawMessage) KE() (uint64, error)

KE returns the ELM Control field.

func (*RawMessage) MB

func (r *RawMessage) MB() (uint64, error)

MB returns the Comm-B Message field.

func (*RawMessage) MD

func (r *RawMessage) MD() ([]byte, error)

MD returns the Comm-D Message field.

func (*RawMessage) ME

func (r *RawMessage) ME() (uint64, error)

ME returns the Extended Squitter Message field.

func (*RawMessage) MV

func (r *RawMessage) MV() (uint64, error)

MV returns the ACAS Message field.

func (*RawMessage) ND

func (r *RawMessage) ND() (uint64, error)

ND returns the Number of D-segment field.

func (*RawMessage) PI

func (r *RawMessage) PI() (uint64, error)

PI returns the Parity / Interrogator Identifier field.

func (*RawMessage) Parity

func (r *RawMessage) Parity() (p uint64)

Parity returns the calculated parity for the message data.

func (*RawMessage) RI

func (r *RawMessage) RI() (uint64, error)

RI returns the Reply Information field.

func (*RawMessage) SL

func (r *RawMessage) SL() (uint64, error)

SL returns the Sensitivity Level field.

func (*RawMessage) TC

func (r *RawMessage) TC() uint64

func (*RawMessage) UM

func (r *RawMessage) UM() (uint64, error)

UM returns the Utility Message field.

func (*RawMessage) UnmarshalBinary

func (r *RawMessage) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the BinaryUnmarshaler interface for storing ADS-B data.

func (*RawMessage) VS

func (r *RawMessage) VS() (uint64, error)

VS returns the Vertical Status field.

Jump to

Keyboard shortcuts

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