The ECU I am trying to communicate with can have an address from 1 through 9.
So I set up the UDS mapping for these IDs. In the current situation I know the ECU will have address 4, so I have that ID hardcoded in the config.
Code: Select all
config_physical.can_id = 0x0CDA04F1UL;
config_physical.can_msgtype = PCANTP_CAN_MSGTYPE_EXTENDED;
config_physical.can_tx_dlc = 8U;
config_physical.nai.protocol = PUDS_MSGPROTOCOL_ISO_15765_2_29B_NORMAL;
config_physical.nai.target_type = PCANTP_ISOTP_ADDRESSING_PHYSICAL;
config_physical.type = PUDS_MSGTYPE_USDT;
for (uint8_t i = 1; i <= 9; i++)
{
source_mapping.can_id = 0x0CDA00F1UL | (i << 8); // Client ID
source_mapping.can_id_flow_ctrl = 0x0CDAF100UL | i; // Server ID
source_mapping.can_msgtype = config_physical.can_msgtype;
source_mapping.can_tx_dlc = config_physical.can_tx_dlc;
source_mapping.nai = config_physical.nai;
UdsStatus = UDS_AddMapping_2013(client_handle, &source_mapping);
(void)UDS_GetErrorText_2013(UdsStatus, 0, err_msg_buff, 4095);
qCritical() << QString(err_msg_buff);
response_mapping = source_mapping;
response_mapping.can_id = source_mapping.can_id_flow_ctrl;
response_mapping.can_id_flow_ctrl = source_mapping.can_id;
response_mapping.nai.source_addr = source_mapping.nai.target_addr;
response_mapping.nai.target_addr = source_mapping.nai.source_addr;
UdsStatus = UDS_AddMapping_2013(client_handle, &response_mapping);
(void)UDS_GetErrorText_2013(UdsStatus, 0, err_msg_buff, 4095);
qCritical() << QString(err_msg_buff);
}
When I request tester present
Code: Select all
UdsStatus = UDS_SvcTesterPresent_2013(client_handle, config_physical, &msg_request, PUDS_SVC_PARAM_DSC_DS);

Can I specify which CAN-ID the client should use?