# Diag IO control Service

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

The diag IOControl service APIs are part of the diagnostic service. The InputOutputControlByIdentifier(0x2F) service is used by the client to substitute a value for an input signal, internal server function and/or force control to a value for an output (actuator) of an electronic system. The client request message contains a dataIdentifier to reference the input signal, internal server function, and/or output signal(s) of the server. The controlOptionRecord parameter shall include all information required by the server’s input signal(s), internal function(s) and/or output signal(s).

## 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 IOControl service.

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

## Server-service APIs

A diag IOControl service reference should be got using [taf\_diagIOCtrl\_GetService()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00410_1ae535f9aca6bf5b75fe5b88dbe07fcfa0.html#Documentationa00410_1ae535f9aca6bf5b75fe5b88dbe07fcfa0) with the data identifier passed as a parameter. Use the returned reference for subsequent operations.

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

taf_diagIOCtrl_ServiceRef_t svcRef;    // Service reference
    
    // Get the service reference.
    svcRef = taf_diagIOCtrl_GetService(dataId);
    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 IO control requests using [taf\_diagIOCtrl\_SetVlanId()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00410_1ad3920298ee2c8e76748326da0b4911f9.html#Documentationa00410_1ad3920298ee2c8e76748326da0b4911f9). It shall be called before registering the handler for the IOControl(0x2F) request message. An application can get the VLAN ID of the request message using [taf\_diagIOCtrl\_GetVlanIdFromMsg()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00410_1a4f0f1c0a3c13720e253f43887382ebf5.html#Documentationa00410_1a4f0f1c0a3c13720e253f43887382ebf5).

- [taf\_diagIOCtrl\_SetVlanId()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00410_1ad3920298ee2c8e76748326da0b4911f9.html#Documentationa00410_1ad3920298ee2c8e76748326da0b4911f9) — Sets the VLAN ID.
- [taf\_diagIOCtrl\_GetVlanIdFromMsg()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00410_1a4f0f1c0a3c13720e253f43887382ebf5.html#Documentationa00410_1a4f0f1c0a3c13720e253f43887382ebf5) — Gets the VLAN ID of the request message.

## InputOutputControlByIdentifier(0x2F) service

After getting the service reference, an application can call [taf\_diagIOCtrl\_AddRxMsgHandler()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00410_1ac0f97c8ea33f3843b944f7f5a9765768.html#Documentationa00410_1ac0f97c8ea33f3843b944f7f5a9765768) to register a message handler for InputOutputControlByIdentifier(0x2F) service. Once an IOControl service request message is received, the handler will be called with the message reference, dataId and inputOutputControlParameter passed as input parameters. The application will get the controlState and controlEnableMaskRecord using [taf\_diagIOCtrl\_GetCtrlState()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00410_1a3ffeb6a849047c21bad476d75b8cca8d.html#Documentationa00410_1a3ffeb6a849047c21bad476d75b8cca8d) and [taf\_diagIOCtrl\_GetCtrlEnableMaskRecd()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00410_1a1b7b0f3bf7ab734c75956c183a098a22.html#Documentationa00410_1a1b7b0f3bf7ab734c75956c183a098a22) function respectively and uses the message reference to send a response message using [taf\_diagIOCtrl\_SendResp()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00410_1a4a5f0dd607a1fddd473ec77dfcd3be4d.html#Documentationa00410_1a4a5f0dd607a1fddd473ec77dfcd3be4d).

// Rx message handler function.
    void RxIOCtrlEventHandler
    (
         taf_diagIOCtrl_RxMsgRef_t rxMsgRef,
         uint16_t dataId,
         uint8_t ioCtrlParameter,
         void* contextPtr
    )
    {
         // Process after succesfully receiving message
    }
    
    // Register the message handler.
    taf_diagIOCtrl_RxMsgHandlerRef_t handlerRef =
        taf_diagIOCtrl_AddRxMsgHandler(svcRef,
             (taf_diagIOCtrl_RxMsgHandlerFunc_t)RxIOCtrlEventHandler, NULL);
    LE_ASSERT(handlerRef != NULL);
    
    // To remove the handler function, when it is not needed.
    taf_diagIOCtrl_RemoveRxMsgHandler(handlerRef);
    
    // To get the controlState.
    taf_diagIOCtrl_GetCtrlState(): Gets the controlState.
    
    // To get the controlEnableMaskRecord.
    taf_diagIOCtrl_GetCtrlEnableMaskRecd(): Gets the controlEnableMaskRecord.
    
    // To send IOControl response.
    uint8_t controlState[TAF_DIAGIOCTRL_MAX_PAYLOAD_SIZE];
    le_result_t result = taf_diagIOCtrl_SendResp(rxMsgRef,
             TAF_DIAGIOCTRL_NO_ERROR, controlState, sizeof(controlState));
    if (result != LE_OK)
    {
       LE_ERROR("Fail to send response.");
       return result;
    }
    Copy to clipboard

An application can remove the IOControl server service by calling [taf\_diagIOCtrl\_RemoveSvc()](https://docs.qualcomm.com/doc/80-41102-2/topic/function_a00410_1ad8bdd498c747b68900e4ac78295b240e.html#Documentationa00410_1ad8bdd498c747b68900e4ac78295b240e).

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

Last Published: Jun 09, 2026

[Previous Topic
Diag IDPS Service](https://docs.qualcomm.com/bundle/publicresource/80-41102-2/topics/page_c_tafDiagIDPS.md) [Next Topic
Diag Reset Service](https://docs.qualcomm.com/bundle/publicresource/80-41102-2/topics/page_c_tafDiagReset.md)