QWindowsPipeWritter error
-
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.
-
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.
-
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
-
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
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#startedand run the write code there / rest of code.
or use
https://doc.qt.io/qt-5/qprocess.html#waitForStarted
to wait before the writes. -
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#startedand run the write code there / rest of code.
or use
https://doc.qt.io/qt-5/qprocess.html#waitForStarted
to wait before the writes.I have implemented a singleshot timer to the concept you said, and still the same issue persists :(
-
I have implemented a singleshot timer to the concept you said, and still the same issue persists :(
Hi
Ok maybe some error happens.
Hook up QProcess error signal and see if they report anything from starting it. -
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
@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
cmdto run one command for you, why do you start an interactivecmdwhen you could just usecmd /c ...? -
Do you need to use
cmdat all, could you not just executeupdateFirmwareCommandwithout it?
-