Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] - QIODevice readyread() not raised
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] - QIODevice readyread() not raised

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 3.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Semtex
    wrote on 9 Jul 2012, 07:57 last edited by
    #1

    Hello,

    I'm trying to use QtSerialPort which use QIOdevice.
    I wonder why but it seems that readyread SIGNAL isn't raised.
    If I use waitForReadyRead() for testing purpose, my SLOT is executed.

    any Idea ?

    @
    void MainWindow::readConfFile()
    {
    if (port->isOpen())
    port->close();
    port = new SerialPort();

    connectionStatus = false;
    QFile file("./config.ini");
    if (file.open(QIODevice::ReadOnly | QIODevice::Text))
    {
        // some configuration file stuff
    
        if (!port->open(QIODevice::ReadWrite))
        {
            QMessageBox::critical(this,"Erreur","La communication n'a pas pu être établie...", QMessageBox::Ok);
            ui->actionConfiguration->trigger();
        }
        // other configuration stuff
        file.close();
    }
    else
    {
        port->setPort("COM1");
        if (!port->open(QIODevice::ReadWrite))
        {
            QMessageBox::critical(this,"Erreur","La communication n'a pas pu être établie...", QMessageBox::Ok);
            ui->actionConfiguration->trigger();
        }
        port->setRate(19200);
        port->setParity(SerialPort::NoParity);
        port->setDataBits(SerialPort::Data8);
        port->setStopBits(SerialPort::OneStop);
        port->setFlowControl(SerialPort::NoFlowControl);
    }
    
    connectSlots();
    

    }
    @
    SLOTS
    @
    void MainWindow::connectSlots()
    {
    connect(port, SIGNAL(readyRead()), this, SLOT(readData()));
    connect(port, SIGNAL(bytesWritten(qint64)), this, SLOT(writeData(qint64)));
    connect(port, SIGNAL(aboutToClose()), this, SLOT(connectionLost()));
    }
    @
    readData
    @
    void MainWindow::readData()
    {
    lastAnswer = port->readLine();
    qDebug("in : "+lastAnswer.toAscii());
    if (lastframe == HANDY_REQUEST)
    {
    if (lastAnswer != "")
    {
    if (lastAnswer != HANDY_CONNECTED)
    {
    connectionStatus = false;
    ui->FrameSeeking->setVisible(true);
    }
    else
    {
    connectionStatus = true;
    ui->FrameSeeking->setVisible(false);
    }
    }
    }
    }
    @

    I feel so screwed because this code was working Friday x)
    Damn I hate Mondays !

    EDIT : Ah, and maybe should I add that writing data on this serial port works fine...

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Semtex
      wrote on 9 Jul 2012, 09:15 last edited by
      #2

      Well...
      It seems to works again (and I didn't do anything...)
      So I bet it is the software I use to simulate COM ports,
      DAMN MONDAYS !

      1 Reply Last reply
      0

      1/2

      9 Jul 2012, 07:57

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved