Zephyr API Documentation 4.0.0-rc3
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
isotp.h File Reference

Public API for ISO-TP (ISO 15765-2:2016) More...

#include <zephyr/drivers/can.h>
#include <zephyr/types.h>
#include <zephyr/net_buf.h>

Go to the source code of this file.

Data Structures

struct  isotp_msg_id
 ISO-TP message id struct. More...
 
struct  isotp_fc_opts
 ISO-TP frame control options struct. More...
 

Macros

#define ISOTP_N_OK   0
 Completed successfully.
 
#define ISOTP_N_TIMEOUT_A   -1
 Ar/As has timed out.
 
#define ISOTP_N_TIMEOUT_BS   -2
 Reception of next FC has timed out.
 
#define ISOTP_N_TIMEOUT_CR   -3
 Cr has timed out.
 
#define ISOTP_N_WRONG_SN   -4
 Unexpected sequence number.
 
#define ISOTP_N_INVALID_FS   -5
 Invalid flow status received.
 
#define ISOTP_N_UNEXP_PDU   -6
 Unexpected PDU received.
 
#define ISOTP_N_WFT_OVRN   -7
 Maximum number of WAIT flowStatus PDUs exceeded.
 
#define ISOTP_N_BUFFER_OVERFLW   -8
 FlowStatus OVFLW PDU was received.
 
#define ISOTP_N_ERROR   -9
 General error.
 
#define ISOTP_NO_FREE_FILTER   -10
 Implementation specific errors.
 
#define ISOTP_NO_NET_BUF_LEFT   -11
 No net buffer left to allocate.
 
#define ISOTP_NO_BUF_DATA_LEFT   -12
 Not sufficient space in the buffer left for the data.
 
#define ISOTP_NO_CTX_LEFT   -13
 No context buffer left to allocate.
 
#define ISOTP_RECV_TIMEOUT   -14
 Timeout for recv.
 
#define ISOTP_FIXED_ADDR_SA_POS   (CONFIG_ISOTP_FIXED_ADDR_SA_POS)
 Position of fixed source address (SA)
 
#define ISOTP_FIXED_ADDR_SA_MASK   (CONFIG_ISOTP_FIXED_ADDR_SA_MASK)
 Mask to obtain fixed source address (SA)
 
#define ISOTP_FIXED_ADDR_TA_POS   (CONFIG_ISOTP_FIXED_ADDR_TA_POS)
 Position of fixed target address (TA)
 
#define ISOTP_FIXED_ADDR_TA_MASK   (CONFIG_ISOTP_FIXED_ADDR_TA_MASK)
 Mask to obtain fixed target address (TA)
 
#define ISOTP_FIXED_ADDR_PRIO_POS   (CONFIG_ISOTP_FIXED_ADDR_PRIO_POS)
 Position of priority in fixed addressing mode.
 
#define ISOTP_FIXED_ADDR_PRIO_MASK   (CONFIG_ISOTP_FIXED_ADDR_PRIO_MASK)
 Mask for priority in fixed addressing mode.
 
#define ISOTP_FIXED_ADDR_RX_MASK   (CONFIG_ISOTP_FIXED_ADDR_RX_MASK)
 CAN filter RX mask to match any priority and source address (SA)
 
ISO-TP message ID flags

#define ISOTP_MSG_EXT_ADDR   BIT(0)
 Message uses ISO-TP extended addressing (first payload byte of CAN frame)
 
#define ISOTP_MSG_FIXED_ADDR   BIT(1)
 Message uses ISO-TP fixed addressing (according to SAE J1939).
 
#define ISOTP_MSG_IDE   BIT(2)
 Message uses extended (29-bit) CAN ID.
 
#define ISOTP_MSG_FDF   BIT(3)
 Message uses CAN FD format (FDF)
 
#define ISOTP_MSG_BRS   BIT(4)
 Message uses CAN FD Baud Rate Switch (BRS).
 

Typedefs

typedef void(* isotp_tx_callback_t) (int error_nr, void *arg)
 Transmission callback.
 

Functions

int isotp_bind (struct isotp_recv_ctx *rctx, const struct device *can_dev, const struct isotp_msg_id *rx_addr, const struct isotp_msg_id *tx_addr, const struct isotp_fc_opts *opts, k_timeout_t timeout)
 Bind an address to a receiving context.
 
void isotp_unbind (struct isotp_recv_ctx *rctx)
 Unbind a context from the interface.
 
int isotp_recv (struct isotp_recv_ctx *rctx, uint8_t *data, size_t len, k_timeout_t timeout)
 Read out received data from fifo.
 
int isotp_recv_net (struct isotp_recv_ctx *rctx, struct net_buf **buffer, k_timeout_t timeout)
 Get the net buffer on data reception.
 
int isotp_send (struct isotp_send_ctx *sctx, const struct device *can_dev, const uint8_t *data, size_t len, const struct isotp_msg_id *tx_addr, const struct isotp_msg_id *rx_addr, isotp_tx_callback_t complete_cb, void *cb_arg)
 Send data.
 

Detailed Description

Public API for ISO-TP (ISO 15765-2:2016)

ISO-TP is a transport protocol for CAN (Controller Area Network)