I have a trouble with the implementation of the UDS library.
I want change the default CAN ID for the standard: 0x7E0 to another value like: 0x420 for example.
I try this:
Code: Select all
uint16_t adress_ecu = (uint16_t)(0x420);
address_diagtool = (uint16_t)(0x421);
// Initialize a physical configuration
config_physical.can_id = adress_ecu;
config_physical.can_msgtype = PCANTP_CAN_MSGTYPE_STANDARD;
config_physical.nai.protocol = PUDS_MSGPROTOCOL_ISO_15765_2_11B_NORMAL;
config_physical.nai.target_type = PCANTP_ISOTP_ADDRESSING_PHYSICAL;
config_physical.type = PUDS_MSGTYPE_USDT;
config_physical.nai.source_addr = address_diagtool;
config_physical.nai.target_addr = adress_ecu;
config_physical.nai.extension_addr = 0;
qDebug() << " config_physical.nai.source_addr = " << QString::number(address_diagtool);
qDebug() << " config_physical.nai.target_addr = " << QString::number(adress_ecu);
uds_msg request;
uds_msg response;
uds_msg confirmation;
QString var_debug = "";
memset(&request, 0, sizeof(uds_msg));
memset(&response, 0, sizeof(uds_msg));
memset(&confirmation, 0, sizeof(uds_msg));
cantp_mapping mapping;
cantp_can_msgtype can_msgtype;
cantp_mapping reverse_mapping;
memset(&mapping, 0, sizeof(cantp_mapping));
memset(&reverse_mapping, 0, sizeof(cantp_mapping));
can_msgtype = PCANTP_CAN_MSGTYPE_STANDARD;
mapping.can_id = address_diagtool;
mapping.can_id_flow_ctrl = adress_ecu;
mapping.can_msgtype = can_msgtype;
mapping.netaddrinfo.extension_addr = 0x00;
mapping.netaddrinfo.format = PCANTP_ISOTP_FORMAT_NORMAL;
mapping.netaddrinfo.msgtype = PCANTP_ISOTP_MSGTYPE_DIAGNOSTIC;
mapping.netaddrinfo.source_addr = address_diagtool;
mapping.netaddrinfo.target_addr = adress_ecu;
mapping.netaddrinfo.target_type = PCANTP_ISOTP_ADDRESSING_PHYSICAL;
// Create the associated isotp reversed mapping:
reverse_mapping = mapping;
reverse_mapping.can_id = mapping.can_id_flow_ctrl;
reverse_mapping.can_id_flow_ctrl = mapping.can_id;
reverse_mapping.netaddrinfo.source_addr = mapping.netaddrinfo.target_addr;
reverse_mapping.netaddrinfo.target_addr = mapping.netaddrinfo.source_addr;
status_cantp = CANTP_AddMapping_2016((cantp_handle)can_handler, &mapping);
qDebug() << " status ADD MAPPING = " << QString::number(status_cantp);
status_cantp = CANTP_AddMapping_2016((cantp_handle)can_handler, &reverse_mapping);
qDebug() << " status ADD MAPPING = " << QString::number(status_cantp);
The function "CANTP_AddMapping_2016" return errort code 14 => 0x0E => PCANTP_ERRSTATUS_MAPPING_INVALID.
And I don't understood why, I have this error.
I also test this, like indicated in the user manual Section: Usage in a Non-Standardized Context :
Code: Select all
uds_mapping mappings[256];
uint16_t count;
uint16_t i;
status = UDS_GetMappings_2013(tp_handle, mappings, 256, &count);
if(!UDS_StatusIsOk_2013(status, PUDS_STATUS_OK, false))
{
qDebug() << "Get mappings failed.\n";
}
for (i = 0; i < count; i++)
{
status = UDS_RemoveMapping_2013(tp_handle, mappings[i]);
if (!UDS_StatusIsOk_2013(status, PUDS_STATUS_OK, false))
{
qDebug() << "Remove mapping failed.\n";
}
else
{
qDebug() << "Remove mapping OK.\n";
}
}
uint16_t param = address_diagtool;
status = UDS_SetValue_2013(tp_handle, PUDS_PARAMETER_SERVER_ADDRESS, ¶m, sizeof(param));
qDebug() << " status new parameter address_diagtool = " << QString::number(status);
// Listen to address 0x11
param = adress_ecu;
status = UDS_SetValue_2013(tp_handle, PUDS_PARAMETER_ADD_LISTENED_ADDRESS, ¶m,sizeof(param));
qDebug() << " status new parameter address ECU = " << QString::number(status);
Do you have an idea, what I do wrong? Or do you have an example of implementation of change CAN ID standard?
Thanks in advance!
Best regards.