现用qextserialport的0.9版,qt:3.3.4版,在qt designer下编写,把qextserialport的类都放入了我要编写的工程中,现在想实现的功能是按某个按钮能够打开串口,并能读写串口数据,下面是我的代码:
open()
{ Posix_QextSerialPort * fd = new Posix_QextSerialPort("/dev/ttyS0");
fd->setBaudRate(BAUD115200); //com1,115200,n,8,1
fd->setFlowControl(FLOW_OFF);
fd->setParity(PAR_NONE);
fd->setDataBits(DATA_8 );
fd->setStopBits(STOP_1);
clippingsListBox->insertItem("N,8,1",0);
if (fd->open())
{
clippingsListBox->insertItem("opened",0);
fd->putch('a');
fd->getch();
fd->writeBlock("abc",3);
fd->readBlock(buff,512);
fd->flush();
fd->close();
}
}
现在的问题运行的结果不显示if语句中的"opened",是不是说明串口未打开呢,奇怪的是把串口改成"/dev/tty"