请问有人用过QextSerialPort里的read()吗? 刚试了试可是行不通,我把读取的那段写在一个read thread里,下面是它的run部分
void readthread::run()
{
    char buff[1024] = "";
    int numBytes = 0;
    QString msg = "";
    QString num;
     for(;;)
      {
        numBytes = port4read->bytesAvailable();
        num = QString::number(numBytes,10);
        emit printStr(num);
        if(numBytes > 0)
        {
            if(numBytes > 1024) numBytes = 1024;
            int i = port4read->read(buff,numBytes);
            emit printStr("readed");
        }else{
            QString str2 = "nothing to read!";
            emit printStr(str2);
        }
        msg = "";
        msleep(100);
        port4read->flush();
      }
}
进行到 int i = port4read->read(buff,numBytes)时,程序就停住了,是这个read的问题吗?可是看看网上,大家都这么用啊. 有谁知道的能给点提示啊,我用的QextSerialPort 1.1的版本. 先谢谢了!!
对了,write()是正常的,所以端口没有问题,是不是在读的时候要用mutex把port锁住呢
[ 此贴被tim09在2008-11-13 06:59重新编辑 ]