Skip to content

File syn_lintp.c

FileList > proto > syn_lintp.c

Go to the source code of this file

ISO 17987-2 (LIN Transport Layer & Network Layer Services / UDSonLIN). More...

  • #include "syn_lintp.h"
  • #include <string.h>

Public Functions

Type Name
bool syn_lintp_get_tx_frame (SYN_LINTP_Link * link, uint8_t out_frame)
Retrieve next queued 8-byte LIN diagnostic payload to transmit on bus (0x3C / 0x3D).
void syn_lintp_init (SYN_LINTP_Link * link, uint8_t nad, uint8_t * rx_buf, size_t rx_size, uint8_t * tx_buf, size_t tx_size)
Initialize LIN TP Link context.
bool syn_lintp_is_tx_idle (const SYN_LINTP_Link * link)
Check if LIN TP TX engine is idle and ready for new message.
void syn_lintp_process_rx_frame (SYN_LINTP_Link * link, const uint8_t frame)
Process an incoming 8-byte LIN diagnostic frame received from bus (0x3C / 0x3D).
ssize_t syn_lintp_receive (SYN_LINTP_Link * link, uint8_t * out_buf, size_t max_len)
Read a fully reassembled message payload from the LIN TP receiver.
SYN_Status syn_lintp_send (SYN_LINTP_Link * link, uint8_t nad, const uint8_t * payload, size_t len)
Queue a message for multi-frame or single-frame LIN TP transmission.
void syn_lintp_set_padding (SYN_LINTP_Link * link, uint8_t pad_byte)
Configure padding byte value for unused frame bytes.
void syn_lintp_set_timeouts (SYN_LINTP_Link * link, uint32_t n_as_ms, uint32_t n_cr_ms)
Configure LIN TP timeouts in milliseconds.
void syn_lintp_step (SYN_LINTP_Link * link, uint32_t dt_ms)
Step LIN TP timers by dt_ms.

Detailed Description

Implements non-blocking, zero-allocation ISO 17987-2 LIN TP segmentation and reassembly state machine.

Public Functions Documentation

function syn_lintp_get_tx_frame

Retrieve next queued 8-byte LIN diagnostic payload to transmit on bus (0x3C / 0x3D).

bool syn_lintp_get_tx_frame (
    SYN_LINTP_Link * link,
    uint8_t out_frame
) 

Parameters:

  • link Pointer to LIN TP link context.
  • out_frame Array of 8 bytes to receive frame data.

Returns:

true if a frame was ready and copied, false otherwise.


function syn_lintp_init

Initialize LIN TP Link context.

void syn_lintp_init (
    SYN_LINTP_Link * link,
    uint8_t nad,
    uint8_t * rx_buf,
    size_t rx_size,
    uint8_t * tx_buf,
    size_t tx_size
) 

Parameters:

  • link Pointer to LIN TP link structure.
  • nad Node Address (NAD) for this device (0x01..0x7D).
  • rx_buf Pointer to buffer for storing received payloads.
  • rx_size Size of RX buffer.
  • tx_buf Pointer to buffer reserved for TX (optional context pointer).
  • tx_size Size of TX buffer.

function syn_lintp_is_tx_idle

Check if LIN TP TX engine is idle and ready for new message.

bool syn_lintp_is_tx_idle (
    const SYN_LINTP_Link * link
) 

Parameters:

  • link Pointer to LIN TP link context.

Returns:

true if idle, false if actively transmitting a message.


function syn_lintp_process_rx_frame

Process an incoming 8-byte LIN diagnostic frame received from bus (0x3C / 0x3D).

void syn_lintp_process_rx_frame (
    SYN_LINTP_Link * link,
    const uint8_t frame
) 

Parameters:

  • link Pointer to LIN TP link context.
  • frame Pointer to 8-byte received LIN frame payload.

function syn_lintp_receive

Read a fully reassembled message payload from the LIN TP receiver.

ssize_t syn_lintp_receive (
    SYN_LINTP_Link * link,
    uint8_t * out_buf,
    size_t max_len
) 

Parameters:

  • link Pointer to LIN TP link context.
  • out_buf Buffer to receive assembled payload.
  • max_len Maximum bytes to copy.

Returns:

Number of payload bytes read, 0 if no complete message ready, or negative error code.


function syn_lintp_send

Queue a message for multi-frame or single-frame LIN TP transmission.

SYN_Status syn_lintp_send (
    SYN_LINTP_Link * link,
    uint8_t nad,
    const uint8_t * payload,
    size_t len
) 

Parameters:

  • link Pointer to LIN TP link context.
  • nad Destination NAD.
  • payload Pointer to payload bytes to send.
  • len Payload length in bytes (1..4095).

Returns:

SYN_OK on success, or error status code.


function syn_lintp_set_padding

Configure padding byte value for unused frame bytes.

void syn_lintp_set_padding (
    SYN_LINTP_Link * link,
    uint8_t pad_byte
) 

Parameters:

  • link Pointer to LIN TP link context.
  • pad_byte Fill byte value (default 0xFF).

function syn_lintp_set_timeouts

Configure LIN TP timeouts in milliseconds.

void syn_lintp_set_timeouts (
    SYN_LINTP_Link * link,
    uint32_t n_as_ms,
    uint32_t n_cr_ms
) 

Parameters:

  • link Pointer to LIN TP link context.
  • n_as_ms Max frame TX time (default 1000ms).
  • n_cr_ms Max time between consecutive RX frames (default 1000ms).

function syn_lintp_step

Step LIN TP timers by dt_ms.

void syn_lintp_step (
    SYN_LINTP_Link * link,
    uint32_t dt_ms
) 

Parameters:

  • link Pointer to LIN TP link context.
  • dt_ms Milliseconds elapsed since last step call.


The documentation for this class was generated from the following file src/syntropic/proto/syn_lintp.c