SAE J1939 - Protocol
SAE J1939 Overview
The SAE J1939 protocol is a set of standards that define standardized methods for ECU communication. It is a higher-layer protocol built on CAN as the physical layer. Supports both node addressing and message addressing. Can transmit up to 1785 bytes. Has its own diagnostic interface with a set of PGNs to handle diagnostic services.
Embien’s SAE J1939 stack supports all messages defined by application and diagnostic layers. Handles the reception and transmission of standard single-frame and multi-frame (i.e., transport protocol) J1939 messages.
The OSI layer of J1939

Some of the salient features of RAPIDSEA SAE-J1939 protocol stack are
Enables in-vehicle network communications (ECU communications)
Supports vehicle diagnostics services and fault-code memory
Supports to transmit and receive the data in More than 8 bytes.
Peer-to-peer Transport Protocol (TP.CM_RTS(Ready to send)/TP.CM_CTS(Clear to send))and Broadcast Announce Message(BAM)
The embedded software code of the Stack is MISRA-C complaint.
Can be used with or without RTOS
Can support 8, 16, 32, 64-bit CPUs
The below diagram captures the block level diagram of the J1939 and how it interfaces with other modules.

SAE J1939 Communication Mechanisms
1. BAM (Broadcast Announce Message)
BAM is used in the J1939 protocol for broadcasting large data. It’s a way for one ECU (or a node) to send a large message to multiple ECUs over the CAN network. BAM is often used for data that needs to be sent to multiple receivers at once, without waiting for individual acknowledgments. It allows for the broadcast of large data to multiple receivers. BAM messages can carry large data over multiple frames. A message is broken into multiple frames, each with an 8-byte data field. Each frame will include a sequence number to reassemble the full message at the receiving end.
Key Features: - Once the message is broadcast, receivers do not acknowledge each frame individually. - One ECU can send the data to many without needing a direct request.
2. RTS/CTS (Request to Send / Clear to Send)
RTS/CTS is a two-step process used for large data transfers in J1939. It is mainly used for point-to-point communication between two ECUs. The RTS/CTS method is used when an ECU needs to send a large amount of data (over 8 bytes) and wants to ensure that the receiving ECU is ready to receive this data without causing data overload or collisions.
RTS (Request to Send): - The sender ECU uses the RTS message to request permission to send a large message. - It includes the PGN (Parameter Group Number) of the message and indicates how many data frames the sender intends to send. - The sender waits for the receiving ECU to respond with a CTS message.
CTS (Clear to Send): - The receiving ECU sends a CTS message in response to an RTS message, indicating it is ready to receive the data. - The CTS message will contain the necessary details for the sender to continue transmitting the data (e.g., the number of frames the receiver is ready to accept).
Key Features: - Ensures that large messages are not sent too quickly or in a way that could overwhelm the receiving ECU. - First, the sender requests permission (RTS), and then the receiver approves (CTS).
3. Request/Response
The Request/Response method is a simple one-to-one communication method used in J1939 for querying data from a specific ECU. It is commonly used for diagnostic services, where one ECU requests a piece of information, and another ECU responds with the requested data.
Request: - An ECU sends a request message to another ECU asking for a specific piece of information, such as sensor data or diagnostic information. - It contains the PGN of the requested data, along with any necessary parameters to specify the data or service needed.
Response: - The ECU that has the requested data sends a response message containing the requested data or an acknowledgment if no data is available. - Contains the requested data or a response code (if the request could not be fulfilled).
Key Features: - Unlike BAM, where data is broadcasted, the Request/Response method is a direct communication between two ECUs. - Suitable for requests where the amount of data is small and the exchange is not as frequent.
Application Interface
This section covers the details of how to use the SAE J1939 stack. It provides the ability to transmit large messages over the Controller Area Network (CAN) bus using a series of smaller frames. It employs mechanisms like BAM (Broadcast Announce Mode) and RTS (Ready to Send)/CTS (Clear to Send) to transmit more than 8 bytes. Broadcast Announce Mode is used to send data to all ECUs with the standard global address (0xFF), while RTS/CTS is used for point-to-point communication.
As it is message-oriented, the RAPIDSEA SAE J1939 stack requires the application to provide buffers during initialization. The size of the buffers can be determined by the user based on their application requirements. For example, if a 4096-byte message size has to be supported, each buffer must be at least this size plus a few more bytes.
When the higher-level application layer wants to transmit and receive a message, it fills the buffer with data and queues it for transmission and reception. J1939 consolidates it over multiple frames into a single message and provides it to the application layer as a complete message.
The below table captures the function that are to be called from the application logic.
Function |
Description |
---|---|
rs_j1939_open |
Initializes the j1939 stack |
rs_j1939_set_tx_msg_buf |
Set up the transmit buffers to be used for the j1939 stack |
rs_j1939_set_rx_msg_buf |
Set up the receive buffers to be used for the j1939 stack |
rs_j1939_set_req_tx_msg_buf |
Set up the transmit buffers to be used for the request response mode in j1939 stack |
rs_j1939_set_req_rx_msg_buf |
Set up the receive buffers to be used for the request response mode in j1939 stack |
rs_j1939_get_transmit_msg_buf |
Requests a transmit buffer for sending message. |
rs_j1939_queue_transmit_msg |
Transmits the given message over one or more frames |
rs_j1939_release_transmit_msg |
Function release the transmit messages |
rs_j1939_rx_buffer_handled |
Indicates the receive buffer is handled |
rs_j1939_get_tx_request_msg_buf |
Retrieve a transmit request message buffer in the J1939 protocol |
rs_j1939_queue_request_tx_msg |
Transmits the given message to push a response message data |
rs_j1939_release_request_tx_msg |
Function release the request transmit messages |
rs_j1939_handled_request_rx_buff |
Indicates the request receive buffer is handled |
rs_j1939_tx_request |
Sends a request message over the J1939 protocol for the specified Parameter Group Number |
rs_j1939_ivn_transmit_handler |
Handle a sequence of data packets to other ECU in BAM or RTS CTS mode. |
rs_j1939_handle_rx_packet |
Function used to handle the received message from CAN. |
rs_j1939_process |
Function to be called periodically to process underlying state machines |
rs_j1939_can_id_is_valid |
validates if the provided CAN ID corresponds to a valid J1939 frame. |
rs_j1939_close |
close j1939 handle |
The details of these functions are covered in the below sections.
There are many functions through which the J1939 stack retrieves information from the application logic or indicate actions to be performed. These functions are captured in the below table.
Function |
Description |
---|---|
rcb_j1939_is_pgn_support |
Check the PGN is supported or not |
rcb_j1939_update_resp_failure_info |
Update the response failure information |
rcb_j1939_ack_resp_received |
Handles the acknowledgment response for a J1939 message |
rcb_j1939_rx_multiple_packet |
Handles to reveive the multiple packets to update the DID |
rs_ret_val_t rcb_j1939_get_ivn_msg_frame |
Prepares and retrieves the IVN (In-Vehicle Network) message frame for J1939. |
rs_ret_val_t rcb_j1939_pgn_is_available |
Checks if a specific Parameter Group Number (PGN) is available. |
rs_ret_val_t rcb_j1939_get_cts_tx_info |
J1939 interface for control information related to the transmission of a CTS message |
rs_ret_val_t rcb_j1939_get_max_frames |
J1939 to set a max number of frames |
The below diagram captures the high level sequence of operations associated with the J1939 stack.

Dependency
This stack depends on the below RAPIDSEA interfaces that can be obtained or custom implemented.
J1939 Header Details
Documentation from the relevant header as follows:
SAE j1939 Module.
This file contains the APIs for using SAE_j1939 communication module
- Author
Embien RAPIDSEA Team
- Copyright
Embien Technologies India Pvt. Ltd.
Defines
-
J1939_ENABLE_EMBIEN_TEST
-
RS_J1939_TP_MODE_BAM
Maximum size of the receive message.
-
RS_J1939_TP_MODE_RTS_CTS
Maximum size of the transmit message.
-
RS_J1939_MAX_RX_MSG_SIZE
Maximum size of the receive message.
-
RS_J1939_MAX_TX_MSG_SIZE
Maximum size of the transmit message.
-
RS_J1939_MSG_STATUS_FREE
Message is unused.
-
RS_J1939_MSG_STATUS_IN_USE
Message is used.
-
RS_J1939_MSG_STATUS_READY_FOR_TX
Message is ready to be transmitted.
-
RS_J1939_MSG_STATUS_DISCARD
Message is to be discarded.
-
RS_J1939_MSG_TYPE_MASK
Msg Type Mask.
-
RS_J1939_MSG_TYPE_TP_DT
BAM Data Transfer msg.
-
RS_J1939_MSG_TYPE_TP_CM
-
RS_J1939_MSG_TYPE_ISO_REQUEST
Read request from other ECU.
-
RS_J1939_MSG_TYPE_ISO_ACKNOWLEDGEMENT
Read Acknowledgement from other ECU.
Transport Protocol - Connection Management
-
RS_J1939_CTRL_BYTE_TP_CM_BAM
-
RS_J1939_CTRL_BYTE_TP_CM_END_OF_MSG_ACK
-
RS_J1939_CTRL_BYTE_TP_CM_CTS
-
RS_J1939_CTRL_BYTE_TP_CM_RTS
-
RS_J1939_CTRL_BYTE_TP_CM_ABORT
Transport Protocol - Connection Management
-
RS_J1939_CUR_STATE_CTS_TX_COMPLETE
-
RS_J1939_CUR_STATE_SEND_CTS
-
RS_J1939_CUR_STATE_SEND_TP_DT
-
RS_J1939_CUR_STATE_IDLE
-
RS_J1939_MAX_IDENTIFICATION
Maximum number of receive messages that can be simultaneously handled.
-
RS_J1939_MAX_NUM_RX_MSG
Maximum number of transmit messages that can be simultaneously handled.
-
RS_J1939_MAX_NUM_TX_MSG
-
RS_J1939_MSG_STATUS_FREE
Message is unused.
-
RS_J1939_MSG_STATUS_IN_USE
Message is used.
-
RS_J1939_MSG_STATUS_READY_FOR_TX
Message is ready to be transmitted.
-
RS_j1939_MSG_STATUS_DISCARD
Message is to be discarded.
-
RS_J1939_SINGLE_FRAME_TRANSMISSION
Macro indicating that the CAN message is a single frame transmission.
-
RS_J1939_MAX_BUF_LEN
Maximum buffer length of j1939.
-
RS_J1939_MAX_NUM_REQ
Maximum number of request have to receive.
-
RS_J1939_REQ_INFO_STATUS_FREE
Request info status free.
-
RS_J1939_REQ_INFO_STATUS_IN_USE
Request info status in use.
-
RS_J1939_MAX_FRAME_DATA
Maximum number of data bytes per frame in data transmission.
-
RS_J1939_SINGLE_FRAME_TX_WAIT_TIMEOUT_MS
Timeout between single data frames in milliseconds (50ms to 200ms)
-
RS_J1939_BAM_TX_WAIT_TIMEOUT_MS
Timeout between BAM data frames in milliseconds (50ms to 200ms)
-
RS_J1939_T1_EXPECTED_TIMEOUT_MS
Timeout for waiting for RTS/CTS responses in milliseconds (750ms)
-
RS_J1939_T2_EXPECTED_TIMEOUT_MS
Timeout for CTS after responder sends CTS (Clear To Send) and originator sending data packets.
-
RS_J1939_T3_EXPECTED_TIMEOUT_MS
Timeout for originator stop data transmission and wait for CTS to stop the packet.
-
RS_J1939_T4_EXPECTED_TIMEOUT_MS
Timeout for CTS(0) after hold connection message and responder sends the another CTS to send a data packet.
-
RS_J1939_TR_EXPECTED_TIMEOUT_MS
Timeout for transmission response.
-
RS_J1939_TX_DT_RESPONSE_TIME_MS
Timeout for expecting a Data Transmission (DT) response in milliseconds (200ms)
-
RS_J1939_CTS_PAUSE_HOLD_TIME_MS
Timeout for expecting a CTS pause and send next packet command hold timeout in milliseconds (500ms)
-
RS_J1939_PAUSE_NXT_SEQ_CMD_WAIT_TIMEOUT_MS
Timeout for expecting a CTS pause and send next packet command in milliseconds (<=500ms)
-
RS_J1939_CTS_PAUSE_CMD_RECEIVED
CTS Pause command received.
-
RS_J1939_TX_CTS_INITIAL_SEQ_NO
SET initial sequence number to transmit a CTS.
-
RS_J1939_TP_CM_CUR_RX_MODE_RTS
Set a receive connection management mode RTS.
-
RS_J1939_TP_CM_CUR_RX_MODE_BAM
Set a receive connection management mode BAM.
-
RS_J1939_TP_CM_CUR_MODE_CTS_SENT
Set a CTS sent conformation.
-
RS_J1939_TP_CUR_MODE_DT_RX_MSG
Set a the device is ready to receive the data.
-
RS_J1939_TP_CUR_MODE_SEND_CTS_PAUSE_SENT
Set a the device to send a pause command.
-
RS_J1939_TP_CM_CUR_RX_MODE_ABORT
Set a the device to a indicate a recived message as abort.
-
RS_J1939_TP_DT_TIMEOUT_ERROR
Timeout error for receiving a Data Transfer (DT) message in J1939 transport protocol.
-
RS_J1939_ABORT_MSG_RESP_TIMEOUT
Abort message indicating that a response timeout occurred.
-
RS_J1939_ABORT_MSG_TP_CM_RTS
Abort message for when a Transport Protocol Connection Request (RTS) number of retry attempts exceed.
-
RS_J1939_ABORT_MSG_TP_DT
Abort message for when a Transport Protocol Data Transfer (DT) terminate the current transmission attempt.
-
RS_J1939_ABORT_CTS_HOLD_CONN_TIMEOUT
Abort message indicating a timeout while holding a connection during the CTS pause and send next sequence number.
-
RS_J1939_ABORT_MSG_T4_RESP_TIME_MS
Timeout for expecting a CTS pause and receive a next packet command in milliseconds (500ms)
-
RS_J1939_ABORT_MSG_T3_RESP_TIME_MS
Timeout for expecting a CTS pause and receive a next packet command in milliseconds (500ms)
-
RS_J1939_CTS_TP_DT_RECEIVED_COMPLETED
State indicating that the Data Transfer (DT) message has been successfully received and completed in the CTS.
-
RS_J1939_MAX_RX_BUFF
Maximum number of receive buffer is used.
-
RS_J1939_RX_BUF_STATE_FREE
Receive buffer state is free.
-
RS_J1939_RX_BUF_STATE_IN_USE
Receive buffer state in use.
-
RS_J1939_RX_BUF_STATE_COMPLETE
Receive buffer state in Complete state.
Typedefs
-
typedef struct tag_rs_j1939_config rs_j1939_config_t
Contains information about J1939 configuration.
-
typedef struct tag_rs_j1939_req_info rs_j1939_req_info_t
Contains information about J1939 request details.
-
typedef struct tag_rs_j1939_rx_rts_info rs_j1939_rx_rts_info_t
-
typedef struct tag_rs_j1939_rx_cts_info rs_j1939_rx_cts_info_t
Contains information about J1939 rx CTS.
-
typedef struct tag_rs_j1939_tx_cts_info rs_j1939_tx_cts_info_t
Contains information about J1939 tx CTS.
-
typedef struct tag_rs_j1939_rx_buff_mgr rs_j1939_rx_buff_mgr_t
Contains information about J1939 rx buffer manager.
-
typedef struct tag_rs_j1939_instance rs_j1939_instance_t
Contains information about J1939.
-
typedef struct tag_rs_j1939_msg rs_j1939_msg_t
Contains information about J1939 Message.
Functions
-
rs_handle_t rs_j1939_open(rs_j1939_instance_t *ptr_instance, rs_j1939_config_t *ptr_config)
Initializes the j1939 stack.
This function initializes the j1939 stack for operation
- Parameters:
ptr_instance – [in] - Pointer to the J1939 instance information
ptr_config – [in] - Pointer to the J1939 configuration
- Returns:
Handle of the J1939 instance information which include configuration information also
-
rs_ret_val_t rs_j1939_set_tx_msg_buf(rs_handle_t j1939_handle, rs_j1939_msg_t *ptr_tx_msgs, uint32_t u32_num_msg, void *ptr_msg_ptr_buf)
Set up the transmit buffers to be used for the j1939 stack.
This function sets up the transmit buffers to be used for j1939 stack
- Parameters:
j1939_handle – [in] - Handle of the j1939 instance information
ptr_tx_msgs – [in] - Pointer to the array of j1939 transmit messages
u32_num_msg – [in] - Number of transmit messages that the j1939 stack can use from the above array
ptr_msg_ptr_buf – [in] - Pointer to the pointer FIFO buffer
- Returns:
Return Zero or negative error code
-
rs_ret_val_t rs_j1939_set_rx_msg_buf(rs_handle_t j1939_handle, rs_j1939_msg_t *ptr_rx_msgs, uint32_t u32_num_msg, void *ptr_msg_ptr_buf)
Set up the receive buffers to be used for the j1939 stack.
This function sets up the receive buffers to be used for j1939 stack
- Parameters:
j1939_handle – [in] - Handle of the j1939 instance information
ptr_tx_msgs – [in] - Pointer to the array of j1939 receive messages
u32_num_msg – [in] - Number of receive messages that the j1939 stack can use from the above array
- Returns:
Return Zero or negative error code
-
rs_ret_val_t rs_j1939_set_req_tx_msg_buf(rs_handle_t j1939_handle, rs_j1939_msg_t *ptr_tx_msgs, uint32_t u32_num_msg, void *ptr_msg_ptr_buf)
Set up the transmit buffers to be used for the request response mode in j1939 stack.
This function Set up the transmit buffers to be used for the request response mode in j1939 stack
- Parameters:
j1939_handle – [in] - Handle of the j1939 instance information
ptr_tx_msgs – [in] - Pointer to the array of j1939 transmit messages
u32_num_msg – [in] - Number of transmit messages that the j1939 stack can use from the above array
ptr_msg_ptr_buf – [in] - Pointer to the pointer FIFO buffer
- Returns:
Return Zero or negative error code
-
rs_ret_val_t rs_j1939_set_req_rx_msg_buf(rs_handle_t j1939_handle, rs_j1939_msg_t *ptr_rx_msgs, uint32_t u32_num_msg, void *ptr_msg_ptr_buf)
Set up the receive buffers to be used for the request response mode in j1939 stack.
This function Set up the transmit buffers to be used for the request response mode in j1939 stack
- Parameters:
j1939_handle – [in] - Handle of the j1939 instance information
ptr_tx_msgs – [in] - Pointer to the array of j1939 receive messages
u32_num_msg – [in] - Number of receive messages that the j1939 stack can use from the above array
- Returns:
Return Zero or negative error code
-
rs_j1939_msg_t *rs_j1939_get_transmit_msg_buf(rs_handle_t j1939_handle)
Requests a transmit buffer for sending message.
This function return a transmit buffer for sending DoCAN message.
- Parameters:
j1939_handle – [in] - Handle of the transport information
- Returns:
Pointer to a free transmit buffer if available or NULL
-
rs_ret_val_t rs_j1939_queue_transmit_msg(rs_handle_t j1939_handle, rs_j1939_msg_t *ptr_tx_msg)
Transmits the given message.
This function transmits the given message over one or more frames
- Parameters:
j1939_handle – [in] - Handle of the transport information
ptr_tx_msg – [in] - Pointer to the message to be transmitted
- Returns:
Return O on success or negative code on failure
-
rs_ret_val_t rs_j1939_release_transmit_msg(rs_handle_t j1939_handle, rs_j1939_msg_t *ptr_tx_msg)
Function release the transmit messages.
This function is release the transmitted messages
- Parameters:
j1939_handle – [in] - Handle of the transport information
ptr_tx_msg – [in] - Pointer to the transmit message which need to be freed.
- Returns:
Return O on success or negative code on failure
-
rs_ret_val_t rs_j1939_rx_buffer_handled(rs_handle_t j1939_handle, rs_j1939_msg_t *ptr_rx_msg)
Indicates the receive buffer is handled.
This function indicates the received buffer is handled and can be freed
- Parameters:
j1939_handle – [in] - Handle of the transport information
ptr_rx_msg – [in] - Pointer to the message received
- Returns:
Return O on success or negative code on failure
-
rs_j1939_msg_t *rs_j1939_get_tx_request_msg_buf(rs_handle_t j1939_handle)
Retrieve a transmit request message buffer in the J1939 protocol.
This function is used to Retrieve a transmit request message buffer in the J1939 protocol
- Parameters:
j1939_handle – [in] - Handle of the transport information
- Returns:
Pointer to a free transmit buffer if available or NULL
-
rs_ret_val_t rs_j1939_queue_request_tx_msg(rs_handle_t j1939_handle, rs_j1939_msg_t *ptr_tx_msg)
Transmits the given message to push a response message data.
This function Transmits the given message to push a response message data
- Parameters:
j1939_handle – [in] - Handle of the transport information
ptr_tx_msg – [in] - Pointer to the message to be transmitted
- Returns:
Return O on success or negative code on failure
-
rs_ret_val_t rs_j1939_release_request_tx_msg(rs_handle_t j1939_handle, rs_j1939_msg_t *ptr_tx_msg)
Function release the request transmit messages.
This function is release the request transmitted messages
- Parameters:
j1939_handle – [in] - Handle of the transport information
ptr_tx_msg – [in] - Pointer to the transmit message which need to be freed.
- Returns:
Return O on success or negative code on failure
-
rs_ret_val_t rs_j1939_handled_request_rx_buff(rs_handle_t j1939_handle, rs_j1939_msg_t *ptr_rx_msg)
Indicates the request receive buffer is handled.
This function indicates the request received buffer is handled and can be freed
- Parameters:
j1939_handle – [in] - Handle of the transport information
ptr_rx_msg – [in] - Pointer to the message received
- Returns:
Return O on success or negative code on failure
-
rs_ret_val_t rs_j1939_msg_status_update(rs_handle_t j1939_handle, rs_j1939_msg_t *ptr_msg, uint8_t u8_msg_status)
Assign the received message status to the appropriate parameter.
This function used to assign the received message status to the appropriate parameter
- Parameters:
j1939_handle – [in] - Handle of the transport information
ptr_msg – [in] - Pointer to the message received
u8_msg_status – [in] - message status need to be assigned
- Returns:
Return O on success or negative code on failure
-
rs_ret_val_t rs_j1939_tx_request(rs_handle_t j1939_handle, uint32_t u32_pgn_number, uint8_t u8_target_addr)
Sends a request message over the J1939 protocol for the specified Parameter Group Number (PGN).
This function sends a request message over the J1939 protocol for the specified Parameter Group Number (PGN).
- Parameters:
j1939_handle – [in] - Handle of the transport information
u32_pgn_number – [in] - The Parameter Group Number (PGN) associated with the request.
u8_target_addr – [in] - The Parameter Target ECU address associated with the request.
- Returns:
Return O on success or negative code on failure
-
rs_ret_val_t rs_j1939_ivn_transmit_handler(rs_handle_t j1939_handle)
Handle a sequence of data packets to other ECU in BAM or RTS CTS mode.
This function used to handle a sequence of data packets to transmit a message to other ECU to select BAM or RTS CTS mode.
- Parameters:
j1939_handle – [in] - Handle of the j1939 instance information
- Returns:
0 on success or error code on failure
-
rs_ret_val_t rs_j1939_handle_rx_packet(rs_handle_t j1939_handle, rs_can_data_t *ptr_rx_data)
Function used to handle the received message from CAN.
This function used to handle the received message from CAN.
- Parameters:
j1939_handle – [in] - Handle of the j1939 instance information
ptr_rx_data – [in] - pointer to the received message
- Returns:
Return 0 on success or negative on failure
-
rs_ret_val_t rs_j1939_process(rs_handle_t j1939_handle)
Function to be called periodically to process underlying state machines.
This function is to be called at not more than 5 ms interval to handle j1939 states
- Parameters:
j1939_handle – [in] - Handle of the j1939 instance information
- Returns:
Return 0 on success or error code on failure
-
rs_ret_val_t rs_j1939_can_id_is_valid(rs_handle_t j1939_handle, uint32_t u32_can_id)
validates if the provided CAN ID corresponds to a valid J1939 frame.
This function validates if the provided CAN ID corresponds to a valid J1939 frame.
- Parameters:
j1939_handle – [in] - handle to the j1939 information
can_id – [in] The CAN ID to be validated.
- Returns:
Return 0 on success or error code on failure
-
rs_ret_val_t rs_j1939_close(rs_handle_t j1939_handle)
close j1939 handle
This function used to stop the j1939
- Parameters:
j1939_handle – [in] - handle to the j1939 information
- Returns:
Return 0 on success or error code on failure
-
rs_ret_val_t rcb_j1939_is_pgn_support(rs_handle_t j1939_handle, uint32_t u32_pgn_num)
Check the PGN is supported or not.
This function used to Check the PGN is supported or not
- Parameters:
j1939_handle – [in] - Handle to the J1939 instance.
u32_pgn_num – [in] - pgn number to check its available or not .
- Returns:
0 on success or error code on failure
-
rs_ret_val_t rcb_j1939_update_resp_failure_info(rs_handle_t j1939_handle, uint32_t u32_pgn_number, uint8_t u8_target_addr)
Update the response failure information.
This function used to update the response failure information
- Parameters:
j1939_handle – [in] - Handle to the J1939 instance.
u32_pgn_number – [in] - Transmit request pgn number
u8_target_addr – [in] - Target ECU address
- Returns:
0 on success or error code on failure
-
rs_ret_val_t rcb_j1939_ack_resp_received(rs_handle_t j1939_handle, uint32_t u32_pgn_number, uint8_t target_addr, uint8_t result)
Handles the acknowledgment response for a J1939 message.
This function processes the acknowledgment (ACK) response received for a J1939 message.
- Parameters:
j1939_handle – [in] - A handle to the J1939 instance.
u32_pgn_number – [in] - The Parameter Group Number (PGN) request message. T
target_addr – [in] - The target address of the acknowledgment message.
result – [in] - The result of the acknowledgment.
- Returns:
0 on success or error code on failure
-
rs_ret_val_t rcb_j1939_rx_multiple_packet(rs_handle_t j1939_handle, rs_j1939_msg_t *ptr_rx_msg)
Handles to reveive the multiple packets to update the DID.
This function Handles to reveive the multiple packets to update the DID
- Parameters:
j1939_handle – [in] - A handle to the J1939 instance.
ptr_rx_msg – [in] - Pointer to the rx message
- Returns:
0 on success or error code on failure
-
rs_ret_val_t rcb_j1939_get_ivn_msg_frame(rs_handle_t j1939_handle, uint32_t u32_index, uint8_t u8_tar_addr)
Prepares and retrieves the IVN (In-Vehicle Network) message frame for J1939.
This function processes the necessary data to prepare the IVN message frame.
- Parameters:
j1939_handle – [in] - A handle to the J1939 instance
u32_index – [in] - The index of the specific message to be prepared.
u8_tar_addr – [in] - The target address of an request message
- Returns:
0 on success or error code on failure
-
rs_ret_val_t rcb_j1939_pgn_is_available(rs_handle_t j1939_handle, uint32_t u32_pgn_number, uint32_t *ptr_msg_index)
Checks if a specific Parameter Group Number (PGN) is available.
This function checks the availability of a specific PGN (Parameter Group Number).
- Parameters:
j1939_handle – [in] - A handle to the J1939 instance
u16_pgn_number – [in] - The specific Parameter Group Number (PGN) to check for availability.
ptr_msg_index – [out] - A pointer to a variable that will be set with the message index of the available PGN.
- Returns:
0 on success or error code on failure
-
rs_ret_val_t rcb_j1939_get_cts_tx_info(rs_handle_t j1939_handle, uint32_t u32_index, uint32_t *u32_max_num_frames)
J1939 interface for control information related to the transmission of a CTS message.
This function J1939 interface for control information related to the transmission of a CTS message
- Parameters:
j1939_handle – [in] - A handle to the J1939 instance.
u32_index – [in] - The index of the CTS message for which transmission control information is requested.
u32_max_num_frames – [out] - A pointer to a variable where the function will store the maximum number of frames that can be transmitted for the given CTS message.
- Returns:
0 on success or error code on failure
-
rs_ret_val_t rcb_j1939_get_max_frames(rs_handle_t j1939_handle)
J1939 to set a max number of frames.
This function J1939 to set a max number of frames
- Parameters:
j1939_handle – [in] - A handle to the J1939 instance.
- Returns:
0 on success or error code on failure
-
struct tag_rs_j1939_config
- #include <rs_j1939.h>
Contains information about J1939 configuration.
-
struct tag_rs_j1939_req_info
- #include <rs_j1939.h>
Contains information about J1939 request details.
-
struct tag_rs_j1939_rx_rts_info
Public Members
-
uint32_t curr_resp_time
Transmission response timeout in milliseconds.
-
uint32_t pgn_number
PGN number of RTS message.
-
uint32_t tx_cts_can_id
Set a CTS CAN ID to transmit.
-
uint32_t max_len
Maximum length of RTS.
-
uint8_t cts_cur_state
Current Transmit state.
-
uint8_t target_addr
Set a CTS CAN ID to transmit.
-
uint8_t remaining_packets
Remaining packets to be transmitted.
-
uint8_t max_seq_no
Maximum sequence number.
-
uint16_t no_of_bytes_received
total number of bytes received
-
uint32_t curr_resp_time
-
struct tag_rs_j1939_rx_cts_info
- #include <rs_j1939.h>
Contains information about J1939 rx CTS.
Public Members
-
uint8_t is_cts_received
CTS Flag.
-
uint8_t num_of_frame_to_tx
Number of frames to transmit.
-
uint8_t initial_seq_no
Set a initial sequence number.
-
uint32_t curr_t4_resp_time
Timeout for CTS after responder sends CTS (Clear To Send) pause command. then receive the next CTS command to send a data packets from orginator.
-
uint8_t is_cts_received
-
struct tag_rs_j1939_tx_cts_info
- #include <rs_j1939.h>
Contains information about J1939 tx CTS.
Public Members
-
uint8_t total_no_of_packets
total number of packets to transmit
-
uint8_t req_no_of_packets
Set a number of packets to CTS to send.
-
uint32_t curr_t3_resp_time
Timeout for CTS after responder sends CTS (Clear To Send) and originator sending data packets.
-
uint32_t curr_hold_time
Set the current hold time (in milliseconds) before sending CTS data after a pause.
-
uint32_t curr_t2_resp_time
Timeout for CTS after responder sends CTS (Clear To Send) and originator sending data packets.
-
uint8_t total_no_of_packets
-
struct tag_rs_j1939_rx_buff_mgr
- #include <rs_j1939.h>
Contains information about J1939 rx buffer manager.
Public Members
-
uint8_t cur_cm_msg_mode
Current Connection Management mode it is necessary for using the timeout handler in j1939.
-
uint8_t cur_rx_buff_state
Current Receive state.
-
uint32_t exp_rx_len
Num frame bytes expected.
-
void *ptr_cur_rx_msg
Current RX msg in progress.
-
uint8_t curr_rx_sn
Next Receive sequence number.
-
uint8_t rx_src_addr
Source address of receive buffer.
-
uint8_t tx_tar_addr
Set a Target address to transmit a data.
-
uint8_t rx_bam_buff_clear_flag
Check the BAM clear buffer flag.
-
uint32_t pgn_number
PGN number of an RX message.
-
uint32_t curr_rx_time
Set the current RX time.
-
rs_j1939_rx_rts_info_t rx_rts_info
Strucure to the RTS information.
-
uint8_t cur_cm_msg_mode
-
struct tag_rs_j1939_instance
- #include <rs_j1939.h>
Contains information about J1939.
Public Members
-
rs_j1939_config_t *ptr_j1939_config
Contains information about J1939 configuration.
-
rs_handle_t can_handle
Can Handle.
-
rs_buffer_mgr_t tx_buf_mgr
Transmit buffer manager.
-
rs_buffer_mgr_t rx_buf_mgr
Receive buffer manager.
-
rs_buffer_mgr_t tx_msg_queue_mgr
TX message FIFO.
-
rs_buffer_mgr_t rx_msg_queue_mgr
RX message FIFO.
-
rs_buffer_mgr_t tx_req_buf_mgr
Request Transmit buffer manager.
-
rs_buffer_mgr_t rx_req_buf_mgr
Request Receive buffer manager.
-
rs_buffer_mgr_t tx_req_msg_queue_mgr
Request TX message FIFO.
-
rs_buffer_mgr_t rx_req_msg_queue_mgr
Request RX message FIFO.
-
rs_can_data_t *ptr_cur_tx_data
Can Data being transmitted.
-
void *ptr_cur_tx_msg
Current RX msg in progress.
-
uint8_t data_buff[RS_J1939_MAX_BUF_LEN]
Data buffer of an j1939.
-
uint8_t curr_tx_tar_addr
Current transmit target address.
-
uint8_t curr_rx_tar_addr
Current reception target address.
-
rs_j1939_req_info_t j1939_req_info[RS_J1939_MAX_NUM_REQ]
TX Request information.
-
uint8_t no_of_tx_req
Number of TX Request send.
-
rs_j1939_rx_buff_mgr_t j1939_rx_buff_mgr[RS_J1939_MAX_RX_BUFF]
RX Buffer Manager (Multi buffer management)
-
rs_j1939_rx_cts_info_t rx_cts_info
RX CTS information.
-
rs_j1939_tx_cts_info_t tx_cts_info
TX CTS information.
-
rs_handle_t j1939_handle
J1939 Handle.
-
uint16_t no_of_bytes_received
Total number of packages received.
-
uint8_t no_of_frames_received
Total number of frames received.
-
rs_j1939_config_t *ptr_j1939_config
-
struct tag_rs_j1939_msg
- #include <rs_j1939.h>
Contains information about J1939 Message.