CAN
The principal operation of SocketCAN in the User VM can be found in the system architecture section.
The code running in the User VM, referred to as the User Code interacts with the CAN subsystems in two ways, firstly by sending Messaging requests to the CAN service in the ACU6 Base System and secondly by normal SocketCAN APIs against the virtual PV-CAN interface inside of the User VM
The diagram below illustrates a typical flow where User Code initializes CAN interfaces, opens a socket and sends and receives any number of frames and then closes the CAN interface.
Configuration
The central functionality of the CAN service is configuration of the physical
CAN interface(s) of the device. The main way to configure a CAN interface is
via the can_configure_req message. For 2.0B (“Classic”)
CAN the main configurable parameter is the data-rate, for CAN FD the
configuration must include both the nominal data-rate and the increased data
data-rate.
In addition to data-rate parameters the configuration allows setting of the CAN
sample points within each bit. For most cases the default of automatic selection
should be suitable, but if needed it can be specified between 0.1% and 99.9%.
It is worth noting that the setting is a hint and the system will select the closest
point supported by the hardware. After an interface has been both requested
and configured the actual configuration can be read back from hardware using the
can_get_configuration_req message.
In addition a CAN interface can be configured as a wake-up source from
Sleep and Stand-by power states (see Power Modes and Handling) by
using the can_set_wakeup_req message.
Status and bus state handling
The bus state is available either by subscribing to can_status_publish_ind
or by polling using the can_status_req message.
If the bus enters an error state such as BUS_OFF the interface needs to be
reset to recover the bus, which can be done with the can_reset_req
message.