Thread Initialisation.......
-
:confused:Hi All, I have a problem in my embedded VC++ which is as follows: There is a Read Thread created during WM_CREATE event, which is supposed to read data from the COM1 port as and when it receives data.I have created the thread in such a way that it is active right from the point of creation - hReadThread = CreateThread (NULL, 0, PortRead, 0, 0, &dwThreadId); The problem is I dont know why the data is not read from COM1 though the read thread is active right from start. It would be very helpful if you could kindly help em out. Thanx Deepa.
-
:confused:Hi All, I have a problem in my embedded VC++ which is as follows: There is a Read Thread created during WM_CREATE event, which is supposed to read data from the COM1 port as and when it receives data.I have created the thread in such a way that it is active right from the point of creation - hReadThread = CreateThread (NULL, 0, PortRead, 0, 0, &dwThreadId); The problem is I dont know why the data is not read from COM1 though the read thread is active right from start. It would be very helpful if you could kindly help em out. Thanx Deepa.
Show us how do you read the data from the COM1 port in your thread! Regards, Daniel. -- FIND A JOB YOU LOVE, AND YOU'LL NEVER HAVE TO WORK A DAY OF YOUR LIFE. ;)
-
Show us how do you read the data from the COM1 port in your thread! Regards, Daniel. -- FIND A JOB YOU LOVE, AND YOU'LL NEVER HAVE TO WORK A DAY OF YOUR LIFE. ;)
Hi, This i how I read the data: SetCommMask (hSerial1, EV_RXCHAR | EV_TXEMPTY |EV_CTS | EV_DSR | EV_RLSD | EV_RING); WaitCommEvent (hSerial1, &dwCommModemStatus, 0); SetCommMask (hSerial1, EV_RXCHAR | EV_TXEMPTY |EV_CTS | EV_DSR | EV_RLSD | EV_RING); if (dwCommModemStatus & (EV_RXCHAR | EV_RLSD | EV_TXEMPTY |EV_CTS | EV_DSR | EV_RING) ) { do { flag = ReadFile(hSerial1,&response, 1, &dwBytesTransferred, NULL); if (flag) { //Process Data } } while(dwBytesTransferred == 1); } Thanx Deepa
-
Hi, This i how I read the data: SetCommMask (hSerial1, EV_RXCHAR | EV_TXEMPTY |EV_CTS | EV_DSR | EV_RLSD | EV_RING); WaitCommEvent (hSerial1, &dwCommModemStatus, 0); SetCommMask (hSerial1, EV_RXCHAR | EV_TXEMPTY |EV_CTS | EV_DSR | EV_RLSD | EV_RING); if (dwCommModemStatus & (EV_RXCHAR | EV_RLSD | EV_TXEMPTY |EV_CTS | EV_DSR | EV_RING) ) { do { flag = ReadFile(hSerial1,&response, 1, &dwBytesTransferred, NULL); if (flag) { //Process Data } } while(dwBytesTransferred == 1); } Thanx Deepa
Are you shure that the thread started correctly? Just show a message box when the thread is started. Just try to read some data from the COM outside of the thread, to see if the serial communication work! PS: I use the Serial library for C++ library (with some little changes that it will compile under eVC++) for my serial communication! Regards, Daniel. -- FIND A JOB YOU LOVE, AND YOU'LL NEVER HAVE TO WORK A DAY OF YOUR LIFE. ;)
-
Are you shure that the thread started correctly? Just show a message box when the thread is started. Just try to read some data from the COM outside of the thread, to see if the serial communication work! PS: I use the Serial library for C++ library (with some little changes that it will compile under eVC++) for my serial communication! Regards, Daniel. -- FIND A JOB YOU LOVE, AND YOU'LL NEVER HAVE TO WORK A DAY OF YOUR LIFE. ;)
Hi all, Thanx a lot for the replies.The Read Thread works fine now.Apparently there was a problem with the firmware. Thanx again:):)