UDS readDataByPeriodicIdentifier How to Read Messages

A free API for the communication with control devices according to UDS (ISO 14229-1)
Post Reply
Cappo
Posts: 14
Joined: Wed 19. Dec 2018, 14:19

UDS readDataByPeriodicIdentifier How to Read Messages

Post by Cappo » Mon 21. Jan 2019, 17:22

Hello to all,

I use:

I have this releases:
PCAN-Basic: 4.3.1.158 (13.12.2018)
PCAN-ISO-TP: 2.0.3.111 (07.12.2018)
PCAN-UDS: 1.3.1.30 (01.03.2018)

PCAN-USB FD - IPEH-004022

I'm using:
Windows 10 Pro for Workstations 64 bit
Visual Studio Professional 2017
.Net Framework 4.6.1

I need to read the periodic messages of readDataByPeriodicIdentifier service:
At the moment I can use the service (request to ECU and read first response), but I have no celar idea how to read additional messages (ID 0x258), somebody can help me?

I tried this way:

Code: Select all

/* Init code */
UInt16 channel = UDSApi.PUDS_USBBUS1;
status = UDSApi.Initialize(channel, TPUDSBaudrate.PUDS_BAUD_500K,0,0,0);
uint iBuffer = UDSApi.PUDS_SERVER_ADDR_TEST_EQUIPMENT;

status = UDSApi.SetValue(channel, TPUDSParameter.PUDS_PARAM_SERVER_ADDRESS, ref iBuffer, 1);

TPCANTPStatus tpSrarus = CanTpApi.AddMapping(
    channel, 
    0x7E0, 
    0x258,
    TPCANTPIdType.PCANTP_ID_CAN_11BIT,
    TPCANTPFormatType.PCANTP_FORMAT_NORMAL,
    TPCANTPMessageType.PCANTP_MESSAGE_DIAGNOSTIC,   
    0x01,
    UDSApi.PUDS_SERVER_ADDR_TEST_EQUIPMENT,
    TPCANTPAddressingType.PCANTP_ADDRESSING_PHYSICAL,
    0);

/* Polling function */
TPCANTPStatus tp_Statud = CanTpApi.Read(Channel, out TPMsg);
if (tp_Statud == TPCANTPStatus.PCANTP_ERROR_OK) 
 {
       /* process whole message */
 }
Thanks
Riccardo
Last edited by K.Wagner on Tue 22. Jan 2019, 07:49, edited 1 time in total.
Reason: Code formatting for better reading

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

Re: UDS readDataByPeriodicIdentifier How to Read Messages

Post by K.Wagner » Tue 22. Jan 2019, 07:55

Hello,

you need to check your mappings. Mappings involving physically addressed communication are most usually defined in pairs: the first mapping defines outgoing communication (i.e. request messages from node A to node B) and the second to match incoming communication (i.e. responses from node B to node A).

If your ECU is hearing to the ID 0x7E0 and responding using ID 0x258 then you need to match this in two mappings:
  1. 0x7E0, 0x258, (sending from Client to ECU)
  2. 0x258, 0x7E0, (receiving from ECU)
Best regards,
Keneth

Cappo
Posts: 14
Joined: Wed 19. Dec 2018, 14:19

Re: UDS readDataByPeriodicIdentifier How to Read Messages

Post by Cappo » Tue 22. Jan 2019, 09:13

Hello,

my ECU hearing 0x7E0 id and respond with 0x7E8, at the moment it works fine. What I nedd to do is add one or more input can ID on PCAN-UDS for periodic DID, for example add a 0x258 id for raw messags. So when I request from PC software to ECU the start send a readDataByPeriodicIdentifier, my ECU first send response with 0x7E8 and then send the periodic messages with anther ID (ie 0x258).
How can I do it?

Kind Regards
Riccardo

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

Re: UDS readDataByPeriodicIdentifier How to Read Messages

Post by K.Wagner » Tue 22. Jan 2019, 09:48

Hello,

OK, maybe I was not clear enough. Any ID you want to receive from the ECU that is not part of the standard communication needs a mapping pair. Otherwise your client will not be able to receive that message. The underlying ISO-TP protocol needs the mapping pair for message handshaking. So, you need to complete the mapping as I said in the last post.

0x7E0, 0x258, 1, 0xF1 (sending from Client to ECU)
0x258, 0x7E0, 0xF1, 1 (receiving from ECU)

Please note: you should not use "CanTpApi.Read" if you are using the on-top protocol UDS. Doing so you will cause a race condition on reading, and the UDS communication can be potentially disturbed (both protocols share only one reception queue). You should use UDS.Read instead.
Best regards,
Keneth

Cappo
Posts: 14
Joined: Wed 19. Dec 2018, 14:19

Re: UDS readDataByPeriodicIdentifier How to Read Messages

Post by Cappo » Tue 22. Jan 2019, 13:02

Hello,

I try to explain better what ia my target:
1) create a UDS client with request ID 0x7E0 and response 0x7E8 - done and it works
2) read a non UDS (UUDT and USDT) packets in consequence to a readDataByPeriodicIdentifier - working on

On PCAN-UDS-API_UserMan_eng.pdf at page 36, I found PUDS_PARAM_MAPPING_ADD parameter and If I'm not in confusion I think that this parameters is used to add an additional address mapping and by UDS_Read I can read a "non uds message (0x7E0 and 0x7E8)". Is possible? If si not how can I do?

Thanks
Riccardo

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

Re: UDS readDataByPeriodicIdentifier How to Read Messages

Post by K.Wagner » Tue 22. Jan 2019, 14:53

Hello,

sorry, I forgot to mention something: ISO-TP doesn't allow non-ISO-TP messages per default. There is a parameter called CANTP_PARAM_UNSEGMENTED, that has to be activated in order to allow UUDT and USDT messages reception. So, not only the mappings are to be added, but also this parameter must be activated.
Cappo wrote:On PCAN-UDS-API_UserMan_eng.pdf at page 36, I found PUDS_PARAM_MAPPING_ADD parameter and If I'm not in confusion I think that this parameters is used to add an additional address mapping and by UDS_Read I can read a "non uds message
yes, you are right. Principally, this parameter does the same as CANTP_AddMaping (it is an internal call to CANTP_AddMapping). The difference is that, when adding the mapping over UDS, the API checks by itself the kind of protocol. If the protocol is 0 (no protocol set), then it activates automatically the CANTP_PARAM_UNSEGMENTED parameter.

In conclusion, you better includes the Mappings using UDS_SetParam. In this way the non-ISO-TP messages are activated automatically and you should receive the data you are expecting over UDS_Read.
Best regards,
Keneth

Post Reply