I have a problem with CAN FD while requesting any UDS Service like (SvcDiagnosticSessionControl_2013).
I set the value of DLC (can_tx_dlc) in (uds_msgconfig request_config) with 15. But when I checked the value of DLC in (uds_msg out_msg_request.msg.can_info.dlc) after sending the service I found the value become 8.
Which make the request not as expected.
This is the code I use to send the UDS Services
Code: Select all
switch (serviceInformation.Service)
{
case uds_service.PUDS_SERVICE_SI_DiagnosticSessionControl:
UDSApi.uds_svc_param_dsc paramDSC = (UDSApi.uds_svc_param_dsc)serviceInformation.ParametersOfService[0];
status = UDSApi.SvcDiagnosticSessionControl_2013(mConnectedPeakChannel, mRequesetMappingInfo.MessageConfig, out mRequest, paramDSC);
break;
case uds_service.PUDS_SERVICE_SI_ReadDataByIdentifier:
UDSApi.uds_svc_param_di[] identifiers = { UDSApi.uds_svc_param_di.FD35};
status = UDSApi.SvcReadDataByIdentifier_2013(mConnectedPeakChannel, mRequesetMappingInfo.MessageConfig, out mRequest, identifiers, (UInt32)identifiers.Length);
break;
case uds_service.PUDS_SERVICE_SI_WriteDataByIdentifier:
UDSApi.uds_svc_param_di DataIdentifier = (UDSApi.uds_svc_param_di)serviceInformation.ParametersOfService[0];
byte[] buffer = (byte[])serviceInformation.ParametersOfService[1];
status = UDSApi.SvcWriteDataByIdentifier_2013(mConnectedPeakChannel, mRequesetMappingInfo.MessageConfig, out mRequest, DataIdentifier, buffer, (UInt32)buffer.Length);
break;
case uds_service.PUDS_SERVICE_SI_SecurityAccess:
byte securityAccessType = Convert.ToByte(serviceInformation.ParametersOfService[0]);
byteBuffer = (byte[])serviceInformation.ParametersOfService[1];
status = UDSApi.SvcSecurityAccess_2013(mConnectedPeakChannel, mRequesetMappingInfo.MessageConfig, out mRequest, securityAccessType, byteBuffer, (UInt32)byteBuffer.Length);
break;
default:
break;
}
And these are the configurations for CAN FD:
Code: Select all
"f_clock_mhz=80, nom_brp=1, nom_tseg1=127, nom_tseg2=32, nom_sjw=32, data_brp=2, data_tseg1=27, data_tseg2=12, data_sjw=12"
Code: Select all
const UInt32 canRequestID = 0x73A;
const UInt32 canResponseID = 0x73C;
mRequesetMappingInfo = new MappingInformation
(
canRequestID,
canResponseID,
(UInt16)uds_address.PUDS_ADDRESS_ISO_15765_4_ADDR_TEST_EQUIPMENT,
(UInt16)uds_address.PUDS_ADDRESS_ISO_15765_4_ADDR_ECU_1
);
mResponseMappingInfo = new MappingInformation
(
canResponseID,
canRequestID,
(UInt16)uds_address.PUDS_ADDRESS_ISO_15765_4_ADDR_ECU_1,
(UInt16)uds_address.PUDS_ADDRESS_ISO_15765_4_ADDR_TEST_EQUIPMENT
);
Code: Select all
public MappingInformation(UInt32 canId, UInt32 responseCanId, UInt16 sourceAddress, UInt16 targetAddress)
{
//Set Mapping parameters.
mMappingInfo = new uds_mapping
{
can_id = canId,
can_id_flow_ctrl = responseCanId,
can_msgtype = cantp_can_msgtype.PCANTP_CAN_MSGTYPE_FD,
can_tx_dlc = 15
};
mMappingInfo.nai.protocol = uds_msgprotocol.PUDS_MSGPROTOCOL_ISO_15765_2_11B_NORMAL;
mMappingInfo.nai.target_type = cantp_isotp_addressing.PCANTP_ISOTP_ADDRESSING_PHYSICAL;
mMappingInfo.nai.source_addr = sourceAddress;
mMappingInfo.nai.target_addr = targetAddress;
mMappingInfo.nai.extension_addr = 0;
//Set Message Configurations
mMessageConfig = new uds_msgconfig
{
type = uds_msgtype.PUDS_MSGTYPE_USDT,
nai = mMappingInfo.nai,
can_id = mMappingInfo.can_id,
can_msgtype = mMappingInfo.can_msgtype,
can_tx_dlc = mMappingInfo.can_tx_dlc
};
}