18EA80'SA' 是发送14ef23 'SA'的PNG请求,此时如果参数j1939->this_proprietary.proprietary_A.total_bytes小于等于8,那么反馈的Message iD就是14ef23 'SA'
如果参数j1939->this_proprietary.proprietary_A.total_bytes大于8的话,就会反馈Multiple messages,通过TP_CM和TP_DT反馈
[C] 纯文本查看 复制代码 ENUM_J1939_STATUS_CODES SAE_J1939_Response_Request_Proprietary_A(J1939* j1939, uint8_t DA) {
/* Find the length of the array fields */
uint16_t length_of_each_field = j1939->this_proprietary.proprietary_A.total_bytes;
if (length_of_each_field < 9) {
/* If each field have the length 8 or less, then we can send Proprietary A as it was a normal message */
uint32_t ID = (0x14EF23 << 8) | j1939->information_this_ECU.this_ECU_address;
uint8_t data[8];
memcpy(data, j1939->this_proprietary.proprietary_A.data, length_of_each_field);
return CAN_Send_Message(ID, data);
}
else {
/* Multiple messages - Load data */
j1939->this_ecu_tp_cm.total_message_size = length_of_each_field;
memcpy(j1939->this_ecu_tp_dt.data, j1939->this_proprietary.proprietary_A.data, length_of_each_field);
/* Send TP CM */
j1939->this_ecu_tp_cm.number_of_packages = j1939->this_ecu_tp_cm.total_message_size % 8 > 0 ? j1939->this_ecu_tp_cm.total_message_size / 8 + 1 : j1939->this_ecu_tp_cm.total_message_size / 8; /* Rounding up */
j1939->this_ecu_tp_cm.PGN_of_the_packeted_message = PGN_PROPRIETARY_A;
j1939->this_ecu_tp_cm.control_byte = DA == 0xFF ? CONTROL_BYTE_TP_CM_BAM : CONTROL_BYTE_TP_CM_RTS; /* If broadcast, then use BAM control byte */
ENUM_J1939_STATUS_CODES status = SAE_J1939_Send_Transport_Protocol_Connection_Management(j1939, DA);
if (status != STATUS_SEND_OK) {
return status;
}
/* Check if we are going to send it directly (BAM) - Else, the TP CM will send a RTS control byte to the other ECU and the ECU will answer with control byte CTS */
if (j1939->this_ecu_tp_cm.control_byte == CONTROL_BYTE_TP_CM_BAM) {
return SAE_J1939_Send_Transport_Protocol_Data_Transfer(j1939, DA);
}
return status;
}
}
|