我在做串口通信时在接收方显示是分开的,就是GetInBufferCount()读取的长度会出错,我发几个字符但接收是分开显示的。例如:我发送的是123456,但接收是下面显示的
 
my dear:[18 : 21 : 42 ]12
my dear:[18 : 21 : 42 ]3
my dear:[18 : 21 : 42 ]4
my dear:[18 : 21 : 42 ]5
my dear:[18 : 21 : 42 ]6代码如下,请各位高手帮忙,就要交毕设了,不胜感激啊!!!!
void CTryDlg::OnOnCommMscomm1() 
{
// TODO: Add your control notification handler code here
short sLen;
VARIANT vString;
CString strIn;
char *pStr;
//为了显示时间的
CTime t = CTime::GetCurrentTime();
CString s = t.Format( "%H : %M : %S "); switch(m_chuankou1.GetCommEvent())
{
case  2: //  串行口数据接收
sLen = m_chuankou1.GetInBufferCount();
if(sLen > 0)
{
//char* temp = new char[sLen+1];
vString = m_chuankou1.GetInput();
pStr = (char *)vString.parray->pvData;
}
int i = 0;
            
char* temp = new char[sLen+1];
while(i < sLen)
{
*(temp+i) = *(pStr+i);
i++;

}
*(temp+i) = '\0';
CString buffer = temp; m_liaotian += ("my dear:["+s+"]"+buffer+"\r\n");

UpdateData(false);


}
}