header

package
v0.0.0-...-4d64c08 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

The header package handles a Multiple Signal Message (MSM) header.

Index

Constants

View Source
const LenMessageType = 12

Field lengths in bits. The visible values are used by other packages.

View Source
const LenStationID = 12
View Source
const LenTimeStamp = 30

Variables

This section is empty.

Functions

This section is empty.

Types

type Header struct {

	// MessageType - uint12 - one of 1074, 1077 etc.
	MessageType int

	// Constellation - one of "GPS, "Beidou" etc.
	Constellation string

	// StationID - uint12.
	StationID uint

	// Timestamp - uint30.
	//
	// The structure of the 30 bits varies with the constellation.  For GPS,
	// Galileo and Beidou it's a single uint, the number of milliseconds from
	// the start of the current week.  For GPS and Galileo that starts on
	// Saturday UTC at a few leap seconds before midnight (in 2013, 18 seconds
	// before.  For Beidou it's similar but, in 2013, 4 seconds before midnight
	// UTC.  The maximum value is ((milliseconds in 7 days) - 1)
	// (utils.MaxTimestamp).
	//
	// For GLONASS the top three bits are the day of the week (0 is Sunday) and
	// the lower 27 bits are milliseconds from the start of the day in the
	// Moscow time zone, which is 3 hours ahead of UTC.  The maximum value is
	// day == 6, milliseconds == ((milliseconds in 24 hours) - 1),
	// (utils.MaxTimestampGlonass).
	Timestamp uint

	// MultipleMessage - bit(1) - true if more MSMs follow for this
	// constellation, station and timestamp.
	MultipleMessage bool

	// IssueOfDataStation - uint3. (Possibly the sequence number of the
	// message in a multiple message sequence?)
	IssueOfDataStation uint

	// SessionTransmissionTime - uint7.
	SessionTransmissionTime uint

	// ClockSteeringIndicator - uint2.
	ClockSteeringIndicator uint

	// ExternalClockSteeringIndicator - uint2.
	ExternalClockSteeringIndicator uint

	// GNSSDivergenceFreeSmoothingIndicator - bit(1).
	GNSSDivergenceFreeSmoothingIndicator bool

	// GNSSSmoothingInterval - uint3.
	GNSSSmoothingInterval uint

	// SatelliteMask is 64 bits, one bit per satellite.  Bit 63
	// is set if signals were observed from satellite 1, bit 62 for
	// satellite 2 and so on.  For example 101000..... means that
	// signals from satellites 1 and 3 were observed.
	SatelliteMask uint64

	// SignalMask is 32 bits, one per signal.  Bit 31 is set if
	// signal 1 was observed from any satellite, bit 30 is set if
	// signal 2 was observed from any satellite, and so on.  For
	// example if signal 1, 3 and 5 were observed from one satellite
	// and signals 1 and 2 from another, then bits 1, 2, 3 and 5
	// will be set in the signal mask.
	SignalMask uint32

	// CellMask is an array of bits nSat X nSig where nSat is the
	// number of observed satellites (the number of bits set in the
	// satellite mask) and nSig is the number of signals types observed
	// across all of the satellites (the number of bits set in the
	// signal mask).  It's guaranteed to be <= 64.
	//
	// For example, if signals 1, 3 and 5 were observed from satellite 1 and
	// signals 1 and 2 were observed from satellite 3, the satellite mask will
	// have bits 63 and 61 set.  The signal mask will have bits 31, 30, 29 and
	// 27 set. The cell mask will be a table 2 X 4 bits long.  In this example,
	// each element indicates whether signals 1, 2, 3 and/or 5 were observed for
	// that satellite so the array would be 1011, 1100.  (In practice all
	// constellations currently (in 2021) use only 2 signals).  Decoding the
	// cell mask requires counting through the bits in the other two masks.
	CellMask uint64

	// Satellites is a slice made from the Satellite Mask bits.  If the satellite
	// mask has bits 63 and 61 set, signals were observed from satellites 1 and 3,
	// the slice will have two elements and will contain {1, 3}.
	Satellites []uint

	// Signals is a slice made from the signal mask.  If signals 1, 2, 3 and 5 were
	// observed from the satellites, the slice will have four elements and will
	// contain {1, 2, 3, 5}
	Signals []uint

	// Cells is a slice of slices representing the cell mask.  For example, if
	// signals 1,2,3 and 5 were observed from satellites 1 and 3, the Cells might
	// be arranged like so: {{t,f,t,t}, {t,t,f,f}}, meaning that signals 1, 3 and 5
	// were observed from satellite 1, no signals were observed from Satellite 2 and
	// signals 1 and 2 were observed from satellite 3.  (At present (2022) the
	// satellites are dual band, so actually they will send two signals and the
	// receiver might observe zero, one or both of them.)
	Cells [][]bool

	// NumSignalCells is the total number of signal cells in the message.  Creating
	// this count avoids having to rummage through the masks when you need to know
	// its value.
	NumSignalCells int

	// LogLevel controls the data output by String.
	LogLevel slog.Level
}

Header holds the header for MSM Messages. Message types 1074, 1077, 1084, 1087 etc have an MSM header at the start.

func GetMSMHeader

func GetMSMHeader(bitStream []byte, logLevel slog.Level) (*Header, uint, error)

GetMSMHeader extracts the header from an MSM message (MSM4 or MSM7). It returns the header data and the bit position of the start of the satellite data (which comes next in the bit stream). If the bit stream is not long enough to hold the header, an error is returned.

func New

func New(
	messageType int,
	stationID uint,
	timestamp uint,
	multipleMessage bool,
	issueOfDataStation uint,
	sessionTransmissionTime uint,
	clockSteeringIndicator uint,
	externalClockSteeringIndicator uint,
	gnssDivergenceFreeSmoothingIndicator bool,
	gnssSmoothingInterval uint,
	satelliteMask uint64,
	signalMask uint32,
	cellMask uint64,
	logLevel slog.Level,
) *Header

New creates a Header.

func (*Header) GetTitle

func (header *Header) GetTitle() string

getTitle gets the title of the MSM.

func (*Header) String

func (header *Header) String() string

String return a text version of the MSMHeader.

Jump to

Keyboard shortcuts

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