/**
 * \brief Artificial interference into IO-Link communication
 * !!!Important: Described functionality is supported only with iqInterface HW Version >= 3.0 and FW Version 1.2.3.x
 * iqInterface (not iqLink) has a possibility to add interference into IO-Link communication
 * This mode helps to detect, if IO-Link device properly react on interferences:
 * •	Wrong CRC
 * •	Invalid message size
 * •	Invalid M-Seq type with wrong CRC

 * \copyright 2022, IQ² Development GmbH, Germany. All rights reserved.
 */

#ifndef _iqi_interference_mode_h
#define _iqi_interference_mode_h

#include "iqi_define.h" 

typedef enum
{
    INTERFERENCE_MODE_WRONG_CRC, //0x00 – insert invalid CRC
    INTERFERENCE_MODE_WRONG_LENGTH, //0x01 – Send M - Seq with wrong length
    INTERFERENCE_MODE_INVALID_MSEQ, //0x02 – Invalid message type with wrong CRC
}INTERFERENCE_MODE_Type;

/**
 * \brief Activate invalid M-SEQ
 *
 * \param[in]   uiPortNo      COM or virtual ethernet port number of iqInterface
 * \param[in]   frequence     How frequent insert interference for each 3 repeated M-Sequence
 *                            Possible values: 0 (disabled), 1, 2, 3
 * \param[in]   type          Type of interference
 *                            0x00 – insert invalid CRC
                              0x01 – Send M-Seq with wrong length
                              0x02 – Invalid message type with wrong CRC
 * \param[out]  cpErrMsg      an error message (minimum 256 symbols!)
 * 
 * \return error code
 */
DLL_API
int16 interference_ActivateInvalidMSeq(
    uint16 uiPortNo, 
    unsigned int frequence, 
    INTERFERENCE_MODE_Type type, 
    char08* cpErrMsg);

/**
 * \brief Deactivate invalid M-SEQ
 *
 * \param[in]   uiPortNo      COM or virtual ethernet port number of iqInterface
 * \param[out]  cpErrMsg      an error message (minimum 256 symbols!)
 *
 * \return error code
 */
DLL_API
int16 interference_DeactivateInvalidMSeq(
    uint16 uiPortNo,
    char08* cpErrMsg);

#endif //_iqi_interference_mode_h
