beast

package
v0.0.0-...-732cea2 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package beast provides objects and methods for decoding and managing raw Mode-S Beast format frames.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoData = errNoData

ErrNoData is returned when the frame does not contain the data necessary to return the requested information.

Functions

func TicksToTimestamp

func TicksToTimestamp(ticks int64) time.Duration

TicksToTimestamp converts 12MHz ticks to a time.Duration.

func TimestampToTicks

func TimestampToTicks(d time.Duration) int64

TimestampToTicks converts a time.Duration to 12MHz ticks.

Types

type Decoder

type Decoder struct {
	// Setting StripEscape to true will remove the extra escape
	// character from 0x1a values in the data passed to the
	// BinaryUnmarshaler by Decode.
	StripEscape bool
	// contains filtered or unexported fields
}

Decoder reads a Beast stream and stores individual frames. It must be created with NewDecoder().

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder returns a Decoder which reads from r.

func (*Decoder) Decode

func (d *Decoder) Decode(f encoding.BinaryUnmarshaler) error

Decode reads the next Beast frame from the input source and stores it in f. The data passed to f remains valid only until the next call to Decode().

func (*Decoder) Reset

func (d *Decoder) Reset(r io.Reader)

Reset resets the Decoder to read from r, allowing reuse of the Decoder and its internal bufio.Reader buffer to reduce allocations.

type Frame

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

Frame is a Beast format message. A Frame is safe to reuse by calling UnmarshalBinary with new data.

func NewFrame

func NewFrame(ticks int64, signal uint8, payload []byte) (*Frame, error)

NewFrame constructs a Frame from individual components. The frame type is inferred from the payload length:

  • 2 bytes → type 0x31 (Mode A/C)
  • 7 bytes → type 0x32 (Mode S short)
  • 14 bytes → type 0x33 (Mode S long)

func (*Frame) Bytes

func (f *Frame) Bytes() []byte

Bytes returns the stored frame data. Escaped 0x1a values in the data are stripped before storing. To obtain the frame in the escaped wire format, use MarshalBinary.

The returned slice remains valid until the next call to UnmarshalBinary. Modifying the returned slice directly may impact future Frame method calls.

func (*Frame) MarshalBinary

func (f *Frame) MarshalBinary() ([]byte, error)

MarshalBinary returns a Beast message.

func (*Frame) ModeAC

func (f *Frame) ModeAC() ([]byte, error)

ModeAC returns the Mode AC data in a type 1 frame.

The returned slice remains valid until the next call to UnmarshalBinary. Modifying the returned slice directly may impact future Frame method calls.

func (*Frame) ModeS

func (f *Frame) ModeS() ([]byte, error)

ModeS returns the Mode S data in a type 2 or 3 frame.

The returned slice remains valid until the next call to UnmarshalBinary. Modifying the returned slice directly may impact future Frame method calls.

func (*Frame) Signal

func (f *Frame) Signal() (uint8, error)

Signal returns the signal level.

func (*Frame) Timestamp

func (f *Frame) Timestamp() (time.Duration, error)

Timestamp returns the MLAT timestamp as a time.Duration.

func (*Frame) TimestampTicks

func (f *Frame) TimestampTicks() (int64, error)

TimestampTicks returns the raw MLAT timestamp in 12MHz ticks.

func (*Frame) Type

func (f *Frame) Type() (byte, error)

Type returns the frame type byte.

func (*Frame) UnmarshalBinary

func (f *Frame) UnmarshalBinary(data []byte) error

UnmarshalBinary stores a Beast message.

Directories

Path Synopsis
Package internal contains mock objects for testing.
Package internal contains mock objects for testing.

Jump to

Keyboard shortcuts

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