Supported platforms: CODESYS 2.3, CODESYS 3.5

 

List of J1939 Library's Data Types

J1939_PGN (STRUCT)

CODESYS 2.3CODESYS 2.3

Name of the Member

Data Type

Range

Description

CANVXD_CobId

DWORD

 

COBID which is used to define callback in CANVXD

PGN_Number

WORD

0..65535

Parameter group number

Priority

BYTE

0..7

Priority of the PGN

SourceAddress

BYTE

0..255

Source address of the PGN

DataPage

BYTE

0..3

2 datapage bits: DP & EDP. Value 0=none, 1=DP, 2=EDP, 3=Both

Destination

BYTE

0..255

Destination address of the PGN

CycleTime

WORD

5..65535

PGN send interval or expected PGN receive interval

DataLength

DWORD

1..117 440 505

Number of bytes in this PGN

PGNDataLength

DWORD

1..117 440 505

Space (number of bytes) reserved for PGN data. This value is initialized once in the beginning and not changed after that. Destination specific transport protocol uses this value to check if it can receive whole message packet or not.

NumberOfSPNs

WORD

1..65535

Number of SPNs in this PGN

pSPNs

POINTER TO J1939_SPN

 

Pointer to the beginning of the list of SPNs in this PGN

NewData

BOOL

TRUE / FALSE

New data received (=TRUE), active one program cycle

SendTrigger

BOOL

TRUE / FALSE

Trigger to send PGN immediately

SendTriggerOld

BOOL

TRUE / FALSE

Previous value of SendTrigger to detect rising edge

SendTriggerImmediately

BOOL

TRUE/FALSE

Trigger to send PGN immediately. Flag is reseted in same cycle when it is set TRUE.

Note! Set this flag to TRUE only once when PGN is wanted to send.

TimeStamp

DWORD

0..4294967295

Time stamp when this message was last sent or received

OldTimeStamp

DWORD

0..4294967295

Reference time stamp

Status

INT

-32768..32767

Error if negative, see J1939_PGNStatus

DataValid

BOOL

TRUE / FALSE

Data validity flag, if FALSE, data is old (not received in CycleTime)

AddTransmitListTime

DWORD

0..4294967295

Used with long data transmission (BAM). Time when PGN status changed to "wait

 for transmission".

UseChecksum

BOOL

TRUE/FALSE

If set to TRUE, a checksum is added to byte 8 of the message

UseMessageCounter

BOOL

TRUE/FALSE

If set to TRUE, a message counter is added to byte 8 of the message.

FillBitTrue

BOOL

TRUE/FALSE

If set to TRUE, unused bits are filled with 1 otherwise with 0

MessageCounter

BYTE

0-7, 15

Message counter value, rolls from 7 to 0, 15 means not available

TransferErrors

J1939_TransferErrors

J1939_TransferErrors

Possible transfer errors for multipacket sending

TransferSendBytes

DWORD

 

Send bytes for multipacket transfer

TransferIntervalForMessages

DWORD

Time

G_J1939_CYCLE_TIME_FOR_DT_MSG

TransferTimeout

DWORD

Time

Timeout for transport protocol and extended transport protocol

pRawData

DWORD

Pointer

Direct pointer to send data, used when extended transport protocol is used. Null pointer is considered as error for extended transport protocol. Extended  transport protocol is used when size of the sent data >  G_J1939_MAX_SIZE_OF_LONG_TRANSFER

CheckSpnSize

BOOL

TRUE/FALSE

If set TRUE J1939 checks SPN size.

CallBackPOUForPgn

WORD

 

Callback POU which is called when PGN is received

CallBackDataPointer

DWORD

Pointer

Callback data pointer

UseFastPacketProtocol

BOOL

TRUE/FALSE

If set to TRUE, NMEA 2000 Fast Packet protocol is used for this PGN.

FastPacketSequenceNumber

BYTE

 

Fast packet sequence number.

 

CODESYS 3.5CODESYS 3.5

Name of the Member

Data Type

Range

Description

CANVXD_CobId

DWORD

 

COBID which is used to define callback in CANVXD.

PGN_Number

WORD

0..65535

Parameter group number.

Priority

BYTE

0..7

Priority of the PGN.

SourceAddress

BYTE

0..255

Source address of the PGN.

DataPage

BYTE

0..3

Data page.

Destination

BYTE

0..255

Destination address of the PGN.

CycleTime

WORD

0..65535

PGN send interval or expected PGN receive interval.

DataLength

DWORD

0…117 440 505

Number of bytes in this PGN.

PGNDataLength

DWORD

0…117 440 505

Space (number of bytes) reserved for PGN data. This value is initialized once in the beginning and not changed after that. Destination specific transport protocol uses this value to check if it can receive whole message packet or not.

NumberOfSPNs

WORD

 

Number of SPNs in this PGN.

pSPNs

POINTER TO J1939_SPN

 

Pointer to the beginning of the list of SPNs in this PGN.

NewData

BOOL

TRUE / FALSE

New data received (=TRUE), active one program cycle.

SendTrigger

BOOL

TRUE / FALSE

Trigger to send PGN immediately.

SendTriggerOld

BOOL

TRUE / FALSE

Previous value of SendTrigger to detect rising edge.

SendTriggerImmediately

BOOL

TRUE / FALSE

Trigger to send PGN immediately. The flag is reset automatically after sending.

TimeStamp

DWORD

 

Time stamp when this message was last sent or received.

OldTimeStamp

DWORD

 

Reference time stamp.

Status

INT

 

Error if negative, see J1939_PGNStatus.

DataValid

BOOL

TRUE / FALSE

Data validity flag, if FALSE, data is old (not received in CycleTime).

AddTransmitListTime

DWORD

 

Used with long data transmission (BAM). Time when PGN status changed to "wait

 for transmission".

UseChecksum

BOOL

TRUE / FALSE

If set to TRUE, a checksum is added to byte 8 of the message.

UseMessageCounter

BOOL

TRUE / FALSE

If set to TRUE, a counter is added to byte 8 of the message.

The counter is incremented each time the message is sent.

Note! Counter and Checksum can be used simultaneously, both using 4 bits of the byte.

FillBitTrue

BOOL

TRUE / FALSE

If TRUE, unused bits are filled with 1 otherwise with 0.

MessageCounter

BYTE

 

Message counter. See 'UseMessageCounter'.

TransferErrors

J1939_TransferErrors

 

Possible transfer errors for multipacket sending.

TransferSendBytes

DWORD

 

Send bytes for multipacket transfer.

TransferIntervalForMessages

DWORD

 

DT message inhibit time.

TransferTimeout

DWORD

 

Timeout for transport protocol and extended transport protocol.

pRawData

DWORD

 

Direct pointer to send data, used when extended transport protocol is used. Null pointer is considered as error for extended transport protocol.  Extended transport protocol is used when size of the sent data > 1785 bytes.

CheckSpnSize

BOOL

TRUE / FALSE

If set TRUE J1939 checks SPN size.

itfCallback

IPGNCallbackHandler

 

Interface to callback POU.

pCallbackData

DWORD

 

Callback data pointer.

UseFastPacketProtocol

BOOL

TRUE / FALSE

If set to TRUE, NMEA 2000 Fast Packet protocol is used for this PGN.

FastPacketSequenceNumber

BYTE

 

Fast packet sequence number.

 

 

J1939_PGNStatus (ENUM)

Name of the Member

Description

 Value

J1939_PGN_SPNUninitialized

SPN data pointer and size are null. (PGN Extract incomplete.)

-7

J1939_PGN_pSPNDataNULL

SPN data pointer in the SPN is NULL

-6

J1939_PGN_pSPNNULL

SPN pointer in the PGN is NULL

-5

J1939_PGN_MultiPacketBufSize

Multi packet buffer size too small

-4

J1949_PGN_BAM_Failure

Broadcast announcement message arrived, before previous was completed.

-3

J1939_PGN_WrongSeqNbr

Wrong sequence number

-2

J1939_PGN_Timeout

PGN timed out.

-1

J1939_PGN_Idle

Idle, status after start.

 0

J1939_PGN_Receiving

Receiving multi packet message.

 1

J1939_PGN_DataReady

Data received and extracted.

 2

J1939_PGN_WaitTransmission

Waiting transmission. Used with long transfer

 3

J1939_PGN_Transmitting

Transmitting multi packet message

 4

J1939_PGN_Transmitting_ETP

Transmitting extended transport protocol message

 5

 

 

J1939_pPGN (STRUCT)

Name of the Member

Data Type

Default value

Description

pPGN

POINTER TO J1939_PGN

-

Pointer to PGN

 

 

J1939_ReturnCodes (ENUM)

CODESYS 2.3CODESYS 2.3

Name of the Member

Description

 Value

J1939_ERR_None

Status OK

0000 h

J1939_ERR_pRxPGNNULL

i_pRxPGNs pointer null, when number of Rx PGNs > 0

8000 h

J1939_ERR_pTxPGNNULL

i_pTxPGNs pointer null, when number of Tx PGNs > 0

8001 h

J1939_ERR_pPGNListNULL

i_pPGNList pointer null, when long transfer is needed ( PGN DataLength > 8)

8002 h

J1939_ERR_RxRegInit

CobID registering failure.

8003 h

J1939_ERR_TxSendFail

Sending of Tx PGN failed.

8004 h

J1939_ERR_pSPNNULL

SPN pointer not initialized.

8005 h

J1939_ERR_MultipacketInit

Multi packet pointer null.

8006 h

J1939_ERR_PGNDataLength

PGN DataLength is over G_J1939_MAX_SIZE_OF_LONG_TRANSFER or size reserved for PGN is smaller than received data size

8007 h

J1939_ERR_pRxPGNNULL

pRxPGN pointer null in pointer array

8008 h

J1939_ERR_pTxPGNNULL

pTxPGN pointer null in pointer array

8009 h

J1939_ERR_pSPNDataNULL

SPN data pointer null.

800A h

J1939_ERR_SPNUninitialized

SPN is uninitialized. (size and data pointer are null)

800B h

J1939_ERR_InvalidCANbusNbr

CAN bus number out of range.

800C h

J1939_ERR_InvalidControlByte

Invalid transport protocol connection management control byte

800D h

J1939_ERR_MultipacketTimeout

Timeout in transport protocol.

800E h

J1939_ERR_NullPointer

Generic null pointer error.

800F h

J1939_ERR_RX_ListFull

Can not add PGN, maximum number of rx PGNs reached.

8010 h

J1939_ERR_TX_ListFull

Can not add PGN, maximum number of tx PGNs reached.

8011 h

J1939_ERR_RQST_ListFull

Reserved size for request callbacks in G_J1939_MAX_NBR_OF_RQST_CALLBACKS is too low.

8012 h

 

CODESYS 3.5CODESYS 3.5

Name of the Member

Description

 Value

J1939_ERR_None

Status OK

0000 h

J1939_ERR_pRxPGNNULL

i_pRxPGNs pointer null, when number of Rx PGNs > 0

8000 h

J1939_ERR_pTxPGNNULL

i_pTxPGNs pointer null, when number of Tx PGNs > 0

8001 h

J1939_ERR_pPGNListNULL

i_pPGNList pointer null, when long transfer is needed ( PGN DataLength > 8)

8002 h

J1939_ERR_RxRegInit

CobID registering failure.

8003 h

J1939_ERR_TxSendFail

Sending of Tx PGN failed.

8004 h

J1939_ERR_pSPNNULL

SPN pointer not initialized.

8005 h

J1939_ERR_MultipacketInit

Multi packet pointer null.

8006 h

J1939_ERR_PGNDataLength

PGN DataLength is over G_J1939_MAX_SIZE_OF_LONG_TRANSFER or size reserved for PGN is smaller than received data size

8007 h

J1939_ERR_pRxPGNNULL

pRxPGN pointer null in pointer array

8008 h

J1939_ERR_pTxPGNNULL

pTxPGN pointer null in pointer array

8009 h

J1939_ERR_pSPNDataNULL

SPN data pointer null.

800A h

J1939_ERR_SPNUninitialized

SPN is uninitialized. (size and data pointer are null)

800B h

J1939_ERR_InvalidCANbusNbr

CAN bus number out of range.

800C h

J1939_ERR_InvalidControlByte

Invalid transport protocol connection management control byte

800D h

J1939_ERR_MultipacketTimeout

Timeout in transport protocol.

800E h

J1939_ERR_NullPointer

Generic null pointer error.

800F h

J1939_ERR_RX_ListFull

Can not add PGN, maximum number of rx PGNs reached.

8010 h

J1939_ERR_TX_ListFull

Can not add PGN, maximum number of tx PGNs reached.

8011 h

J1939_ERR_RQST_ListFull

Reserved size for request callbacks in G_J1939_MAX_NBR_OF_RQST_CALLBACKS is too low.

8012 h

J1939_ERR_RQST_NotInUse

Request PGNs not set to use before adding them.

8013 h

J1939_ERR_InvalidSPNFMIConversionMethod

Given invalid SPN/FMI conversion method.

8014 h

J1939_ERR_DM1LogFull

DM1 log is full.

8015 h

J1939_ERR_DM2LogFull

DM2 log is full.

8016 h

J1939_ERR_DMLogSizeTooSmall

DM1 log maximum size is too small. Minimum size is 2 DTCs.

8017 h

J1939_ERR_DM2LogSavingFailed

Saving the DM2 log failed.

8018 h

J1939_ERR_DataOutOfRange

Data out of specified range.

8019 h

 

 

 

J1939_FastPacketTransfer (STRUCT)

CODESYS 2.3CODESYS 2.3

Name of the Member

Data Type

Range

Description

pBasePGN

POINTER TO J1939_PGN

-

Pointer to received PGN

TotalNumberOfBytes

BYTE

2..255

Number of bytes in fast transfer.

FrameNumber

BYTE

 

Frame number of packet.

SequenceNumber

BYTE

 

Sequence number of packet.

DataBuffer

ARRAY [0..G_J1939_MAX_SIZE_OF_FAST_TRANSFER] OF BYTE

 

Fast-packet data buffer.

DataBufferIndex

BYTE

0..G_J1939_MAX_SIZE_OF_FAST_TRANSFER

Data buffer index.

 

 

J1939_MultiPackerTransfer (STRUCT)

CODESYS 2.3CODESYS 2.3

Name of the Member

Data Type

Range

Description

pBasePGN

POINTER TO J1939_PGN

-

Pointer to received PGN

TotalNumberOfPackets

BYTE

2..255

TP: Number of packets in multipacket transfer

MaxNumberOfPackets

BYTE

2..255

TP: The message originator uses the maximum number of packets to limit the responder CTS request. Used only with destination spesific communication.

SequenceNumber

BYTE

1..255

TP/ETP: Sequence number of packet

AllowDataTransfer

BOOL

TRUE/FALSE

Data transfer allowed.

DestinationSpecific

BOOL

TRUE/FALSE

Multi packet transfer is destination specific i.e. peer to peer connection

DataMessageSize

DWORD

0…117 440 505

TP/ETP: Size of data message

NumberOfPacketsOffset

BYTE

0…255

ETP: Number of packets to apply next data offset

PacketNumForNextCTSMsg

DWORD

 

TP/ETP: Packet number when next CTS msg should be send or waited. Used only with destination spesific communication

ExtendedTransfer

BOOL

TRUE/FALSE

If true extended transfer used. Extended transfer protocol is used if data size > G_J1939_MAX_SIZE_OF_LONG_TRANSFER

DataOffset

DWORD

 

ETP: Offset for send data

DataPacketNumber

DWORD

 

ETP: Next packet number

DataBuffer

ARRAY [0..J1939_MAX_SIZE_OF_LONG_TRANSFER] OF BYTE

0

Data buffer for receiving

pDataDirect

DWORD

Pointer

Pointer to data if extended transport protocol is used. In this case data is send directly without copying to temp data buffer.

 

 

 

J1939_SPNFMI (STRUCT)

Name of the Member

Data Type

Range

Description

SPN

DWORD

0..524287

Suspect Parameter Number

FMI

BYTE

0..31

Failure Mode Identifier

OC

BYTE

0..255

Occurrence Count

CM

BOOL

TRUE / FALSE

Conversion Method

 

J1939_SPN (STRUCT)

J1939_SPN structure defines one SPN. The structure consists of a pointer to the actual variable containing the value, and the size of the value in bits.

 

Name of the Member

Data Type

Range

Description

Size

DWORD

0…4294967296

Size of the SPN (bits)

pData

POINTER TO BYTE

-

Pointer to data

 

 

J1939_TP_CM (ENUM)

Transport protocol connection management enumeration.

 

CODESYS 2.3CODESYS 2.3

Enumeration is also used for ISO 11783-3 extended transport protocol connection management.

 

Name of the Member

Description

 Value

J1939_TP_CM_RTS

TP Request to send

16

J1939_TP_CM_CTS

TP Clear to send

17

J1939_TP_CM_EOMA

TP End of message acknowledgement

19

J1939_ETP_CM_RTS

ETP Request to send

20

J1939_ETP_CM_CTS

ETP clear to send

21

J1939_ETP_CM_DPO

ETP packet offset

22

J1939_ETP_CM_EOMA

ETP End of message acknowledgement

23

J1939_TP_CM_BAM

TP Broadcast Announce Message

32

J1939_TP_CM_ConnAbort

Connection aborted

255

J1939_TP_DT

TP Data transfer

256

J1939_ETP_DT

ETP Data transfer

257

 

 

 

J1939_TransferErrors (ENUM)

Enumeration defines possible errors in data transfer. Used as abort codes in destination specific transport protocol (see J1939-21 or ISO 11783-3:2014).

 

Name of the Member

Description

 Value

J1939_TRS_ERR_SUCCESS

Transfer success

0

J1939_TRS_ERR_SESSION_ON

Already in one or more connection-managed sessions AND cannot support another

1

J1939_TRS_ERR_NO_SYS_RES

System resources were needed for another task so this connection managed session was terminated

2

J1939_TRS_ERR_TIMEOUT

A timeout occurred and this is the connection abort to close the session

3

J1939_TRS_ERR_WRONG_CTS_MSG

CTS messages received when data transfer is in progress

4

J1939_TRS_ERR_RETRANS_LIMIT_REACHED

Maximum retransmit request limit reached

5

J1939_TRS_ERR_UNEXCP_DATA_PACKET

Unexpected data transfer packet

6

J1939_TRS_ERR_BAD_SEG_NBR

Bad sequence number and software is not able to recover

7

J1939_TRS_ERR_DUP_SEQ_NBR

Duplicate sequence number and software is not able to recover

8

 

 

J1939_RequestedPGN (STRUCT)

This is PGN request structure for received EA00 requests. Defines the requested PGN and callback POU pair.

 

CODESYS 2.3CODESYS 2.3

Name of the Member

Data Type

Range

Description

PGN

WORD

0…65535

Requested PGN

CallbackPOU

WORD

INDEXOF POU

POU index which is called when PGN is requested

pPGNData

DWORD

Pointer

Callback parameter: Pointer to PGN structure

pUserData

DWORD

Pointer

Callback parameter: Pointer to user specific data

 

 

 

J1939_RequestedPGNData (STRUCT)

Structure defines PGN request callback’s data. Callback data is set when the callback is triggered.

 

Name of the Member

Data Type

Range

Description

SA

BYTE

0…255

Source address of request

DA

BYTE

0…255

Destination address for request

pPGNData

DWORD

Pointer

Callback parameter: Pointer to PGN structure

pUserData

DWORD

Pointer

Pointer Callback parameter: Pointer to user specific data

 

J1939_RequestedPGNList (STRUCT)

Received EA00 request callback list.

 

CODESYS 2.3CODESYS 2.3

Name of the Member

Data Type

Range

Description

RequestPGN

ARRAY [1..G_J1939_MAX_NBR_OF_RQST_CALLBACKS] OF J1939_RequestedPGN

Array

List of defined PGN request callbacks

NumberOfRequestPGN

WORD

0… G_J1939_MAX_NBR_OF_RQST_CALLBACKS

Amount of currently defined callbacks.

 

 

 

 

 

 

 

 

 

Source file Topic000441.htm

Last updated 13-Jun-2024