decoder

package
v0.6.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSignalNameColision = errors.New("name of signals have to be unique")
)
View Source
var (
	ErrUnsuportedType = errors.New("given type is unsuported")
)
View Source
var SignalTypeMap = map[SignalType]struct{}{
	STInteger: {},
	STEnum:    {},
	STBitset:  {},
}

Functions

func DecodeRawValue

func DecodeRawValue(startBit, bitSize uint32, canData can.Data) (uint64, error)

func RawValueToSigned

func RawValueToSigned(bitSize uint32, rawValue uint64) int64

Types

type Bitset

type Bitset struct {
	SID       SignalId       `json:"sid"`
	Value     uint64         `json:"value"`
	BitStates map[int64]bool `json:"bit_states"`
}

func ProcessBitset

func ProcessBitset(cfg *SignalConfig, canData can.Data) (Bitset, error)

func (*Bitset) GetSignalId

func (bi *Bitset) GetSignalId() SignalId

type CanIdConfig

type CanIdConfig struct {
	Id  uint32 `json:"id" toml:"id"`
	Ide bool   `json:"ext" toml:"ide"`
	Rtr bool   `json:"rtr" toml:"rtr"`
}

type DecoderConfig

type DecoderConfig struct {
	Signals []SignalConfig `json:"signals" toml:"signals"`
}

func MergeDecoderConfig

func MergeDecoderConfig(a *DecoderConfig, b *DecoderConfig) *DecoderConfig

func (*DecoderConfig) Preprocess

func (dc *DecoderConfig) Preprocess() error

type Enum

type Enum struct {
	SID       SignalId `json:"sid"`
	Value     int64    `json:"value"`
	ValueName string   `json:"value_name"`
}

func ProcessEnum

func ProcessEnum(cfg *SignalConfig, canData can.Data) (Enum, error)

func (*Enum) GetSignalId

func (en *Enum) GetSignalId() SignalId

type Scalar

type Scalar struct {
	SID   SignalId `json:"sid"`
	Value float64  `json:"value"`
}

func ProcessIntegerScalar

func ProcessIntegerScalar(cfg *SignalConfig, canData can.Data) (Scalar, error)

func (*Scalar) GetSignalId

func (sc *Scalar) GetSignalId() SignalId

type Signal

type Signal interface {
	GetSignalId() SignalId
}

type SignalConfig

type SignalConfig struct {

	// Common
	Type     SignalType  `json:"type" toml:"type"`
	CanId    CanIdConfig `json:"canid" toml:"canid"`
	Name     string      `json:"name" toml:"name"`
	Category string      `json:"category" toml:"category"`
	StartBit uint32      `json:"startbit" toml:"startbit"`
	BitSize  uint32      `json:"bitsize" toml:"bitsize"`

	// Scalar
	Unit       string   `json:"unit" toml:"unit"`
	Multiplier *float64 `json:"multiplier" toml:"multiplier"`
	Offset     *float64 `json:"offset" toml:"offset"`
	Signed     bool     `json:"signed" toml:"signed"`

	// Enum
	Enum map[int64]string `json:"enum" toml:"enum"`

	// Bitset
	BitNames map[int64]string `json:"bitnames" toml:"bitnames"`
	// contains filtered or unexported fields
}

func (*SignalConfig) GetCanId

func (cif *SignalConfig) GetCanId() can.Id

func (*SignalConfig) GetCategory

func (cif *SignalConfig) GetCategory() string

func (*SignalConfig) GetName

func (cif *SignalConfig) GetName() string

func (*SignalConfig) GetSignalId

func (cif *SignalConfig) GetSignalId() SignalId

func (*SignalConfig) GetType

func (cif *SignalConfig) GetType() SignalType

type SignalDecoder

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

func NewSignalDecoder

func NewSignalDecoder(dcfg *DecoderConfig) (*SignalDecoder, error)

func (*SignalDecoder) DecodeCanFrame

func (sp *SignalDecoder) DecodeCanFrame(frame can.Frame) ([]Signal, error)

func (*SignalDecoder) ListOfNames

func (sp *SignalDecoder) ListOfNames() []SignalId

func (*SignalDecoder) SignalConfiguration

func (sp *SignalDecoder) SignalConfiguration() map[SignalId]SignalConfig

type SignalId

type SignalId string

type SignalList

type SignalList struct {
	NameList      []SignalId                `json:"names"`
	NameConfigMap map[SignalId]SignalConfig `json:"signals"`
}

func NewSignalList

func NewSignalList(dcfg *DecoderConfig) (*SignalList, error)

type SignalType

type SignalType string
const (
	STInteger SignalType = "integer"
	STEnum    SignalType = "enum"
	STBitset  SignalType = "bitset"
)

Jump to

Keyboard shortcuts

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