Page 1 of 2
UDS API
Posted: Mon 7. Jan 2019, 08:47
by hanxueqiong129
Dear Friend
Recently I have used UDS API to send some services.I have a question confusing me .when I send UDS_SvcDiagnosticSessioncontrol service TesterPresent service will be send in periods.The testerPresent service's ID is physical .I want to know How to change its Id to function. I don't see API used testerPresent service but it send this service. I hope you can help me solve this problem.Thank you very much
best wishes
Re: UDS API
Posted: Mon 7. Jan 2019, 09:16
by K.Wagner
Re: UDS API
Posted: Mon 7. Jan 2019, 09:44
by hanxueqiong129
Dear
Maybe I don't express my request clearly. I don't want to know how to mapping between ECU and Client.After I send 0x10 03 service 0x3E 80 service will be following .And the type of ID 0x3e service is physical ,I want to change this service's Id type only .I want to know how 0x3E service worked.
best wishes
Re: UDS API
Posted: Mon 7. Jan 2019, 09:53
by hanxueqiong129
Dear
As we all know ,after send 0x10 service,0x3e service send automatic.I want to know how to change this automatic service 's AddressingType
Re: UDS API
Posted: Mon 7. Jan 2019, 10:08
by K.Wagner
Hello,
ok, if I (now) understand well, you want to configure your diagnostic session to use a functional address for tester present, right? For this, you need to re-configure the current session information to specify the functional address. This is done using the function UDS_SetValue and the parameter PUDS_PARAM_SESSION_INFO - (PCAN-UDS API - User Manual, page 35).
Re: UDS API
Posted: Mon 7. Jan 2019, 10:26
by hanxueqiong129
Dear
like this ?
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 = 0x00;
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.SESSION_TYPE = (byte)UDSApi.TPUDSSvcParamDSC.PUDS_SVC_PARAM_DSC_DS;
status = UDSApi.SetValue(m_PcanHandle, TPUDSParameter.PUDS_PARAM_SESSION_INFO, sessionPtr, (uint)sessionSize);
}
}
}
Re: UDS API
Posted: Mon 7. Jan 2019, 10:50
by K.Wagner
Hello
yes, kind of. Just remember to set the
sessionInfo.NETADDRINFO.TA_TYPE to Functional.
Please note that the solution was actually in the very first answer you have received from my colleague U.Wilhelm: [
Disable TesterPresent].
Re: UDS API
Posted: Mon 7. Jan 2019, 11:01
by hanxueqiong129
Dear
need I to change sessionInfo.SESSION_TYPE = (byte)UDSApi.TPUDSSvcParamDSC.PUDS_SVC_PARAM_DSC_ECUEDS or PUDS_SVC_PARAM_DSC_ECUPS? if I set it as PUDS_SVC_PARAM_DSC_DS,is it mean disable TesterPresent Automatic?
best wishes
Re: UDS API
Posted: Mon 7. Jan 2019, 11:38
by K.Wagner
You need to disable it in order to configured again. Basically, you need to follow these staps
- Get the current session:
Code: Select all
UDS_GetValue(Channel, PUDS_PARAM_SESSION_INFO, &sessionInfo, sizeof(TPUDSSessionInfo));
- Disable the TesterPresent
Code: Select all
sessionInfo.SESSION_TYPE = PUDS_SVC_PARAM_DSC_DS;
result = UDS_SetValue(Channel, PUDS_PARAM_SESSION_INFO, &sessionInfo, sizeof(TPUDSSessionInfo));
- Configure the NETADDRINFO as needed, e.g. as functional:
Code: Select all
...
sessionInfo.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_FUNCTIONAL;
sessionInfo.NETADDRINFO.TA = 0xXX; // needs to match with your defined mapping
...
- Set the SESSION_TYPE to anything different than "PUDS_SVC_PARAM_DSC_DS" to activate the TesterPresent again with the new parameters.
Code: Select all
sessionInfo.SESSION_TYPE = PUDS_SVC_PARAM_XXX;
result = UDS_SetValue(Channel, PUDS_PARAM_SESSION_INFO, &session, sizeof(TPUDSSessionInfo));
- Check that the automatic TesterPresent is enabled and using functional addressing
Re: UDS API
Posted: Mon 7. Jan 2019, 11:47
by hanxueqiong129
Dear
Unluckly,I set it like you follwing s,but it is not worked ,the AddressType unchanged.
Code: Select all
TPUDSSessionInfo sessionInfo = new TPUDSSessionInfo();
int sessionSize;
IntPtr sessionPtr;
sessionInfo.NETADDRINFO.SA = 0xF1;
sessionInfo.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_OBD_FUNCTIONAL;
sessionInfo.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_FUNCTIONAL;
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.SESSION_TYPE = (byte)UDSApi.TPUDSSvcParamDSC.PUDS_SVC_PARAM_DSC_DS;
status = UDSApi.SetValue(m_PcanHandle, TPUDSParameter.PUDS_PARAM_SESSION_INFO, sessionPtr, (uint)sessionSize);
sessionInfo.SESSION_TYPE = (byte)UDSApi.TPUDSSvcParamDSC.PUDS_SVC_PARAM_DSC_ECUEDS;
status = UDSApi.SetValue(m_PcanHandle, TPUDSParameter.PUDS_PARAM_SESSION_INFO, sessionPtr, (uint)sessionSize);
I don't know where is wrong?