how to read data from com port
-
i have a program to connect the system with mobile via bluetooth serial connection and when it comes to read method it just stops. and the read methos is
bool ReadPort() { long int dwSize = 0; bool hResult = false; std::string sb = ""; DWORD dwEventMask; if(!SetCommMask(hComm, EV_RXCHAR)) /* Setting Event Type */ { return hResult; } if(WaitCommEvent(hComm, &dwEventMask, NULL)) /* Waiting For Event to Occur */ { char szBuf[1024]; DWORD dwIncommingReadSize; do { if(ReadFile(hComm, &szBuf, 1024, &dwIncommingReadSize, NULL) != 0) { if(dwIncommingReadSize > 0) { dwSize += dwIncommingReadSize; sb.append(szBuf); } hResult = true; } else { unsigned long error = ::GetLastError(); hResult = false; printf("the error while reading error is %dl\n", error); break; } } while(dwIncommingReadSize > 0); *readData = new char[dwSize]; strcpy(*readData, sb.c_str()); return hResult; } else { return hResult; } }
the program just goes to wait mode in the WaitCommEvent function, even when i send a file via bluetooth from my mobile it does'nt reads and while iam sending the file the bluetooth pops the message that PIM transfer is happining, how to send file serial so that my read function should read the data and store in a file......