Ejemplo n.º 1
0
//edited
void MainWindow::sendData(QString data) {
    AbstractSerial *tempDev = (AbstractSerial *) ioDev;
    tempDev->setDtr(true);
    tempDev->setRts(false);
    if(ioDev->write(data.toAscii()) == -1) {
         statusBar()->showMessage(tr("Can't send data!"));
         printChat(System, "Can't send data :o");
     } else {
         printChat(Send, data);
     }
    tempDev->setDtr(false);
    tempDev->setRts(true);
}
Ejemplo n.º 2
0
MainWindow::MainWindow(QIODevice *ioDev, QWidget *parent) :
        QMainWindow(parent),
        ioDev(ioDev),
        ui(new Ui::MainWindow)
{
    this->setWindowFlags(Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
    ui->setupUi(this);
    connect(ioDev, SIGNAL(readyRead()), this, SLOT(onReadyRead()));

    //edited
    AbstractSerial *tempDev = (AbstractSerial *) ioDev;
    tempDev->setDtr(false);
    tempDev->setRts(true);

    save="";
    readFormatedTimer = new QTimer(this);
    readFormatedTimer->start(1000);
    connect(readFormatedTimer,SIGNAL(timeout()),this,SLOT(checkData()));
    ///

    readWaitTimer = new QTimer(this);
    connect(readWaitTimer, SIGNAL(timeout()), this, SLOT(onReadyRead()));

    onReadyRead();
}