Error 0x00040009 with UDSApi.Write_2013

A free API for the communication with control devices according to UDS (ISO 14229-1)
Post Reply
ipte-ugu
Posts: 2
Joined: Fri 10. Sep 2021, 14:26

Error 0x00040009 with UDSApi.Write_2013

Post by ipte-ugu » Fri 10. Sep 2021, 15:31

Hello,

I have a problem writing UDS requests on the bus. Initializing worked (PCANTP_HANDLE_PCIBUS2;PCANTP_BAUDRATE_500K). For message configuration I followed the provided samples. Here is the code:

Code: Select all

            request = new byte[] { 0x22, 0x42, 0x85 }
            
            //initialize message configuration
            uds_msgconfig msgconfig = new uds_msgconfig();
            msgconfig.can_id = 0xFFFFFFFF;
            msgconfig.can_msgtype = cantp_can_msgtype.PCANTP_CAN_MSGTYPE_STANDARD;
            msgconfig.nai.protocol = uds_msgprotocol.PUDS_MSGPROTOCOL_ISO_15765_2_11B_NORMAL;
            msgconfig.nai.target_type = cantp_isotp_addressing.PCANTP_ISOTP_ADDRESSING_PHYSICAL;
            msgconfig.type = uds_msgtype.PUDS_MSGTYPE_USDT;
            msgconfig.nai.source_addr = 0x6F1;
            msgconfig.nai.target_addr = 0x610;

            //setup request
            uds_msg msg_request = new uds_msg();
            uds_status status = UDSApi.MsgAlloc_2013(out msg_request, msgconfig, (uint)request.Length); //--> PUDS_STATUS_CAUTION_INPUT_MODIFIED
            bool success = CanTpApi.setData_2016(ref msg_request.msg, 0, request, request.Length); // --> true

            status = UDSApi.Write_2013(_canChannel, ref msg_request); // --> {Wrong message parameters; input was modified by the API}-0x00040009
            
The UDSApi.MsgAlloc_2013 returns the status "PUDS_STATUS_CAUTION_INPUT_MODIFIED", but the method "UDSApi.StatusIsOk_2013(PUDS_STATUS_CAUTION_INPUT_MODIFIED)" returns true, so I guess that is just a warning and can be ignored!?

However the call to UDSApi.Write_2013 failed.

What am I missing? Could it be a mapping? I haven't understood the mapping stuff yet.

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

Re: Error 0x00040009 with UDSApi.Write_2013

Post by F.Vergnaud » Fri 10. Sep 2021, 17:15

Hello,

The maximum value for the addresses in the Network Addressing Information is 0xFF (except for PUDS_MSGPROTOCOL_ISO_15765_3_29B_ENHANCED which is now deprecated in the ISO standards).
You should use, for instance:

Code: Select all

            msgconfig.nai.source_addr = 0xF1;
            msgconfig.nai.target_addr = 0x10;
Also be careful that a request with PUDS_MSGPROTOCOL_ISO_15765_2_11B_NORMAL requires to configure mappings when you are not communicating with standard addresses (i.e. predefined mappings use source = 0xF1, target = [0x01 to 0x08]).
This will be the case with a target_addr value of 0x10.

You'll find more information on that matter in the documentation §4.3: UDS and ISO-TP Network Addressing Information p.762
Best regards,
Fabrice

ipte-ugu
Posts: 2
Joined: Fri 10. Sep 2021, 14:26

Re: Error 0x00040009 with UDSApi.Write_2013

Post by ipte-ugu » Mon 13. Sep 2021, 09:04

Hello,

thank you. I guess I mixed up the can_id's with source/target addresses. I have to communicate with my customer's ECU and got little information so far about the configuration parameters, but I got two traces. One Ethernet request/response packet and a CAN trace.

Ethernet:
00 00 00 05 00 01 F4 10 22 FD 01 --> 00 00 00 16 00 01 10 F4 62 FD 01 56 50 4D 4B 41 46 2D 31 34 42 31 31 35 2D 44 41 4A

CAN:
6F1, 8, 10 03 22 42 85 FF FF FF
610, 5, F1 03 7F 22 78
610, 8, F1 10 33 62 42 85 0A 29
6F1, 4, 10 30 00 00
610, 8, F1 21 5A 00 0A 29 5A 00
610, 8, F1 22 01 00 13 00 01 00
610, 8, F1 23 13 00 0A 29 5A 00
610, 8, F1 24 0A 29 5A 00 01 00
610, 8, F1 25 13 00 01 00 13 00
610, 8, F1 26 0A 29 03 00 0A 29
610, 8, F1 27 03 00 00 00 00 00
610, 6, F1 28 00 16 00 00

So I guess the source address is 0xF4 (Ethernet) and 0xF1 (CAN). Is that correct?
The target address is 0x10. The can_id (request) is 0x6F1 and the can_id (response) 0x610.

Now the question remains how to set this up correctly with the Peak UDS API? Well, the CAN communication at least. I guess I need a mapping or where else the response id should go to? Is there something else I need to take care of?

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

Re: Error 0x00040009 with UDSApi.Write_2013

Post by F.Vergnaud » Mon 13. Sep 2021, 10:11

Hello,

The CAN trace shows that the target address is written in the first data byte:
- CAN ID 0x6F1 communicates to address 0x10
- CAN ID 0x610 communicates to address 0xF1

THen I guess you have the following ISO-TP configuration:
- Source is 0xF1 (usually called TesterClient) and it communicates using EXTENDED addressing format with ECU 0x10 using CAN ID 0x6F1,
- Target is ECU 0x10 and it communicates using EXTENDED addressing format with TesterClient 0xF1 using CAN ID 0x610.

You can check exemple 08 on how to configure a mapping, but here is what your mappings should look like

Code: Select all

        // Initialize source mapping
	source_mapping.can_id = 0x6F1;
	source_mapping.can_id_flow_ctrl = 0x610;
	source_mapping.can_msgtype = PCANTP_CAN_MSGTYPE_STANDARD;
	source_mapping.can_tx_dlc = 8;
	source_mapping.nai.protocol = PUDS_MSGPROTOCOL_ISO_15765_2_11B_EXTENDED;
	source_mapping.nai.target_type = PCANTP_ISOTP_ADDRESSING_PHYSICAL;
	source_mapping.nai.source_addr = 0xF1;
	source_mapping.nai.target_addr = 0x10;

	// Initialize response mapping
	response_mapping = source_mapping;
	response_mapping.can_id = source_mapping.can_id_flow_ctrl;
	response_mapping.can_id_flow_ctrl = source_mapping.can_id;
	response_mapping.nai.source_addr = source_mapping.nai.target_addr;
	response_mapping.nai.target_addr = source_mapping.nai.source_addr;

	// Add UDS mappings on transmitter
	status = UDS_AddMapping_2013(transmitter_handle, &source_mapping);
	printf("Add source mapping on transmitter: %s\n", STATUS_OK_KO(status));
	status = UDS_AddMapping_2013(transmitter_handle, &response_mapping);
	printf("Add response mapping on transmitter: %s\n", STATUS_OK_KO(status));
Best regards,
Fabrice

Post Reply