|
1,单片机发送数据在串口助手的显示效果如图
2,在我写的qt中的显示效果
数据出来的有点乱,修改半天不知道,哪里有错误。
3,涉及数据处理的代码
void MainWidget::readMyCom()//读串口函数
{
QByteArray temp;
temp = myCom->readAll();
if(!((temp.isEmpty())|(temp.isNull())))
{
strReBuf.append(QString(temp));
//if(strReBuf.contains("�"))
strReBuf.remove(QString("�"), Qt::CaseInsensitive);
strReBuf.remove(QChar('\n'), Qt::CaseInsensitive);
//strReBuf.re
/*while(1)
{
if(strReBuf.startsWith("S"))break;
if(strReBuf.isEmpty())break;
strReBuf.remove(0,1);
}
*/
if(strReBuf.length()>=longth)emit comOver();
//connect(this,SIGNAL(comOver()),this,SLOT(writeSheet()));
}
}
void MainWidget::writeSheet()
{
QString str = strReBuf.left(longth);
strReBuf.remove(1,longth);
textBrowser->append(str);
} |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|