# Diag Data ID Service

- [API reference](https://docs.qualcomm.com/doc/80-41102-2/topic/_doxygen_rst_file__doxygen_sources_taf_diagDataID_interface_h.html#file-taf-diagdataid-interface-h)

The diag DataID service APIs are part of the diagnostic service. The DataID service provides ReadDataByIdentifier(0x22) and WriteDataByIdentifier(0x2E) service. The ReadDataByIdentifier(0x22) service allows the client to request data record values from the server identified by one or more data identifiers, and the WriteDataByIdentifier(0x2E) service allows the client to write information into the server at an internal location specified by the provided data identifier.

## IPC interfaces binding

The functions of this API are provided by the **tafDiagSvc** platform service.

The following example illustrates how to bind to the diag DataID service.

bindings:
    {
         clientExe.clientComponent.taf_diagDataID -> tafDiagSvc.taf_diagDataID
    }
    Copy to clipboard

## Server-service APIs

A diag DataID service reference should be got using [taf\_diagDataID\_GetService()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00356_1a6c6374e080cb5dccf6f1d3358fd42bac.html#Documentationa00356_1a6c6374e080cb5dccf6f1d3358fd42bac). Use the returned reference for subsequent operations.

The following example illustrates how to set up a diag DataID server-service-instance.

taf_diagDataID_ServiceRef_t svcRef;    // Service reference
    
    // Get the service reference.
    svcRef = taf_diagDataID_GetService();
    LE_ASSERT(svcRef != NULL);
    Copy to clipboard

## Set/get VLAN ID

After getting a service reference, an application can set the VLAN ID to the service to filter ReadDataByIdentifier/WriteDataByIdentifier requests using [taf\_diagDataID\_SetVlanId()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00356_1ad45e105dc0ea0aee8ecae99fbaa60b68.html#Documentationa00356_1ad45e105dc0ea0aee8ecae99fbaa60b68). It shall be called before registering the handler for the ReadDID(0x22) and WriteDID(0x2E) request messages. An application can get the VLAN ID of the request message using [taf\_diagDataID\_GetVlanIdFromMsg()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00356_1ad60b239ead61e81f8db8553a0db4f21f.html#Documentationa00356_1ad60b239ead61e81f8db8553a0db4f21f).

- [taf\_diagDataID\_SetVlanId()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00356_1ad45e105dc0ea0aee8ecae99fbaa60b68.html#Documentationa00356_1ad45e105dc0ea0aee8ecae99fbaa60b68) — Sets the VLAN ID.
- [taf\_diagDataID\_GetVlanIdFromMsg()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00356_1ad60b239ead61e81f8db8553a0db4f21f.html#Documentationa00356_1ad60b239ead61e81f8db8553a0db4f21f) — Gets the VLAN ID of the request message.

## ReadDataByIdentifier(0x22) service

After getting the service reference, an application can call [taf\_diagDataID\_AddRxReadDIDMsgHandler()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00356_1a88cba96898887ce98bf61e96754b93d5.html#Documentationa00356_1a88cba96898887ce98bf61e96754b93d5) to register a message handler for ReadDataByIdentifier(0x22) service. Once a ReadDataByIdentifier service request message is received, the handler will be called with the message reference and data identifier passed as input parameters. The application will read the data record for requested DID and uses the message reference to send a response message using [taf\_diagDataID\_SendReadDIDResp()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00356_1a16cb942b88711d843ceb1b5aab41c88c.html#Documentationa00356_1a16cb942b88711d843ceb1b5aab41c88c).

// Rx message handler function.
    void RxReadDIDHandler
    (
        taf_diagDataID_RxReadDIDMsgRef_t rxReadMsgRef,
        const uint16_t* dataIdPtr,
        size_t dataIdSize,
        void* contextPtr
    )
    {
        // Process after succesfully receiving message
    }
    
    // Register the message handler.
    taf_diagDataID_RxReadDIDMsgHandlerRef_t RxReadDIDMsgHandlerRef =
        taf_diagDataID_AddRxReadDIDMsgHandler(SvcRef,
           (taf_diagDataID_RxReadDIDMsgHandlerFunc_t)RxReadDIDHandler, NULL);
    LE_ASSERT(RxReadDIDMsgHandlerRef != NULL);
    
    // To remove the handler function, when it is not needed.
    taf_diagDataID_RemoveRxReadDIDMsgHandler(RxReadDIDMsgHandlerRef);
    
    // To send ReadDataByIdentifier response.
    uint8_t data[TAF_DIAGDATAID_MAX_READ_DID_PAYLOAD_SIZE];
    le_result_t result = taf_diagDataID_SendReadDIDResp(rxReadMsgRef,
            TAF_DIAGDATAID_READ_DID_NO_ERROR, data, sizeof(data));
    if (result != LE_OK)
    {
        LE_ERROR("Fail to send response.");
        return result;
    }
    Copy to clipboard

## WriteDataByIdentifier(0x2E) service

After getting the service reference, an application can call [taf\_diagDataID\_AddRxWriteDIDMsgHandler()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00356_1a8afa90ca7765ad0870009d7ff4a41acc.html#Documentationa00356_1a8afa90ca7765ad0870009d7ff4a41acc) to register a message handler for WriteDataByIdentifier(0x2E) service. Once a WriteDataByIdentifier service request message is received, the handler will be called with the message reference and data identifier passed as input parameters. The application will get the request data record using [taf\_diagDataID\_GetWriteDataRecord()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00356_1a9ab0192ef1176f81bf518e627c1a1a3d.html#Documentationa00356_1a9ab0192ef1176f81bf518e627c1a1a3d) and uses the message reference to send a response message using [taf\_diagDataID\_SendReadDIDResp()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00356_1a16cb942b88711d843ceb1b5aab41c88c.html#Documentationa00356_1a16cb942b88711d843ceb1b5aab41c88c).

// Rx message handler function.
    void RxWriteDIDHandler
    (
        taf_diagDataID_RxWriteDIDMsgRef_t rxWriteMsgRef,
        uint16_t dataId,
        void* contextPtr
    )
    {
        // Process after succesfully receiving message
    }
    
    // Register the message handler.
    taf_diagDataID_RxWriteDIDMsgHandlerRef_t RxWriteDIDMsgHandlerRef =
        taf_diagDataID_AddRxWriteDIDMsgHandler(SvcRef,
            (taf_diagDataID_RxWriteDIDMsgHandlerFunc_t)RxWriteDIDHandler, NULL);
    LE_ASSERT(RxWriteDIDMsgHandlerRef != NULL);
    
    // To remove the handler function, when it is not needed.
    taf_diagDataID_RemoveRxWriteDIDMsgHandler(RxWriteDIDMsgHandlerRef);
    
    // To get the WriteDataByIdentifier data record.
    taf_diagDataID_GetWriteDataRecord(): Gets the data record.
    
    // To send WriteDataByIdentifier response.
    le_result_t result = taf_diagDataID_SendWriteDIDResp(rxWriteMsgRef,
            TAF_DIAGDATAID_WRITE_DID_NO_ERROR, dataId);
    if (result != LE_OK)
    {
        LE_ERROR("Fail to send response.");
        return result;
    }
    Copy to clipboard

An application can remove the Data ID server service by calling [taf\_diagDataID\_RemoveSvc()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00356_1af8f6505a10af369ac4a00b496f5c645f.html#Documentationa00356_1af8f6505a10af369ac4a00b496f5c645f).

le_result_t result = taf_diagDataID_RemoveSvc(svcRef);
    LE_ASSERT(result == LE_OK);
    Copy to clipboard

Last Published: Jun 09, 2026

[Previous Topic
Diag Authentication Service](https://docs.qualcomm.com/bundle/publicresource/80-41102-2/topics/page_c_tafDiagAuth.md) [Next Topic
Diag DoIP Service](https://docs.qualcomm.com/bundle/publicresource/80-41102-2/topics/page_c_tafDiagDoIP.md)