UDS API

A free API for the communication with control devices according to UDS (ISO 14229-1)
hanxueqiong129
Posts: 7
Joined: Mon 7. Jan 2019, 07:05

UDS API

Post by hanxueqiong129 » Mon 7. Jan 2019, 08:47

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

K.Wagner
Software Development
Software Development
Posts: 1082
Joined: Wed 22. Sep 2010, 13:36

Re: UDS API

Post by K.Wagner » Mon 7. Jan 2019, 09:16

Best regards,
Keneth

hanxueqiong129
Posts: 7
Joined: Mon 7. Jan 2019, 07:05

Re: UDS API

Post by hanxueqiong129 » Mon 7. Jan 2019, 09:44

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

hanxueqiong129
Posts: 7
Joined: Mon 7. Jan 2019, 07:05

Re: UDS API

Post by hanxueqiong129 » Mon 7. Jan 2019, 09:53

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

K.Wagner
Software Development
Software Development
Posts: 1082
Joined: Wed 22. Sep 2010, 13:36

Re: UDS API

Post by K.Wagner » Mon 7. Jan 2019, 10:08

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).
Best regards,
Keneth

hanxueqiong129
Posts: 7
Joined: Mon 7. Jan 2019, 07:05

Re: UDS API

Post by hanxueqiong129 » Mon 7. Jan 2019, 10:26

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);
               }
            }            
        }
Last edited by M.Gerber on Mon 7. Jan 2019, 10:37, edited 1 time in total.
Reason: Inserted code tag for improved readability

K.Wagner
Software Development
Software Development
Posts: 1082
Joined: Wed 22. Sep 2010, 13:36

Re: UDS API

Post by K.Wagner » Mon 7. Jan 2019, 10:50

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].
Best regards,
Keneth

hanxueqiong129
Posts: 7
Joined: Mon 7. Jan 2019, 07:05

Re: UDS API

Post by hanxueqiong129 » Mon 7. Jan 2019, 11:01

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

K.Wagner
Software Development
Software Development
Posts: 1082
Joined: Wed 22. Sep 2010, 13:36

Re: UDS API

Post by K.Wagner » Mon 7. Jan 2019, 11:38

You need to disable it in order to configured again. Basically, you need to follow these staps
  1. Get the current session:

    Code: Select all

    UDS_GetValue(Channel, PUDS_PARAM_SESSION_INFO, &sessionInfo, sizeof(TPUDSSessionInfo));
    
  2. 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));
    
  3. 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
    ...
    
  4. 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));
    
  5. Check that the automatic TesterPresent is enabled and using functional addressing
Best regards,
Keneth

hanxueqiong129
Posts: 7
Joined: Mon 7. Jan 2019, 07:05

Re: UDS API

Post by hanxueqiong129 » Mon 7. Jan 2019, 11:47

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?

Post Reply