Documentation ¶
Overview ¶
Package can provides primitives for working with CAN.
Index ¶
Constants ¶
const ( MaxID = 0x7ff MaxExtendedID = 0x1fffffff )
CAN format constants.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Frame ¶
type Frame struct { // ID is the CAN ID ID uint32 // Length is the number of bytes of data in the frame. Length uint8 // Data is the frame data. Data Data // IsRemote is true for remote frames. IsRemote bool // IsExtended is true for extended frames, i.e. frames with 29-bit IDs. IsExtended bool }
Frame represents a CAN frame.
A Frame is intentionally designed to fit into 16 bytes on common architectures and is therefore amenable to pass-by-value and judicious copying.
func (Frame) JSON ¶
JSON returns the JSON-encoding of f, using hex-encoding for the data.
Examples:
{"id":32,"data":"0102030405060708"} {"id":32,"extended":true,"remote":true,"length":4}
func (Frame) MarshalJSON ¶
MarshalJSON returns the JSON-encoding of f, using hex-encoding for the data.
See JSON for an example of the JSON schema.
func (Frame) String ¶
String returns an ASCII representation the CAN frame.
Format:
([0-9A-F]{3}|[0-9A-F]{3})#(R[0-8]?|[0-9A-F]{0,16})
The format is compatible with the candump(1) log file format.
func (*Frame) UnmarshalJSON ¶
UnmarshalJSON sets *f using the provided JSON-encoded values.
See MarshalJSON for an example of the expected JSON schema.
The result should be checked with Validate to guard against invalid JSON data.
func (*Frame) UnmarshalString ¶
UnmarshalString sets *f using the provided ASCII representation of a Frame.
type FrameMarshaler ¶
FrameMarshaler can marshal itself to a CAN frame.
type FrameUnmarshaler ¶
FrameUnmarshaler can unmarshal itself from a CAN frame.
type Message ¶
type Message interface { FrameMarshaler FrameUnmarshaler }
Message is anything that can marshal and unmarshal itself to/from a CAN frame.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
pkg
|
|
clock
Package clock provides primitives for mocking time.
|
Package clock provides primitives for mocking time. |
dbc
Package dbc provides primitives for parsing, formatting and linting DBC files.
|
Package dbc provides primitives for parsing, formatting and linting DBC files. |
generated
Package generated provides primitives for working with code-generated CAN messages.
|
Package generated provides primitives for working with code-generated CAN messages. |
mocks/gen/mockcanrunner
Package mockcanrunner is a generated GoMock package.
|
Package mockcanrunner is a generated GoMock package. |
mocks/gen/mockclock
Package mockclock is a generated GoMock package.
|
Package mockclock is a generated GoMock package. |
mocks/gen/mocksocketcan
Package mocksocketcan is a generated GoMock package.
|
Package mocksocketcan is a generated GoMock package. |
reinterpret
Package reinterpret provides primitives for reinterpreting arbitrary-length values as signed or unsigned.
|
Package reinterpret provides primitives for reinterpreting arbitrary-length values as signed or unsigned. |