A free API for the communication with control units based on the Universal Measurement and Calibration Protocol (XCP) by ASAM for Windows®
-
ValeV
Post
by ValeV » Thu 13. May 2021, 18:25
Hi,
I am out of ideas why Download() function returns TXCPStatus XCP_ERR_OUT_OF_RANGE if I set numberOfElements parameter to number 4 (or more).
Here is screenshot from debugging. mDownload() just calls XCP_Download().

- Screenshot 2021-05-13 182036.jpg (267.32 KiB) Viewed 6037 times
I am just learning XCP, so i'll be ok if it's a stupid mistake from my side.

My colleague showed me how the traffic should look like (where it's shown that his num_of_data is set to 0x30):
-
Attachments
-

- Screenshot 2021-05-13 182255_2.jpg (89.28 KiB) Viewed 6037 times
-
K.Wagner
- Software Development

- Posts: 1080
- Joined: Wed 22. Sep 2010, 13:36
Post
by K.Wagner » Mon 17. May 2021, 13:08
Hello,
Please first note that the PXCP-API has a function for each XCP command, whos data is as specified in the XCP documentation (with exception of the first byte used for command identification, which is automatically included). This means, XCP commands in the API can be up to MAX_CTO-1 bytes in length. When using CAN as protocol, this means having a maximum of 7 bytes of data per command.
The DOWNLOAD command (XCP_Download function), takes into account the granularity being used (this is automatically communicated by the slave at connection time). If this is set to 2 (a WORD) as I can interpretate in your example, then you can send a maximum of 3 data elements within a call to XCP_Download (i.e. 6 bytes of Data --> 2 * 3), since one byte is used to specify the amount of data to be downloaded (numberOfElements). If you want to send more than 3 data elements (more than 6 bytes) as in your example, then you have to send the first 3 data elements with XCP_Download, and the rest of the data using XCP_DownloadNext (as your traffic-picture shows) - this is the so called block mode.
Hope this is more clear now
Best regards,
Keneth
-
ValeV
Post
by ValeV » Tue 18. May 2021, 13:15
Thank you for the long answer, sadly I'm still having hard time understanding where the problem is in my code.
I tried making a simplest call for function XCP_Download(), as seen on screenshot below. I am sending DOWNLOAD command with numberOfElements = 0x05, dataBuffer = 6 unsigned chars (so 6/2 = 3 elements), and dataBufferLength = 0x06.
It's still returning error XCP_ERR_OUT_OF_RANGE, so there is clearly something specific I am not understanding. I kindly ask you for specific answer, or if you can provide example code of using XCP_Download() function call.
-
Attachments
-

- Screenshot 2021-05-18 125801.jpg (218.59 KiB) Viewed 6002 times
-
K.Wagner
- Software Development

- Posts: 1080
- Joined: Wed 22. Sep 2010, 13:36
Post
by K.Wagner » Wed 19. May 2021, 08:34
Hello,
Indeed, it seems to be a problem within the XCP_Download function, as my own try of today failed. We will check this and get back to you soon with more details.
Thanks for bringing this to our attention.
Best regards,
Keneth
-
ValeV
Post
by ValeV » Wed 19. May 2021, 11:25
Thank you, in the meantime I will use PCANBasic.
-
K.Wagner
- Software Development

- Posts: 1080
- Joined: Wed 22. Sep 2010, 13:36
Post
by K.Wagner » Wed 19. May 2021, 13:20
Hello again,
the problem is, that sending in "block mode" is wrongly being rejected by the API. This will be corrected. If you are interested, we can provide you with a test version, so you can assert that the fix solves your problem. For this, please send a short email referencing this post and my name to support[@]peak-system.com
Best regards,
Keneth
-
ValeV
Post
by ValeV » Thu 20. May 2021, 18:52
Thanks for getting back.
I'd love to help you in return, but I'd need a couple more hours in a day to do all the work. I am interested in getting the final fixed version though, please let me know!
-
ValeV
Post
by ValeV » Tue 1. Jun 2021, 11:26
Thank you, that was very quick. In the meantime we moved to use PCAN-Basic instead of XCP so for our current project we want need it yet, but certainly in the future.
-
K.Wagner
- Software Development

- Posts: 1080
- Joined: Wed 22. Sep 2010, 13:36
Post
by K.Wagner » Tue 1. Jun 2021, 11:28
Closed.
Best regards,
Keneth