I have a question want to ask for help ,after send SvcDiagnosticSessionControl(10 03) services,then TesterPresent Sevices will be send Automatic in period. I have see someone ask for this question and solve it .so I did as the example by the step .but Why I did not worked
my code as follwing,can you help me changed it
Code: Select all
TPUDSStatus status;
status = UDSApi.SvcDiagnosticSessionControl(m_PcanHandle, ref UDSMsg, UDSApi.TPUDSSvcParamDSC.PUDS_SVC_PARAM_DSC_ECUEDS);
if (status == TPUDSStatus.PUDS_ERROR_OK)
{
status = UDSApi.WaitForService(m_PcanHandle, out ResponseMsg, ref UDSMsg, out UDSMsg);
if (status == TPUDSStatus.PUDS_ERROR_OK)
{
TPUDSSessionInfo sessionInfo = new TPUDSSessionInfo();
int sessionSize;
IntPtr sessionPtr;
sessionInfo.NETADDRINFO.SA = 0xF1;
sessionInfo.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_1;
sessionInfo.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
sessionInfo.NETADDRINFO.RA = 0x00;
sessionInfo.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
sessionSize = Marshal.SizeOf(sessionInfo);
sessionPtr = Marshal.AllocHGlobal(sessionSize);
Marshal.StructureToPtr(sessionInfo, sessionPtr, false);
status = UDSApi.GetValue(m_PcanHandle, TPUDSParameter.PUDS_PARAM_SESSION_INFO, sessionPtr, (uint)sessionSize);
sessionInfo = (TPUDSSessionInfo)Marshal.PtrToStructure(sessionPtr, typeof(TPUDSSessionInfo));
Marshal.FreeHGlobal(sessionPtr);
sessionInfo.SESSION_TYPE = (byte)UDSApi.TPUDSSvcParamDSC.PUDS_SVC_PARAM_DSC_DS;
status = UDSApi.SetValue(m_PcanHandle, TPUDSParameter.PUDS_PARAM_SESSION_INFO, sessionPtr, (uint)sessionSize);
}
}
best wishes