Click here to Skip to main content
15,070,680 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: WaitForSingleObject best practices Pin
Joe Woodbury24-Oct-16 14:29
professionalJoe Woodbury24-Oct-16 14:29 
QuestionDevice on RS232 only responds to first send request (Visual C++) Pin
David MacKinnon27-Sep-16 8:18
MemberDavid MacKinnon27-Sep-16 8:18 
AnswerRe: Device on RS232 only responds to first send request (Visual C++) Pin
jeron127-Sep-16 10:41
Memberjeron127-Sep-16 10:41 
GeneralRe: Device on RS232 only responds to first send request (Visual C++) Pin
David MacKinnon27-Sep-16 11:38
MemberDavid MacKinnon27-Sep-16 11:38 
GeneralRe: Device on RS232 only responds to first send request (Visual C++) Pin
jeron127-Sep-16 11:44
Memberjeron127-Sep-16 11:44 
GeneralRe: Device on RS232 only responds to first send request (Visual C++) Pin
David MacKinnon27-Sep-16 12:10
MemberDavid MacKinnon27-Sep-16 12:10 
GeneralRe: Device on RS232 only responds to first send request (Visual C++) Pin
jeron127-Sep-16 13:28
Memberjeron127-Sep-16 13:28 
GeneralRe: Device on RS232 only responds to first send request (Visual C++) Pin
David MacKinnon28-Sep-16 12:30
MemberDavid MacKinnon28-Sep-16 12:30 
I tried different timeouts and the following work for the first read:

C++
CTimeouts.ReadIntervalTimeout = 20;          // msec between bytes arriving
CTimeouts.ReadTotalTimeoutMultiplier = 10;   // msec*bytes = 2560
CTimeouts.ReadTotalTimeoutConstant = 100;    // Added to above
CTimeouts.WriteTotalTimeoutMultiplier = 0;   //10;  // msec*bytes = 1280
CTimeouts.WriteTotalTimeoutConstant = 0;     //100;


I also added a loop using ClearCommError to verify that cbInQue has returned before performing ReadFile so was able to do that as soon as data arrived. Everything in that first request-receipt cycle works fine.

I still have the problem that the next WriteFile is essentially ignored, although it is sent without errors. The device appears to be waiting for something after the read was completed before it can respond to whatever is sent on the transmit line.
GeneralRe: Device on RS232 only responds to first send request (Visual C++) Pin
jeron129-Sep-16 4:19
Memberjeron129-Sep-16 4:19 
GeneralRe: Device on RS232 only responds to first send request (Visual C++) Pin
David MacKinnon29-Sep-16 4:43
MemberDavid MacKinnon29-Sep-16 4:43 
AnswerRe: Device on RS232 only responds to first send request (Visual C++) Pin
leon de boer27-Sep-16 17:18
Memberleon de boer27-Sep-16 17:18 
GeneralRe: Device on RS232 only responds to first send request (Visual C++) Pin
David MacKinnon29-Sep-16 4:45
MemberDavid MacKinnon29-Sep-16 4:45 
AnswerRe: Device on RS232 only responds to first send request (Visual C++) Pin
David MacKinnon29-Sep-16 4:40
MemberDavid MacKinnon29-Sep-16 4:40 
Question_tcscpy_s and unused buffer part Pin
leon de boer27-Sep-16 5:39
Memberleon de boer27-Sep-16 5:39 
AnswerRe: _tcscpy_s and unused buffer part Pin
Richard MacCutchan27-Sep-16 6:26
mveRichard MacCutchan27-Sep-16 6:26 
GeneralRe: _tcscpy_s and unused buffer part Pin
leon de boer27-Sep-16 18:36
Memberleon de boer27-Sep-16 18:36 
AnswerRe: _tcscpy_s and unused buffer part Pin
Richard MacCutchan27-Sep-16 6:33
mveRichard MacCutchan27-Sep-16 6:33 
AnswerRe: _tcscpy_s and unused buffer part Pin
Chris Losinger27-Sep-16 7:28
professionalChris Losinger27-Sep-16 7:28 
GeneralRe: _tcscpy_s and unused buffer part Pin
leon de boer27-Sep-16 20:24
Memberleon de boer27-Sep-16 20:24 
GeneralRe: _tcscpy_s and unused buffer part Pin
David Crow27-Sep-16 8:20
MemberDavid Crow27-Sep-16 8:20 
GeneralRe: _tcscpy_s and unused buffer part Pin
leon de boer27-Sep-16 18:35
Memberleon de boer27-Sep-16 18:35 
QuestionRe: _tcscpy_s and unused buffer part Pin
David Crow28-Sep-16 2:35
MemberDavid Crow28-Sep-16 2:35 
AnswerRe: _tcscpy_s and unused buffer part Pin
leon de boer28-Sep-16 17:47
Memberleon de boer28-Sep-16 17:47 
GeneralRe: _tcscpy_s and unused buffer part Pin
David Crow28-Sep-16 18:09
MemberDavid Crow28-Sep-16 18:09 
GeneralRe: _tcscpy_s and unused buffer part Pin
leon de boer28-Sep-16 18:14
Memberleon de boer28-Sep-16 18:14 

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.