Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    [SOLVED] - QIODevice readyread() not raised

    General and Desktop
    1
    2
    3366
    Loading More Posts
    • 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
      Semtex last edited by

      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 Reply Quote 0
      • S
        Semtex last edited by

        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 Reply Quote 0
        • First post
          Last post