Problem with new Digi AccelePort Xp Adapter,Version 8.1.22.0

Hello to Digi support!!!

We work with our application with digi version 3.7.3.0(April 14, 2000) Windows XP Professional Installation CD release and application works properly.But when we try to work with new driver for Digi it seems to be some incorrect behaivor(delays,data floodings) in our application all those disturbance make application runs unstable.Can you please help with this issue.May be i shoul config some flags in my code?

With respect Alex.

This is my code:
// SerialChn.cpp

#include “stdafx.h”
#include “SerialChn.h”

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CSerialChn::CSerialChn()
{
memset( &m_OverlappedRead, 0, sizeof( OVERLAPPED ) );
memset( &m_OverlappedWrite, 0, sizeof( OVERLAPPED ) );
m_hIDComDev = NULL;
m_bOpened = FALSE;

// InitComm(nPort);
}

CSerialChn::~CSerialChn()
{

Close();

}

//////////////////////////////////////////////////////////////////////
// Methods
//////////////////////////////////////////////////////////////////////
BOOL CSerialChn::Open( int nPort , int nBaudRate , int nParity , int nStop_bits , int nByte_len , BOOL isOverlapped)
{
if( m_bOpened )
return( TRUE );

m_bOpened = FALSE;
m_isOverlapped = isOverlapped;

DWORD dwFlags = PURGE_RXCLEAR | PURGE_TXCLEAR | PURGE_TXABORT | PURGE_RXABORT;
DWORD dwCreateFileFlags = FILE_ATTRIBUTE_NORMAL | (m_isOverlapped ? FILE_FLAG_OVERLAPPED : 0);

char szPort[15];


wsprintf( szPort, "\\\\.\\COM%d", nPort );
m_hIDComDev = CreateFile( szPort, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, dwCreateFileFlags, NULL );
if( m_hIDComDev != INVALID_HANDLE_VALUE )
{
	m_bOpened = TRUE;
}
else
{
	m_hIDComDev = NULL;
}

if (m_bOpened)
{
	memset( &m_OverlappedRead, 0, sizeof( OVERLAPPED ) );
	memset( &m_OverlappedWrite, 0, sizeof( OVERLAPPED ) );

	COMMTIMEOUTS CommTimeOuts;
	CommTimeOuts.ReadIntervalTimeout = 0xFFFFFFFF;
	CommTimeOuts.ReadTotalTimeoutMultiplier = 0;
	CommTimeOuts.ReadTotalTimeoutConstant = 0;
	CommTimeOuts.WriteTotalTimeoutMultiplier = 0;
	CommTimeOuts.WriteTotalTimeoutConstant = 0;
	if (!SetCommTimeouts( m_hIDComDev, &CommTimeOuts ))
		Close();
	else
	{
		m_OverlappedRead.hEvent = CreateEvent( NULL, TRUE, FALSE, NULL );
		m_OverlappedWrite.hEvent = CreateEvent( NULL, TRUE, FALSE, NULL );

		if (!UpdateDcb(nBaudRate, nParity, nStop_bits, nByte_len))
			Close();
		else if (!PurgeComm( m_hIDComDev, dwFlags))
			Close();
	}
}

return( m_bOpened );

}

BOOL CSerialChn::UpdateDcb( int nBaud, int nParity, int nStop_bits,int nByte_len)
{
DCB dcb;

dcb.DCBlength = sizeof( DCB );
GetCommState( m_hIDComDev, &dcb );
dcb.BaudRate = nBaud;
dcb.ByteSize = nByte_len; //8;
dcb.fTXContinueOnXoff = 1;
dcb.Parity = nParity; //0;
dcb.StopBits = nStop_bits;

//////////////////////////////////////////////////////////////////////////
//TODO: check if those initializations are required in overlapped mode
dcb.fOutxCtsFlow = 0;
dcb.fAbortOnError = 1;
dcb.XonLim = 2014;
dcb.XoffLim = 2014;
dcb.fOutX = 0;
dcb.fInX = 0;
//////////////////////////////////////////////////////////////////////////
unsigned char ucSet;
ucSet = (unsigned char) ( ( FC_RTSCTS & FC_DTRDSR ) != 0 );
ucSet = (unsigned char) ( ( FC_RTSCTS & FC_RTSCTS ) != 0 );
ucSet = (unsigned char) ( ( FC_RTSCTS & FC_XONXOFF ) != 0 );
if( !SetCommState( m_hIDComDev, &dcb ) ||
!SetupComm( m_hIDComDev, 8330, 8330 ) ||
m_OverlappedRead.hEvent == NULL ||
m_OverlappedWrite.hEvent == NULL ){
DWORD dwError = GetLastError();
if( m_OverlappedRead.hEvent != NULL ) CloseHandle( m_OverlappedRead.hEvent );
if( m_OverlappedWrite.hEvent != NULL ) CloseHandle( m_OverlappedWrite.hEvent );
CloseHandle( m_hIDComDev );
return( FALSE );
}

return( TRUE );

}

BOOL CSerialChn::Close( void )
{
//changed by sharon - 15-12-03
// if( !m_bOpened || m_hIDComDev == NULL ) return( TRUE );

if (m_hIDComDev != NULL)
{
	if (m_isOverlapped)
	{
		if( m_OverlappedRead.hEvent != NULL ) CloseHandle( m_OverlappedRead.hEvent );
		if( m_OverlappedWrite.hEvent != NULL ) CloseHandle( m_OverlappedWrite.hEvent );
	}
	CloseHandle( m_hIDComDev );
	m_hIDComDev = NULL;
}
m_bOpened = FALSE;

return TRUE ;

}

int CSerialChn::ReadData(void *buffer, int limit)
{

if( !m_bOpened || m_hIDComDev == NULL ) return( 0 );

DWORD dwTimeout = 0;
BOOL bReadStatus;
DWORD dwBytesRead, dwErrorFlags;
COMSTAT ComStat;
LPOVERLAPPED lpOverlappedRead = (m_isOverlapped ? (&m_OverlappedRead) : NULL);

// LPOVERLAPPED lpOverlappedRead = NULL;

ClearCommError( m_hIDComDev, &dwErrorFlags, &ComStat );

dwBytesRead = (DWORD) ComStat.cbInQue;
if ( limit > (int) dwBytesRead ) 
		WaitForSingleObject( m_OverlappedRead.hEvent, dwTimeout );
ClearCommError( m_hIDComDev, &dwErrorFlags, &ComStat );
dwBytesRead = (DWORD) ComStat.cbInQue;
if( limit < (int) dwBytesRead ) dwBytesRead = (DWORD) limit;

bReadStatus = ReadFile( m_hIDComDev, buffer, dwBytesRead, &dwBytesRead, lpOverlappedRead);
if( !bReadStatus ){
	if( GetLastError() == ERROR_IO_PENDING ){
		return( (int) dwBytesRead );
		}
	return( 0 );
	}

return( (int) dwBytesRead );

}

BOOL CSerialChn::SendData(const char *ucBuff, int size)
{
BOOL bWriteStat;
BOOL retVal(TRUE);

DCB dcb;
dcb.DCBlength = sizeof( DCB );
GetCommState( m_hIDComDev, &dcb );


if( !m_bOpened || m_hIDComDev == NULL ) return( 0 );

DWORD dwBytesWritten = 0;
LPOVERLAPPED lpOverlappedWrite = (m_isOverlapped ? (&m_OverlappedWrite) : NULL);

bWriteStat = WriteFile( m_hIDComDev, (LPSTR) ucBuff, size, &dwBytesWritten, lpOverlappedWrite);
if( !bWriteStat )
{

// return FALSE;

	if (GetLastError() != ERROR_IO_PENDING) 
	{ 
    // WriteFile failed, but it isn't delayed. Report error and abort.
		retVal = FALSE;
	}

// else
// { // Write is pending.
// if (!GetOverlappedResult(m_hIDComDev, &m_OverlappedWrite, &dwBytesWritten, TRUE))
// RetVal = FALSE;
// else
// // Write operation completed successfully.
// RetVal = TRUE;
// }
}
// else
// {
// return TRUE;
//
// RetVal = TRUE;
// }

return retVal;

}

BOOL CSerialChn::HasDataArrived(int limit)
{

if( !m_bOpened || m_hIDComDev == NULL ) return( 0 );

DWORD dwBytesRead, dwErrorFlags;
COMSTAT ComStat;

// BOOL OvStatus;

ClearCommError( m_hIDComDev, &dwErrorFlags, &ComStat );

dwBytesRead = (DWORD) ComStat.cbInQue;

if( limit > (int) dwBytesRead ) return( 0 );

return(TRUE);

}

int CSerialChn::ReadDataWaiting()
{
if( !m_bOpened || m_hIDComDev == NULL ) return( 0 );

DWORD dwErrorFlags;
COMSTAT ComStat;

ClearCommError( m_hIDComDev, &dwErrorFlags, &ComStat );

return (int) ComStat.cbInQue;

}

BOOL CSerialChn::IsDataRx()
{

DWORD dwEventMask = 0;
BOOL  bEventStat = TRUE;
DWORD err = GetLastError();

if( !m_bOpened || m_hIDComDev == NULL ) return( FALSE );

bEventStat = WaitCommEvent( m_hIDComDev, &dwEventMask, &m_OverlappedRead);
err = GetLastError();
if(dwEventMask == EV_RXCHAR ) 
	return(TRUE);
else
{
	return(FALSE);
}



return(TRUE);

}
/*
BOOL CSerialChn::InitComm(int nPort)
{
DWORD dwFlags = PURGE_RXCLEAR | PURGE_TXCLEAR | PURGE_TXABORT | PURGE_RXABORT;
char* szConfile;
int nBaudRate;
int nRs422Chn;
int nHdlcChn;
int nSelectedChn;
BOOL CommStatus;

// memset( &m_OverlappedRead, 0, sizeof( OVERLAPPED ) );
// memset( &m_OverlappedWrite, 0, sizeof( OVERLAPPED ) );
// m_hIDComDev = NULL;
// m_bOpened = FALSE;

 // Open configuration file for reading
if ((szConfile = GetConfigFile()) == NULL)
{
	nBaudRate =115200;
	nRs422Chn = 1;
	nHdlcChn = 2;
}
else
{
	char szStr[20];
	// Check if the floating point error can generate exceptions
	// and activate the current setting.
	GetPrivateProfileString("SERIAL_CHANNEL", "BaudRate", "115200",  szStr, 20, szConfile);
	sscanf(szStr, "%d", &nBaudRate); 
	GetPrivateProfileString("SERIAL_CHANNEL", "Rs422ChannelNo", "1",  szStr, 20, szConfile);
	sscanf(szStr, "%d", &nRs422Chn); 
	GetPrivateProfileString("SERIAL_CHANNEL", "HdlcChannelNo", "2",  szStr, 20, szConfile);
	sscanf(szStr, "%d", &nHdlcChn); 
}


CommStatus = Open(nPort);

// UpdateDcb(nBaudRate);
//
// PurgeComm( m_hIDComDev, dwFlags);

return (CommStatus);

}

*/
BOOL CSerialChn::Purge()
{
if( !m_bOpened || m_hIDComDev == NULL )
return( TRUE );

DWORD dwFlags = PURGE_RXCLEAR | PURGE_TXCLEAR | PURGE_TXABORT | PURGE_RXABORT;

return PurgeComm( m_hIDComDev, dwFlags);

}