S32 SDK

Detailed Description

Diagnostic services defines methods to implement diagnostic data transfer between a master node connected with a diagnostic tester and the slave nodes.

Three different classes of diagnostic nodes are supported.

The master node and the diagnostic tester are connected via a back-bone bus (e.g. CAN). The master node shall receive all diagnostic requests addressed to the slave nodes from the back-bone bus, and gateway them to the correct LIN cluster(s). Responses from the slave nodes shall be gatewayed back to the back-bone bus through the master node.

All diagnostic requests and responses (services) addressed to the slave nodes can be routed in the network layer (i.e. no application layer routing). In this case, the master node must implement the LIN transport protocol, see Transport Layer Specification, as well as the transport protocols used on the back- bone busses (e.g. ISO15765-2 on CAN).

Currently, LinStack support some service. With other service which LinStack doesn't support or user want to add action when any service is received, user can choose or create service in supported services of PEX GUI and use API of transport layer to implement it. in application.

Example in slave node:

for(;;)
{
/* length shall specify the maximum length allowed */
length = 106;
ld_receive_message(LI0,&length, &nad, req_data);
/* if receive READ_DATA_BY_IDENTIFIER master request successfully */
if(diag_get_flag(LI0, LI0_DIAGSRV_READ_DATA_BY_IDENTIFIER_ORDER))
{
diag_clear_flag(LI0, LI0_DIAGSRV_READ_DATA_BY_IDENTIFIER_ORDER);
/* implement what you want to do when receive this message
length will return real length of this message
req_data will contain SID and data of this message */
/* send back response data */
ld_send_message(LI0,17,nad, res_data);
}
}

Modules

 Node configuration
 This group contains APIs that used for node configuration purpose.
 
 Node identification
 This group contains API that used for node identification purpose.
 

Functions

void diag_read_data_by_identifier (l_ifc_handle iii, const l_u8 NAD, const l_u8 *const data)
 This function reads data by identifier, Diagnostic Class II service (0x22). More...
 
void diag_write_data_by_identifier (l_ifc_handle iii, const l_u8 NAD, l_u16 data_length, const l_u8 *const data)
 Write Data by Identifier for a specified node - Diagnostic Class II service (0x2E) More...
 
void diag_session_control (l_ifc_handle iii, const l_u8 NAD, l_u16 data_length, const l_u8 *const data)
 This function is used for master node only. It will pack data and send request to slave node with service ID = 0x10: Session control. More...
 
void diag_fault_memory_read (l_ifc_handle iii, const l_u8 NAD, l_u16 data_length, const l_u8 *const data)
 This function is used for master node only. It will pack data and send request to slave node with service ID = 0x19: Fault memory read. More...
 
void diag_fault_memory_clear (l_ifc_handle iii, const l_u8 NAD, l_u16 data_length, const l_u8 *const data)
 This function is used for master node only. It will pack data and send request to slave node with service ID = 0x14: Fault memory clear. More...
 
void diag_IO_control (l_ifc_handle iii, const l_u8 NAD, l_u16 data_length, const l_u8 *const data)
 This function is used for master node only. It will pack data and send request to slave node with service ID = 0x2F: Input/Output control service. More...
 
l_u8 diag_get_flag (l_ifc_handle iii, l_u8 flag_order)
 This function will return flag of diagnostic service, if LIN slave node receive master request of the diagnostic service. More...
 
void diag_clear_flag (l_ifc_handle iii, l_u8 flag_order)
 This function will clear flag of diagnostic service,. More...
 

Function Documentation

void diag_clear_flag ( l_ifc_handle  iii,
l_u8  flag_order 
)

This function will clear flag of diagnostic service,.

Parameters
[in]iiiLIN interface handle
[in]flag_orderOrder of service flag
Returns
void

Definition at line 1031 of file lin_diagnostic_service.c.

void diag_fault_memory_clear ( l_ifc_handle  iii,
const l_u8  NAD,
l_u16  data_length,
const l_u8 *const  data 
)

This function is used for master node only. It will pack data and send request to slave node with service ID = 0x14: Fault memory clear.

Parameters
[in]iiiLIN interface handle
[in]NADNode address value of the destination node for the transmission
[in]data_lengthData length of frame
[in]dataBuffer for the data to be transmitted
Returns
void

Definition at line 765 of file lin_diagnostic_service.c.

void diag_fault_memory_read ( l_ifc_handle  iii,
const l_u8  NAD,
l_u16  data_length,
const l_u8 *const  data 
)

This function is used for master node only. It will pack data and send request to slave node with service ID = 0x19: Fault memory read.

Parameters
[in]iiiLIN interface handle
[in]NADNode address value of the destination node for the transmission
[in]data_lengthData length of frame
[in]dataBuffer for the data to be transmitted
Returns
void

Definition at line 718 of file lin_diagnostic_service.c.

l_u8 diag_get_flag ( l_ifc_handle  iii,
l_u8  flag_order 
)

This function will return flag of diagnostic service, if LIN slave node receive master request of the diagnostic service.

Parameters
[in]iiiLIN interface handle
[in]flag_orderOrder of service flag
Returns
1 if LIN Slave node receives master request of the diagnostic service, and the flag has not been cleared by diag_clear_flag
0 default value
0xFF if service is not supported

Definition at line 1000 of file lin_diagnostic_service.c.

void diag_IO_control ( l_ifc_handle  iii,
const l_u8  NAD,
l_u16  data_length,
const l_u8 *const  data 
)

This function is used for master node only. It will pack data and send request to slave node with service ID = 0x2F: Input/Output control service.

Parameters
[in]iiiLIN interface handle
[in]NADNode address value of the destination node for the transmission
[in]data_lengthData length of frame
[in]dataBuffer for the data to be transmitted
Returns
void

Definition at line 811 of file lin_diagnostic_service.c.

void diag_read_data_by_identifier ( l_ifc_handle  iii,
const l_u8  NAD,
const l_u8 *const  data 
)

This function reads data by identifier, Diagnostic Class II service (0x22).

Parameters
[in]iiiLIN interface handle
[in]NADNode address value of the destination node for the transmission
[in]dataBuffer for the data to be transmitted
Returns
void

This function is for Master node only.

Definition at line 571 of file lin_diagnostic_service.c.

void diag_session_control ( l_ifc_handle  iii,
const l_u8  NAD,
l_u16  data_length,
const l_u8 *const  data 
)

This function is used for master node only. It will pack data and send request to slave node with service ID = 0x10: Session control.

Parameters
[in]iiiLIN interface handle
[in]NADNode address value of the destination node for the transmission
[in]data_lengthData length of frame
[in]dataBuffer for the data to be transmitted
Returns
void

Definition at line 671 of file lin_diagnostic_service.c.

void diag_write_data_by_identifier ( l_ifc_handle  iii,
const l_u8  NAD,
l_u16  data_length,
const l_u8 *const  data 
)

Write Data by Identifier for a specified node - Diagnostic Class II service (0x2E)

Parameters
[in]iiiLin interface handle
[in]NADNode address value of the destination node for the transmission
[in]data_lengthData length of frame
[in]dataBuffer for the data to be transmitted
Returns
void

This function is for Master node only.

Definition at line 611 of file lin_diagnostic_service.c.