5.5. isotp — ISO-TP

Source code: src/inet/isotp.h, src/inet/isotp.c

Test code: tst/inet/isotp/main.c


Defines

ISOTP_FLAGS_NO_FLOW_CONTROL (1 << 0)

Functions

int isotp_init(struct isotp_t *self_p, uint8_t *message_p, size_t size, int flags)

Initialize given ISO-TP object. An object can either be used to transmit or receive an ISO-TP message. Once isotp_input() or isotp_output() returns a positive value the message transmission is completed.

An object can only be used to transmit one message. Initialize a new object to transmit another message.

Return
zero(0) or negative error code.
Parameters
  • self_p: Driver object to initialize.
  • message_p: ISO-TP message to transmit, or a reception buffer for an incoming message.
  • size: Size of the message buffer in bytes.
  • flags: Configuration flags.

ssize_t isotp_input(struct isotp_t *self_p, const uint8_t *buf_p, size_t size)

Input a CAN frame into given ISO-TP object. Always call isotp_output() after this function returns zero(0) to check if there are frames to transmit.

For an ISO-TP object that transmits a message this function always returns zero(0) or negative error code.

Return
Once a complete ISO-TP message has been received the size of the message is returned. Meanwhile, zero(0) is returned if the frame was expected. A negative error code is returned if the frame was unexpected or invalid.
Parameters
  • self_p: Initialized ISO-TP object.
  • buf_p: Input data.
  • size: Data buffer length is bytes.

ssize_t isotp_output(struct isotp_t *self_p, uint8_t *buf_p, size_t *size_p)

Check if there is data to be transmitted. The caller must transmit all frames this function creates.

For an ISO-TP object that receives a message this function always returns zero(0) or negative error code.

Return
Once a complete ISO-TP message has been transmitted the size of the message is returned. Meanwhile, zero(0) or negative error code is returned.
Parameters
  • self_p: Initialized ISO-TP object.
  • buf_p: Output data to be transmitted to the peer. The size of this buffer must be at least eight bytes.
  • size_p: Number of bytes to be transmitted.

struct isotp_t

Public Members

uint8_t *message_p
size_t size
int state
int flags
size_t offset
int next_index
struct isotp_t::@51 isotp_t::message