Documentation
¶
Index ¶
- type Database
- type Message
- type Node
- type SendType
- type Signal
- func (s *Signal) FromPhysical(physical float64) float64
- func (s *Signal) MarshalBool(d *common.Data, value bool)
- func (s *Signal) MarshalSigned(d *common.Data, value int64)
- func (s *Signal) MarshalUnsigned(d *common.Data, value uint64)
- func (s *Signal) MaxSigned() int64
- func (s *Signal) MaxUnsigned() uint64
- func (s *Signal) MinSigned() int64
- func (s *Signal) SaturatedCastSigned(value int64) int64
- func (s *Signal) SaturatedCastUnsigned(value uint64) uint64
- func (s *Signal) ToPhysical(value float64) float64
- func (s *Signal) UnmarshalBool(d common.Data) bool
- func (s *Signal) UnmarshalPhysical(d common.Data) float64
- func (s *Signal) UnmarshalSigned(d common.Data) int64
- func (s *Signal) UnmarshalUnsigned(d common.Data) uint64
- func (s *Signal) UnmarshalValueDescription(d common.Data) (string, bool)
- func (s *Signal) ValueDescription(value int64) (string, bool)
- type ValueDescription
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct {
// SourceFile of the database.
//
// Example:
// github.com/einride/can-databases/dbc/j1939.dbc
SourceFile string
// Version of the database.
Version string
// Messages in the database.
Messages []*Message
// Nodes in the database.
Nodes []*Node
}
Database represents a CAN database.
type Message ¶
type Message struct {
// Description of the message.
Name string
// ID of the message.
ID uint32
// IsExtended is true if the message is an extended CAN message.
IsExtended bool
// Length in bytes.
Length uint8
// SendType is the message's send type.
SendType SendType
// Description of the message.
Description string
// Signals in the message payload.
Signals []*Signal
// SenderNode is the name of the node sending the message.
SenderNode string
// CycleTime is the cycle time of a cyclic message.
CycleTime time.Duration
// DelayTime is the allowed delay between cyclic message sends.
DelayTime time.Duration
}
Message describes a CAN message.
func (*Message) MultiplexerSignal ¶
MultiplexerSignal returns the message's multiplexer signal.
type Node ¶
type Node struct {
// Description of the CAN node.
Name string
// Description of the CAN node.
Description string
}
Node describes a CAN node.
type SendType ¶
type SendType uint8
SendType represents the send type of a message.
func (*SendType) UnmarshalString ¶
UnmarshalString sets the value of *s from the provided string.
type Signal ¶
type Signal struct {
// Description of the signal.
Name string
// Start bit.
Start uint8
// Length in bits.
Length uint8
// IsBigEndian is true if the signal is big-endian.
IsBigEndian bool
// IsSigned is true if the signal uses raw signed values.
IsSigned bool
// IsMultiplexer is true if the signal is the multiplexor of a multiplexed message.
IsMultiplexer bool
// IsMultiplexed is true if the signal is multiplexed.
IsMultiplexed bool
// MultiplexerValue is the value of the multiplexer when this signal is present.
MultiplexerValue uint
// Offset for real-world transform.
Offset float64
// Scale for real-world transform.
Scale float64
// Min real-world value.
Min float64
// Max real-world value.
Max float64
// Unit of the signal.
Unit string
// Description of the signal.
Description string
// ValueDescriptions of the signal.
ValueDescriptions []*ValueDescription
// ReceiverNodes is the list of names of the nodes receiving the signal.
ReceiverNodes []string
// DefaultValue of the signal.
DefaultValue int
}
Signal describes a CAN signal.
func (*Signal) FromPhysical ¶
FromPhysical converts a physical signal value to its raw value.
func (*Signal) MarshalBool ¶
MarshalBool sets the bool value of the signal in the provided CAN frame.
func (*Signal) MarshalSigned ¶
MarshalSigned sets the signed value of the signal in the provided CAN frame.
func (*Signal) MarshalUnsigned ¶
MarshalUnsigned sets the unsigned value of the signal in the provided CAN frame.
func (*Signal) MaxUnsigned ¶
MaxUnsigned returns the maximum unsigned value representable by the signal.
func (*Signal) SaturatedCastSigned ¶
SaturatedCastSigned performs a saturated cast of an int64 to the value domain of the signal.
func (*Signal) SaturatedCastUnsigned ¶
SaturatedCastUnsigned performs a saturated cast of a uint64 to the value domain of the signal.
func (*Signal) ToPhysical ¶
ToPhysical converts a raw signal value to its physical value.
func (*Signal) UnmarshalBool ¶
UnmarshalBool returns the bool value of the signal in the provided CAN frame.
func (*Signal) UnmarshalPhysical ¶
UnmarshalPhysical returns the physical value of the signal in the provided CAN frame.
func (*Signal) UnmarshalSigned ¶
UnmarshalSigned returns the signed value of the signal in the provided CAN frame.
func (*Signal) UnmarshalUnsigned ¶
UnmarshalUnsigned returns the unsigned value of the signal in the provided CAN frame.
func (*Signal) UnmarshalValueDescription ¶
UnmarshalValueDescription returns the value description of the signal in the provided CAN data.