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 ??
{
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 ??