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. Open Serial Port

Open Serial Port

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 501 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.
  • martial123M Offline
    martial123M Offline
    martial123
    wrote on last edited by
    #1

    Hi !

    To open serial port, we just need this ligne ? :

    port = new QSerialPort();
    port->open(QIODevice::ReadWrite);
    

    when i execute, i have an error :

    QIODevice::write (QSerialPort): device not open

    ps : ( i have config port like this : )

    SerialPort::SerialPort(QWidget *parent):
        QDialog(parent)
    {
    
       port = new QSerialPort();
       port->setPortName("portname");
       port->setBaudRate(QSerialPort::Baud115200);
       port->setParity(QSerialPort::NoParity);
       port->setDataBits(QSerialPort::Data8);
       port->setStopBits(QSerialPort::OneStop);
    
       //bool a = port->open(QIODevice::ReadWrite);
       //cout<< "le port est ouveret ?  " << a << endl;
    
    }```
    cout send me : a = 0 if i execute last 2 ligne ... and i see in documentation if port open is successful, so it's return false ...
    1 Reply Last reply
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on last edited by kuzulis
      #2

      You need to set a right device name (aka port name) before opening.

      1 Reply Last reply
      3
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        just as a note.
        This example is very good for testing out serialport
        https://doc.qt.io/qt-5/qtserialport-terminal-example.html

        1 Reply Last reply
        3
        • martial123M Offline
          martial123M Offline
          martial123
          wrote on last edited by
          #4

          Yes i have see that befor your answer ^^ its COM3 and not portname When i setPortName
          ty !

          1 Reply Last reply
          0

          • Login

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