transport

package
v0.0.0-...-f2d3015 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MagicNumCmd       = 0x73133C2C // "tele-exec"
	PingCID           = 0x01000001
	MagSetPwrStateCID = 0x02000001
)
View Source
const (
	Escape    = 0xFF
	EscEscape = 0x11
	EscSOP    = 0x22
	EscEOP    = 0x33
)
View Source
const (
	MagicNumTlm           = 0x7313DA7A // "tele-data"
	CmdReceivedTID        = 0x01000001
	CmdCompletedTID       = 0x01000002
	CmdNotRecognizedTID   = 0x01000003
	TlmDroppedTID         = 0x01000004
	PongTID               = 0x01000005
	ClockCalibratedTID    = 0x01000006
	HeartbeatTID          = 0x01000007
	MagPwrStateChangedTID = 0x02000001
	MagReadingsArrayTID   = 0x02000002
)

Variables

This section is empty.

Functions

func AttachReceiver

func AttachReceiver(ctx model.SimContext, source *telecomm.Connection, callback func(packet *CommPacket), onErrors func(int))

Types

type BaseTelemetry

type BaseTelemetry struct{}

func (*BaseTelemetry) Decode

func (bt *BaseTelemetry) Decode(t Telemetry, dataBytes []byte, tlmId uint32) error

type ClockCalibrated

type ClockCalibrated struct {
	BaseTelemetry
	Adjustment int64
}

func (*ClockCalibrated) String

func (c *ClockCalibrated) String() string

type CmdCompleted

type CmdCompleted struct {
	BaseTelemetry
	OriginalTimestamp uint64
	OriginalCommandId uint32
	Success           bool
}

func (*CmdCompleted) String

func (c *CmdCompleted) String() string

type CmdNotRecognized

type CmdNotRecognized struct {
	BaseTelemetry
	OriginalTimestamp uint64
	OriginalCommandId uint32
	Length            uint32
}

func (*CmdNotRecognized) String

func (c *CmdNotRecognized) String() string

type CmdReceived

type CmdReceived struct {
	BaseTelemetry
	OriginalTimestamp uint64
	OriginalCommandId uint32 // the CID
}

func (*CmdReceived) String

func (c *CmdReceived) String() string

type CommPacket

type CommPacket struct {
	MagicNumber uint32
	CmdTlmId    uint32
	Timestamp   uint64
	DataBytes   []byte
	CRC         uint32
}

func DecodeCommPacket

func DecodeCommPacket(stream []byte) (packet *CommPacket, bytesUsed int, errors int)

func EncodeCommand

func EncodeCommand(cmd Command, timestamp uint64) *CommPacket

func (*CommPacket) ComputeCRC

func (cp *CommPacket) ComputeCRC() uint32

func (*CommPacket) Encode

func (cp *CommPacket) Encode() []byte

type Command

type Command interface {
	CmdId() uint32
}

func GenerateCmd

func GenerateCmd(r *rand.Rand) Command

type Heartbeat

type Heartbeat struct {
	BaseTelemetry
}

func (*Heartbeat) String

func (h *Heartbeat) String() string

type MagPwrStateChanged

type MagPwrStateChanged struct {
	BaseTelemetry
	PowerState bool
}

func (*MagPwrStateChanged) String

func (m *MagPwrStateChanged) String() string

type MagReading

type MagReading struct {
	ReadingTime      uint64
	MagX, MagY, MagZ int16
}

func (*MagReading) String

func (m *MagReading) String() string

type MagReadingsArray

type MagReadingsArray struct {
	Header struct {
		EarliestTime uint64
		LatestTime   uint64
	}
	Readings []MagReading
}

func (*MagReadingsArray) Decode

func (m *MagReadingsArray) Decode(_ Telemetry, dataBytes []byte, tlmId uint32) error

func (*MagReadingsArray) String

func (m *MagReadingsArray) String() string

type MagSetPwrState

type MagSetPwrState struct {
	PowerState bool
}

func (MagSetPwrState) CmdId

func (MagSetPwrState) CmdId() uint32

func (MagSetPwrState) String

func (c MagSetPwrState) String() string

type Ping

type Ping struct {
	PingID uint32
}

func (Ping) CmdId

func (Ping) CmdId() uint32

func (Ping) String

func (c Ping) String() string

type Pong

type Pong struct {
	BaseTelemetry
	PingID uint32
}

func (*Pong) String

func (p *Pong) String() string

type Sender

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

func MakeSender

func MakeSender(ctx model.SimContext, dest *telecomm.Connection) *Sender

func (*Sender) CanSend

func (s *Sender) CanSend() bool

func (*Sender) Send

func (s *Sender) Send(packet *CommPacket) bool

func (*Sender) Subscribe

func (s *Sender) Subscribe(callback func()) (cancel func())

type Telemetry

type Telemetry interface {
	// Decode takes a reference to this interface itself, just to simplify the implementation of BaseTelemetry
	Decode(t Telemetry, dataBytes []byte, tlmId uint32) error
}

func DecodeTelemetry

func DecodeTelemetry(cp *CommPacket) (t Telemetry, timestamp model.VirtualTime, err error)

type TlmDropped

type TlmDropped struct {
	BaseTelemetry
	MessagesLost uint32
}

func (*TlmDropped) String

func (t *TlmDropped) String() string

Jump to

Keyboard shortcuts

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