packets

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: NIST-PD-fallback Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByteSwap added in v0.3.1

func ByteSwap(vectorIn interface{}) error

Types

type HeadCounter

type HeadCounter struct {
	ID    int16
	Count int32
}

HeadCounter represents a counter found in a packet header

type Packet

type Packet struct {

	// The data payload
	Data interface{}
	// contains filtered or unexported fields
}

Packet represents the header of an Abaco data packet

func NewPacket

func NewPacket(version uint8, sourceID uint32, sequenceNumber uint32, chanOffset int) *Packet

NewPacket generates a new packet with the given facts. No data are configured or stored.

func ReadPacket

func ReadPacket(data io.Reader) (p *Packet, err error)

ReadPacket returns a Packet read from an io.reader

func ReadPacketPlusPad

func ReadPacketPlusPad(data io.Reader, stride int) (p *Packet, err error)

ReadPacketPlusPad reads a packet from data, then consumes the padding bytes that follow (if any) so that a multiple of stride bytes is read.

func (*Packet) Bytes

func (p *Packet) Bytes() []byte

Bytes converts the Packet p to a []byte slice for transport.

func (*Packet) ChannelInfo

func (p *Packet) ChannelInfo() (nchan, offset int)

ChannelInfo returns the number of channels in this packet, and the first one

func (*Packet) ClearData

func (p *Packet) ClearData() error

ClearData removes the data payload from a packet.

func (*Packet) Frames

func (p *Packet) Frames() int

Frames returns the number of data frames in the packet

func (*Packet) IsExternalTrigger added in v0.3.1

func (p *Packet) IsExternalTrigger() bool

IsExternalTrigger tests a packet for whether it (appears to) contain external trigger timestamps

func (*Packet) Length

func (p *Packet) Length() int

Length returns the length of the entire packet, in bytes

func (*Packet) MakePretendPacket

func (p *Packet) MakePretendPacket(seqnum uint32, nchan int) *Packet

MakePretendPacket generates a copy of p with the given sequence number. Each channel will repeat the first value in p. Use it for making fake data to fill in where packets were dropped.

func (*Packet) NewData

func (p *Packet) NewData(data interface{}, dims []int16) error

NewData adds data to the packet, and creates the format and shape TLV items to match.

func (*Packet) ReadValue

func (p *Packet) ReadValue(sample int) int

ReadValue returns a single sample from the packet's data payload. Not efficient for reading the whole data slice.

func (*Packet) ResetTimestamp

func (p *Packet) ResetTimestamp() error

ResetTimestamp removes any timestamp from the header.

func (*Packet) SequenceNumber

func (p *Packet) SequenceNumber() uint32

SequenceNumber returns the packet's internal sequenceNumber

func (*Packet) SetTimestamp

func (p *Packet) SetTimestamp(ts *PacketTimestamp) error

SetTimestamp puts timestamp `ts` into the header.

func (*Packet) String

func (p *Packet) String() string

String returns a string summarizing the packet's version, sequence number, and size.

func (*Packet) Timestamp

func (p *Packet) Timestamp() *PacketTimestamp

Timestamp returns a copy of the first PacketTimestamp found in the header, or nil if none.

type PacketTag

type PacketTag uint32

PacketTag represents a data type tag.

type PacketTimestamp

type PacketTimestamp struct {
	T    uint64  // Counter offset
	Rate float64 // Count rate, in counts per second
}

PacketTimestamp represents a single timestamp in the header

func MakeTimestamp

func MakeTimestamp(x uint16, y uint32, rate float64) *PacketTimestamp

MakeTimestamp creates a `PacketTimestamp` from data

type PayloadLabel added in v0.3.1

type PayloadLabel string

PayloadLabel represents the label (field names) for a payload's data section

Jump to

Keyboard shortcuts

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