Click here to Skip to main content
15,899,679 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: NetWkstaUserGetInfo Pin
alphaxz4-Sep-08 17:06
alphaxz4-Sep-08 17:06 
GeneralRe: NetWkstaUserGetInfo Pin
Rane4-Sep-08 17:32
Rane4-Sep-08 17:32 
GeneralRe: NetWkstaUserGetInfo Pin
alphaxz4-Sep-08 18:25
alphaxz4-Sep-08 18:25 
QuestionRe: NetWkstaUserGetInfo Pin
David Crow5-Sep-08 2:34
David Crow5-Sep-08 2:34 
AnswerRe: NetWkstaUserGetInfo Pin
alphaxz5-Sep-08 3:06
alphaxz5-Sep-08 3:06 
QuestionLet parent window handle its child dialog control's message Pin
followait4-Sep-08 15:07
followait4-Sep-08 15:07 
AnswerRe: Let parent window handle its child dialog control's message Pin
Naveen4-Sep-08 15:39
Naveen4-Sep-08 15:39 
QuestionSerial port Receive problem Pin
sunny_vc4-Sep-08 14:55
sunny_vc4-Sep-08 14:55 
Hi All,
I am working on Serial port function using NonOverlapped I/O(using VC6.0).
My Application to be communicated with a hardware device with 115200 baud rate.
Im able to receive the data correctly if I place a Sleep(1), in between two characters.

If I remove the Sleep, the data im received is correct for a single write and
Read. If it is continuous the data is corrupted.But If Sleep is there the response time of my application is very slow.

My Code is:

<pre>BOOL PortReadThread (COMMN_CTRL_CLASS *pCCommnCtrl)
{
while (TRUE)
{

// Wait for a character in input buffer
WaitCommEvent(pCCommnCtrl-&gt;hCommn, &amp;wEvent, NULL); //from NULL

do
{

// Sleep(1);
wToRead = pCCommnCtrl-&gt;ReadPort(&amp;cRcvdByte,1);

if(wToRead&gt;0)
{
Count++;
pCCommnCtrl-&gt;CopyRx(cRcvdByte);//process rxbyte
}
}while(Count&lt;1);

}

CloseHandle(pCCommnCtrl-&gt;hReadThread);

return TRUE;
}
}
DWORD CCommnCtrl::ReadPort(BYTE *pBuff, DWORD nToRead)
{
if(!(ReadFile(hCommn, pBuff, nToRead, &amp;wsidytesRead, NULL)))
{
if(GetLastError() == ERROR_IO_PENDING)
{
AfxMessageBox("PENDING");
}
else
{
wsidytesRead = 0;
ClearCommError(hCommn, &amp;wErrorFlags, &amp;comstat);
}
}
return wsidytesRead;
}

Communication time outs:
timeout.ReadIntervalTimeout = 0xFFFFFFFF;
timeout.ReadTotalTimeoutMultiplier =0;
timeout.ReadTotalTimeoutConstant = 0;
timeout.WriteTotalTimeoutMultiplier = 0;
timeout.WriteTotalTimeoutConstant = 0;

</pre>

If I place a Sleep(1), in ReadThread then even for continuous read and write the data is correct.But If I remove sleep, the data I receive is very fast but corrupted.
Please clarify If I need to chnage my code.

Regards,
Sunil Kumar
AnswerRe: Serial port Receive problem Pin
Iain Clarke, Warrior Programmer5-Sep-08 1:25
Iain Clarke, Warrior Programmer5-Sep-08 1:25 
Questionclear input buffer Pin
Sunday8PM4-Sep-08 12:15
Sunday8PM4-Sep-08 12:15 
AnswerRe: clear input buffer Pin
vikas amin4-Sep-08 13:40
vikas amin4-Sep-08 13:40 
QuestionRe: clear input buffer Pin
David Crow4-Sep-08 16:31
David Crow4-Sep-08 16:31 
AnswerRe: clear input buffer Pin
Sunday8PM4-Sep-08 19:38
Sunday8PM4-Sep-08 19:38 
QuestionCreateProcess(), CMD and character encoding. Pin
Member 38520244-Sep-08 11:43
Member 38520244-Sep-08 11:43 
QuestionAnother CScrollBar question Pin
KellyR4-Sep-08 11:08
KellyR4-Sep-08 11:08 
AnswerRe: Another CScrollBar question Pin
Mark Salsbery4-Sep-08 11:33
Mark Salsbery4-Sep-08 11:33 
GeneralRe: Another CScrollBar question Pin
KellyR4-Sep-08 11:51
KellyR4-Sep-08 11:51 
Questionproblems in Modeless dialog (on ok) writing to a file(internet sessiosion - ftpconnection) Pin
simon alec smith4-Sep-08 9:17
simon alec smith4-Sep-08 9:17 
QuestionMessageBox changes a str255 variable Pin
Grant Hudgens4-Sep-08 9:11
Grant Hudgens4-Sep-08 9:11 
QuestionHow to stop PC suspending or sleeping while app is running.. Pin
montiee4-Sep-08 9:03
montiee4-Sep-08 9:03 
AnswerRe: How to stop PC suspending or sleeping while app is running.. Pin
Perspx4-Sep-08 9:29
Perspx4-Sep-08 9:29 
GeneralRe: How to stop PC suspending or sleeping while app is running.. Pin
montiee4-Sep-08 12:20
montiee4-Sep-08 12:20 
QuestionSetting Children Nodes of Tree View Based on Parent Node [modified] Pin
Stuck At Zero4-Sep-08 7:42
Stuck At Zero4-Sep-08 7:42 
AnswerRe: Setting Children Nodes of Tree View Based on Parent Node Pin
led mike4-Sep-08 7:55
led mike4-Sep-08 7:55 
GeneralRe: Setting Children Nodes of Tree View Based on Parent Node Pin
Stuck At Zero4-Sep-08 8:00
Stuck At Zero4-Sep-08 8:00 

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.