How to specify transmit CAN-ID?
Posted: Mon 20. Mar 2023, 15:01
I'm trying to send a UDS request with a specific ID, but I am unable to figure out how I should achieve this.
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.
With CAN-TP Write I can specify which map to use, but for UDS I don't see a similar function.
When I request tester present
I do pass the config, but the ID that is being used to send the request is not the ID in the config. Instead it uses the ID of the latest added UDS map, in this case it's using the last added response map their CAN-ID (0x0CDAF109), however I want it to be 0x0CDA04F1. It is quite possible that I misunderstand the concept of maps
Can I specify which CAN-ID the client should use?
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?