Click here to Skip to main content
15,914,780 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: postmessage and send message Pin
Russell'9-Sep-07 23:37
Russell'9-Sep-07 23:37 
AnswerRe: postmessage and send message Pin
ThatsAlok10-Sep-07 2:53
ThatsAlok10-Sep-07 2:53 
AnswerRe: postmessage and send message Pin
David Crow10-Sep-07 5:39
David Crow10-Sep-07 5:39 
QuestionAccessing the serial port in multithreading [modified] Pin
Cedric Moonen9-Sep-07 22:39
Cedric Moonen9-Sep-07 22:39 
GeneralRe: Accessing the serial port in multithreading Pin
Matthew Faithfull9-Sep-07 22:51
Matthew Faithfull9-Sep-07 22:51 
GeneralRe: Accessing the serial port in multithreading Pin
Cedric Moonen9-Sep-07 23:40
Cedric Moonen9-Sep-07 23:40 
GeneralRe: Accessing the serial port in multithreading Pin
Matthew Faithfull9-Sep-07 23:43
Matthew Faithfull9-Sep-07 23:43 
AnswerRe: Accessing the serial port in multithreading Pin
Roger Stoltz10-Sep-07 0:23
Roger Stoltz10-Sep-07 0:23 
Cedric Moonen wrote:
if anybody knows a way to read and write simeltaneously on the serial port, it will be really appreciated.


To my knowledge this is not possible on Windows Mobile, since you cannot use overlapped I/O.
By not using overlapped I/O the driver has to complete each IRP before it begins executing the next one.
This enforces a synchronous behavior towards the driver and the point of using different threads for reading and writing is lost.

I see two scenarios with two different questions of importance:

1. You're using handshaking so you won't lose any data that is supposed to be received. Writing has priority over reading and your concern would probably be how long you can delay a write request.

2. You're not using handshaking so you may lose data that is supposed to be received unless you read frequently enough. Reading has priority over writing and your concern would probably be how fast you need to read to avoid loss of data.

Suggestion:
I would try having a queue with messages to be sent that is synchronized with a semaphore which the thread that does the reading and writing waits for. When the semaphore is signaled you write the next message and then issue a read request. If the semaphore is not signaled the wait function will timeout.
I would tweak the COMMTIMEOUTS::ReadTotalTimeoutConstant and the timeout value for the wait function to find a suitable balance between reading and writing depending on whether you're using handshaking or not.

I would avoid ::WaitCommEvent() since it requires something to happen on the UART for it to return. If nothing happens your call may result in a deadlock. If your calling thread is preempted after the write request yet before the request issued by ::WaitCommEvent(), all data may have been transmitted and the call may never return.


"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown

QuestionDrive's last formatted date/time Pin
vipin_nvk9-Sep-07 22:00
vipin_nvk9-Sep-07 22:00 
QuestionDraw on the none-client area [modified] Pin
kcynic9-Sep-07 21:47
kcynic9-Sep-07 21:47 
AnswerRe: Draw on the none-client area Pin
Jason Teagle9-Sep-07 22:14
Jason Teagle9-Sep-07 22:14 
GeneralRe: Draw on the none-client area Pin
kcynic9-Sep-07 22:49
kcynic9-Sep-07 22:49 
AnswerRe: Draw on the none-client area Pin
Naveen9-Sep-07 22:32
Naveen9-Sep-07 22:32 
GeneralRe: Draw on the none-client area Pin
kcynic9-Sep-07 22:50
kcynic9-Sep-07 22:50 
GeneralRe: Draw on the none-client area Pin
Naveen9-Sep-07 23:15
Naveen9-Sep-07 23:15 
GeneralRe: Draw on the none-client area Pin
kcynic10-Sep-07 16:31
kcynic10-Sep-07 16:31 
QuestionChild-process without parents Pin
baerten9-Sep-07 21:31
baerten9-Sep-07 21:31 
AnswerRe: Child-process without parents [modified] Pin
Stephen Hewitt9-Sep-07 22:26
Stephen Hewitt9-Sep-07 22:26 
GeneralRe: Child-process without parents Pin
baerten9-Sep-07 22:50
baerten9-Sep-07 22:50 
GeneralRe: Child-process without parents Pin
Stephen Hewitt10-Sep-07 14:37
Stephen Hewitt10-Sep-07 14:37 
GeneralRe: Child-process without parents Pin
baerten10-Sep-07 21:52
baerten10-Sep-07 21:52 
GeneralRe: Child-process without parents Pin
Stephen Hewitt10-Sep-07 22:05
Stephen Hewitt10-Sep-07 22:05 
GeneralRe: Child-process without parents Pin
baerten10-Sep-07 22:27
baerten10-Sep-07 22:27 
GeneralRe: Child-process without parents Pin
Stephen Hewitt11-Sep-07 19:26
Stephen Hewitt11-Sep-07 19:26 
AnswerRe: Child-process without parents Pin
vipin_nvk9-Sep-07 22:27
vipin_nvk9-Sep-07 22:27 

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.