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

C / C++ / MFC

 
GeneralRe: a question of c++ primer in chaper 10 Pin
Luc Pattyn1-Feb-08 12:09
sitebuilderLuc Pattyn1-Feb-08 12:09 
QuestionComm Timeout problem Pin
jonsey298471-Feb-08 10:18
jonsey298471-Feb-08 10:18 
GeneralRe: Comm Timeout problem Pin
Luc Pattyn1-Feb-08 12:13
sitebuilderLuc Pattyn1-Feb-08 12:13 
GeneralRe: Comm Timeout problem Pin
jonsey298471-Feb-08 23:24
jonsey298471-Feb-08 23:24 
GeneralRe: Comm Timeout problem Pin
Luc Pattyn2-Feb-08 2:31
sitebuilderLuc Pattyn2-Feb-08 2:31 
GeneralRe: Comm Timeout problem Pin
jonsey298472-Feb-08 7:56
jonsey298472-Feb-08 7:56 
GeneralRe: Comm Timeout problem Pin
Luc Pattyn2-Feb-08 8:01
sitebuilderLuc Pattyn2-Feb-08 8:01 
GeneralRe: Comm Timeout problem Pin
CPallini2-Feb-08 11:04
mveCPallini2-Feb-08 11:04 
Luc Pattyn wrote:
AFAIK, if there is no data at all, the read call does not return. The timeout
starts as soon as the first byte is received, no sooner.


Actually this applies only to the ReadIntervalTimeout member.
The following little test (on disconnected serial port):
...
ct.ReadIntervalTimeout = 1000;
ct.ReadTotalTimeoutConstant = 1000;
ct.ReadTotalTimeoutMultiplier = 1000;
ct.WriteTotalTimeoutConstant = 1000;
ct.WriteTotalTimeoutMultiplier = 1000;

fSuccess = SetCommTimeouts(hCom, &ct);
char Buf[0x10];
DWORD dwRead;

DWORD dwStart = timeGetTime();
ReadFile(hCom, Buf, 1, &dwRead, NULL);
DWORD dwEnd = timeGetTime();
printf("elapsed milliseconds %d", dwEnd-dwStart);


outputs elapsed milliseconds 2000, i.e.
ReadTotalTimeoutConstant + 1 * ReadTotalTimeoutMultiplier


Probably the relatively large value of ReadTotalTimeoutMultiplier (1 second per character) chosen by OP makes the application appear hung on read request for significative number of bytes.
Smile | :)

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.

[my articles]


GeneralRe: Comm Timeout problem Pin
Luc Pattyn2-Feb-08 11:38
sitebuilderLuc Pattyn2-Feb-08 11:38 
GeneralRe: Comm Timeout problem Pin
CPallini2-Feb-08 22:10
mveCPallini2-Feb-08 22:10 
GeneralMFC component gallery Pin
MFCfun1-Feb-08 7:37
MFCfun1-Feb-08 7:37 
GeneralRe: MFC component gallery Pin
Dave Calkins1-Feb-08 7:52
Dave Calkins1-Feb-08 7:52 
GeneralRe: MFC component gallery Pin
MFCfun1-Feb-08 8:04
MFCfun1-Feb-08 8:04 
GeneralRe: MFC component gallery Pin
Dave Calkins1-Feb-08 9:12
Dave Calkins1-Feb-08 9:12 
QuestionRe: MFC component gallery Pin
David Crow1-Feb-08 10:30
David Crow1-Feb-08 10:30 
GeneralConvert TLB file (type library) to IDL definition file Pin
Alexander M.,1-Feb-08 7:11
Alexander M.,1-Feb-08 7:11 
GeneralRe: Convert TLB file (type library) to IDL definition file Pin
led mike1-Feb-08 7:35
led mike1-Feb-08 7:35 
GeneralRe: Convert TLB file (type library) to IDL definition file Pin
Dave Calkins1-Feb-08 7:56
Dave Calkins1-Feb-08 7:56 
GeneralRe: Convert TLB file (type library) to IDL definition file Pin
Alexander M.,1-Feb-08 9:19
Alexander M.,1-Feb-08 9:19 
QuestionHow to have more basic colors for choosing in color dialog? [modified] Pin
followait1-Feb-08 6:07
followait1-Feb-08 6:07 
AnswerRe: How to have more basic colors for choosing in color dialog? Pin
led mike1-Feb-08 6:13
led mike1-Feb-08 6:13 
GeneralRe: How to have more basic colors for choosing in color dialog? Pin
Mark Salsbery1-Feb-08 6:14
Mark Salsbery1-Feb-08 6:14 
GeneralRe: How to have more basic colors for choosing in color dialog? Pin
followait1-Feb-08 7:05
followait1-Feb-08 7:05 
AnswerRe: How to have more basic colors for choosing in color dialog? Pin
Mark Salsbery1-Feb-08 6:13
Mark Salsbery1-Feb-08 6:13 
GeneralRe: How to have more basic colors for choosing in color dialog? Pin
followait1-Feb-08 7:04
followait1-Feb-08 7:04 

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.