Interfaces
Interface
CANBus.Interfaces.Interface — Type
iface = Interface(ifacecfg::InterfaceConfig)Setup CAN Bus Interfaces.
This function throws CANBusOpenError when it failed to setup.
do statement is also supported.
Interface(ifacecfg::InterfaceConfig) do iface
# do something like:
# ret = recv(iface)
endCANBus.Interfaces.send — Function
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
FrameandFDFrame
CANBus.Interfaces.recv — Function
recv(interface::T<:Interface; timeout_s::Real=0)function for receive message.
It behaves:
- Default non-blocking.
- For blocking receivement, set kwarg
timeout_sin seconds. - Set
timeout_s< 0 for infinite bloking.
- For blocking receivement, set kwarg
- When receive successed, returns
FrameorFDFrame. - When receive queue is empty, returns
nothing. - When fails to receive in other reasons, throws error.
- Classic CAN interfaces return only
Frameobject (exceptslcan). - CAN FD compliant interfaces return either
FrameorFDFrameobject.
CANBus.Interfaces.shutdown — Function
shutdown(interface::T<:Interface)function for shutdown interface. Always returns nothing.
CANBus.Interfaces.status — Function
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.