Frames
In CANBus.jl, send/receive messages are represented in CANBus.Frames module. For CAN frame, Frame is used, or for CAN FD frame, FDFrame is used.
Base type
CANBus.Frames.AbstractFrame — TypeAbstract type for Frames.
Frame
CANBus.Frames.Frame — TypeCANBus.Frame(id::Integer, data::AbstractVector, is_extended:Bool)Frame struct represents classic (8bytes) CAN frame.
id: arbitration iddata: Vector of Integer with length <= 8. If input has element > 255, throws error.is_extended: Flag which arbitration id is extended.
frame = CANBus.Frame(0x5, [1, 2, 3, 4, 5, 6, 7, 8], true)FDFrame
CANBus.Frames.FDFrame — TypeCANBus.FDFrame(id::Integer, data::AbstractVector, is_extended::Bool,
bitrate_switch::Bool, error_state::Bool)FDFrame struct represents CAN FD (64bytes) frame.
id: arbitration iddata: Vector of Integer. Length must be in CAN FD DLC standard. Elements must not be > 255.is_extended: Flag which arbitration id is extended.bitrate_switch: Flag to usebitrate_switch.error_state: Flag corresponds toerror_state_indicator. This is used in receiving, so that it is ignore in transmitting (always treat as =false).
Compatibility with CANalyze package
Frame and FDFrame has intercompatibility with CANalyze.CANFrame and CANAlyze.CANFdFrame respectively.
For instance, Frame constructor has a converter from CANalyze.CANFrame struct, you can use it like below:
using CANBus
using CANalyze
vector1 = VectorInterface(0, 500000, "NewApp")
frm = CANalyze.CANFrame(1, [1, 2, 3, 4, 5, 6, 7, 8])
msg = Frame(frm)
send(vector1, msg)In the opposite direction, CANalyze.CANFrame and CANalyze.CANFdFrame constructors are overridden, so that you can feed Frame and FDFrame structs to CANalyze.Decode.decode function with conversion.
frm = CANBus.Frame(0x0e, [1, 2, 3, 4], false)
signal = CANalyze.Signals.NamedSignal("myfloat", nothing, nothing,
CANalyze.Signals.Float32Signal(start=0; byte_order=:little_endian))
msg = CANalyze.Messages.Message(0x0e, 4, "msg1", signal)
d = CANalyze.Decode.decode(msg, CANalyze.Frames.CANFrame(frm))