reader

package
v0.0.0-...-2bca03d Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFileAlreadyOpened = errors.New("file already opened")

ErrFileAlreadyOpened occurs when trying to open a file that is currently open

View Source
var ErrReaderClosed = errors.New("reader closed")

ErrReaderClosed occurs when trying to read data using a bufio reader that has already been closed

View Source
var ErrUnsupportedMessageType = errors.New("unsupported message type")

ErrUnsupportedMessageType indicates the given MessageType isn't supported. This shouldn't happen.

Functions

func ReadOSIFile

func ReadOSIFile(filename string, msgType MessageType) ([]proto.Message, error)

ReadOSIFile reads an OSI trace file and returns all messages matching the msgType. It assumes messages are length-prefixed with uint32 (little endian).

Types

type MessageType

type MessageType string

MessageType represents the type of OSI message.

const (
	GroundTruth             MessageType = "GroundTruth"
	SensorData              MessageType = "SensorData"
	SensorView              MessageType = "SensorView"
	SensorViewConfiguration MessageType = "SensorViewConfiguration"
	HostVehicleData         MessageType = "HostVehicleData"
	TrafficCommand          MessageType = "TrafficCommand"
	TrafficCommandUpdate    MessageType = "TrafficCommandUpdate"
	TrafficUpdate           MessageType = "TrafficUpdate"
	MotionRequest           MessageType = "MotionRequest"
)

type OSIFileReader

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

OSIFileReader provides a struct-like interface to read OSI messages from a file.

func NewOSIFileReader

func NewOSIFileReader(filename string, msgType MessageType) (*OSIFileReader, error)

NewOSIFileReader opens the file and prepares the reader for the given message type.

func (*OSIFileReader) Close

func (r *OSIFileReader) Close() error

Close closes the underlying file.

func (*OSIFileReader) GetMessageIndex

func (r *OSIFileReader) GetMessageIndex() int

GetMessageIndex returns the current index

func (*OSIFileReader) JumpTo

func (r *OSIFileReader) JumpTo(messageIndex int) error

JumpTo seeks to the beginning of the specified message (0-indexed). After calling JumpTo(n), ReadNext() will return the (n+1)th message.

func (*OSIFileReader) Open

func (r *OSIFileReader) Open() error

Open reopens the file if it was previously closed.

func (*OSIFileReader) ReadAll

func (r *OSIFileReader) ReadAll() ([]proto.Message, error)

ReadAll resets the reader and reads all messages of the specified type from the start.

func (*OSIFileReader) ReadNext

func (r *OSIFileReader) ReadNext() (proto.Message, error)

ReadNext reads the next message of the specified type from the file. Returns io.EOF if no more messages are available.

func (*OSIFileReader) ReadRest

func (r *OSIFileReader) ReadRest() ([]proto.Message, error)

ReadRest reads all remaining messages of the specified type from the current position.

func (*OSIFileReader) Reset

func (r *OSIFileReader) Reset() error

Reset seeks back to the beginning of the file and resets the buffered reader.

func (*OSIFileReader) Size

func (r *OSIFileReader) Size() (int64, error)

Size returns the current file size in bytes.

Jump to

Keyboard shortcuts

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