请问qt 串口编程使用的第三方类支持/dev/ttymxc4这样的串口名么???
运行时明明显示打开串口成功,但是数据发送不出去呢??
我查看了下开发板上/dev下的串口节点时间,这个/dev/ttymxc4节点每次都是运行完qt程序新建的囧。。。所以我在程序中试着打开一个不存在的串口ttymxc5,竟然也成功了= =。。。。。在开发板/dev下也出现了个ttymxc5的节点!!
所以我觉得,程序是不是压根就没有和硬件联系上,根本就没有打开板子上的串口啊?? 但是程序就是照着范例写的啊 应该木有问题把。。。
请各位大神指教
#include "widget.h"
#include "ui_widget.h"
#include "posix_qextserialport.h"
#include <QTimer>
#include <QtGui>
#include "qextserialbase.h"
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);//shun xu cuo le rong yi fa sheng duan cuo wu
// QString portname = ui->portnamelineEdit->text();
//QString portname="ttymxc4";
//myCom = new Posix_QextSerialPort(portname,QextSerialBase::Polling);
myCom=new Posix_QextSerialPort("/dev/ttymxc4",QextSerialBase::Polling);
isOpen=myCom->open(QIODevice::ReadWrite);
if(!isOpen)
{
QMessageBox::critical(this,tr("open failure"),tr("can not open serial")+"/dev/ttymxc4"+tr("\n this device may not exsit or has been used"),QMessageBox::Ok);
//ui->portnamelineEdit->setText("open"+portname+"successed!");
}
myCom->setBaudRate(BAUD115200);
myCom->setDataBits(DATA_8);
myCom->setParity(PAR_NONE);
myCom->setStopBits(STOP_1);
myCom->setFlowControl(FLOW_OFF);
myCom->setTimeout(10);
QTimer *readTimer=new QTimer(this);
//connect(readTimer,SIGNAL(timeout()),this,SLOT(readMyCom()));
//added
connect(readTimer,SIGNAL(timeout()),this,SLOT(sendMyCom()));
readTimer->start(100);
}
Widget::~Widget()
{
delete ui;
}