

#ifndef RBA_DEMOBDBASIC_DCM_H
#define RBA_DEMOBDBASIC_DCM_H

#include "rba_DemObdBasic_Types.h"

#define DEM_START_SEC_ROM_CODE
#include "Dem_Cfg_MemMap.h"

/**
 * @ingroup DEM_H
 *
 * Dem318: Service to report the value of PID $01 - Monitor status since DTCs cleared (4 bytes) - computed by the Dem.
 *
 * @param [out] PID01value Buffer containing the contents of PID $01 computed by the Dem.
 *                         The buffer is provided by the Dcm with the appropriate size, i.e.
 *                         during configuration, the Dcm identifies the required size from the
 *                         largest PID in order to configure a PIDBuffer.
 *
 * @return E_NOT_OK is returned when OBD support is not enabled in Dem. Otherwise, E_OK is returned.
 */
Std_ReturnType Dem_DcmReadDataOfPID01 (uint8* PID01value);


/**
 * @ingroup DEM_H
 *
 * Dem325: Service to report the value of PID $1C - OBD requirements to which vehicle or engine is certified (1 byte)- computed by the Dem.
 *
 * @param [out] PID1Cvalue Buffer containing the contents of PID $1C computed by the Dem.
 *                         The buffer is provided by the Dcm with the appropriate size, i.e.
 *                         during configuration, the Dcm identifies the required size from the
 *                         largest PID in order to configure a PIDBuffer.
 *
 * @return  Always E_OK is returned, as E_NOT_OK will never appear.
 */
Std_ReturnType Dem_DcmReadDataOfPID1C (uint8* PID1Cvalue);


/**
 * @ingroup DEM_H
 *
 * Dem319: Service to report the value of PID $21 - Distance Traveled While MIL is Activated (2 bytes) - computed by the Dem.
 *
 * @param [out] PID21value Buffer containing the contents of PID $21 computed by the Dem.
 *                         The buffer is provided by the Dcm with the appropriate size, i.e.
 *                         during configuration, the Dcm identifies the required size from the
 *                         largest PID in order to configure a PIDBuffer.
 *
 * @return  Always E_OK is returned, as E_NOT_OK will never appear.
 */
Std_ReturnType Dem_DcmReadDataOfPID21 (uint8* PID21value);


/**
 * @ingroup DEM_H
 *
 * Dem320: Service to report the value of PID $30 - Number of warm-ups since DTCs cleared (1 byte) - computed by the Dem.
 *
 * @param [out] PID30value Buffer containing the contents of PID $30 computed by the Dem.
 *                         The buffer is provided by the Dcm with the appropriate size, i.e.
 *                         during configuration, the Dcm identifies the required size from the
 *                         largest PID in order to configure a PIDBuffer.
 *
 * @return  Always E_OK is returned, as E_NOT_OK will never appear.
 */
Std_ReturnType Dem_DcmReadDataOfPID30 (uint8* PID30value);


/**
 * @ingroup DEM_H
 *
 * Dem321: Service to report the value of PID $31 - Distance traveled since DTCs cleared (2 bytes) - computed by the Dem.
 *
 * @param [out] PID31value Buffer containing the contents of PID $31 computed by the Dem.
 *                         The buffer is provided by the Dcm with the appropriate size, i.e.
 *                         during configuration, the Dcm identifies the required size from the
 *                         largest PID in order to configure a PIDBuffer.
 *
 * @return  Always E_OK is returned, as E_NOT_OK will never appear.
 */
Std_ReturnType Dem_DcmReadDataOfPID31 (uint8* PID31value);


/**
 * @ingroup DEM_H
 *
 * Dem322: Service to report the value of PID $41 - Monitor status this driving cycle (4 bytes) - computed by the Dem.
 *
 * @param [out] PID41value Buffer containing the contents of PID $41 computed by the Dem.
 *                         The buffer is provided by the Dcm with the appropriate size, i.e.
 *                         during configuration, the Dcm identifies the required size from the
 *                         largest PID in order to configure a PIDBuffer.
 *
 * @return E_NOT_OK is returned when support for OBD or PID$41 computation is not enabled in Dem. \n
 * Otherwise, E_OK is returned.
 */
Std_ReturnType Dem_DcmReadDataOfPID41 (uint8* PID41value);


/**
 * @ingroup DEM_H
 *
 * Dem323: Service to report the value of PID $4D - Engine run time while MIL is activated (2 bytes) - computed by the Dem.
 *
 * @param [out] PID4Dvalue Buffer containing the contents of PID $4D computed by the Dem.
 *                         The buffer is provided by the Dcm with the appropriate size, i.e.
 *                         during configuration, the Dcm identifies the required size from the
 *                         largest PID in order to configure a PIDBuffer.
 *
 * @return  Always E_OK is returned, as E_NOT_OK will never appear.
 */
Std_ReturnType Dem_DcmReadDataOfPID4D (uint8* PID4Dvalue);


/**
 * @ingroup DEM_H
 *
 * Dem324: Service to report the value of PID $4E - Engine run time since DTCs cleared (2 bytes) - computed by the Dem.
 *
 * @param [out] PID4Evalue Buffer containing the contents of PID $4E computed by the Dem.
 *                         The buffer is provided by the Dcm with the appropriate size, i.e.
 *                         during configuration, the Dcm identifies the required size from the
 *                         largest PID in order to configure a PIDBuffer.
 *
 * @return  Always E_OK is returned, as E_NOT_OK will never appear.
 */
Std_ReturnType Dem_DcmReadDataOfPID4E (uint8* PID4Evalue);


/**
 * @ingroup DEM_H
 */
Std_ReturnType Dem_DcmGetInfoTypeValue08(Dcm_OpStatusType OpStatus, uint8* Iumprdata08, uint8* Iumprdata08BufferSize);


/**
 * @ingroup DEM_H
 */
Std_ReturnType Dem_DcmGetInfoTypeValue0B(Dcm_OpStatusType OpStatus,uint8* Iumprdata0B, uint8* Iumprdata0BBufferSize);


/**
 * @ingroup DEM_H
 *
 * Dem327:  Gets data element per PID and index of the most important freeze frame being selected for the output of service $02.
 *          The function stores the data in the provided DestBuffer.
 *
 * @param [in] PID This parameter is an identifier for a PID as defined in ISO15031-5.
 *
 * @param [in] DataElementIndexOfPID Data element index of this PID according to the Dcm configuration of service $02.
 *                                   It is zero-based and consecutive, and ordered by the data element positions
 *                                   (configured in Dcm, refer to Dem597).
 *
 * @param [in,out] DestBuffer This parameter contains a byte pointer that points to the buffer, to which the data element of the PID shall be written to.
 *                           The format is raw hexadecimal values and contains no header-information.
 *
 * @param [in,out] BufSize When the function is called this parameter contains the maximum number of data bytes that can be written to the buffer.
 *                        The function returns the actual number of written data bytes in this parameter.
 *
 * @return  E_OK Freeze frame data was successfully reported\n
 *          E_NOT_OK Freeze frame data was not successfully reported
 */
Std_ReturnType Dem_ReadDataOfOBDFreezeFrame (uint8 PID, uint8 DataElementIndexOfPID, uint8* DestBuffer, uint8* BufSize);

/**
 * @ingroup DEM_H
 *
 * Dem624:  Gets DTC by freeze frame record number.
 *
 * @param [in] FrameNumber Unique identifier for a freeze frame record as defined in ISO 15031-5.
 *                         The value 0x00 indicates the complete OBD freeze frame.
 *                         Other values are reserved for future functionality.
 *
 * @param [out] DTC Diagnostic Trouble Code. If the return value of the function is other than E_OK this parameter does not contain valid data.
 *
 * @return  E_OK: operation was successful\n
 *          E_NOT_OK: no DTC available
 */
Std_ReturnType Dem_GetDTCOfOBDFreezeFrame (uint8 FrameNumber, uint32* DTC);

/**
 * @ingroup DEM_H
 *
 * Dem235: Gets DTC and its associated freeze frame record by absolute record number. The function stores the data in the provided DestBuffer.
 * @param[in]       RecordNumber           This parameter is a unique identifier for a freeze frame record.
 *                                         Only the value 0x00 which indicates the complete OBD freeze frame is supported.
 * @param[in]       DTCOrigin              If the Dem supports more than one event memory, this parameter is used to select
 *                                         the source memory the DTCs shall be read from.
 * @param[in,out]   BufSize                When the function is called this parameter contains the maximum number of data bytes that can be written to the buffer.
 *                                         The function returns the actual number of written data bytes in this parameter.
 * @param[out]      DTC                    Receives the DTC value returned by the function.
 *                                         If the return value of the function is other than DEM_GET_FFBYRECORD_OK this parameter does not contain valid data.
 * @param[out]      DestBuffer             This parameter contains a byte pointer that points to the buffer, to which the freeze frame data record shall be written to.
 *                                         The format is: {NumOfDIDs, DID[1], data[1], ..., DID[N], data[N]}.
 * @return      Dem_ReturnGetFreezeFrameDataByRecordType : Status of the operation to retrieve the DTC and its associated freeze frame record
 *
 * <b>Note:</b>\n
 - returntype Dem_ReturnGetFreezeFrameDataByRecordType extended by one additional value:
   DEM_GET_FFBYRECORD_WRONG_BUFFERSIZE (value 0x03)
 - Restrict allowed record numbers to only OBD-record (0x00)
 */

Dem_ReturnGetFreezeFrameDataByRecordType Dem_GetFreezeFrameDataByRecord( uint8 RecordNumber, Dem_DTCOriginType DTCOrigin,  uint32* DTC, uint8* DestBuffer, uint16* BufSize );

#define DEM_STOP_SEC_ROM_CODE
#include "Dem_Cfg_MemMap.h"

#endif
