Unsolved QSerialPort's read buffer is always empty while running another func.
-
@J.Hilk said in QSerialPort's read buffer is always empty while running another func.:
also the deleteLater has to be moved to the destructor
If you pass the parent in the constructor there is no need to manually do this
-
-
@J-Hilk I did them you said, but the result is the same. It never gives the finished event, so it is always running.
-
-
@jsulm "/k img_cvt -i %1 -f 0" this is a one line command, so it has to write in one line. While I was also manually using this cmd application before, using it the same. Also, it successfully completes the conversion and creates a new folder within hex code. However, it never gives the finished information, it is continuous running to finish. I can see it's still running when re-click the button.
-
@Gokhan said in QSerialPort's read buffer is always empty while running another func.:
/k img_cvt -i %1 -f 0
Wrong it consists of several parameters: "/k" "img_cvt" "-i" "%1" "-f" "0"
-
That is a part of the user manual. I don't know how to use it like you said? However, it's normally running if use the waitforfinish function like I have mentioned above.
The usage is : img_cvt -i inputfilename -f format format is as follow: 0 : ARGB1555 [default] 1 : L1 2 : L4 3 : L8 4 : RGB332 5 : ARGB2 6 : ARGB4 7 : RGB565 8 : PALETTEED [FT80X only] 9 : L2 [FT81X only] Example : img_cvt -i lenaface40.png -f 8
-
@Gokhan
Just pass each parameter as one string in the string list (as shown here http://doc.qt.io/qt-5/qprocess.html):arguments <<"/k"<<"img_cvt"<<"-i"<<QString(%1).arg(img_down[0].image_with_ext)<<"-f"<<"0";
Also you should connect http://doc.qt.io/qt-5/qprocess.html#errorOccurred signal to a slot to check whether something went wrong.
-
@jsulm I just changed my code like you said and connected the signals that are like below in the constructor. The issue isn't solved. ErrorOccurred don't give an error while running.
proc = new QProcess (); connect(proc, & QProcess::errorOccurred, proc,[=](QProcess::ProcessError error){qDebug() <<"Process had an error:" << error; }); connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(finishProcess(int, QProcess::ExitStatus)) );
-
@Gokhan Connect http://doc.qt.io/qt-5/qprocess.html#readyReadStandardError and http://doc.qt.io/qt-5/qprocess.html#readyReadStandardOutput to slots and print out what http://doc.qt.io/qt-5/qprocess.html#readAllStandardError and http://doc.qt.io/qt-5/qprocess.html#readAllStandardOutput return. Maybe you will then see what is going on.
-
@jsulm There is no any readAllStandardError and you can see the output of readAllStandardOutput below. Everything shows normal.
readyReadStandardOutput "image conversion utility for FT8XX V0.7\r\nconvert complete!\r\n" readyReadStandardOutput "\r\nD:I\\conv>"
-
I'm trying that it, but I get an error that is "no matching function for call to 'image_down_dialog::connect(QProcess*&, <unresolved overloaded function type>, image_down_dialog*, void (image_down_dialog::*)(int, QProcess::ExitStatus))' " Why do I get this?
^
connect(proc, &QProcess::finished, this, &image_down_dialog::finishProcess); -
How did you declare
proc
? -
@Gokhan
Sadly, Signal finished is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast:connect(process, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), [=](int exitCode, QProcess::ExitStatus exitStatus){ /* ... */ });
-
@J-Hilk It should be connected below to compile successfully, so it's static cast. I did it and it can compile and connect now without an issue. However, I haven't solved this problem yet, it isn't still giving the finished event. Can it be a bug with qprocess ? Should I write a bug report?
QObject::connect(proc, (void (QProcess::*)(int,QProcess::ExitStatus))&QProcess::finished, this, &image_down_dialog::finished); -
You should rather use qOverload. In the case you can't, use a static_cast like @J-Hilk shown, not a C-Style cast.
As for never finishing, maybe because cmd.exe is still running. You are passing the
/k
parameter to cmd.exe which AFAIK meansrun the command and return to the CMD prompt
. Shouldn't you be using/C
? -
@SGaist thank you. The problem was solved when changed "/k" with "/c". However, the problem which I have mentioned in the title hasn't been solved yet. I'm still missing some data during communication with MCU through the serial port. The missing data are around 3K while sending 300K.
Also, I able to read max 512 byte in the readyRead signal, Is it writing to its read buffer during making another process like filling a table? If yes, how can I read the all buffer without missing any data?
-
Do you have any protocol established for the communication ?
-
@SGaist I have just solved this problem. it was caused by debugging mode. After it was realesed and run .exe, it normally ran, until the application window is moved. Yes, I have a new problem :). It's lagging and missing data during moving or resizing the application window. I just tried to up to real time priority for windows on task manager, but it's still missing.
-
@Gokhan
how about moving your QSerialPort stuff into int's own thread? Should make things a bit smoother as in its not blocked when your main thread is busy with ui-stuff.