J1939 Documentation
Version 4.16.00
Loading...
Searching...
No Matches
j1939_diag.h File Reference

Detailed Description

The diagnostics service provides the following PGs defined inside the J1939-73 specification:

PGN Parameter Group Label Acronym Handler
65226 Active Diagnostic Trouble Codes DM1 ECU_Pgn65226()
65227 Previously Active Diagnostic Trouble Codes DM2 ECU_Pgn65227()
65228 Diagnostics Data Clear/Reset for Previously Active DTCs DM3 ECU_Pgn65228()
65230 Diagnostic Readiness 1 DM5 ECU_Pgn65230()
65235 Diagnostic Data Clear/Reset for Active DTCs DM11 ECU_Pgn65235()
57088 Stop Start Broadcast DM13 ECU_Pgn57088()
+ Include dependency graph for j1939_diag.h:

Functions

int16_t ECU_Pgn57088 (uint8_t *pubDataV, uint16_t uwSizeV, uint8_t ubSrcAddrV, uint8_t ubNetV)
 
int16_t ECU_Pgn65226 (uint8_t *pubDataV, uint16_t uwSizeV, uint8_t ubSrcAddrV, uint8_t ubNetV)
 
int16_t ECU_Pgn65227 (uint8_t *pubDataV, uint16_t uwSizeV, uint8_t ubSrcAddrV, uint8_t ubNetV)
 
int16_t ECU_Pgn65228 (uint8_t *pubDataV, uint16_t uwSizeV, uint8_t ubSrcAddrV, uint8_t ubNetV)
 
int16_t ECU_Pgn65230 (uint8_t *pubDataV, uint16_t uwSizeV, uint8_t ubSrcAddrV, uint8_t ubNetV)
 
int16_t ECU_Pgn65235 (uint8_t *pubDataV, uint16_t uwSizeV, uint8_t ubSrcAddrV, uint8_t ubNetV)
 
void J1939_DiagAddDtc (uint8_t ubNetV, uint32_t ulSpnV, uint8_t ubFmiV, uint8_t ubCountV)
 
void J1939_DiagAddDtcPrev (uint8_t ubNetV, uint32_t ulSpnV, uint8_t ubFmiV, uint8_t ubCountV)
 
void J1939_DiagClearDtc (uint8_t ubNetV)
 
void J1939_DiagClearDtcPrev (uint8_t ubNetV)
 
void J1939_DiagHoldEvent (uint8_t ubNetV, uint8_t ubBroadcastSignalV)
 

Enumeration Type Documentation

◆ J1939_Broadcast_e

Definitions for Stop Start Broadcast (DM13)

Enumerator
eJ1939_BROADCAST_STOP 

Stop broadcast messages

eJ1939_BROADCAST_START 

Start broadcast messages

eJ1939_BROADCAST_NO_ACTION 

No action / change required

Function Documentation

◆ ECU_Pgn57088()

int16_t ECU_Pgn57088 ( uint8_t * pubDataV,
uint16_t uwSizeV,
uint8_t ubSrcAddrV,
uint8_t ubNetV )
Parameters
[in,out]pubDataVPointer to message data
[in]uwSizeVSize of data
[in]ubSrcAddrVSource address of PDU
[in]ubNetVJ1939 Network channel
Returns
Defined by J1939_Handler_Result_e

This handler covers the DM13 diagnostic message.

◆ ECU_Pgn65226()

int16_t ECU_Pgn65226 ( uint8_t * pubDataV,
uint16_t uwSizeV,
uint8_t ubSrcAddrV,
uint8_t ubNetV )
Parameters
[in,out]pubDataVPointer to message data
[in]uwSizeVSize of data
[in]ubSrcAddrVSource address of PDU
[in]ubNetVJ1939 Network channel
Returns
Defined by J1939_Handler_Result_e

The DM1 handler is automatically sent by the protocol stack in case a DTC is added by J1939_DiagAddDtc().

◆ ECU_Pgn65227()

int16_t ECU_Pgn65227 ( uint8_t * pubDataV,
uint16_t uwSizeV,
uint8_t ubSrcAddrV,
uint8_t ubNetV )
Parameters
[in,out]pubDataVPointer to message data
[in]uwSizeVSize of data
[in]ubSrcAddrVSource address of PDU
[in]ubNetVJ1939 Network channel
Returns
Defined by J1939_Handler_Result_e

The DM2 handler is called by the protocol stack in case a DTC is added by J1939_DiagAddDtcPrev().

◆ ECU_Pgn65228()

int16_t ECU_Pgn65228 ( uint8_t * pubDataV,
uint16_t uwSizeV,
uint8_t ubSrcAddrV,
uint8_t ubNetV )
Parameters
[in,out]pubDataVPointer to message data
[in]uwSizeVSize of data
[in]ubSrcAddrVSource address of PDU
[in]ubNetVJ1939 Network channel
Returns
Defined by J1939_Handler_Result_e

The DM3 handler clear previously active diagnostic trouble codes and responds with an ACK message.

◆ ECU_Pgn65230()

int16_t ECU_Pgn65230 ( uint8_t * pubDataV,
uint16_t uwSizeV,
uint8_t ubSrcAddrV,
uint8_t ubNetV )
Parameters
[in,out]pubDataVPointer to message data
[in]uwSizeVSize of data
[in]ubSrcAddrVSource address of PDU
[in]ubNetVJ1939 Network channel
Returns
Defined by J1939_Handler_Result_e

The DM5 handler reports the number of active and previously active DTCs.

◆ ECU_Pgn65235()

int16_t ECU_Pgn65235 ( uint8_t * pubDataV,
uint16_t uwSizeV,
uint8_t ubSrcAddrV,
uint8_t ubNetV )
Parameters
[in,out]pubDataVPointer to message data
[in]uwSizeVSize of data
[in]ubSrcAddrVSource address of PDU
[in]ubNetVJ1939 Network channel
Returns
Defined by J1939_Handler_Result_e

The DM11 handler clears active diagnostic trouble codes and responds with an ACK message

◆ J1939_DiagAddDtc()

void J1939_DiagAddDtc ( uint8_t ubNetV,
uint32_t ulSpnV,
uint8_t ubFmiV,
uint8_t ubCountV )
Parameters
[in]ubNetVJ1939 Network channel
[in]ulSpnVSPN - Suspect Parameter Number
[in]ubFmiVFMI - Failure Mode Identifier
[in]ubCountVOC - Occurrence Count

The function creates a DTC consisting of the parameters SPN (value range 0 .. 524287) ulSpnV, FMI (value range 0 .. 31) ubFmiV and OC (value range 0 .. 127) ubCountV. The DTC is added to the list of Active Diagnostic Trouble Codes (DM1).

◆ J1939_DiagAddDtcPrev()

void J1939_DiagAddDtcPrev ( uint8_t ubNetV,
uint32_t ulSpnV,
uint8_t ubFmiV,
uint8_t ubCountV )
Parameters
[in]ubNetVJ1939 Network channel
[in]ulSpnVSPN - Suspect Parameter Number
[in]ubFmiVFMI - Failure Mode Identifier
[in]ubCountVOC - Occurrence Count

The function creates a DTC consisting of the parameters SPN (value range 0 .. 524287) ulSpnV, FMI (value range 0 .. 31) ubFmiV and OC (value range 0 .. 127) ubCountV. The DTC is added to the list of Previously Active Diagnostic Trouble Codes (DM2).

◆ J1939_DiagClearDtc()

void J1939_DiagClearDtc ( uint8_t ubNetV)
Parameters
[in]ubNetVJ1939 Network channel

The function clears all DTCs from the list of Active Diagnostic Trouble Codes (DM1).

◆ J1939_DiagClearDtcPrev()

void J1939_DiagClearDtcPrev ( uint8_t ubNetV)
Parameters
[in]ubNetVJ1939 Network channel

The function clears all DTCs from the list of Previously Active Diagnostic Trouble Codes (DM2).

◆ J1939_DiagHoldEvent()

void J1939_DiagHoldEvent ( uint8_t ubNetV,
uint8_t ubBroadcastSignalV )
Parameters
[in]ubNetVJ1939 Network channel
[in]ubBroadcastSignalVSignal type defined by J1939_Broadcast_e

The function is called when a DM13 message is received.

A sample implementation of he function is located inside the j1939_user.c file.

void J1939_DiagHoldEvent(uint8_t ubNetV, uint8_t ubBroadcastSignalV)
{
if (ubBroadcastSignalV == eJ1939_BROADCAST_START)
{
//-------------------------------------------------------------------------------------------
// re-start DM01 transmission
//
(void) J1939_PgnSetCounter(ubNetV, 65226, 1);
}
if (ubBroadcastSignalV == eJ1939_BROADCAST_STOP)
{
//-------------------------------------------------------------------------------------------
// suspend DM01 transmission for 6 seconds
//
(void) J1939_PgnSetCounter(ubNetV, 65226, J1939_TmrCalcTicks(6000));
}
}
@ eJ1939_BROADCAST_START
Definition j1939_diag.h:92
@ eJ1939_BROADCAST_STOP
Definition j1939_diag.h:89
void J1939_DiagHoldEvent(uint8_t ubNetV, uint8_t ubBroadcastSignalV)
uint16_t J1939_TmrCalcTicks(uint16_t uwReqTimingV)
Calculate number of timer ticks.