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. QWindowsPipeWritter error
Forum Updated to NodeBB v4.3 + New Features

QWindowsPipeWritter error

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 1.5k Views 2 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.
  • Dharani PrasadD Offline
    Dharani PrasadD Offline
    Dharani Prasad
    wrote on last edited by
    #1

    Hi all,

    QWindowsPipeWriter::write failed. (The handle is invalid.)
    

    is the issue I'm facing while I try to write a cmd to CLI using QProcess in Qt to update a firmware connected to my port. Could anyone help me resolve this?

    Thanks in Advance.

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

      Hi
      Without code its very hard to guess at as it sounds like something internal is not valid.

      So please show the code that result in this error and make sure its not due to QProcess running out of scope.

      1 Reply Last reply
      0
      • Dharani PrasadD Offline
        Dharani PrasadD Offline
        Dharani Prasad
        wrote on last edited by
        #3
        QProcess *updateFirmwareProcess;
            updateFirmwareProcess = new QProcess(this);
            updateFirmwareProcess->start(CLI.exe_path);
            updateFirmwareProcess->write(updateFirmwareCommand.toUtf8().data());
            updateFirmwareProcess->write("\n\r");
            updateFirmwareProcess->write("");
            updateFirmwareProcess->closeWriteChannel();
            if (updateFirmwareProcess->waitForFinished())
            {
                    QByteArray output = updateFirmwareProcess->readAllStandardOutput();
                    qDebug() << output;
            }
        

        Here is the code

        mrjjM JonBJ 2 Replies Last reply
        0
        • Dharani PrasadD Dharani Prasad
          QProcess *updateFirmwareProcess;
              updateFirmwareProcess = new QProcess(this);
              updateFirmwareProcess->start(CLI.exe_path);
              updateFirmwareProcess->write(updateFirmwareCommand.toUtf8().data());
              updateFirmwareProcess->write("\n\r");
              updateFirmwareProcess->write("");
              updateFirmwareProcess->closeWriteChannel();
              if (updateFirmwareProcess->waitForFinished())
              {
                      QByteArray output = updateFirmwareProcess->readAllStandardOutput();
                      qDebug() << output;
              }
          

          Here is the code

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Dharani-Prasad

          Super.

          It could be that the actual exe you start is a few moments to start and since qprocess::start is async
          it can be the error is due to you write too soon.

          so hook a slot up to the started signal
          https://doc.qt.io/qt-5/qprocess.html#started

          and run the write code there / rest of code.
          or use
          https://doc.qt.io/qt-5/qprocess.html#waitForStarted
          to wait before the writes.

          Dharani PrasadD 1 Reply Last reply
          3
          • mrjjM mrjj

            @Dharani-Prasad

            Super.

            It could be that the actual exe you start is a few moments to start and since qprocess::start is async
            it can be the error is due to you write too soon.

            so hook a slot up to the started signal
            https://doc.qt.io/qt-5/qprocess.html#started

            and run the write code there / rest of code.
            or use
            https://doc.qt.io/qt-5/qprocess.html#waitForStarted
            to wait before the writes.

            Dharani PrasadD Offline
            Dharani PrasadD Offline
            Dharani Prasad
            wrote on last edited by
            #5

            @mrjj

            I have implemented a singleshot timer to the concept you said, and still the same issue persists :(

            mrjjM 1 Reply Last reply
            0
            • Dharani PrasadD Dharani Prasad

              @mrjj

              I have implemented a singleshot timer to the concept you said, and still the same issue persists :(

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Dharani-Prasad

              Hi
              Ok maybe some error happens.
              Hook up QProcess error signal and see if they report anything from starting it.

              1 Reply Last reply
              0
              • Dharani PrasadD Dharani Prasad
                QProcess *updateFirmwareProcess;
                    updateFirmwareProcess = new QProcess(this);
                    updateFirmwareProcess->start(CLI.exe_path);
                    updateFirmwareProcess->write(updateFirmwareCommand.toUtf8().data());
                    updateFirmwareProcess->write("\n\r");
                    updateFirmwareProcess->write("");
                    updateFirmwareProcess->closeWriteChannel();
                    if (updateFirmwareProcess->waitForFinished())
                    {
                            QByteArray output = updateFirmwareProcess->readAllStandardOutput();
                            qDebug() << output;
                    }
                

                Here is the code

                JonBJ Online
                JonBJ Online
                JonB
                wrote on last edited by
                #7

                @Dharani-Prasad
                A couple of observations. They probably have nothing to do with the error you are seeing, but anyway:

                • updateFirmwareProcess->write("\n\r"); You should have "\r\n"?

                • Assuming you are just asking cmd to run one command for you, why do you start an interactive cmd when you could just use cmd /c ...?

                • Do you need to use cmd at all, could you not just execute updateFirmwareCommand without it?

                1 Reply Last reply
                1

                • Login

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