Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Serial Port not Opening
Forum Updated to NodeBB v4.3 + New Features

Serial Port not Opening

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 337 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.
  • V Offline
    V Offline
    Vijaykarthikeyan
    wrote on last edited by
    #1

    I'm trying to serial connect to the arduino Mega board through QSerialPort.But,the port is not opening.I have checked the port and it is properly connected with the board.Also,I have updated all the drivers. I have checked the connection in Putty.exe..the data bytes are coming in the putty.exe.But, when I tries to run in Qt..It saya error like this:
    Error opening serial port: "The semaphore timeout period has expired."
    bool QSerialPort::flush(): device not open

        foreach (const QSerialPortInfo &serial_Info, QSerialPortInfo::availablePorts()) {
            qDebug() << "Port: " << serial_Info.portName();
            portname = serial_Info.portName();
            qDebug() << "ProductId: " << serial_Info.vendorIdentifier();
            vendorId = serial_Info.vendorIdentifier();
            qDebug() << "VendorId: " << serial_Info.productIdentifier();
            productId = serial_Info.productIdentifier();
        }
        serial = new QSerialPort(this);
        serial->setPortName(portname);
        serial->setBaudRate(QSerialPort::Baud115200);
        serial->setDataBits(QSerialPort::Data8);
        serial->setParity(QSerialPort::NoParity);
        serial->setStopBits(QSerialPort::OneStop);
        serial->setFlowControl(QSerialPort::NoFlowControl);
        serial->setReadBufferSize(8192); // Sets the read buffer size to 8192 bytes
        serial->open(QIODevice::ReadWrite);
    
        if (serial->error() != QSerialPort::NoError) {
            qDebug() << "Serial port error: " << serial->errorString();
        } else {
            qDebug() << "Port opened";
        }
        QTimer *timer = new QTimer(this);
        connect(timer, &QTimer::timeout, this, &serial_link::serial_read);
        timer->start(1000);
    
    mzimmersM 1 Reply Last reply
    0
    • V Vijaykarthikeyan

      I'm trying to serial connect to the arduino Mega board through QSerialPort.But,the port is not opening.I have checked the port and it is properly connected with the board.Also,I have updated all the drivers. I have checked the connection in Putty.exe..the data bytes are coming in the putty.exe.But, when I tries to run in Qt..It saya error like this:
      Error opening serial port: "The semaphore timeout period has expired."
      bool QSerialPort::flush(): device not open

          foreach (const QSerialPortInfo &serial_Info, QSerialPortInfo::availablePorts()) {
              qDebug() << "Port: " << serial_Info.portName();
              portname = serial_Info.portName();
              qDebug() << "ProductId: " << serial_Info.vendorIdentifier();
              vendorId = serial_Info.vendorIdentifier();
              qDebug() << "VendorId: " << serial_Info.productIdentifier();
              productId = serial_Info.productIdentifier();
          }
          serial = new QSerialPort(this);
          serial->setPortName(portname);
          serial->setBaudRate(QSerialPort::Baud115200);
          serial->setDataBits(QSerialPort::Data8);
          serial->setParity(QSerialPort::NoParity);
          serial->setStopBits(QSerialPort::OneStop);
          serial->setFlowControl(QSerialPort::NoFlowControl);
          serial->setReadBufferSize(8192); // Sets the read buffer size to 8192 bytes
          serial->open(QIODevice::ReadWrite);
      
          if (serial->error() != QSerialPort::NoError) {
              qDebug() << "Serial port error: " << serial->errorString();
          } else {
              qDebug() << "Port opened";
          }
          QTimer *timer = new QTimer(this);
          connect(timer, &QTimer::timeout, this, &serial_link::serial_read);
          timer->start(1000);
      
      mzimmersM Offline
      mzimmersM Offline
      mzimmers
      wrote on last edited by
      #2

      @Vijaykarthikeyan is your PuTTY application (or any other application) currently using that port?

      V 1 Reply Last reply
      0
      • mzimmersM mzimmers

        @Vijaykarthikeyan is your PuTTY application (or any other application) currently using that port?

        V Offline
        V Offline
        Vijaykarthikeyan
        wrote on last edited by
        #3

        @mzimmers No..I closed it before running the qt.Actually ,I found the solution.Im initializing the class in both the serial_link.cpp and in main.cpp.So,both have opened the port that's why it is giving the error

        1 Reply Last reply
        0
        • V Vijaykarthikeyan has marked this topic as solved on

        • Login

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