Click here to Skip to main content
15,890,897 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Changing the color of dialog box Pin
Hamid_RT6-Mar-06 2:52
Hamid_RT6-Mar-06 2:52 
AnswerRe: Changing the color of dialog box Pin
J51219826-Mar-06 1:23
J51219826-Mar-06 1:23 
GeneralRe: Changing the color of dialog box Pin
rajeev826-Mar-06 2:01
rajeev826-Mar-06 2:01 
QuestionREceive events in serial comms Pin
Trollslayer6-Mar-06 0:55
mentorTrollslayer6-Mar-06 0:55 
AnswerRe: REceive events in serial comms Pin
kakan6-Mar-06 1:39
professionalkakan6-Mar-06 1:39 
GeneralRe: REceive events in serial comms Pin
Trollslayer6-Mar-06 1:54
mentorTrollslayer6-Mar-06 1:54 
GeneralRe: REceive events in serial comms Pin
kakan6-Mar-06 2:38
professionalkakan6-Mar-06 2:38 
AnswerRe: REceive events in serial comms Pin
Roger Stoltz6-Mar-06 1:54
Roger Stoltz6-Mar-06 1:54 
Hi Elaine,

I suggest you forget about MsComm32.ocx and write your own class for serial communications.
If you really want an "event" you can use ::WaitCommEvent().

I've written a lot of applications for serial communications all using the same technique:
overlapped I/O, three threads, two message object queues for each port and one callback for received data.
One sending thread, one receiving thread that are spawned from the main thread when the port is opened with a call to ::CreateFile().
The sending thread waits, ::WaitForMultipleObjects(), for a semaphore released with the same amount as message objects added to the send queue.
The receiving thread issues a ::ReadFile() which usually will return FALSE since I use overlapped I/O and ::GetLastError() will return ERROR_IO_PENDING. The receive thread then waits for the event in the OVERLAPPED struct to be signaled.
Having set the comm timeouts properly with ::SetCommTimeouts() the receive event should be signalled after each data package received. How to set the values for the comm timeouts depends on your requirements. Usually I use '1' for ReadIntervalTimeout and '0' for the rest of the parameters.
When the event is signalled, verify the read operation with ::GetOverlappedResult() and you will also get the number of bytes actually read and copied to the buffer you supplied with the call to ::ReadFile(). You could call a callback function from here, or send a windows message or whatever you like for notification, just remember that this is another thread (especially if you use the callback technique).

When you "close" the port, you have to call ::CancelIo() from each thread that has issued a request to the port driver before calling ::CloseHandle().


It's supposed to be hard, otherwise anybody could do it!
GeneralRe: REceive events in serial comms Pin
Trollslayer6-Mar-06 1:57
mentorTrollslayer6-Mar-06 1:57 
Questionplease read it is importent Pin
baldha rakesh6-Mar-06 0:47
baldha rakesh6-Mar-06 0:47 
AnswerRe: please read it is importent Pin
Christian Graus6-Mar-06 1:03
protectorChristian Graus6-Mar-06 1:03 
Questionproblem using NtQuerySystemInformation Pin
gamitech6-Mar-06 0:19
gamitech6-Mar-06 0:19 
QuestionDirectory Pin
sundar_mca6-Mar-06 0:17
sundar_mca6-Mar-06 0:17 
QuestionRe: Directory Pin
David Crow6-Mar-06 2:48
David Crow6-Mar-06 2:48 
QuestionProblem with SQLSetEnvAttr Pin
Amit j Patil5-Mar-06 23:49
Amit j Patil5-Mar-06 23:49 
QuestionDeclare in form1.h causes error Pin
jantimmerman5-Mar-06 23:43
jantimmerman5-Mar-06 23:43 
AnswerRe: Declare in form1.h causes error Pin
Sebastian Schneider5-Mar-06 23:46
Sebastian Schneider5-Mar-06 23:46 
AnswerRe: Declare in form1.h causes error Pin
Ryan Binns5-Mar-06 23:57
Ryan Binns5-Mar-06 23:57 
GeneralRe: Declare in form1.h causes error Pin
jantimmerman6-Mar-06 1:14
jantimmerman6-Mar-06 1:14 
GeneralRe: Declare in form1.h causes error Pin
Ryan Binns6-Mar-06 3:10
Ryan Binns6-Mar-06 3:10 
QuestionVS 2005 manifest file problem. Pin
yourbuddy775-Mar-06 23:39
yourbuddy775-Mar-06 23:39 
QuestionConversion from VS 6.0 to .Net Pin
Neelesh K J Jain5-Mar-06 23:28
Neelesh K J Jain5-Mar-06 23:28 
AnswerRe: Conversion from VS 6.0 to .Net Pin
Nibu babu thomas5-Mar-06 23:36
Nibu babu thomas5-Mar-06 23:36 
AnswerRe: Conversion from VS 6.0 to .Net Pin
Christian Graus6-Mar-06 1:04
protectorChristian Graus6-Mar-06 1:04 
QuestionPower of 2 Pin
RichardS5-Mar-06 23:23
RichardS5-Mar-06 23:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.