Hi guys, i have a problem with the serial port communication. I am trying to read from the serial port, but it appears that only 14 bytes can be read at once. This is probably the size of the serial port receive buffer.
I have a serial extension card in my pc which adds 2 serial ports. With a null modem cable i can send data from one serial port to the other.
If i send 20 bytes i want to read 20 bytes at the other side. Does anybody have a solution for this problem?Code:m_SerialPort.SetCommMask(EV_RXCHAR); if(m_SerialPort.WaitCommEvent(&dwEventMask, NULL)) { unsigned char szBuf; DWORD dwIncomingReadSize; DWORD dwSize = 0; int iByteCount = 0; do { if(m_SerialPort.ReadData(&szBuf, 1, &dwIncomingReadSize) != 0) { if(dwIncomingReadSize > 0) { dwSize += dwIncomingReadSize; m_pReceiveBuf[iByteCount] = szBuf; iByteCount++; } } else { // Handle error condition } }while( (dwIncomingReadSize > 0) && (iByteCount < RECEIVE_BUF_SIZE) ); *dwReceivedBytes = iByteCount; }





Reply With Quote