logformat

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 10 Imported by: 0

README

logformat

Go Reference gotest

This repository contains the log formats used in the FS World Datalogger used in Formula Student competitions.

Usage

go get github.com/fs-world/logformat

Modifying

The marshalling functions for the structs are autogenerated using msgp and easyjson.

To update the generated code follow these steps:

# Install msgp & easyjson
go install github.com/tinylib/msgp@latest
go install github.com/mailru/easyjson/...@latest
# run generators
go generate

Documentation

Index

Constants

View Source
const (
	BufferedMeasurementSize    = 50
	BufferedMeasurementSizeIvt = 8  // BufferedMeasurementSizeIvt must be at least (BufferedMeasurementSize / 8) + 1
	BufferedMeasurementSizeAux = 11 // BufferedMeasurementSizeIvt must be at least (BufferedMeasurementSize / 5) + 1
)
View Source
const (
	CANFrameLength = 16 // CANFrameLength is total length of the frame in the kernel.
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CANFrame

type CANFrame struct {
	TimestampSoftware Timespec `json:"tss" msg:"tss"` // Software (kernel) timestamp of the frame
	TimestampHardware Timespec `json:"tsh" msg:"tsh"` // Hardware timestamp of the frame
	ID                uint32   `json:"id" msg:"id"`   // CAN ID
	DLC               uint8    `json:"l" msg:"l"`     // CAN DLC (data length code)
	Data              []byte   `json:"d" msg:"d"`     // CAN Data (0-8 bytes)

} // CANFrame64 is a CAN frame wikth 64-bit timestamps

CANFrame is a CAN frame

func (*CANFrame) DecodeMsg

func (z *CANFrame) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*CANFrame) EncodeMsg

func (z *CANFrame) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (CANFrame) MarshalEasyJSON

func (v CANFrame) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (CANFrame) MarshalJSON

func (v CANFrame) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*CANFrame) MarshalMsg

func (z *CANFrame) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*CANFrame) Msgsize

func (z *CANFrame) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*CANFrame) String

func (f *CANFrame) String() string

String formats a CAN message in human-readable format

func (*CANFrame) UnmarshalEasyJSON

func (v *CANFrame) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*CANFrame) UnmarshalJSON

func (v *CANFrame) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

func (*CANFrame) UnmarshalMsg

func (z *CANFrame) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type CANFrame64 added in v0.5.0

type CANFrame64 struct {
	TimestampSoftware Timespec64 `json:"tss" msg:"tss"` // Software (kernel) timestamp of the frame
	TimestampHardware Timespec64 `json:"tsh" msg:"tsh"` // Hardware timestamp of the frame
	ID                uint32     `json:"id" msg:"id"`   // CAN ID
	DLC               uint8      `json:"l" msg:"l"`     // CAN DLC (data length code)
	Data              []byte     `json:"d" msg:"d"`     // CAN Data (0-8 bytes)
}

func (*CANFrame64) DecodeMsg added in v0.5.0

func (z *CANFrame64) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*CANFrame64) EncodeMsg added in v0.5.0

func (z *CANFrame64) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (CANFrame64) MarshalEasyJSON added in v0.5.0

func (v CANFrame64) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (CANFrame64) MarshalJSON added in v0.5.0

func (v CANFrame64) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*CANFrame64) MarshalMsg added in v0.5.0

func (z *CANFrame64) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*CANFrame64) Msgsize added in v0.5.0

func (z *CANFrame64) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*CANFrame64) String added in v0.5.0

func (f *CANFrame64) String() string

String formats a CAN message in human-readable format

func (*CANFrame64) ToOld added in v0.5.0

func (f *CANFrame64) ToOld() *CANFrame

func (*CANFrame64) UnmarshalEasyJSON added in v0.5.0

func (v *CANFrame64) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*CANFrame64) UnmarshalJSON added in v0.5.0

func (v *CANFrame64) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

func (*CANFrame64) UnmarshalMsg added in v0.5.0

func (z *CANFrame64) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type IvtBufferedMeasurement added in v0.3.0

type IvtBufferedMeasurement struct {
	Voltages         [BufferedMeasurementSize]int32      `json:"u" msg:"u"`         // Voltage in mV
	Currents         [BufferedMeasurementSize]int32      `json:"i" msg:"i"`         // Current in mA
	Temperatures     [BufferedMeasurementSizeIvt]int32   `json:"t" msg:"t"`         // Temperature of the shunt in 1/10 °C
	LVSupplyVoltage  [BufferedMeasurementSizeAux]float32 `json:"us" msg:"us"`       // LV Supply voltage in V
	IVTSupplyVoltage [BufferedMeasurementSizeAux]float32 `json:"ui" msg:"ui"`       // IVT Supply voltage in V
	PGood5V          [BufferedMeasurementSizeAux]bool    `json:"pg5" msg:"pg5"`     // Power Good 5V
	PGood3V3         [BufferedMeasurementSizeAux]bool    `json:"pg3v3" msg:"pg3v3"` // Power Good 3v3
	SegmentStart     Timespec                            `json:"s" msg:"s"`         // SegmentStart is the time the first message of this segment was recorded
	SegmentEnd       Timespec                            `json:"e" msg:"e"`         // SegmentEnd is the timestamp the last message of this sement was recorded
}

IvtBufferedMeasurement is collection of multiple measurements from the IVT sensor

func (*IvtBufferedMeasurement) DecodeMsg added in v0.3.0

func (z *IvtBufferedMeasurement) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*IvtBufferedMeasurement) EncodeMsg added in v0.3.0

func (z *IvtBufferedMeasurement) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (IvtBufferedMeasurement) MarshalEasyJSON added in v0.3.0

func (v IvtBufferedMeasurement) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (IvtBufferedMeasurement) MarshalJSON added in v0.3.0

func (v IvtBufferedMeasurement) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*IvtBufferedMeasurement) MarshalMsg added in v0.3.0

func (z *IvtBufferedMeasurement) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*IvtBufferedMeasurement) Msgsize added in v0.3.0

func (z *IvtBufferedMeasurement) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*IvtBufferedMeasurement) UnmarshalEasyJSON added in v0.3.0

func (v *IvtBufferedMeasurement) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*IvtBufferedMeasurement) UnmarshalJSON added in v0.3.0

func (v *IvtBufferedMeasurement) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

func (*IvtBufferedMeasurement) UnmarshalMsg added in v0.3.0

func (z *IvtBufferedMeasurement) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type LogReader added in v0.1.0

type LogReader interface {
	// ReadAll reads all log data from the file
	ReadAll() ([]Serializable, error)

	// Close closes the logfile
	Close() error
}

LogReader is an interface for log readers

type LogWriter added in v0.1.0

type LogWriter interface {
	// Write writes a Serializable msg to the logfile
	Write(msg Serializable) error

	// Sync flushes the buffers and syncs the file to disk
	Sync() error

	// Close closes the logfile
	Close() error
}

LogWriter is an interface for log writers

type Serializable

Serializable is an interface that all data to be persisted as log data must satisfy

type SerializedLogReader added in v0.1.0

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

SerializedLogReader is a reader for log files with Serializable messages. It hashes the input file in the background.

func NewSerializedLogReader added in v0.1.0

func NewSerializedLogReader(filename string) (*SerializedLogReader, error)

NewSerializedLogReader creates a new SerializedLogReader from the provided file for the provided dataType

func (*SerializedLogReader) Close added in v0.1.0

func (r *SerializedLogReader) Close() error

Close closes the underlying file handle

func (*SerializedLogReader) ReadAllCanFrames added in v0.3.0

func (r *SerializedLogReader) ReadAllCanFrames() ([]CANFrame, []byte, error)

ReadAllCanFrames reads messages of type CANFrame from logfile. return slice of all messages, b3 hash of logfile and error

func (*SerializedLogReader) ReadAllIvtBufferedMessages added in v0.3.0

func (r *SerializedLogReader) ReadAllIvtBufferedMessages() ([]IvtBufferedMeasurement, []byte, error)

ReadAllIvtBufferedMessages reads messages of type IvtBufferedMeasurement from logfile. return slice of all messages, b3 hash of logfile and error

type SerializedLogWriter added in v0.1.0

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

SerializedLogWriter writes Serializable messages to a logfile and hashes the logfile in the background.

func NewSerializedLogWriter added in v0.1.0

func NewSerializedLogWriter(filename string) (*SerializedLogWriter, error)

NewSerializedLogWriter creates a new LogWriter

func (*SerializedLogWriter) Close added in v0.1.0

func (w *SerializedLogWriter) Close() ([]byte, error)

Close syncs and closes the logfile; returns the hash of the file

func (*SerializedLogWriter) Sync added in v0.1.0

func (w *SerializedLogWriter) Sync() error

Sync flushes the internal buffers and syncs the logfile to disk

func (*SerializedLogWriter) Write added in v0.1.0

func (w *SerializedLogWriter) Write(msg msgp.Encodable) error

Write writes a message to the logfile

type Timespec

type Timespec struct {
	Sec  int32 `json:"s" msg:"s"`   // Seconds
	Nsec int32 `json:"ns" msg:"ns"` // Nanoseconds
}

Timespec is the unix.Timespec struct with msgp tags

func (*Timespec) DecodeMsg

func (z *Timespec) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (Timespec) EncodeMsg

func (z Timespec) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (Timespec) MarshalEasyJSON

func (v Timespec) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Timespec) MarshalJSON

func (v Timespec) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (Timespec) MarshalMsg

func (z Timespec) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (Timespec) Msgsize

func (z Timespec) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Timespec) UnmarshalEasyJSON

func (v *Timespec) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Timespec) UnmarshalJSON

func (v *Timespec) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

func (*Timespec) UnmarshalMsg

func (z *Timespec) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Timespec64 added in v0.4.0

type Timespec64 struct {
	Sec  uint64 `json:"s" msg:"s"`   // Seconds
	Nsec uint64 `json:"ns" msg:"ns"` // Nanoseconds

}

Timespec64 is the unix.Timespec struct for newer 64-bit platforms with msgp tags

func (*Timespec64) DecodeMsg added in v0.4.0

func (z *Timespec64) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (Timespec64) EncodeMsg added in v0.4.0

func (z Timespec64) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (Timespec64) MarshalEasyJSON added in v0.4.0

func (v Timespec64) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Timespec64) MarshalJSON added in v0.4.0

func (v Timespec64) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (Timespec64) MarshalMsg added in v0.4.0

func (z Timespec64) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (Timespec64) Msgsize added in v0.4.0

func (z Timespec64) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Timespec64) UnmarshalEasyJSON added in v0.4.0

func (v *Timespec64) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Timespec64) UnmarshalJSON added in v0.4.0

func (v *Timespec64) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

func (*Timespec64) UnmarshalMsg added in v0.4.0

func (z *Timespec64) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

Jump to

Keyboard shortcuts

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