

/*
 ***************************************************************************************************
 * Includes
 ***************************************************************************************************
 */

#include "ComM_Priv.h"

/*
 ***************************************************************************************************
 * Defines
 ***************************************************************************************************
 */

/*
 ***************************************************************************************************
 * Type definitions
 ***************************************************************************************************
 */

/*
 ***************************************************************************************************
 * Variables
 ***************************************************************************************************
 */

#define COMM_START_SEC_CODE
#include "ComM_MemMap.h"


/*****************************************************************************************
 * Function name    : ComM_GetRequestedComMode
 * Syntax           : Std_ReturnType ComM_GetRequestedComMode
 *                   (
 *                     ComM_UserHandleType User, ComM_ModeType* ComMode
 *                     )
 * Description      : Function to query the currently requested Communication Mode of the corresponding
 *                    user.
 * Parameters       : User -> Handle of the user who requests a mode
 *                    ComMode -> Name of the requested mode
 * Return value     : E_OK: Successfully returned requested Communication Mode
 *                    E_NOT_OK: Return of requested Communication Mode failed
 *                    COMM_E_UNINIT: ComM not initialized
 *****************************************************************************************/
/* MR12 RULE 8.3 VIOLATION:Two declarations exists for this api. One is in ComM.h & another generated by RTE. Hence,the difference in identifiers.*/
Std_ReturnType ComM_GetRequestedComMode(ComM_UserHandleType User, ComM_ModeType * ComMode)
{
    /* Local Variables Declaration */
    /* Functions return type */
    ComM_UserVarType_tst *      userRamPtr_pst;

    /* DET for ComM initialization */
    #if (COMM_DEV_ERROR_DETECT != STD_OFF)
    if (ComM_GlobalStruct.ComM_InitStatus_en != COMM_INIT)
    {
        /* Report DET with ComM not initialized status */
        (void)Det_ReportError(COMM_MODULE_ID,COMM_INSTANCE_ID,COMM_GET_REQ_COMMODE_APIID,COMM_E_NOT_INITED);
        return COMM_E_NOT_INITIALIZED;
    }
        /* DET check for Null pointer for communication mode */
    if (ComMode == NULL_PTR)
    {
        /* Report DET with NULL parameter*/
        (void)Det_ReportError(COMM_MODULE_ID,COMM_INSTANCE_ID,COMM_GET_REQ_COMMODE_APIID,COMM_E_WRONG_PARAMETERS);
        return E_NOT_OK;
    }

    /* DET for user validation */
    if ( ComM_Prv_ValidateUserId(User) == FALSE )
    {
        /* Report DET when User is not present in the list */
        (void)Det_ReportError(COMM_MODULE_ID,COMM_INSTANCE_ID,COMM_GET_REQ_COMMODE_APIID,COMM_E_WRONG_PARAMETERS);
        return E_NOT_OK;
    }
    #endif  /*  #if (COMM_DEV_ERROR_DETECT != STD_OFF)  */

    User = ComM_UserId_MappingTable_acst[User];
    userRamPtr_pst = &ComM_UserStruct[User];

    /* Get the users Requested mode and pass to the calling API*/

    *ComMode = userRamPtr_pst->RequestedUserMode_u8 ;

    /* Pass the return status as E_OK */
    return E_OK;
}

#define COMM_STOP_SEC_CODE
#include "ComM_MemMap.h"

