Documentation
¶
Overview ¶
Package pus implements the ECSS Packet Utilization Standard, PUS-C, per ECSS-E-ST-70-41C (15 April 2016).
PUS defines what travels inside a CCSDS Space Packet. Where pkg/spp gives you a packet with an application-defined payload, PUS says how that payload is laid out: a secondary header naming a service and subtype, then the request or report body that pair implies.
The two secondary header types here implement spp.SecondaryHeader, so they plug straight into spp.WithSecondaryHeader and spp.WithDecodeSecondaryHeader without either package knowing about the other.
PUS is a tailoring standard. Several field widths are declared per mission rather than fixed by the text, so every codec in this package takes a MissionProfile. There is no package-level state and no implicit default: a profile is always passed explicitly, because two missions that disagree about widths cannot read each other's packets.
Index ¶
- Constants
- Variables
- type AckFlags
- type AreYouAliveReport
- type AreYouAliveRequest
- type DisabledEventsReport
- type EventControlRequest
- type EventReport
- type HousekeepingControlRequest
- type HousekeepingReport
- type HousekeepingStructure
- type MessageKey
- type MissionProfile
- func (p MissionProfile) APIDSize() int
- func (p MissionProfile) NewTCHeader(service, subtype uint8, sourceID uint16, ack AckFlags) *TCHeader
- func (p MissionProfile) NewTMHeader(service, subtype uint8, destinationID uint16, t time.Time) *TMHeader
- func (p MissionProfile) TCHeaderSize() int
- func (p MissionProfile) TMHeaderSize() int
- func (p MissionProfile) TimeSize() int
- func (p MissionProfile) Validate() error
- type OnBoardConnectionReport
- type OnBoardConnectionRequest
- type Registry
- func (r *Registry) DecodeReport(key MessageKey, data []byte) (Report, error)
- func (r *Registry) DecodeRequest(key MessageKey, data []byte) (Request, error)
- func (r *Registry) KnownReports() []MessageKey
- func (r *Registry) KnownRequests() []MessageKey
- func (r *Registry) Profile() MissionProfile
- func (r *Registry) RegisterReport(key MessageKey, decoder ReportDecoder) error
- func (r *Registry) RegisterRequest(key MessageKey, decoder RequestDecoder) error
- type Report
- type ReportDecoder
- type ReportDisabledEventsRequest
- type Request
- type RequestDecoder
- type RequestID
- type Severity
- type SuperCommutatedSet
- type TCHeader
- type TMHeader
- type TimeFormat
- type VerificationReport
Constants ¶
const ( // SourceIDSize is the TC source ID width (16 bits, Figure 7-9). SourceIDSize = 2 // MessageTypeCounterSize is the TM message type counter width // (16 bits, Figure 7-7). MessageTypeCounterSize = 2 // DestinationIDSize is the TM destination ID width (16 bits, Figure 7-7). DestinationIDSize = 2 )
Field widths the standard fixes outright, in octets. These are not mission-tailorable: Figure 7-7 and Figure 7-9 give them explicit bit counts.
const ( ServiceRequestVerification uint8 = 1 SubtypeAcceptSuccess uint8 = 1 // TM[1,1] clause 8.1.2.1 SubtypeAcceptFailure uint8 = 2 // TM[1,2] clause 8.1.2.2 SubtypeStartSuccess uint8 = 3 // TM[1,3] clause 8.1.2.3 SubtypeStartFailure uint8 = 4 // TM[1,4] clause 8.1.2.4 SubtypeProgressSuccess uint8 = 5 // TM[1,5] clause 8.1.2.5 SubtypeProgressFailure uint8 = 6 // TM[1,6] clause 8.1.2.6 SubtypeCompleteSuccess uint8 = 7 // TM[1,7] clause 8.1.2.7 SubtypeCompleteFailure uint8 = 8 // TM[1,8] clause 8.1.2.8 SubtypeRoutingFailure uint8 = 10 // TM[1,10] clause 8.1.2.10 )
ST[01] request verification, per ECSS-E-ST-70-41C clause 8.1.
Every report in this service carries a request ID naming the telecommand it concerns, and the failure reports add a failure notice.
const ( ServiceHousekeeping uint8 = 3 SubtypeCreateHKStructure uint8 = 1 // TC[3,1] clause 8.3.2.1 SubtypeDeleteHKStructure uint8 = 3 // TC[3,3] clause 8.3.2.3 SubtypeEnableHKGeneration uint8 = 5 // TC[3,5] clause 8.3.2.5 SubtypeDisableHKGeneration uint8 = 6 // TC[3,6] clause 8.3.2.6 SubtypeHKParameterReport uint8 = 25 // TM[3,25] clause 8.3.2.25 )
ST[03] housekeeping, per ECSS-E-ST-70-41C clause 8.3.
A housekeeping parameter report structure names a set of on-board parameters and how often to sample them. Once defined and enabled, the on-board system emits TM[3,25] reports carrying those parameters' values.
This package handles the structure definitions and the report framing. It does not sample anything: parameter values are supplied by the caller, since only the flight software knows what they mean.
const ( ServiceEventReporting uint8 = 5 SubtypeInformativeEvent uint8 = 1 // TM[5,1] clause 8.5.2.1 SubtypeLowSeverity uint8 = 2 // TM[5,2] clause 8.5.2.2 SubtypeMediumSeverity uint8 = 3 // TM[5,3] clause 8.5.2.3 SubtypeHighSeverity uint8 = 4 // TM[5,4] clause 8.5.2.4 SubtypeEnableEvents uint8 = 5 // TC[5,5] clause 8.5.2.5 SubtypeDisableEvents uint8 = 6 // TC[5,6] clause 8.5.2.6 SubtypeReportDisabled uint8 = 7 // TC[5,7] clause 8.5.2.7 SubtypeDisabledList uint8 = 8 // TM[5,8] clause 8.5.2.8 )
ST[05] event reporting, per ECSS-E-ST-70-41C clause 8.5.
An on-board event produces a report at one of four severities. Each report carries an event definition ID and, optionally, auxiliary data whose structure that ID implies.
const ( ServiceTest uint8 = 17 SubtypeAreYouAlive uint8 = 1 // TC[17,1] clause 8.17.2.1 SubtypeAreYouAliveReport uint8 = 2 // TM[17,2] clause 8.17.2.2 SubtypeOnBoardConnection uint8 = 3 // TC[17,3] clause 8.17.2.3 SubtypeOnBoardReport uint8 = 4 // TM[17,4] clause 8.17.2.4 )
ST[17] test, per ECSS-E-ST-70-41C clause 8.17.
The simplest service in the standard: a liveness check. The ground asks whether an application process is alive and it answers. Neither message carries a body.
const RequestIDSize = 4
RequestIDSize is the encoded width of a request ID, in octets. Figure 8-1 lays it out as packet version number (3) + packet type (1) + secondary header flag (1) + APID (11) + sequence flags (2) + sequence count (14), which is 32 bits — exactly the first four octets of a CCSDS primary header.
const Version = 2
Version is the TC and TM packet PUS version number for PUS-C, per clauses 7.4.3.1c and 7.4.4.1c. Version 0 was the ESA PUS, version 1 was ECSS-E-70-41A.
Variables ¶
var ( // ErrDataTooShort indicates the input ended before a field it must contain. ErrDataTooShort = errors.New("data too short for the PUS field being read") // ErrInvalidVersion indicates a PUS version other than 2, the value // ECSS-E-ST-70-41C clauses 7.4.3.1c and 7.4.4.1c require for PUS-C. ErrInvalidVersion = errors.New("invalid PUS version: this implementation speaks PUS-C (version 2)") // ErrInvalidProfile indicates mission-tailorable widths that cannot work. ErrInvalidProfile = errors.New("invalid mission profile") // ErrHeaderTooLarge indicates a mission profile whose secondary header is // wider than this package accepts. The bound is this package's own; CCSDS // 133.0-B-2 puts no upper limit on a Packet Secondary Header beyond the // packet data field maximum. ErrHeaderTooLarge = errors.New("PUS secondary header exceeds the 63-octet mission profile limit") // ErrUnknownMessageType indicates no codec is registered for a // (service, subtype) pair. ErrUnknownMessageType = errors.New("unknown PUS message type") // ErrDuplicateMessageType indicates two codecs registered for one // (service, subtype) pair. ErrDuplicateMessageType = errors.New("duplicate PUS message type registration") // ErrWrongMessageType indicates a decoder was handed another type's bytes. ErrWrongMessageType = errors.New("message type does not match the decoder") // ErrValueTooLarge indicates a value too wide for the field the profile // allocates to it. ErrValueTooLarge = errors.New("value does not fit the width the mission profile declares") // ErrUnsupportedTimeFormat indicates a time format this package cannot encode. ErrUnsupportedTimeFormat = errors.New("unsupported time format") // ErrInvalidSeverity indicates an event severity outside ST[05]'s four subtypes. ErrInvalidSeverity = errors.New("invalid event severity") // ErrTrailingBytes indicates octets left over after a fixed-size message // body. The PUS acceptance checks verify a request against its type's // structure, so a body longer than its type allows is rejected rather // than silently truncated. ErrTrailingBytes = errors.New("trailing octets after a fixed-size PUS message body") // ErrHeaderNotWordAligned indicates a secondary header whose size is not a // whole number of mission words (clauses 7.4.3.1l and 7.4.4.1g), when the // profile declares a word size to check against. ErrHeaderNotWordAligned = errors.New("PUS secondary header is not a whole number of mission words") )
Sentinel errors returned by the PUS codecs.
Functions ¶
This section is empty.
Types ¶
type AckFlags ¶
type AckFlags uint8
AckFlags are the four acknowledgement request bits of a TC secondary header, per ECSS-E-ST-70-41C clause 7.4.4.1d.
Each bit asks the destination application process for one verification report from service ST[01]. The bit positions are fixed by the standard: bit 3 acceptance, bit 2 start, bit 1 progress, bit 0 completion.
const ( // AckCompletion asks for a report on successful completion of execution // (bit 0, clause 7.4.4.1d.4). AckCompletion AckFlags = 1 << 0 // AckProgress asks for reports on successful progress of execution // (bit 1, clause 7.4.4.1d.3). AckProgress AckFlags = 1 << 1 // AckStart asks for a report on successful start of execution // (bit 2, clause 7.4.4.1d.2). AckStart AckFlags = 1 << 2 // AckAcceptance asks for a report on successful acceptance // (bit 3, clause 7.4.4.1d.1). AckAcceptance AckFlags = 1 << 3 )
type AreYouAliveReport ¶
type AreYouAliveReport struct{}
AreYouAliveReport is TM[17,2]. Its source data field is empty.
func (AreYouAliveReport) Encode ¶
func (AreYouAliveReport) Encode() ([]byte, error)
Encode returns an empty source data field.
func (AreYouAliveReport) Humanize ¶
func (AreYouAliveReport) Humanize() string
Humanize returns a human-readable summary.
func (AreYouAliveReport) Key ¶
func (AreYouAliveReport) Key() MessageKey
Key returns the message type.
type AreYouAliveRequest ¶
type AreYouAliveRequest struct{}
AreYouAliveRequest is TC[17,1]. Its application data field is empty.
func (AreYouAliveRequest) Encode ¶
func (AreYouAliveRequest) Encode() ([]byte, error)
Encode returns an empty application data field.
func (AreYouAliveRequest) Humanize ¶
func (AreYouAliveRequest) Humanize() string
Humanize returns a human-readable summary.
func (AreYouAliveRequest) Key ¶
func (AreYouAliveRequest) Key() MessageKey
Key returns the message type.
type DisabledEventsReport ¶
type DisabledEventsReport struct {
Profile MissionProfile
// EventDefinitionIDs names the events whose report generation is disabled.
EventDefinitionIDs []uint64
}
DisabledEventsReport is TM[5,8]: the disabled event definitions list report, per clause 8.5.2.8. It carries a count followed by that many event definition IDs, the answer to TC[5,7].
func DecodeDisabledEventsReport ¶
func DecodeDisabledEventsReport(profile MissionProfile, data []byte) (*DisabledEventsReport, error)
DecodeDisabledEventsReport parses TM[5,8].
func (*DisabledEventsReport) Encode ¶
func (r *DisabledEventsReport) Encode() ([]byte, error)
Encode serializes the source data field: a count followed by that many event definition IDs.
func (*DisabledEventsReport) Humanize ¶
func (r *DisabledEventsReport) Humanize() string
Humanize returns a human-readable summary.
func (*DisabledEventsReport) Key ¶
func (r *DisabledEventsReport) Key() MessageKey
Key returns the message type.
type EventControlRequest ¶
type EventControlRequest struct {
Profile MissionProfile
// Enable selects TC[5,5] when true and TC[5,6] when false.
Enable bool
// EventDefinitionIDs names the events to enable or disable.
EventDefinitionIDs []uint64
}
EventControlRequest is TC[5,5] and TC[5,6]: enable or disable the report generation of a list of event definitions.
func DecodeEventControlRequest ¶
func DecodeEventControlRequest(profile MissionProfile, enable bool, data []byte) (*EventControlRequest, error)
DecodeEventControlRequest parses TC[5,5] or TC[5,6].
func (*EventControlRequest) Encode ¶
func (r *EventControlRequest) Encode() ([]byte, error)
Encode serializes the application data field: a count followed by that many event definition IDs.
func (*EventControlRequest) Humanize ¶
func (r *EventControlRequest) Humanize() string
Humanize returns a human-readable summary.
func (*EventControlRequest) Key ¶
func (r *EventControlRequest) Key() MessageKey
Key returns the message type.
type EventReport ¶
type EventReport struct {
Profile MissionProfile
Severity Severity
// EventDefinitionID, with the application process ID, identifies the
// event definition and therefore the shape of the auxiliary data.
EventDefinitionID uint64
// AuxiliaryData is deduced from the event definition. This package carries
// it verbatim rather than interpreting it.
AuxiliaryData []byte
}
EventReport is TM[5,1] through TM[5,4], per Figure 8-59 and its siblings.
The four subtypes share one structure and differ only in severity, so one type covers them all.
func DecodeEventReport ¶
func DecodeEventReport(profile MissionProfile, severity Severity, data []byte) (*EventReport, error)
DecodeEventReport parses an ST[05] event report of the given severity.
func (*EventReport) Encode ¶
func (r *EventReport) Encode() ([]byte, error)
Encode serializes the source data field.
func (*EventReport) Humanize ¶
func (r *EventReport) Humanize() string
Humanize returns a human-readable summary.
type HousekeepingControlRequest ¶
type HousekeepingControlRequest struct {
Profile MissionProfile
// Subtype selects which of the three requests this is.
Subtype uint8
// StructureIDs names the report structures to act on.
StructureIDs []uint64
}
HousekeepingControlRequest is TC[3,3], TC[3,5] and TC[3,6]: delete report structures, or enable and disable their periodic generation. All three carry a count followed by that many structure IDs.
func DecodeHousekeepingControlRequest ¶
func DecodeHousekeepingControlRequest(profile MissionProfile, subtype uint8, data []byte) (*HousekeepingControlRequest, error)
DecodeHousekeepingControlRequest parses TC[3,3], TC[3,5] or TC[3,6].
func (*HousekeepingControlRequest) Encode ¶
func (r *HousekeepingControlRequest) Encode() ([]byte, error)
Encode serializes the application data field.
func (*HousekeepingControlRequest) Humanize ¶
func (r *HousekeepingControlRequest) Humanize() string
Humanize returns a human-readable summary.
func (*HousekeepingControlRequest) Key ¶
func (r *HousekeepingControlRequest) Key() MessageKey
Key returns the message type.
func (*HousekeepingControlRequest) Validate ¶
func (r *HousekeepingControlRequest) Validate() error
Validate checks the request.
type HousekeepingReport ¶
type HousekeepingReport struct {
Profile MissionProfile
// StructureID names the report structure these values belong to.
StructureID uint64
// ParameterValues holds the sampled values, laid out as the structure
// definition dictates. The caller supplies and interprets them.
ParameterValues []byte
}
HousekeepingReport is TM[3,25]: a housekeeping parameter report.
The report carries the structure ID and then the sampled parameter values back to back. Their layout is deduced from the structure definition, which both ends already share, so this package moves the values verbatim.
func DecodeHousekeepingReport ¶
func DecodeHousekeepingReport(profile MissionProfile, data []byte) (*HousekeepingReport, error)
DecodeHousekeepingReport parses TM[3,25].
func (*HousekeepingReport) Encode ¶
func (r *HousekeepingReport) Encode() ([]byte, error)
Encode serializes the source data field.
func (*HousekeepingReport) Humanize ¶
func (r *HousekeepingReport) Humanize() string
Humanize returns a human-readable summary.
func (*HousekeepingReport) Key ¶
func (r *HousekeepingReport) Key() MessageKey
Key returns the message type.
type HousekeepingStructure ¶
type HousekeepingStructure struct {
Profile MissionProfile
// StructureID names this report structure.
StructureID uint64
// CollectionInterval is how often the report is generated, in the units
// the mission declares.
CollectionInterval uint64
// ParameterIDs are the parameters sampled once per interval.
ParameterIDs []uint64
// SuperCommutated are the parameter groups sampled several times per
// interval.
SuperCommutated []SuperCommutatedSet
}
HousekeepingStructure is TC[3,1]: create a housekeeping parameter report structure, per Figure 8-21.
func DecodeHousekeepingStructure ¶
func DecodeHousekeepingStructure(profile MissionProfile, data []byte) (*HousekeepingStructure, error)
DecodeHousekeepingStructure parses TC[3,1].
func (*HousekeepingStructure) Encode ¶
func (s *HousekeepingStructure) Encode() ([]byte, error)
Encode serializes the application data field per Figure 8-21: structure ID, collection interval, N1, N1 parameter IDs, NFA, then for each of NFA groups a repetition number, N2, and N2 parameter IDs.
func (*HousekeepingStructure) Humanize ¶
func (s *HousekeepingStructure) Humanize() string
Humanize returns a human-readable summary.
func (*HousekeepingStructure) Key ¶
func (s *HousekeepingStructure) Key() MessageKey
Key returns the message type.
func (*HousekeepingStructure) Validate ¶
func (s *HousekeepingStructure) Validate() error
Validate checks the structure definition.
type MessageKey ¶
MessageKey names one PUS message type: a service type ID and a message subtype ID, the pair that clause 5.3.3.1c calls the message type identifier.
It is written TC[service,subtype] for requests and TM[service,subtype] for reports, which is how the standard refers to them throughout.
func (MessageKey) String ¶
func (k MessageKey) String() string
String renders the key the way the standard writes it.
type MissionProfile ¶
type MissionProfile struct {
// TCSpareBytes and TMSpareBytes pad each secondary header out to the
// mission's word size. Clauses 7.4.4.1g and 7.4.3.1l make their presence
// and size a per-application-process declaration.
TCSpareBytes int
TMSpareBytes int
// TimeFormat selects the TM absolute time encoding (clause 7.4.3.1j).
TimeFormat TimeFormat
// CUCCoarseBytes and CUCFineBytes size a CUC time field. Used when
// TimeFormat is TimeCUC or TimeCUCExplicit.
CUCCoarseBytes int
CUCFineBytes int
// CUCEpoch is the epoch a CUC time counts from. The zero value means the
// CCSDS 1958 epoch that pkg/tcf defaults to.
CUCEpoch time.Time
// TimeRawBytes is the width of an opaque time field. Used only when
// TimeFormat is TimeRaw.
TimeRawBytes int
// StepIDBytes sizes the step ID of the ST[01] progress reports, TM[1,5]
// and TM[1,6]. Figures 8-5 and 8-6 mark it enumerated without a width.
StepIDBytes int
// FailureCodeBytes sizes the failure notice code of the ST[01] failure
// reports. Figure 8-2 and its siblings mark it enumerated.
FailureCodeBytes int
// EventDefinitionIDBytes sizes the ST[05] event definition ID
// (Figure 8-59, enumerated).
EventDefinitionIDBytes int
// Housekeeping widths for ST[03] (Figure 8-21, all enumerated or
// unsigned integer without a stated width).
HousekeepingStructureIDBytes int
ParameterIDBytes int
CollectionIntervalBytes int
CountBytes int
// APIDBytes sizes the APID field of TC[17,3] and TM[17,4]. Clauses
// 8.17.2.3 and 8.17.2.4 mark it enumerated without a stated width, so it
// is mission-tailorable like the other enumerated fields. Zero selects
// the 2-octet width most missions use.
APIDBytes int
// WordSizeBytes is the mission's word size, in octets. Clauses 7.4.3.1l
// and 7.4.4.1g size the spare fields so each secondary header ends on a
// word boundary. When non-zero, Validate checks that both header sizes are
// whole multiples of this value. Zero disables the check, leaving word
// alignment to the caller-supplied spare widths.
WordSizeBytes int
}
MissionProfile pins every width that ECSS-E-ST-70-41C leaves to the mission. It is a value type and must not be mutated once codecs are using it.
Widths the standard fixes — TC source ID, TM message type counter, TM destination ID, all 16 bits — are deliberately absent. They are constants.
func DefaultProfile ¶
func DefaultProfile() MissionProfile
DefaultProfile returns a profile using the widths most European missions pick: no spare padding, a 6-octet CUC time, and one or two octets for the enumerated identifiers.
It is a convenience for tooling and tests, not a standard-mandated default. ECSS-E-ST-70-41C states no defaults for these fields; a real mission declares them.
func (MissionProfile) APIDSize ¶
func (p MissionProfile) APIDSize() int
APIDSize returns the width of the ST[17] APID field in octets: APIDBytes, or the 2-octet default when the profile leaves it zero.
func (MissionProfile) NewTCHeader ¶
func (p MissionProfile) NewTCHeader(service, subtype uint8, sourceID uint16, ack AckFlags) *TCHeader
NewTCHeader builds a telecommand secondary header under a profile.
func (MissionProfile) NewTMHeader ¶
func (p MissionProfile) NewTMHeader(service, subtype uint8, destinationID uint16, t time.Time) *TMHeader
NewTMHeader builds a telemetry secondary header under a profile.
func (MissionProfile) TCHeaderSize ¶
func (p MissionProfile) TCHeaderSize() int
TCHeaderSize returns the encoded width of a TC secondary header: version and ack flags (1) + service (1) + subtype (1) + source ID (2) + spare (Figure 7-9).
func (MissionProfile) TMHeaderSize ¶
func (p MissionProfile) TMHeaderSize() int
TMHeaderSize returns the encoded width of a TM secondary header: version and time reference status (1) + service (1) + subtype (1) + message type counter (2) + destination ID (2) + time + spare (Figure 7-7).
func (MissionProfile) TimeSize ¶
func (p MissionProfile) TimeSize() int
TimeSize returns the width of the TM absolute time field in octets.
func (MissionProfile) Validate ¶
func (p MissionProfile) Validate() error
Validate checks the profile's widths.
Both header sizes must be at least 1 octet and no more than 63. Only the lower bound comes from a standard: CCSDS 133.0-B-2 4.1.4.2.1.3 requires the Packet Secondary Header to be a whole number of octets, and pkg/spp refuses a zero-length one. The Blue Book sets no upper limit at all — the data field maximum is the only ceiling it gives. The 63-octet cap here is this package's own sanity bound on a mission profile: a PUS secondary header of that width already carries an 8-octet time code and 50-odd octets of spare, so a larger one is far more likely to be a mistyped profile than a real design. Missions that genuinely need more should raise it here.
type OnBoardConnectionReport ¶
type OnBoardConnectionReport struct {
Profile MissionProfile
// APID identifies the application process that was tested.
APID uint16
}
OnBoardConnectionReport is TM[17,4], the answer to TC[17,3]. Its APID field uses the same profile-declared width as the request.
func DecodeOnBoardConnectionReport ¶
func DecodeOnBoardConnectionReport(profile MissionProfile, data []byte) (*OnBoardConnectionReport, error)
DecodeOnBoardConnectionReport parses TM[17,4].
func (OnBoardConnectionReport) Encode ¶
func (r OnBoardConnectionReport) Encode() ([]byte, error)
Encode serializes the source data field.
func (OnBoardConnectionReport) Humanize ¶
func (r OnBoardConnectionReport) Humanize() string
Humanize returns a human-readable summary.
func (OnBoardConnectionReport) Key ¶
func (OnBoardConnectionReport) Key() MessageKey
Key returns the message type.
type OnBoardConnectionRequest ¶
type OnBoardConnectionRequest struct {
Profile MissionProfile
// APID identifies the application process to test.
APID uint16
}
OnBoardConnectionRequest is TC[17,3]: a connection test addressed to another application process on board. The APID of the process under test travels in the application data field, at the width the profile's APIDBytes declares (two octets when unset).
func DecodeOnBoardConnectionRequest ¶
func DecodeOnBoardConnectionRequest(profile MissionProfile, data []byte) (*OnBoardConnectionRequest, error)
DecodeOnBoardConnectionRequest parses TC[17,3].
func (OnBoardConnectionRequest) Encode ¶
func (r OnBoardConnectionRequest) Encode() ([]byte, error)
Encode serializes the application data field.
func (OnBoardConnectionRequest) Humanize ¶
func (r OnBoardConnectionRequest) Humanize() string
Humanize returns a human-readable summary.
func (OnBoardConnectionRequest) Key ¶
func (OnBoardConnectionRequest) Key() MessageKey
Key returns the message type.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry maps message types to the codecs that handle them.
A mission registers the services it supports; anything unregistered decodes to ErrUnknownMessageType rather than being guessed at. That matters because PUS lets missions define their own service types in the ranges the standard leaves open.
A Registry is safe for concurrent use once built.
func NewDefaultRegistry ¶
func NewDefaultRegistry(profile MissionProfile) (*Registry, error)
NewDefaultRegistry returns a registry with every service this package implements already registered: ST[01] request verification, ST[03] housekeeping, ST[05] event reporting, and ST[17] test.
func NewRegistry ¶
func NewRegistry(profile MissionProfile) (*Registry, error)
NewRegistry returns an empty registry bound to a mission profile.
func (*Registry) DecodeReport ¶
func (r *Registry) DecodeReport(key MessageKey, data []byte) (Report, error)
DecodeReport parses the source data of a telemetry packet.
func (*Registry) DecodeRequest ¶
func (r *Registry) DecodeRequest(key MessageKey, data []byte) (Request, error)
DecodeRequest parses the application data of a telecommand.
func (*Registry) KnownReports ¶
func (r *Registry) KnownReports() []MessageKey
KnownReports lists the registered report types.
func (*Registry) KnownRequests ¶
func (r *Registry) KnownRequests() []MessageKey
KnownRequests lists the registered request types.
func (*Registry) Profile ¶
func (r *Registry) Profile() MissionProfile
Profile returns the mission profile this registry decodes against.
func (*Registry) RegisterReport ¶
func (r *Registry) RegisterReport(key MessageKey, decoder ReportDecoder) error
RegisterReport adds a report decoder.
func (*Registry) RegisterRequest ¶
func (r *Registry) RegisterRequest(key MessageKey, decoder RequestDecoder) error
RegisterRequest adds a request decoder. Registering a key twice is an error rather than a silent overwrite.
type Report ¶
type Report interface {
// Key returns the message type this report carries.
Key() MessageKey
// Encode serializes the source data field.
Encode() ([]byte, error)
}
Report is the source data of a telemetry packet: the body that follows the TM secondary header. Clause 8 specifies the structure for each report type.
type ReportDecoder ¶
type ReportDecoder func(profile MissionProfile, data []byte) (Report, error)
ReportDecoder parses the source data of one report type.
type ReportDisabledEventsRequest ¶
type ReportDisabledEventsRequest struct{}
ReportDisabledEventsRequest is TC[5,7]: report the list of event definitions whose report generation is disabled, per clause 8.5.2.7. Its application data field is empty; the answer is a TM[5,8] report.
func DecodeReportDisabledEventsRequest ¶
func DecodeReportDisabledEventsRequest(data []byte) (*ReportDisabledEventsRequest, error)
DecodeReportDisabledEventsRequest parses TC[5,7], whose body is empty.
func (ReportDisabledEventsRequest) Encode ¶
func (ReportDisabledEventsRequest) Encode() ([]byte, error)
Encode returns an empty application data field.
func (ReportDisabledEventsRequest) Humanize ¶
func (ReportDisabledEventsRequest) Humanize() string
Humanize returns a human-readable summary.
func (ReportDisabledEventsRequest) Key ¶
func (ReportDisabledEventsRequest) Key() MessageKey
Key returns the message type.
type Request ¶
type Request interface {
// Key returns the message type this request carries.
Key() MessageKey
// Encode serializes the application data field.
Encode() ([]byte, error)
}
Request is the application data of a telecommand: the body that follows the TC secondary header. Clause 6 specifies the structure for each request type.
type RequestDecoder ¶
type RequestDecoder func(profile MissionProfile, data []byte) (Request, error)
RequestDecoder parses the application data of one request type.
type RequestID ¶
type RequestID struct {
PacketVersion uint8 // 3 bits
PacketType uint8 // 1 bit
SecondaryHeaderFlag uint8 // 1 bit
APID uint16 // 11 bits
SequenceFlags uint8 // 2 bits
SequenceCount uint16 // 14 bits
}
RequestID identifies the telecommand a verification report concerns (Figure 8-1).
It does not name the source of the request. As the standard's note points out, that comes from the destination ID of the report's own secondary header.
func DecodeRequestID ¶
DecodeRequestID parses a request ID from the front of data.
type Severity ¶
type Severity uint8
Severity names the four levels of ST[05] event report.
const ( // SeverityInformative is a normal, expected event. SeverityInformative Severity = Severity(SubtypeInformativeEvent) // SeverityLow is a low severity anomaly. SeverityLow Severity = Severity(SubtypeLowSeverity) // SeverityMedium is a medium severity anomaly. SeverityMedium Severity = Severity(SubtypeMediumSeverity) // SeverityHigh is a high severity anomaly. SeverityHigh Severity = Severity(SubtypeHighSeverity) )
type SuperCommutatedSet ¶
type SuperCommutatedSet struct {
// RepetitionNumber is how many times each parameter in this set is
// sampled per collection interval.
RepetitionNumber uint64
// ParameterIDs names the parameters in the set.
ParameterIDs []uint64
}
SuperCommutatedSet is one group of parameters sampled more than once per collection interval (Figure 8-21).
Ordinary parameters are sampled once per interval. A super-commutated set repeats its sampling a fixed number of times, which is how a fast-changing value rides in a slow report.
type TCHeader ¶
type TCHeader struct {
// Profile pins the mission-tailorable widths. A TCHeader without one
// cannot encode, which is deliberate.
Profile MissionProfile
// AckFlags asks for verification reports (clause 7.4.4.1d).
AckFlags AckFlags
// Service and Subtype are the message type ID (clause 7.4.4.1e).
Service uint8
Subtype uint8
// SourceID identifies the issuing entity (clause 7.4.4.1f), 16 bits.
SourceID uint16
// Spare pads the header to the mission's word size. Its length must match
// the profile's TCSpareBytes.
Spare []byte
}
TCHeader is the telecommand packet secondary header of Figure 7-9.
It implements spp.SecondaryHeader, so a PUS telecommand is built by handing one to spp.WithSecondaryHeader.
func (*TCHeader) Decode ¶
Decode parses the header. The receiving header must already carry the profile, since the wire format is not self-describing.
func (*TCHeader) Key ¶
func (h *TCHeader) Key() MessageKey
Key returns the message type this header names.
type TMHeader ¶
type TMHeader struct {
// Profile pins the mission-tailorable widths and the time format.
Profile MissionProfile
// TimeReferenceStatus reports the status of the on-board time reference
// used to time tag this packet (clause 7.4.3.1d). An application process
// that cannot report it sets zero (clause 7.4.3.1e).
TimeReferenceStatus uint8
// Service and Subtype are the message type ID (clause 7.4.3.1f).
Service uint8
Subtype uint8
// MessageTypeCounter counts messages of this type per destination
// (clause 7.4.3.1g), 16 bits. Zero when the capability is absent
// (clause 7.4.3.1h).
MessageTypeCounter uint16
// DestinationID is the application process user identifier of the
// addressed process (clause 7.4.3.1i), 16 bits.
DestinationID uint16
// Time is the time tag of the report (clause 7.4.3.1k). Used when the
// profile selects TimeCUC.
Time time.Time
// RawTime carries the time field verbatim when the profile selects
// TimeRaw. Its length must match the profile's TimeRawBytes.
RawTime []byte
// Spare pads the header to the mission's word size. Its length must match
// the profile's TMSpareBytes.
Spare []byte
}
TMHeader is the telemetry packet secondary header of Figure 7-7.
It implements spp.SecondaryHeader, so a PUS report is built by handing one to spp.WithSecondaryHeader.
func (*TMHeader) Decode ¶
Decode parses the header. The receiving header must already carry the profile, since the wire format is not self-describing.
func (*TMHeader) Key ¶
func (h *TMHeader) Key() MessageKey
Key returns the message type this header names.
type TimeFormat ¶
type TimeFormat uint8
TimeFormat selects how the TM secondary header's absolute time field is encoded. Clause 7.4.3.1j leaves the PFC to the mission's time service.
const ( // TimeNone omits the time field. Useful for ground tooling and tests; // a flight profile normally carries a time. TimeNone TimeFormat = iota // TimeCUC encodes a CCSDS Unsegmented Time Code with an implicit P-field, // which is what PFC 3 to 46 of Table 7-10 specify: the field carries the // coarse and fine octets alone, because the PFC already says how wide they // are. This is the usual choice. TimeCUC // TimeCUCExplicit encodes a CUC that carries its own P-field, which is // PFC 0 of Table 7-10: "explicit definition of time format (CUC or CDS), // i.e. including the P-field". TimeCUCExplicit // TimeRaw carries a fixed-width opaque field the mission defines // elsewhere. This package moves the bytes without interpreting them. TimeRaw )
type VerificationReport ¶
type VerificationReport struct {
Profile MissionProfile
Subtype uint8
// RequestID names the telecommand being reported on.
RequestID RequestID
// StepID is present on TM[1,5] and TM[1,6] only. Its width comes from the
// profile, since Figures 8-5 and 8-6 mark it enumerated without one.
StepID uint64
// FailureCode and FailureData form the failure notice on the even
// subtypes. FailureData is deduced from the code and carried verbatim.
FailureCode uint64
FailureData []byte
}
VerificationReport is any of the nine ST[01] reports: TM[1,1] to TM[1,8], plus the TM[1,10] failed routing verification report.
Which fields carry meaning depends on the subtype: the progress reports (subtypes 5 and 6) add a step ID, and the failure reports (even subtypes, including TM[1,10]) add a failure notice.
func DecodeVerificationReport ¶
func DecodeVerificationReport(profile MissionProfile, subtype uint8, data []byte) (*VerificationReport, error)
DecodeVerificationReport parses an ST[01] report of the given subtype.
func (*VerificationReport) Encode ¶
func (r *VerificationReport) Encode() ([]byte, error)
Encode serializes the source data field.
func (*VerificationReport) HasStepID ¶
func (r *VerificationReport) HasStepID() bool
HasStepID reports whether this subtype carries a step ID.
func (*VerificationReport) Humanize ¶
func (r *VerificationReport) Humanize() string
Humanize returns a human-readable summary.
func (*VerificationReport) IsFailure ¶
func (r *VerificationReport) IsFailure() bool
IsFailure reports whether this subtype carries a failure notice. The even subtypes are the failures, per clause 8.1.2 — including TM[1,10], whose body is a request ID and a failure notice, like TM[1,2].
func (*VerificationReport) Key ¶
func (r *VerificationReport) Key() MessageKey
Key returns the message type.
func (*VerificationReport) Validate ¶
func (r *VerificationReport) Validate() error
Validate checks the report against clause 8.1.2. The valid subtypes are 1 to 8 and 10; the standard defines no TM[1,9].