/**
 * \brief IQI's direct mode via RS232
 * \copyright 2013-2014, IQ² Development GmbH, Neckartenzlingen. All rights reserved.
 */

#ifndef _iqi_dm_h
#define _iqi_dm_h

enum
{
  DM_SPEED_COM1 /* 4.8 kBps */,
  DM_SPEED_COM2 /* 38.4 kBps */,
  DM_SPEED_COM3 /* 230.4 kBps */,
  DM_SPEED_END,
};

/**
 * \brief Start direct mode between Master and IO-Link device on required speed (COM1 / COM2 / COM3).
 *
 * \param[in]	uiPortNo        COM or virtual ethernet port number of iqInterface
 * \param[in]   ucSpeed			direct mode speed (0 - COM0, 1 - COM1, 2 - COM3, see also 'DM_SPEED_*' constants)
 * \param[out]  cpErrMsg		an error message (minimum 256 symbols!)
 */
DLL_API
int16 dm_Start(uint16 uiPortNo,
			   uchar08 ucSpeed,
	           char08 *cpErrMsg);

/**
 * \brief Stop direct mode between Master and IO-Link device.
 *
 * Master returns to the previous mode automatically - master or device.
 *
 * \param[in]	uiPortNo        COM or virtual ethernet port number of iqInterface
 * \param[out]  cpErrMsg            an error message (minimum 256 symbols!)
 */
DLL_API
int16 dm_Stop(uint16 uiPortNo,
              char08 *cpErrMsg);

/**
 * \brief Send & receive or take acknowledge for a block of bytes between Master and Device.
 *
 * \param[in]	uiPortNo        COM or virtual ethernet port number of iqInterface
 * \param[in]   ucpSendBuf		pointer on send buffer
 * \param[in]	uiBytesCount    count of bytes to send
 * \param[out]	ucpRecvBuf      a pointer on receive buffer
 * \param[in]   uiBufSize		a size of receive buffer
 * \param[out]  cpErrMsg        an error message (minimum 256 symbols!)
 *
 * \return the count of received bytes
 */
DLL_API
int16 dm_SendRecv(uint16 uiPortNo,
	              uchar08 *ucpSendBuf,
				  uchar08 ucBytesCount,
				  uchar08 *ucpRecvBuf,
				  uint16 uiBufSize,
				  char08 *cpErrMsg);

#endif
