CAN bus

Configuration Options

API Reference

Defines

THINGSET_CAN_SOURCE_POS
THINGSET_CAN_SOURCE_MASK
THINGSET_CAN_SOURCE_SET(addr)
THINGSET_CAN_SOURCE_GET(id)
THINGSET_CAN_TARGET_POS
THINGSET_CAN_TARGET_MASK
THINGSET_CAN_TARGET_SET(addr)
THINGSET_CAN_TARGET_GET(id)
THINGSET_CAN_ADDR_MIN
THINGSET_CAN_ADDR_MAX
THINGSET_CAN_ADDR_ANONYMOUS
THINGSET_CAN_ADDR_BROADCAST
THINGSET_CAN_DATA_ID_POS
THINGSET_CAN_DATA_ID_MASK
THINGSET_CAN_DATA_ID_SET(id)
THINGSET_CAN_DATA_ID_GET(id)
THINGSET_CAN_SEQ_NO_POS
THINGSET_CAN_SEQ_NO_MASK
THINGSET_CAN_SEQ_NO_SET(no)
THINGSET_CAN_SEQ_NO_GET(id)
THINGSET_CAN_MF_TYPE_POS
THINGSET_CAN_MF_TYPE_MASK
THINGSET_CAN_MF_TYPE_FIRST
THINGSET_CAN_MF_TYPE_CONSEC
THINGSET_CAN_MF_TYPE_LAST
THINGSET_CAN_MF_TYPE_SINGLE
THINGSET_CAN_MSG_NO_POS
THINGSET_CAN_MSG_NO_MASK
THINGSET_CAN_MSG_NO_SET(no)
THINGSET_CAN_MSG_NO_GET(id)
THINGSET_CAN_SOURCE_BUS_POS
THINGSET_CAN_SOURCE_BUS_MASK
THINGSET_CAN_SOURCE_BUS_SET(id)
THINGSET_CAN_SOURCE_BUS_GET(id)
THINGSET_CAN_SOURCE_BUS_DEFAULT
THINGSET_CAN_TARGET_BUS_POS
THINGSET_CAN_TARGET_BUS_MASK
THINGSET_CAN_TARGET_BUS_SET(id)
THINGSET_CAN_TARGET_BUS_GET(id)
THINGSET_CAN_TARGET_BUS_DEFAULT
THINGSET_CAN_BRIDGE_POS
THINGSET_CAN_BRIDGE_MASK
THINGSET_CAN_BRIDGE_SET(id)
THINGSET_CAN_BRIDGE_GET(id)
THINGSET_CAN_BRIDGE_LOCAL
THINGSET_CAN_RAND_POS
THINGSET_CAN_RAND_MASK
THINGSET_CAN_RAND_SET(id)
THINGSET_CAN_RAND_GET(id)
THINGSET_CAN_TYPE_POS
THINGSET_CAN_TYPE_MASK
THINGSET_CAN_TYPE_REQRESP
THINGSET_CAN_TYPE_MF_REPORT
THINGSET_CAN_TYPE_SF_REPORT
THINGSET_CAN_TYPE_NETWORK
THINGSET_CAN_PRIO_POS
THINGSET_CAN_PRIO_MASK
THINGSET_CAN_PRIO_SET(prio)
THINGSET_CAN_PRIO_GET(id)
THINGSET_CAN_PRIO_CONTROL_EMERGENCY
THINGSET_CAN_PRIO_CONTROL_HIGH
THINGSET_CAN_PRIO_CONTROL_LOW
THINGSET_CAN_PRIO_NETWORK_MGMT
THINGSET_CAN_PRIO_REPORT_HIGH
THINGSET_CAN_PRIO_REQRESP
THINGSET_CAN_PRIO_REPORT_LOW
THINGSET_CAN_CONTROL(id)
THINGSET_CAN_SF_REPORT(id)
THINGSET_CAN_MF_REPORT(id)
THINGSET_CAN_REQRESP(id)

Typedefs

typedef void (*thingset_can_addr_claim_rx_callback_t)(const uint8_t eui64[8], uint8_t source_addr)

Callback typedef for received address claim frames from other nodes

Param eui64:

The EUI-64 of the node used for the address claim message.

Param source_addr:

Node address the address claim was received from

typedef void (*thingset_can_report_rx_callback_t)(const uint8_t *report_buf, size_t report_len, uint8_t source_addr)

Callback typedef for received multi-frame reports (type 0x1) via CAN

Param report_buf:

Pointer to the buffer containing the received report (text or binary format)

Param report_len:

Length of the report in the buffer

Param source_addr:

Node address the report was received from

typedef void (*thingset_can_item_rx_callback_t)(uint16_t data_id, const uint8_t *value, size_t value_len, uint8_t source_addr)

Callback typedef for received single-frame reports (type 0x2) via CAN

Param data_id:

ThingSet data object ID

Param value:

Buffer containing the CBOR raw data of the value

Param value_len:

Length of the value in the buffer

Param source_addr:

Node address the item was received from

typedef void (*thingset_can_reqresp_callback_t)(uint8_t *data, size_t len, int send_err, int recv_err, uint8_t source_addr, void *arg)

Callback typedef for received responses via CAN ISO-TP

Param data:

Buffer containing the ThingSet response or NULL in case of error.

Param length:

Length of the data in the buffer

Param send_err:

0 for success or negative errno indicating a send error.

Param recv_err:

0 for success or negative errno indicating a receive error.

Param source_addr:

Node address the response was received from

Param arg:

User-data passed to the callback

Functions

int thingset_can_send_report(const char *path, enum thingset_data_format format)

Send ThingSet report to the CAN bus.

Parameters:
  • path – Path of subset/group/record to be published

  • format – Protocol data format to be used (text, binary with IDs or binary with names)

Returns:

0 for success or negative errno in case of error

int thingset_can_send(uint8_t *tx_buf, size_t tx_len, uint8_t target_addr, uint8_t route, thingset_can_reqresp_callback_t callback, void *callback_arg, k_timeout_t timeout)

Send ThingSet message to other node

See thingset_can_send_inst() for function parameters.

Returns:

0 for success or negative errno in case of error

struct thingset_can *thingset_can_get_inst()

Get ThingSet CAN instance

Returns:

Pointer to internal ThingSet CAN instance

struct thingset_can_request_response

Public Members

struct k_sem sem
struct k_timer timer
uint32_t can_id
thingset_can_reqresp_callback_t callback
void *cb_arg
struct thingset_can
#include <can.h>

ThingSet CAN context storing all information required for one instance.

Public Members

const struct device *dev
struct k_work_delayable live_reporting_work
struct k_work_delayable addr_claim_work
thingset_can_addr_claim_rx_callback_t addr_claim_callback
struct isotp_fast_ctx ctx
struct k_sem report_tx_sem
struct k_event events
struct thingset_can_request_response request_response
uint8_t rx_buffer[CONFIG_THINGSET_CAN_RX_BUF_SIZE]
int64_t next_live_report_time
struct k_timer timeout_timer
uint8_t node_addr
uint8_t route

bus or bridge number

uint8_t msg_no