Documentation ¶
Overview ¶
Package adsb provides objects and methods for decoding and managing raw ADS-B messages.
Index ¶
- Constants
- Variables
- func DecodeGlobalPosition(c1 *CPR, c2 *CPR) ([]float64, error)
- type CPR
- type Message
- func (m *Message) Alt() (int64, error)
- func (m *Message) CPR() (*CPR, error)
- func (m *Message) Call() (string, error)
- func (m *Message) GroundSpeed() (velocity, heading float64, err error)
- func (m *Message) ICAO() (uint64, error)
- func (m *Message) Raw() *RawMessage
- func (m *Message) Sqk() ([]byte, error)
- func (m *Message) UnmarshalBinary(data []byte) error
- func (m *Message) VerticalSpeed() (float64, error)
- type RawMessage
- func (r *RawMessage) AA() (uint64, error)
- func (r *RawMessage) AC() (uint64, error)
- func (r *RawMessage) AF() (uint64, error)
- func (r *RawMessage) AP() (uint64, error)
- func (r *RawMessage) Bit(n int) uint8
- func (r *RawMessage) Bits(n int, z int) (bits uint64)
- func (r *RawMessage) CA() (uint64, error)
- func (r *RawMessage) CC() (uint64, error)
- func (r *RawMessage) CF() (uint64, error)
- func (r *RawMessage) DF() (uint64, error)
- func (r *RawMessage) DP() (uint64, error)
- func (r *RawMessage) DR() (uint64, error)
- func (r *RawMessage) ESAltitude() (uint64, error)
- func (r *RawMessage) ESType() (uint64, error)
- func (r *RawMessage) FS() (uint64, error)
- func (r *RawMessage) ID() (uint64, error)
- func (r *RawMessage) KE() (uint64, error)
- func (r *RawMessage) MB() (uint64, error)
- func (r *RawMessage) MD() ([]byte, error)
- func (r *RawMessage) ME() (uint64, error)
- func (r *RawMessage) MV() (uint64, error)
- func (r *RawMessage) ND() (uint64, error)
- func (r *RawMessage) PI() (uint64, error)
- func (r *RawMessage) Parity() (p uint64)
- func (r *RawMessage) RI() (uint64, error)
- func (r *RawMessage) SL() (uint64, error)
- func (r *RawMessage) TC() uint64
- func (r *RawMessage) UM() (uint64, error)
- func (r *RawMessage) UnmarshalBinary(data []byte) error
- func (r *RawMessage) VS() (uint64, error)
Constants ¶
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 ¶
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 ¶
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.
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) GroundSpeed ¶
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 ¶
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) UnmarshalBinary ¶
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 ¶
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) 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) CC ¶
func (r *RawMessage) CC() (uint64, error)
CC returns the Cross-link Capability field.
func (*RawMessage) DF ¶
func (r *RawMessage) DF() (uint64, error)
DF returns the Downlink Format 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) 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.