title: Transmitting 1500KB (hex files )data over UDS using CAPL test module
body: <p>I am trying to download my hex file of size 1500KB via UDS with CAPL test module,</p>
  <pre><code>p2 timer  = 50ms 
  p2* timer = 5000ms
  </code></pre>
  <p>Here is snippet of my code for data transfer :</p>
  <pre><code>void TS_transferData()
  
  {
  
      byte transferData_serviceid = 0x36;
      byte blockSequenceCounter = 0x1;
      byte buffer[4093];
      byte binarydata[4095];
      long i,ret1,ret2,ret3,temp,timeout = 0,Counter = 0;
      char filename[30] = &quot;xxx.bin&quot;;
      dword readaccess_handle;
      diagrequest ECU_QUALIFIER.* request;
      long valueleft;
    
   
      readaccess_handle = OpenFileRead(filename,1);
  
      if (readaccess_handle != 0  )
      {
        
             while( (valueleft = fileGetBinaryBlock(buffer,elcount(buffer),readaccess_handle))==4093 )
          {
                
              
            
  
               binarydata[0] = transferData_serviceid;
               binarydata[1] = blockSequenceCounter;
               
                for(i=0;i&lt;elcount(buffer);i++)
                {
                    binarydata[i+2] = buffer[i];                 
                }     
                
               
                diagResize(request, elCount(binarydata));
                DiagSetPrimitiveData(request,binarydata,elcount(binarydata));
                DiagSendRequest(request);
  
                write(&quot;length of binarydata %d  &quot;,elcount(binarydata));
                // Wait until the request has been completely sent
                  ret1 = TestWaitForDiagRequestSent(request, 20000);
                if(ret1 == 1) // Request sent
                  {
                    ret2=TestWaitForDiagResponse(request,50);
                    if(ret2==1) // Response received
                    { 
                        ret3=DiagGetLastResponseCode(request); // Get the code of the response                         
                              if(ret3==-1) // Is it a positive response?
                              {
                           ;  
                        }
                        else
                        {
                                   testStepFail(0, &quot;4.0&quot;,&quot;Binary Datatransfer on server Failed&quot;);
                             break;
                          }
                    }
                    else if(ret2 == timeout)
                    {
                         testStepFail(0, &quot;4.0&quot;,&quot;Binary Datatransfer on server Failed&quot;);
                         write(&quot;timeout occured while TestWaitForDiagResponse with block %d  &quot;,blockSequenceCounter);
                        
                        
                    }
               }
               else if(ret1 == timeout)
               {
                    testStepFail(0, &quot;4.0&quot;,&quot;Binary Datatransfer on server Failed&quot;);
                    write(&quot;timeout occured while TestWaitForDiagRequestSent %d  &quot;,blockSequenceCounter);                  
               }
  
              if(blockSequenceCounter == 255)
                    blockSequenceCounter = 0;
                else
                    ++blockSequenceCounter;
      
          }
      
      }
       //handle the rest of the bytes to be transmitted
      fileClose (readaccess_handle);
  
      
    
  }
  </code></pre>
  <p>The software downloading is happening but it is taking a long.... time for download.
  For TestWaitForDiagRequestSent() function any value for timeout less than 20000 is giving me timeout error.</p>
  <p>Is there any other way I can reduce the software transfer time or where am I going wrong with calculation?</p>
  <p>Is there any example I can refer to see How to transmit such a long data using CAPL ?</p>
  <p>Sorry, I am a beginner to CAPL and UDS protocol.</p>