Why does it takes soo long...?
-
@AnneRanch said in Why does it takes soo long...?:
I have removed the stupid mistake of adding ":command" text
command
is an actual CL command, but I dont think it's needed here to callbluetoothctl
."Failed Controller"
Note this error, which comes from
bluetoothctl
output.@Pl45m4 Partially solved. Had two instances of QProcess...
Will add real time timer to see the actual processing time. Still feels sluggish. -
@Pl45m4 Partially solved. Had two instances of QProcess...
Will add real time timer to see the actual processing time. Still feels sluggish.@AnneRanch Here is the latest - after fixing few "yser errors" it is still back to the original - why it takes 30 seconds to finish ??
It look s as the QProcess ":finished" is not really monitoring the "finished " but it runs some standard fixed timeout
12:18:01: Starting /mnt/RAID_124/PROJECTS_MAR1_/mdi/MDI... Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway. "void MainWindow::menu_slot_indexed(int)" "add it as subwindow " "setup Bluetooth virtual serial port \n void MainWindow_Bluetooth::on_actionBluetooith_virtiual_port_triggered()" "Process command...QString BT_Utility_Library::ProcessCommand(char *)" DEBUG TRACE start new QProcess(); "DEBUG TRACE start new QProcess();" "QProcess running.." **"QProcess elapsed time 30035"** "read stadard error " "read stadard output " "Waiting to connect to bluetoothd...\r\u001B[0;94m[bluetooth]\u001B[0m# \r\r\u001B[0;94m[bluetooth]\u001B[0m# \r \rAgent registered\n\u001B[0;94m[bluetooth]\u001B[0m# \r \r[\u0001\u001B[0;93m\u0002CHG\u0001\u001B[0m\u0002] Controller 00:50:B6:80:4D:5D Pairable: yes\n\u001B[0;94m[bluetooth]\u001B[0m# \r \r[\u0001\u001B[0;93m\u0002CHG\u0001\u001B[0m\u0002] Controller 00:15:83:15:A2:CB Pairable: yes\n\u001B[0;94m[bluetooth]\u001B[0m# " "Waiting to connect to bluetoothd...\r\u001B[0;94m[bluetooth]\u001B[0m# \r\r\u001B[0;94m[bluetooth]\u001B[0m# \r \rAgent registered\n\u001B[0;94m[bluetooth]\u001B[0m# \r \r[\u0001\u001B[0;93m\u0002CHG\u0001\u001B[0m\u0002] Controller 00:50:B6:80:4D:5D Pairable: yes\n\u001B[0;94m[bluetooth]\u001B[0m# \r \r[\u0001\u001B[0;93m\u0002CHG\u0001\u001B[0m\u0002] Controller 00:15:83:15:A2:CB Pairable: yes\n\u001B[0;94m[bluetooth]\u001B[0m# " "result OK" "Waiting to connect to bluetoothd...\r\u001B[0;94m[bluetooth]\u001B[0m# \r\r\u001B[0;94m[bluetooth]\u001B[0m# \r \rAgent registered\n\u001B[0;94m[bluetooth]\u001B[0m# \r \r[\u0001\u001B[0;93m\u0002CHG\u0001\u001B[0m\u0002] Controller 00:50:B6:80:4D:5D Pairable: yes\n\u001B[0;94m[bluetooth]\u001B[0m# \r \r[\u0001\u001B[0;93m\u0002CHG\u0001\u001B[0m\u0002] Controller 00:15:83:15:A2:CB Pairable: yes\n\u001B[0;94m[bluetooth]\u001B[0m# " "Controller" "Agent registered" 12:18:54: /mnt/RAID_124/PROJECTS_MAR1_/mdi/MDI exited with code 0
-
@AnneRanch Here is the latest - after fixing few "yser errors" it is still back to the original - why it takes 30 seconds to finish ??
It look s as the QProcess ":finished" is not really monitoring the "finished " but it runs some standard fixed timeout
12:18:01: Starting /mnt/RAID_124/PROJECTS_MAR1_/mdi/MDI... Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway. "void MainWindow::menu_slot_indexed(int)" "add it as subwindow " "setup Bluetooth virtual serial port \n void MainWindow_Bluetooth::on_actionBluetooith_virtiual_port_triggered()" "Process command...QString BT_Utility_Library::ProcessCommand(char *)" DEBUG TRACE start new QProcess(); "DEBUG TRACE start new QProcess();" "QProcess running.." **"QProcess elapsed time 30035"** "read stadard error " "read stadard output " "Waiting to connect to bluetoothd...\r\u001B[0;94m[bluetooth]\u001B[0m# \r\r\u001B[0;94m[bluetooth]\u001B[0m# \r \rAgent registered\n\u001B[0;94m[bluetooth]\u001B[0m# \r \r[\u0001\u001B[0;93m\u0002CHG\u0001\u001B[0m\u0002] Controller 00:50:B6:80:4D:5D Pairable: yes\n\u001B[0;94m[bluetooth]\u001B[0m# \r \r[\u0001\u001B[0;93m\u0002CHG\u0001\u001B[0m\u0002] Controller 00:15:83:15:A2:CB Pairable: yes\n\u001B[0;94m[bluetooth]\u001B[0m# " "Waiting to connect to bluetoothd...\r\u001B[0;94m[bluetooth]\u001B[0m# \r\r\u001B[0;94m[bluetooth]\u001B[0m# \r \rAgent registered\n\u001B[0;94m[bluetooth]\u001B[0m# \r \r[\u0001\u001B[0;93m\u0002CHG\u0001\u001B[0m\u0002] Controller 00:50:B6:80:4D:5D Pairable: yes\n\u001B[0;94m[bluetooth]\u001B[0m# \r \r[\u0001\u001B[0;93m\u0002CHG\u0001\u001B[0m\u0002] Controller 00:15:83:15:A2:CB Pairable: yes\n\u001B[0;94m[bluetooth]\u001B[0m# " "result OK" "Waiting to connect to bluetoothd...\r\u001B[0;94m[bluetooth]\u001B[0m# \r\r\u001B[0;94m[bluetooth]\u001B[0m# \r \rAgent registered\n\u001B[0;94m[bluetooth]\u001B[0m# \r \r[\u0001\u001B[0;93m\u0002CHG\u0001\u001B[0m\u0002] Controller 00:50:B6:80:4D:5D Pairable: yes\n\u001B[0;94m[bluetooth]\u001B[0m# \r \r[\u0001\u001B[0;93m\u0002CHG\u0001\u001B[0m\u0002] Controller 00:15:83:15:A2:CB Pairable: yes\n\u001B[0;94m[bluetooth]\u001B[0m# " "Controller" "Agent registered" 12:18:54: /mnt/RAID_124/PROJECTS_MAR1_/mdi/MDI exited with code 0
@AnneRanch SOLVED ??
I just realized I have been here before....
Here is the problem
"finished" does NOT monitor the QProcess for "end of story, done" it just waits until preset timeout... ( 30 s default )waitForReadyRead() actu8ally monitors the QProcess BUT
bluetoothctl FIRST line response is
"Waiting to connect to bluetoothd..."
and
waitForReadyRead() detect that line as " QProcess is done ..."DEBUG TRACE start new QProcess();
"DEBUG TRACE start new QProcess();"
"QProcess running.."
"QProcess finished"
"QProcess elapsed time 24"
"read stadard error "
"read stadard output "
"Waiting to connect to bluetoothd..."
"Waiting to connect to bluetoothd..."
"result OK"
"Waiting to connect to bluetoothd..."
"Failed Controller"
"Failed Agent registered"
12:49:17: /mnt/RAID_124/PROJECTS_MAR1_/mdi/MDI exited with code 0 -
@AnneRanch SOLVED ??
I just realized I have been here before....
Here is the problem
"finished" does NOT monitor the QProcess for "end of story, done" it just waits until preset timeout... ( 30 s default )waitForReadyRead() actu8ally monitors the QProcess BUT
bluetoothctl FIRST line response is
"Waiting to connect to bluetoothd..."
and
waitForReadyRead() detect that line as " QProcess is done ..."DEBUG TRACE start new QProcess();
"DEBUG TRACE start new QProcess();"
"QProcess running.."
"QProcess finished"
"QProcess elapsed time 24"
"read stadard error "
"read stadard output "
"Waiting to connect to bluetoothd..."
"Waiting to connect to bluetoothd..."
"result OK"
"Waiting to connect to bluetoothd..."
"Failed Controller"
"Failed Agent registered"
12:49:17: /mnt/RAID_124/PROJECTS_MAR1_/mdi/MDI exited with code 0@AnneRanch IIRC finished() is a signal that is emitted when the process is actually finished. However, waitForFinished() has a default parameter for 3 seconds. So, after 3 seconds it will just stop waiting. This is most likely now what you want.
-
@AnneRanch IIRC finished() is a signal that is emitted when the process is actually finished. However, waitForFinished() has a default parameter for 3 seconds. So, after 3 seconds it will just stop waiting. This is most likely now what you want.
@SimonSchroeder said in Why does it takes soo long...?:
has a default parameter for 3 seconds
The default is 30000 ms == 30 seconds.
-
@AnneRanch IIRC finished() is a signal that is emitted when the process is actually finished. However, waitForFinished() has a default parameter for 3 seconds. So, after 3 seconds it will just stop waiting. This is most likely now what you want.
@SimonSchroeder OK, let's define "process is finished" .
In my case the process task is to execute system command.
The command response is a raw text output - control characters and ASCII .How does process detects that the command output is done / fished?
( how does QProcess detects ANY "task is finished " ?)
In my opinion - it cannot .
So I ended with this - pseudo code
do
wait for "finshed"
check for "ReadyRead"did the read text contain desired data
in selected time interval ?while
no, go back to "do"or if selected time interval expired without data
exit -
@SimonSchroeder OK, let's define "process is finished" .
In my case the process task is to execute system command.
The command response is a raw text output - control characters and ASCII .How does process detects that the command output is done / fished?
( how does QProcess detects ANY "task is finished " ?)
In my opinion - it cannot .
So I ended with this - pseudo code
do
wait for "finshed"
check for "ReadyRead"did the read text contain desired data
in selected time interval ?while
no, go back to "do"or if selected time interval expired without data
exit@AnneRanch said in Why does it takes soo long...?:
How does process detects that the command output is done / fished?
( how does QProcess detects ANY "task is finished " ?)
In my opinion - it cannot .QProcess
detects when the process exits, which the OS reports to it. It is not determined by any output the process might or might not produce.While the process is still running the parent does not get/emit the finished signal and it may see output from the subprocess depending on how the sub-process output code is written.
When the process does finish any remaining output can be read.
-
@AnneRanch said in Why does it takes soo long...?:
How does process detects that the command output is done / fished?
( how does QProcess detects ANY "task is finished " ?)
In my opinion - it cannot .QProcess
detects when the process exits, which the OS reports to it. It is not determined by any output the process might or might not produce.While the process is still running the parent does not get/emit the finished signal and it may see output from the subprocess depending on how the sub-process output code is written.
When the process does finish any remaining output can be read.
@JonB So when I actually time my process by monitoring the actual data detected I get something around 500 ms. However , when I set the "finished" back to default ( 30 s) - the QProcess runs full 30 s .
I can probably set the "finished" to an hours and it will wait that long...
It tells me that OS , as you claim, does not generate anything to the QProcess to tell it (OS) is finished.
Your claim and my practical example just do not agree...
-
@JonB So when I actually time my process by monitoring the actual data detected I get something around 500 ms. However , when I set the "finished" back to default ( 30 s) - the QProcess runs full 30 s .
I can probably set the "finished" to an hours and it will wait that long...
It tells me that OS , as you claim, does not generate anything to the QProcess to tell it (OS) is finished.
Your claim and my practical example just do not agree...
@AnneRanch
Mine isn't a claim, it's how it works. You can also check the Qt source code.If
waitForFinished()
takes 30 seconds that tells you the subprocess has not exited. So obviously if you have connected thefinished
signal you will never get that.You can verify whether the subprocess you have spawned is still running (while your Qt app is still running) via a suitable
ps
.If what you spawn is an "interactive" program which waits for the user to type something it will not finish/exit. If your command is
bluetoothctl
does that not sit and wait for the user to type into it? -
@JonB So when I actually time my process by monitoring the actual data detected I get something around 500 ms. However , when I set the "finished" back to default ( 30 s) - the QProcess runs full 30 s .
I can probably set the "finished" to an hours and it will wait that long...
It tells me that OS , as you claim, does not generate anything to the QProcess to tell it (OS) is finished.
Your claim and my practical example just do not agree...
@AnneRanch Disregard r my last post... I just recall I have been thru this before and the real "problem" is - the "command" DOES not finishes - it is still running the "script" hence there is nothing to tell OS it is done .
END OF STORY