Socket CAN driver (Linux)

File: csp/drivers/csp_socketcan.h

Description: Socket CAN driver (Linux).

Note

This driver requires the libsocketcan library.

Interface Functions

int csp_can_socketcan_open_and_add_interface(const char *device, const char *ifname, unsigned int node_id, int bitrate, _Bool promisc, csp_iface_t **return_iface)
[source]

Open CAN socket and add CSP interface.

Parameters:

Parameters:
  • device – CAN device name (Linux device).

  • ifname – CSP interface name, use #CSP_IF_CAN_DEFAULT_NAME for default name.

  • node_id – CSP address of the interface.

  • bitrate – if different from 0, it will be attempted to change the bitrate on the CAN device - this may require increased OS privileges.

  • promisc – if true, receive all CAN frames. If false a filter is set on the CAN device, using device->addr

  • return_iface – the added interface.

Returns:

The added interface, or NULL in case of failure.

csp_iface_t *csp_can_socketcan_init(const char *device, unsigned int node_id, int bitrate, _Bool promisc)
[source]

Initialize socketcan and add CSP interface.

deprecated version 1.6, use csp_can_socketcan_open_and_add_interface()

Parameters:

Parameters:
  • device – CAN device name (Linux device).

  • node_id – CSP address of the interface.

  • bitrate – if different from 0, it will be attempted to change the bitrate on the CAN device - this may require increased OS privileges.

  • promisc – if true, receive all CAN frames. If false a filter is set on the CAN device, using device->addr

Returns:

The added interface, or NULL in case of failure.

int csp_can_socketcan_stop(csp_iface_t *iface)
[source]

Stop the Rx thread and free resources (testing).

Note

This will invalidate CSP, because an interface can’t be removed. This is primarily for testing.

Parameters:

Parameters:
  • iface – interface to stop.

Returns:

#CSP_ERR_NONE on success, otherwise an error code.