J1939 结构体
J1939_MSG 是用于接收 J1939 参数和数据的消息结构体。
示例:
J1939_MSG objMsg;
| Member s of J1939_MSG | Description |
|---|---|
| id | 用于 J1939 消息标识的扩展 CAN 标识符。包含 PGN、Priority、PDU Format、Pdu Specific 和 Source Address。示例:要设置标识符,objMsg.id**=**0x1cfefefe。要获取标识符,unsigned int nId = id; |
| dlc | 数据长度,以字节为单位 [0-1784] |
| cluster | 接收或传输帧的通道 |
| data[1785] | 消息数据 |
| timeStamp | 接收帧时间戳,以 100 微秒为单位 |
| bool byteAt(int index, unsigned char val) | 设置数据字节(8 位)。可能的索引:[0-7]。示例:byteAt(0, 10); ‘0’ 是索引,10 是值 |
| bool wordAt(int index, unsigned short val) | 设置数据字(16 位)。可能的索引:[0-3]。示例:wordAt(0, 10); ‘0’ 是索引,10 是值。 |
| bool longAt(int index, unsigned long val) | 设置数据字(32 位)。可能的索引:[0-1]。示例:longAt(0, 10); ‘0’ 是索引,10 是值。 |
访问 J1939 特定参数:
Parameter Description extendedId 用于 J1939 消息标识的扩展 CAN 标识符。示例:id.extendedId = 0x1cfefefe void setId(unsigned int _extendedId) 设置扩展标识符。示例:id.setId(0x1cfefefe); void setPGN(unsigned int _pgn) 设置参数组编号。示例:id.setPGN(0xfefe); void setPriority(unsigned char _priority) 设置 PGN 中的 Priority 参数。示例:id.setPriority(1); void setPDUFormat(unsigned char _pduFormat) 设置 PGN 中的 PDU Format。示例:id.setPDUFormat(0xfe); void setPDUSpecific(unsigned char _pduSpecific) 设置 PGN 中的 PDU Specific。示例:id.setPDUSpecific(0xfe); void setDataPage(unsigned char _dataPage) 设置 PGN 中的数据页 void setSourceAddress(unsigned char _sourceAddress) 设置源地址。示例:id.setSourceAddress(0xfe); unsigned int getPGN() 获取 J1939 消息的 PGN。示例:unsigned int pgn = id.getPGN(); unsigned char getPriority() 获取 Priority。示例:unsigned char priority = id.getPriority(); unsigned char getPDUFormat() 获取 Pdu Format。示例:unsigned char pduFormat = id.getPDUFormat(); unsigned char getPDUSpecific() 获取 Pdu Specific。示例:unsigned char pduSpecific = id.getPDUSpecific(); unsigned char getDataPage() 获取数据页。示例:unsigned char dataPage = id.getDataPage(); unsigned char getSourceAddress() 获取源地址。示例:unsigned char nPduSpecific = id.getSourceAddress();
权威来源: BUSMASTER DITA help source stcan_struct_J1939.dita, compiled into BUSMASTER.CHM with the application.