Send text data and receive text data from a modem with LF detect.
download source with EXE
Compiled with Visual C++ 6.0
void CRs232aDlg::OnTimer(UINT nIDEvent)
{
unsigned char buf[500];
int xx,index;
if(nIDEvent==1)
{
xx = ReadRs232Input(buf, COM1);
if(xx)
{
index=0;
while(xx--) { m_strEditRead += buf[index];
RxBuffer[iRxIndex++] = buf[index];
if(buf[index] == LF) LineFeedDetected();
index++;
}
UpdateData(false);
}
}
CDialog::OnTimer(nIDEvent);
}
void CRs232aDlg::LineFeedDetected()
{
CString str;
RxBuffer[iRxIndex]=0; // end of string; now you can evaluate this string
iRxIndex=0;
str.Format("LineFeed%c%c",CR,LF);
m_strEditRead += str;
}
There is a periodically readout of the input buffer of RS232 with a TIMER-Function.
In the function "LineFeedDetected()" you can evaluate the content of RxBuffer