J1939 Structures
J1939_MSG is the message structure which accepts J1939 parameters and data.
Example:
J1939_MSG objMsg;
| Member s of J1939_MSG | Description |
|---|---|
| id | Extended CAN identifier used for J1939 message identification.Contains PGN, Priority, PDU Format, Pdu Specific and Source Address. Example: To set identifier, objMsg.id**=**0x1cfefefe.To get identifier, unsigned int nId = id; |
| dlc | Data Length in bytes [0-1784] |
| cluster | channel on which the frame is received or to be transmitted |
| data[1785] | Message data |
| timeStamp | Received frame timestamp in 100 microseconds |
| bool byteAt(int index, unsigned char val) | To set data byte (8 bit). Possible index: [0-7]. Example: byteAt(0, 10); ‘0’ is index, 10 is value |
| bool wordAt(int index, unsigned short val) | To set data word (16 bit). Possible index: [0-3]. Example: wordAt(0, 10); ‘0’ is index, 10 is value. |
| bool longAt(int index, unsigned long val) | To set data word (32 bit). Possible index: [0-1]. Example: longAt(0, 10); ‘0’ is index, 10 is value. |
Accessing J1939 specific parameters:
Parameter Description extendedId Extended CAN identifier used for J1939 message identification. Example: id.extendedId = 0x1cfefefe void setId(unsigned int _extendedId) To set extended identifier. Example: id.setId(0x1cfefefe); void setPGN(unsigned int _pgn) To set Parameter Group Number. Example: id.setPGN(0xfefe); void setPriority(unsigned char _priority) To set Priority parameter in PGN. Example: id.setPriority(1); void setPDUFormat(unsigned char _pduFormat) To set PDU Format in PGN. Example: id.setPDUFormat(0xfe); void setPDUSpecific(unsigned char _pduSpecific) To set PDU Specific in PGN. Example: id.setPDUSpecific(0xfe); void setDataPage(unsigned char _dataPage) To set data Page in PGN void setSourceAddress(unsigned char _sourceAddress) To set Source Address. Example: id.setSourceAddress(0xfe); unsigned int getPGN() To get PGN of J1939 message. Example: unsigned int pgn = id.getPGN(); unsigned char getPriority() To get Priority. Example: unsigned char priority = id.getPriority(); unsigned char getPDUFormat() To get Pdu Format. Example: unsigned char pduFormat = id.getPDUFormat(); unsigned char getPDUSpecific() To get Pdu Specific. Example: unsigned char pduSpecific = id.getPDUSpecific(); unsigned char getDataPage() To get data page. Example: unsigned char dataPage = id.getDataPage(); unsigned char getSourceAddress() To get Source Address. Example: unsigned char nPduSpecific = id.getSourceAddress();
Authoritative source: BUSMASTER DITA help source stcan_struct_J1939.dita, compiled into BUSMASTER.CHM with the application.