DoCAN UDS Server Demo

There is an example implementation of UDS server available in apps folder. In this implementation, a model ECU is created to mimic various features.

Following DTC test codes are available in the example:

Example DTC Codes

DTC Record

Size

Description

0x12

4 Bytes

CAN transmit counter

0x34

4 Bytes

CAN receive counter

0x56

1 Byte

AIR Bag status

Following Data IDs are available in the example:

Supported Data IDs

Data ID

Size

Read/Write

Description

0x0101

1 Byte

Read Only

Battery Level from 0 to 100

0x0105

1 Byte

Read Only

Speed Value from 0 to 200

0x2109

1 Byte

Read Write

Drive Mode Value from 0 to 4

0x4567

1 Byte

Read Write

Gear Value from -1 to 5

0x7890

1 Byte

Read Write

Self Check start from 0 to 1

0xABCD

4 Bytes

Read Only

Trip A Value from 0 to 800000

0xF190

21 bytes

Read Only

VIN Number value “Hello From UDS Server”

0xF200

2 Bytes

Read Only

RPM Value from 0 to 8000

0xF205

1 Byte

Read Write

Left Indicator On from 0 to 1

Scaling data is supported for only one id : 0x0105 with a value of [0x01, 0x95, 0x00, 0xE0, 0x4B, 0x00, 0x1E, 0xA1, 0x30].

A memory region of size 1500 bytes is defined starting at address 0x20001000 for performing read/write memory by address operations. This is implemented via a simple array.

One routine is defined at 0x4321 to blink a LED given number of times.

While all the implementation are meant to be tested without any underlying hardware, enabling a compile time macro PLATFORM_TEST_SUPPORT, will call some function that can be used to certain real functionalities such as LED on, soft reset etc.

Diagnostic Session Control (0x10) service

The example implementation just prints out the session type requested and returns a positive response.

ECU Reset (0x11) service

The type of request is just printed. For Enable Rapid power shutdown mode, the power down timing is returned as 5. But no other actions taken. platform_sw_reset is called for Soft reset request in PLATFORM_TEST_SUPPORT mode.

Clear Diagnostic Information (0x14) Service

The DTC group code is printed out. In PLATFORM_TEST_SUPPORT mode, CAN transmit/receive counters are cleared.

Read DTC Information (0x19) Service

Specific DTC record IDs can be read using RS_IS14229_READ_DTC_REPORT_DTC_STORED_DATA_BY_RECORD_NUMBER sub-function code. Others are not supported. With 0xFF, all the 3 DTC records can be read in a single shot. In PLATFORM_TEST_SUPPORT mode, CAN transmit/receive counters and Air bag information from a GPIO are used.

Read Data By ID (0x22) service

Few Data IDs are supported in the demo where many of them are automatically incrementing so that it can be read to find the differences.

Read Memory By Address (0x23) service

Data can be read from address 0x20001000 using this service for up to 1500 bytes.

Read Scaling Data By Identifier (0x24) service

Scaling data can be read for Vehicle speed data ID

Security Access (0x27) service

Initiates security access on the server. To be elaborated.

Communication Control (0x28) service

Simply prints the control type information received from the tester. Few global variables updated but not used.

Read Data By Periodic Identifier (0x2A) service

Yet to be implemented in the example.

Write Data By Identifier (0x2E) service

Data ID specified as Read/Write are allowed to be written

Input Output Control By Identifier (0x2F) service

Only prints are supported with fixed response value.

Routine Control (0x31) service

A single routine to blink a LED is supported. When starting the routine, number of blinks to be done can be passed. The same can be stopped and or status queried.

RequestDownload (0x34) service

The example allows the client to download a data and optionally store it in local file system as a file.

TransferData (0x36) service

The example allows the client to transfer data.

RequestTransferExit (0x37) service

The example allows the client to complete data transfer.

Write Memory By Address (0x3D) service

Data can be written from address 0x20001000 using this service for up to 1500 bytes.

Tester Present (0x3E) service

A simple print can be seen on receiving this service request.

Access Timing Parameter (0x83) service

Simple prints can be seen on receiving this service request.

SecuredDataTransmission (0x84) service

The example simply returns one’s complement of the given input.

Control DTC Setting (0x85) service

The example simply prints the given input.