upload with SvcTransferData_2013

A free API for the communication with control devices according to UDS (ISO 14229-1)
Post Reply
fabio.parodi@technoleader.it
Posts: 21
Joined: Thu 28. Apr 2022, 14:48

upload with SvcTransferData_2013

Post by fabio.parodi@technoleader.it » Thu 28. Apr 2022, 15:40

hello

I am trying to use functions SvcRequestFileTransfer_2013() and SvcTransferData_2013() to read a directory listing out of an ECU.
I have not found examples of upload.
The documentation says "The TransferData service is used by the client to transfer data either from the client to the server/ECU (download) or from the server/ECU to the client (upload)".
The call to SvcRequestFileTransfer_2013() produces the correct message sequence:

Code: Select all

            
            result = UDSApi.SvcRequestFileTransfer_2013(
                canport, config,
                out request, UDSApi.uds_svc_param_rft_moop.PUDS_SVC_PARAM_RFT_MOOP_RDDIR,
                file_path_and_name_size,
                file_path_and_name,
                compression_method,
                encrypting_method,
                file_size_parameter_size,
                file_size_uncompressed,
                file_size_compressed);
hich produces the following messages:

Code: Select all

   130)   7538761.1  Rx         07E0  8  07 38 05 00 03 43 3A 5C      client sends a RequestFileTransfer, modeOfOperation=05 RDDIR, filename = C:\
   131)   7538765.7  Rx         07E8  8  10 09 78 05 02 00 0A 00      server answers: ok ready to transfer 10 bytes
   132)   7538765.9  Rx         07E0  8  30 0A 0A 55 55 55 55 55      ... (flow control)
   133)   7538767.3  Rx         07E8  8  21 02 00 0A 00 00 00 00      ... last message of server answer

Then I'm calling SvcTransferData_2013():

Code: Select all

               
	result = UDSApi.SvcTransferData_2013(
                    canport, config,
                    out request,
                    (byte)(block_sequence_counter & 0xff));
The clients sends the request, which looks fine to me:

Code: Select all

  134)   7538768.6  Rx         07E0  8  02 36 01 55 55 55 55 55      client calls TransferData
Now the server transfers the data:

Code: Select all

   
   135)   7538769.0  Rx         07E8  8  10 0A 53 54 4D 33 32 2E      server transfers data
   136)   7538769.3  Rx         07E0  8  30 0A 0A 55 55 55 55 55      ... (flow control: the client accepts to receive 10 bytes from te server)
   137)   7538770.7  Rx         07E8  8  21 54 58 54 00 00 00 00      ... (last part of data sent from server to client)
My problem: I do not know how to get the data in C#. The flow control machine works but then, which function should I call to access the data?
Thanks and regards.


Fabio

F.Vergnaud
Software Development
Software Development
Posts: 305
Joined: Mon 9. Sep 2013, 12:21

Re: upload with SvcTransferData_2013

Post by F.Vergnaud » Thu 28. Apr 2022, 16:19

Hello Fabio,

After you make a call to a UDS service request, you need to call function WaitForService(). The data will be stored in the response message.
You can check sample 06_client_all_request for an example:

Code: Select all

            status = UDSApi.SvcTransferData_2013(channel, config, out request, 0x01, record, record_size);
            if (UDSApi.StatusIsOk_2013(status))
                status = UDSApi.WaitForService_2013(channel, ref request, out response, out confirmation);
            Console.WriteLine(" UDS_SvcTransferData_2013: {0}", (int)status);
            if (UDSApi.StatusIsOk_2013(status))
                display_uds_msg(ref confirmation, ref response, false);
Finally function display_uds_msg_response will give you hints on how to access the received data.

Should your file be too big to be stored in a single response from SvcTransferData_2013, you will need to call multiple times SvcTransferData_2013 and then handle all the chunks of data.
Best regards,
Fabrice

fabio.parodi@technoleader.it
Posts: 21
Joined: Thu 28. Apr 2022, 14:48

Re: upload with SvcTransferData_2013

Post by fabio.parodi@technoleader.it » Fri 29. Apr 2022, 16:31

Thanks for answering Fabrice.

Actually, after SvcTransferData_2013 I am calling WaitForService_2013, which fails with PUDS_STATUS_SERVICE_TIMEOUT_RESPONSE.
This is my C# code:

Code: Select all

                result = UDSApi.SvcTransferData_2013(
                    canport, config,
                    out request,
                    (byte)(block_sequence_counter & 0xff));
                Console.Out.WriteLine($"SvcTransferData_2013 returned {result}"); // --> PUDS_STATUS_CAUTION_INPUT_MODIFIED
                if (UDSApi.StatusIsOk_2013(result))
                {
                    result = UDSApi.WaitForService_2013(canport,
                        ref request, out response, out request_confirmation);
                    Console.Out.WriteLine($"WaitForService_2013 returned {result}"); // --> PUDS_STATUS_SERVICE_TIMEOUT_RESPONSE
                }
This is the commented trace:

Code: Select all

     1)      4315.9  Rx         07E0  8  02 27 01 55 55 55 55 55      client sends security access : request seed
     2)      4317.3  Rx         07E8  8  06 67 01 78 3E E2 06 55      server sends seed
     3)      4317.6  Rx         07E0  8  06 27 02 DA D9 20 19 55      client resonds with the key
     4)      4319.0  Rx         07E8  8  03 67 02 34 55 55 55 55      server grants access
     5)      4319.4  Rx         07E0  8  02 10 02 55 55 55 55 55      client sends DiagnosticSessionControl 02 = ProgrammingSession 
     6)      4320.8  Rx         07E8  8  02 50 02 55 55 55 55 55      server enters ProgrammingSession
     7)      4321.1  Rx         07E0  8  07 38 05 00 03 43 3A 5C      client sends RequestFileTransfer MOOP=5 read directory "C:\"
     8)      4328.3  Rx         07E8  8  10 09 78 05 02 00 15 00      server answers: 78 05 02 00 15 00 02 00 15 
     9)      4328.4  Rx         07E0  8  30 0A 0A 55 55 55 55 55      ...
    10)      4329.9  Rx         07E8  8  21 02 00 15 00 00 00 00      ...
    11)      4330.3  Rx         07E0  8  02 36 01 55 55 55 55 55      c# calls SvcTransferData_2013
    12)      4337.1  Rx         07E8  8  10 15 53 54 4D 33 32 2E      client sends data (total payload is 21 bytes)
    14)      4338.7  Rx         07E8  8  21 54 58 54 00 54 65 73      ...
    15)      4340.0  Rx         07E8  8  22 74 46 77 2E 68 65 78      ...
    16)      4341.4  Rx         07E8  8  23 00 00 00 00 00 00 00      ...
                                                                      c# calWaitForService_2013 error: timeout
I must be doing something wrong, either on the client or on the server side.
This is strange: the function SvcTransferData_2013() can be used to transfer data in both directions client->server and server->client, but there is no parameter to specify the direction.

thanks and regards

Fabio

F.Vergnaud
Software Development
Software Development
Posts: 305
Joined: Mon 9. Sep 2013, 12:21

Re: upload with SvcTransferData_2013

Post by F.Vergnaud » Fri 29. Apr 2022, 17:11

Hello Fabio,

Your trace lacks entry 13).. Can you confirm there was a Flow Control from 07E0?
Best regards,
Fabrice

fabio.parodi@technoleader.it
Posts: 21
Joined: Thu 28. Apr 2022, 14:48

Re: upload with SvcTransferData_2013

Post by fabio.parodi@technoleader.it » Mon 2. May 2022, 09:39

Yes, message 13 is flow control sent by slave. Sorry, I did remove the message from the trace when editing. This is another similar trace:

Code: Select all

     1)      8501.9  Rx         07E0  8  02 27 01 55 55 55 55 55 
     2)      8503.4  Rx         07E8  8  06 67 01 F8 D6 5A 2D 55 
     3)      8505.9  Rx         07E0  8  06 27 02 21 39 35 9B 55 
     4)      8507.3  Rx         07E8  8  03 67 02 34 55 55 55 55 
     5)      8508.0  Rx         07E0  8  02 10 02 55 55 55 55 55 
     6)      8509.4  Rx         07E8  8  02 50 02 55 55 55 55 55 
     7)      8510.3  Rx         07E0  8  07 38 05 00 03 43 3A 5C 
     8)      8517.5  Rx         07E8  8  10 09 78 05 02 00 15 00 
     9)      8517.7  Rx         07E0  8  30 0A 0A 55 55 55 55 55 
    10)      8519.2  Rx         07E8  8  21 02 00 15 00 00 00 00 
    11)      8520.9  Rx         07E0  8  02 36 01 55 55 55 55 55 
    12)      8526.4  Rx         07E8  8  10 15 53 54 4D 33 32 2E 
    13)      8526.6  Rx         07E0  8  30 0A 0A 55 55 55 55 55  <--- flow control
    14)      8528.0  Rx         07E8  8  21 54 58 54 00 54 65 73 
    15)      8529.4  Rx         07E8  8  22 74 46 77 2E 68 65 78 
    16)      8530.8  Rx         07E8  8  23 00 00 00 00 00 00 00 
SvcTransferData_2013 returned PUDS_STATUS_CAUTION_INPUT_MODIFIED
WaitForService_2013 returned PUDS_STATUS_SERVICE_TIMEOUT_RESPONSE

F.Vergnaud
Software Development
Software Development
Posts: 305
Joined: Mon 9. Sep 2013, 12:21

Re: upload with SvcTransferData_2013

Post by F.Vergnaud » Mon 2. May 2022, 10:14

Hello Fabio,

I think that the response from the server is missing the Service ID :

Code: Select all

    11)      8520.9  Rx         07E0  8  02 36 01 55 55 55 55 55  <--- client request SvcTransferData_2013
    12)      8526.4  Rx         07E8  8  10 15 53 54 4D 33 32 2E  <--- server response: Segmented Frame of length 0x15, Service ID = 0x53
    13)      8526.6  Rx         07E0  8  30 0A 0A 55 55 55 55 55  <--- flow control (client)
    14)      8528.0  Rx         07E8  8  21 54 58 54 00 54 65 73  <--- server CF #1
    15)      8529.4  Rx         07E8  8  22 74 46 77 2E 68 65 78  <--- server CF #2
    16)      8530.8  Rx         07E8  8  23 00 00 00 00 00 00 00  <--- server CF #3
The API is expecting something like:

Code: Select all

07E8  8  10 xx 76 01 .. .. .. .. ..
where 01 is the block sequence counter.
This is why it returns PUDS_STATUS_SERVICE_TIMEOUT_RESPONSE: no response was received in the expected time.
Best regards,
Fabrice

fabio.parodi@technoleader.it
Posts: 21
Joined: Thu 28. Apr 2022, 14:48

Re: upload with SvcTransferData_2013

Post by fabio.parodi@technoleader.it » Mon 2. May 2022, 13:12

Now I am receiving the data.
Thanks for the great support!

Post Reply