Hello Fabrice,
thank you for our answer.
While setting mappings for tester outgoing messages, the last set mapping overrides the previous ones. This makes sense and we can handle that.
For incoming message the multiple mappings seem to work.
However, I have some problems regarding the PUDS_PARAM_SERVER_ADDRESS. I set it like you recommended in my last post (http://www.peak-system.com/forum/viewtopic.php?f=182&t=1446). I get some strange behavior setting the value. Sometimes is seems to work and sometimes not.
I also tried the default address (0xF1) without setting PUDS_PARAM_SERVER_ADDRESS and the tester does not send any message.
My plan to solve the whole problem:
* use fixed test UDS address, say 0xF1
* use some target UDS address, say 0x01
* set PUDS_PARAM_SERVER_ADDRESS to 0xF1
* set outgoing mapping: current CAN ID (0x2F1) -> Tester UDS (0xF1)
* set incoming mappings:
* CAN ID App(0x4F1 ) -> ECU UDS (0x01)
* CAN ID Bootloader(0x400 ) -> ECU UDS (0x01)
If ECU changes to Bootloader
* remove outgoing mapping: CAN ID (0x2F1) -> Tester UDS (0xF1)
* set outgoing mapping: CAN ID (0x200) -> Tester UDS (0xF1)
If ECU changes to App
* remove outgoing mapping: CAN ID (0x200) -> Tester UDS (0xF1)
* set outgoing mapping: CAN ID (0x2F1) -> Tester UDS (0xF1)
But as mentioned above I have massive problems setting PUDS_PARAM_SERVER_ADDRESS.
Here is my current version without setting the mutliple mappings for incoming:
Code: Select all
Message setUdsAddressMapping( Api::CanInterface::Channel channel,
unsigned long source,
unsigned long target )
{
unsigned char ch = toPcanChannel( channel );
unsigned char sourceUds = PUDS_SERVER_ADDR_TEST_EQUIPMENT;
unsigned char targetUds = mapToUdsAddress( target );
unsigned char remoteUds = 0x00; // TODO???
std::cout << "source " << std::hex << (int) sourceUds << std::endl;
std::cout << "target " << std::hex << (int)targetUds << std::dec << std::endl;
// Set the "server address" for the UDS driver. If not set to the source
// (tester), the driver won't forward the messages!
// See: http://www.peak-system.com/forum/viewtopic.php?f=182&t=1446
TPCANTPStatus s = UDS_SetValue( ch, PUDS_PARAM_SERVER_ADDRESS,
&sourceUds, 1);
if ( s != PCANTP_ERROR_OK )
{
return toMessage( s );
}
// TODO: How to set the different formats, addressing? In the Config?
// When source sends the outgoing CAN ID must be the target address.
s = CANTP_AddMapping( ch, target, source,
PCANTP_ID_CAN_11BIT,
PCANTP_FORMAT_NORMAL,
PCANTP_MESSAGE_DIAGNOSTIC,
sourceUds, targetUds,
PCANTP_ADDRESSING_PHYSICAL,
remoteUds );
std::this_thread::sleep_for( std::chrono::milliseconds( 50 ) );
if ( s != PCANTP_ERROR_OK )
{
return toMessage( s );
}
// When target sends back the incoming CAN ID must be the source address.
s = CANTP_AddMapping( ch, source, target,
PCANTP_ID_CAN_11BIT,
PCANTP_FORMAT_NORMAL,
PCANTP_MESSAGE_DIAGNOSTIC,
targetUds, sourceUds,
PCANTP_ADDRESSING_PHYSICAL,
remoteUds );
std::this_thread::sleep_for( std::chrono::milliseconds( 50 ) );
return toMessage( s );
}
The function mapToUdsAddress use some internal singleton to provide unique uds addresses.
The above code does not work currently. It is not possible to send any message.
What's wrong here?
Thanks,
Tobias