k. But i tested same qt program with simple C program . it will just print 1,2,3,4,5,4,3,2,1... and no serial port setting in C program , it worked fine and giving continues output without delay .
k. But i tested same qt program with simple C program . it will just print 1,2,3,4,5,4,3,2,1... and no serial port setting in C program , it worked fine and giving continues output without delay .
Serial port is set in C program , so calling QProcess will set serial port . thats y not using Qserialport in Qt .Also , C program process the received signal from serial port and print output . this output is storing in byte array and using for plot .
I compiled C program from terminal and getting correct output in terminal . but Qt taking more time call QProcess and plot , don't getting idea where this delay occurring ...
I still think you need to break the problem down into the smallest piece possible, than add more features. I would start by writing a Qt program that simply starts the listener process, reads the output from your sensor and prints it using qDebug(). No printing it to a text edit, no logging to files, no plotting. At this point, you have no idea which step in this chain is going wrong, so eliminate everything except the first one: getting data successfully from the QProcess into your program. Once that seems to be working in the same way as your C program, then you know the communication works, so add the graphics and other features.
You might also try using QProcess:readAllStandardOutput() to get all of the available data at once instead of using readLine(). Use QByteArray::data() or QByteArray::constData() to get the NULL-terminated C string it contains. This way you do not have to worry about the buffer size or whether you have read it all.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
suhairkp (23rd February 2017)
k . sir. I am testing it without plot . in my above code , it displaying "process error code : 2 " in Application output area of Qt Creator , when output gui display open and saying " Qprocess : Destroyed while process is still running ". when i changed process->waitForStarted from process->waitForFinished , it show that "process error code : 5 "
Last edited by suhairkp; 23rd February 2017 at 11:10.
Once again : why You use external program to read data from serial port ? Why You don't do it in Qt program ?
Bookmarks