IPC Module - CAN Service

This page contains documentation of the CAN API.

The IPC API controls the physical interfaces. Data is sent using [SocketCAN](https://www.kernel.org/doc/Documentation/networking/can.txt) interfaces (canX).

Messages

message can_request_req
Parameters:
  • user (string) – User identifier, max 15 characters long.

  • index (uint8) – Index of the requested interface

Return message:

can_request_rsp

Request a CAN interface.

The interface will not be turned on if it’s not configured.

message can_request_rsp
Parameters:
  • result (enum can_result) – Result of the operation

  • index (uint8) – Index of the requested interface

CAN interface request result.

message can_release_req
Parameters:
  • user (string) – User identifier, max 15 characters long.

  • index (uint8) – Index of the requested interface

Return message:

can_release_rsp

Release a CAN interface.

message can_release_rsp
Parameters:
  • result (enum can_result) – Result of the operation

  • index (uint8) – Index of the requested interface

CAN interface release result.

message can_configure_req
Parameters:
  • index (uint8) – Index of the requested interface

  • nominal_bitrate (enum can_nominal_bitrate) – Nominal bitrate

  • data_bitrate (enum can_data_bitrate) – Data bitrate The data bitrate is only used when the CAN type is CAN_FD

  • type (enum can_type) – Interface type

  • nominal_sample_point (uint16) – Nominal sample point. Valid range is 0..999, where 0 means the system will choose itself, and 1-999 corresponds to a sample point of 0.1-99.9% Note, not all hardware supports all sample points. Best effort will be used in selection, if critical check the returned value after configuration.

  • data_sample_point (uint16) – Data sample point. Only used when CAN type is CAN_FD. Valid range is 0..999, where 0 means the system will choose itself, and 1-999 corresponds to a sample point of 0.1-99.9% Note, not all hardware supports all sample points. Best effort will be used in selection, if critical check the returned value after configuration.

Return message:

can_configure_rsp

Request to configure a CAN interface.

If any user has requested the interface prior to configuration, this call will also turn it on. The result is received in a can_configure_rsp message.

message can_configure_rsp
Parameters:
  • result (enum can_result) – Result of the operation

  • index (uint8) – Index of the requested interface

Sent in response to can_configure_req message.

message can_get_configuration_req
Parameters:

index (uint8) – Index of the requested interface

Return message:

can_get_configuration_rsp

Get the current configuration of a CAN interface.

message can_get_configuration_rsp
Parameters:
  • result (enum can_result) – Result of the operation

  • index (uint8) – Index of the requested interface

  • type (enum can_type) – Interface type

  • nominal_bitrate (enum can_nominal_bitrate) – Nominal bitrate

  • data_bitrate (enum can_data_bitrate) – Data bitrate The data bitrate is only used when the CAN type is CAN_FD

  • nominal_sample_point (uint16) – Nominal sample point. Valid range is 0..999, where 0 means the system will choose itself, and 1-999 corresponds to a sample point of 0.1-99.9% Note, not all hardware supports all sample points. Best effort will be used in selection, if critical check the returned value after configuration.

  • data_sample_point (uint16) – Data sample point. Only used when CAN type is CAN_FD. Valid range is 0..999, where 0 means the system will choose itself, and 1-999 corresponds to a sample point of 0.1-99.9% Note, not all hardware supports all sample points. Best effort will be used in selection, if critical check the returned value after configuration.

Response with current configuration of a CAN interface.

message can_status_req
Parameters:

index (uint8) – Index of the requested interface

Return message:

can_status_rsp

Check the state of the CAN interface.

message can_status_rsp
Parameters:
  • result (enum can_result) – Result of the operation

  • state (enum can_state) – Current state of the interface

  • index (uint8) – Index of the requested interface

  • rx_packets (uint64) – RX packets

  • rx_bytes (uint64) – RX bytes

  • rx_dropped (uint64) – RX dropped

  • rx_errors (uint64) – RX errors

  • tx_packets (uint64) – TX packets

  • tx_bytes (uint64) – TX bytes

  • tx_dropped (uint64) – TX dropped

  • tx_errors (uint64) – TX errors

  • bus_errors (uint32) – Bus errors

  • error_warning (uint32) – Changes to error warning state

  • bus_off (uint32) – Changes to bus off state

CAN interface state.

message can_status_publish_ind
Parameters:

states (enum can_state[]) – Current state for each CAN interface. The length is equal to the number of interfaces on the device. State values are indexed according to the order of interfaces. For example, the state of interface 0 is at index 0.

CAN interface state message. Sent once per second to all subscribers.

message can_status_subscribe_req

Subscribe to can_status_publish_ind messages

message can_status_subscribe_rsp
Parameters:

result (enum ipc_subscribe_result)

Result from can_status_subscribe_req

message can_status_unsubscribe_req_norsp

Unsubscribe from can_status_publish_ind messages

message can_set_wakeup_req
Parameters:
  • index (uint8) – Index of the requested interface

  • state (uint8) – 0: Disable, 1: Enable

Return message:

can_set_wakeup_rsp

CAN wakeup configuration.

message can_set_wakeup_rsp
Parameters:
  • index (uint8) – Index of the requested interface

  • result (enum can_result) – Result of the operation

Sent in response to can_set_wakeup_req message.

message can_reset_req
Parameters:

index (uint8) – Index of the requested interface

Return message:

can_reset_rsp

CAN reset request.

Resets the CAN interface from e.g. BUS OFF.

message can_reset_rsp
Parameters:

result (enum can_result) – Result of the operation

Sent in response to can_reset_req message.

message can_set_listen_only_req
Parameters:
  • index (uint8) – Index of the requested interface

  • mode (uint8) – listen mode on or off

Return message:

can_set_listen_only_rsp

CAN listen only request.

Sets the CAN interface to listen only mode e.g for autobaud implementation.

message can_set_listen_only_rsp
Parameters:

result (enum can_result) – Result of the operation

Sent in response to can_set_listen_only_req message.

Enums

enum can_result

Result codes.

Constant

Value

Description

OK

0

No error

INVALID_INTERFACE

1

The specified interface does not exist

UNSUPPORTED_NOMINAL_BITRATE

2

The specified nominal bitrate is not supported

UNSUPPORTED_DATA_BITRATE

3

The specified data bitrate is not supported

UNSUPPORTED_TYPE

4

The specified type is not supported

INTERFACE_NOT_PROCURED

5

The interface was not connected with the supplied user

UNSUPPORTED_WAKEUP_SOURCE

6

The specified interface does not support wakeup

UNKNOWN_ERROR

7

Unknown error

INVALID_SAMPLEPOINT

8

The specified sample point is invalid

INVALID_DATA_SAMPLEPOINT

9

The specified data sample point is invalid

enum can_type

CAN types.

Constant

Value

Description

CAN_2_0_B

0

CAN 2.0B

CAN_FD

1

CAN FD

enum can_nominal_bitrate

CAN nominal bitrates.

Constant

Value

Description

RATE_125000

0

125000

RATE_250000

1

250000

RATE_500000

2

500000

RATE_1000000

3

1000000

enum can_data_bitrate

CAN data bitrates.

Constant

Value

Description

RATE_1000000

0

1000000

RATE_2000000

1

2000000

RATE_3000000

2

3000000

RATE_4000000

3

4000000

RATE_5000000

4

5000000

enum can_state

CAN interface states.

Constant

Value

Description

ERROR_ACTIVE

0

ERROR_WARNING

1

ERROR_PASSIVE

2

BUS_OFF

3

STOPPED

4

SLEEPING

5