Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot read serial data at 19200 baud

Status
Not open for further replies.

goju

Programmer
Sep 25, 2001
6
US
void SerialCom1::ComRead()
{
int i=0;
int recv;
CString x_Received_String; // Without this line, I cannot
read serial data at 19200 baud

while ( /* allow 5 seconds */)
{
if((ReadFile(m_hCom, &recv, 1, &iBytesRead, NULL)) == 0)
{
return;
}
else
{
if(i==0 && recv=='V') // first char must be 'V'
{
RxString = (char)recv;
i++;
}
if(i != 0)
{
RxString = (char)recv;
if(recv == ';')
{
RxString[i+1] = '\0';
return;
}
i++;
}
} // end else
} // end while loop
}

char result[80];
SerialCom1 com1;

com1.ComRead()
com1.GetRxString(result);

My program works fine at 1200 baud.
At 19200 baud, I am unable to read serial data unless I
add the CString declaration line shown above. Sending a
serial command always works. Editing other parts of the
program may cause the ComRead not to work. Once again,
at 1200 baud, there is never a problem. Any suggestions ??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top