Serial Communication Problem
Recently i have been developing an application to handle serial
communication events throught the serial connection interface provided by the
Microsoft Windows XP Operating System.
My application creates (at least) two threads and listens to two different serial ports
(COM1 and COM2). Two embedded devices connected to these serial ports
are constantly sending characters which are actually short string messages.
Everything works pretty well except one problem: sometimes some of characters are missing
from COM1 or COM2 (the characters are sent, but Win32 serial driver doesn't receive them)
The problem doesn't happen:
1. if i open two seperate application (processes) connected to the mentioned above ports.
2. if i open only one thread at a time connected to COM1 or COM2.
I have also tried to downloading a Commercial Serial Communication Application.
For example - when i used CRT (www.vandyke.com) with more than one tab
(CRT 5.0 application allows to open two serial ports in two seperate threads)
i encountered the same problem!!! Many lines of characters were lost on COM1 / COM2,
so i guess this might be somekind of a OS problem or BUG?
These are my serial port settings:
m_hPort= CreateFile( sPortName,
(GENERIC_READ | GENERIC_WRITE ),
0,
NULL,
OPEN_EXISTING ,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
NULL);
#define CommInQueSize 8192
#define CommOutQueSize 2048
if (! SetupComm( this->m_hPort,
CommInQueSize,
CommOutQueSize))
{
throw;
}
if (! SetCommMask(this->m_hPort, EV_RXFLAG
| EV_RXCHAR))
{
throw;
}
DCB dcbSerial;
memset(&dcbSerial, 0, sizeof(dcbSerial));
dcbSerial.DCBlength = sizeof(dcbSerial);
dcbSerial.BaudRate = ulBaudRate;
dcbSerial.fBinary = TRUE;
dcbSerial.fParity = FALSE;
dcbSerial.fOutxCtsFlow = FALSE;
dcbSerial.fOutxDsrFlow = FALSE;
dcbSerial.fDtrControl = RTS_CONTROL_DISABLE;// DTR_CONTROL_ENABLE;//DTR_CONTROL_DISABLE;
dcbSerial.fDsrSensitivity = FALSE;
dcbSerial.fTXContinueOnXoff = FALSE;
dcbSerial.fOutX = FALSE;
dcbSerial.fInX = FALSE;
dcbSerial.fErrorChar = FALSE;
dcbSerial.fNull = FALSE;
dcbSerial.fRtsControl = RTS_CONTROL_DISABLE;//RTS_CONTROL_ENABLE ;//RTS_CONTROL_DISABLE;
dcbSerial.fAbortOnError = FALSE;
dcbSerial.XonLim = CommXonLim;
dcbSerial.XoffLim = CommXoffLim;
dcbSerial.ByteSize = 8;
dcbSerial.Parity = NOPARITY;
dcbSerial.StopBits = ONESTOPBIT;
dcbSerial.XonChar = 0;//CommXONChar;
dcbSerial.XoffChar = 0;//CommXOFFChar;
dcbSerial.ErrorChar = 0;
dcbSerial.EofChar = 0;
dcbSerial.EvtChar = '\n';
I have opened a thread on Microsoft support sight here is a link to it if you are interested:
http://support.microsoft.com/newsgroups/newsReader.aspx?dg=microsoft.public.win32.programmer.kernel
Please help me deal with it,
as i really don't know where to look for a solution for this.
Thanks in advance.

