Dear sir
Abouting UDS APi I have some question want to ask for help .
because the customer asked the client send 10 83 /10 82/10 01,so In this diagnosticsession,I send 27 03/27 04and other services.But After the client send 27 03 and the ECU has response positive response,the 27 04 can't send .But when I Set breakpoints,step by step debugging,after receive positive response ,then 27 04 send normally.
but when I don't step by step debugging,although it receive positive response ,the status is PCAN-ERROR-No-Message,then it didn't continue send 27 04.
In other services ,if the client send the data 's length more than 8 ,after receive 30 00 10,the remain data is did not send
I want to know the reasons for this result.Thank you very much for help me solving it
best wishes
the UDS send SecurityAccess
-
- Software Development
- Posts: 305
- Joined: Mon 9. Sep 2013, 12:21
Re: the UDS send SecurityAccess
Dear H.Tina,
The problem you are describing is similar to your previous posts. You need to solve your problems step by step:
The problem you are describing is similar to your previous posts. You need to solve your problems step by step:
- 1. Make sure you are able to send and receive fragmented messages. If you are not able to receive fragmented message then you have a problem with the definition of your UDS mappings.
- 2. Having a response after you set a breakpoint is not relevant: you may not receive a response because you are not able to receive fragmented messages. When you are debugging step by step, UDS timeouts probably occur and the ECU's response may not be a fragmented message anymore but a negative response contained in a single CAN frame. That could explain why you are receiving a response.
Best regards,
Fabrice
Fabrice
Re: the UDS send SecurityAccess
dear sir
I am sure I mapping address right.because I have send data and receive data normally before
the code is as following
sometimes,it can get into if(OK==res),sometimes it can not get into if(OK==res).I can receive postive response all the time.the picture is the result,after receive the postive respons ,the 27 22 cant not send,then all the service is stop.
I am sure I mapping address right.because I have send data and receive data normally before
the code is as following
Code: Select all
public uint SecurityAcess()
{
uint res = ERROR;
TPUDSStatus status;
TPUDSMsg request = new TPUDSMsg();
TPUDSMsg response = new TPUDSMsg();
request.NETADDRINFO.SA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_TEST_EQUIPMENT;
request.NETADDRINFO.TA = (byte)TPUDSAddress.PUDS_ISO_15765_4_ADDR_ECU_8;
request.NETADDRINFO.TA_TYPE = TPUDSAddressingType.PUDS_ADDRESSING_PHYSICAL;
request.NETADDRINFO.RA = 0x00;
request.NETADDRINFO.PROTOCOL = TPUDSProtocol.PUDS_PROTOCOL_ISO_15765_2_11B;
byte[] buffer = new byte[0];
byte[] buffer1 = new byte[4];
status = UDSApi.SvcSecurityAccess(m_PcanHandle, ref request, 0x21, buffer, (ushort)buffer.Length);
if (status == TPUDSStatus.PUDS_ERROR_OK)
{
status = UDSApi.WaitForService(m_PcanHandle, out response, ref request, out request);
Thread.Sleep(300);
if (status == TPUDSStatus.PUDS_ERROR_OK)
{
if (response.DATA[0] == 0x67 && response.DATA[1] == 0x21)
{
seedkey.seed = new byte[4];
seedkey.seed[0] = response.DATA[5];
seedkey.seed[1] = response.DATA[4];
seedkey.seed[2] = response.DATA[3];
seedkey.seed[3] = response.DATA[2];
UInt32 Seed = BitConverter.ToUInt32(seedkey.seed, 0);
Securekey sa = new Securekey();
sa.seedToKey(Seed, seedkey.key);
buffer1[0] = seedkey.key[0];
buffer1[1] = seedkey.key[1];
buffer1[2] = seedkey.key[2];
buffer1[3] = seedkey.key[3];
res = OK;
}
}
else
{
res =ERROR;
}
}
if (OK == res)
{
request.NO_POSITIVE_RESPONSE_MSG = 0x00;
status = UDSApi.SvcSecurityAccess(m_PcanHandle, ref request, 0x22, buffer1, (ushort)buffer1.Length);
if (status == TPUDSStatus.PUDS_ERROR_OK)
{
status = UDSApi.WaitForService(m_PcanHandle, out response, ref request, out request);
if (status == TPUDSStatus.PUDS_ERROR_OK)
{
if (response.DATA[0] == 0x67)
{
res = OK;
}
else
{
res = ERROR;
}
}
}
}
return res;
}
- Attachments
-
- IJ1X_YXZZ[TAIUV(`M$3YLT.png (4.2 KiB) Viewed 5593 times
Last edited by F.Vergnaud on Mon 11. Mar 2019, 13:16, edited 1 time in total.
Reason: Inserted code tag for improved readability.
Reason: Inserted code tag for improved readability.
-
- Software Development
- Posts: 305
- Joined: Mon 9. Sep 2013, 12:21
Re: the UDS send SecurityAccess
Have you analyzed why you do not always enter the statement "if(OK==res)"?sometimes,it can get into if(OK==res),sometimes it can not get into if(OK==res).I can receive postive response all the time
If you are always receiving a positive response after your seed request, it means that the status of UDSApi.WaitForService is PUDS_ERROR_OK and sometimes the response contains a Negative Response Code or the response failed with an ISO-TP Network error.
Note that a NRC can occur after too many SecurityAccess retries, or if you are not in the correct Diagnostic Session.
You are waiting some time after the reception of the UDS SecurityAccess Request Seed.Thread.Sleep(300);
Do you confirm that the ECU needs that much time between its Seed response and the next request?
Depending on the specifications of your ECU, it may exit the current diagnostic session as no "tester present" request is sent to keep alive the session.
A request not being sent is extremely rare on a functional CAN bus: it can occur if a similar message (i.e. with the same CAN ID) is already being transmitted. However it does not seem to be your case..after receive the postive respons ,the 27 22 cant not send,then all the service is stop.
What is the return status of the function SvcSecurityAccess? likewise, if that status is Ok, what is the status of the next WaitForService function?
Please note that if the request is not successfully sent, then the default timeout in the WaitForService function is at least 10s.
If you wish to change that settings use the following parameters: PUDS_PARAM_TIMEOUT_REQUEST and PUDS_PARAM_TIMEOUT_RESPONSE.
Code: Select all
uint ibuf = UDS_TIMEOUT_RESPONSE;
sts = UDSApi.SetValue(handle, TPUDSParameter.PUDS_PARAM_TIMEOUT_REQUEST, ref ibuf, sizeof(uint));
if (sts != TPUDSStatus.PUDS_ERROR_OK) {
// Failed to set UDS default timeout request
...
}
ibuf = UDS_TIMEOUT_RESPONSE;
sts = UDSApi.SetValue(handle, TPUDSParameter.PUDS_PARAM_TIMEOUT_RESPONSE, ref ibuf, sizeof(uint));
if (sts != TPUDSStatus.PUDS_ERROR_OK) {
// Failed to set UDS default timeout response
...
}
Finally, here is a short review of your trace file. I don't see any timestamps, have you seen unexpected delay in the "seed" response ?
Note that the call to the Service CommunicationControl stops all Tx communication. You need to revert everything (communication control, dtc setting and session) prior to restarting your application.
Code: Select all
07DF 8 02 10 83 00 00 00 00 00 <--- Set ECU Extended Diagnostic Session (no response required)
07DF 8 02 85 82 00 00 00 00 00 <--- ControlDTCSetting: OFF (no response required)
07DF 8 03 28 83 01 00 00 00 00 <--- CommunicationControl: Enable Rx and Disable Tx (no response required)
0702 8 02 10 82 00 00 00 00 00 <--- Set ECU Programming Session (no response required)
0702 8 02 27 21 00 00 00 00 00 <--- SecurityAccess: Request Seed
070A 8 06 67 21 41 AB 8E 30 00 <--- SecurityAccess: Seed Response from ECU
Best regards,
Fabrice
Fabrice