Interfaces

Interface

CANBus.Interfaces.InterfaceType
iface = Interface(ifacecfg::InterfaceConfig)

Setup CAN Bus Interfaces.

This function throws CANBusOpenError when it failed to setup.

source

do statement is also supported.

Interface(ifacecfg::InterfaceConfig) do iface
    # do something like:
    # ret = recv(iface)
end
source
CANBus.Interfaces.sendFunction
send(interface::T<:Interface, frame::AbstractFrame)

function for send message.

It behaves:

  • When send successed, returns nothing.
  • When send failed, throws error.
  • Classic CAN interfaces can send ONLY Frame
  • CAN FD interfaces can send both Frame and FDFrame
source
CANBus.Interfaces.recvFunction
recv(interface::T<:Interface; timeout_s::Real=0)

function for receive message.

It behaves:

  • Default non-blocking.
    • For blocking receivement, set kwarg timeout_s in seconds.
    • Set timeout_s < 0 for infinite bloking.
  • When receive successed, returns Frame or FDFrame.
  • When receive queue is empty, returns nothing.
  • When fails to receive in other reasons, throws error.
  • Classic CAN interfaces return only Frame object (except slcan).
  • CAN FD compliant interfaces return either Frame or FDFrame object.
source
CANBus.Interfaces.statusFunction
status(interface::T<:Interface)

This functions checks and returns bus status.

The bus status is any of the following:

  • NO_STATUS: No status information.
  • BUSOFF: Bus is offline.
  • ERROR_ACTIVE: Bus is fine.
  • ERROR_WARNING: The error counter has reached the warning level.
  • ERROR_PASSIVE: The error counter has reached the error level.

More details is described in many websites, such as here.

ERROR_WARNING level is vendor-specific status. See official documents of their APIs for details.

source