AnnM
29th July 2013, 22:41
Hi!
I'm having a lot of trouble getting my QProcess to interact with an executable file. Just a bit of background, I have a QT application in Linux and I'm trying to import some data (electromagnetic tracker) from an existing Windows executable to use in my linux code. This windows executable is able to stream the data I need after first connecting to the tracking device over the network. I'm using wine to run the executable in linux, and it works great with the command line. What I want though, is to have my QT application (a simulation with a haptic device) to automatically run the executable, input the commands needed to start data acquisition (i.e. connect to the correct IP address for the device and enter a few specific commands like numbers and enter key presses).
I am able to get xterm (or gnome-terminal) to run my windows executable with the following commands:
QObject *parent;
....
QString arguments;
arguments <<"-e" << "wine ./{path to exe}/{name}.exe"; // stuff in {} is specific to my program. the path and name is correct.
QProcess *myProcess = new QProcess(parent); // this might be unnecessarily complicated with the parent.
myProcess->start("xterm",arguments); // here the windows executable command line interface shows up on the new terminal.
myProcess->write("1\n"); // THIS AND BELOW DON'T WORK. using the wait until complete function doesn't help
myProcess->write(" {dev IP address} 0/n");
myProcess->write("19/n");
myProcess->write("20000/n");
<here I'm expecting to see data streaming on the terminal>
-------
When the terminal window opens, I am actually able to manually enter the necessary commands, and the program works fine. However, I can't figure out how to input the commands automatically with my QT code. After extensive searching online, I thought it might have something to do with not starting bash so I added that to my argument list, but with that addition, it looked like my executable didn't start and neither did the new terminal. Also, hopefully this bug isn't due to wine - I can't avoid that! Any help would be greatly appreciated!!
Thanks!
Ann
PS - I still haven't tried to collect data from the terminal and plan to do so with myProcess->readAllStandardOutput() once I can actually get data to stream. If you forsee any issues with that, please let me know!
I'm having a lot of trouble getting my QProcess to interact with an executable file. Just a bit of background, I have a QT application in Linux and I'm trying to import some data (electromagnetic tracker) from an existing Windows executable to use in my linux code. This windows executable is able to stream the data I need after first connecting to the tracking device over the network. I'm using wine to run the executable in linux, and it works great with the command line. What I want though, is to have my QT application (a simulation with a haptic device) to automatically run the executable, input the commands needed to start data acquisition (i.e. connect to the correct IP address for the device and enter a few specific commands like numbers and enter key presses).
I am able to get xterm (or gnome-terminal) to run my windows executable with the following commands:
QObject *parent;
....
QString arguments;
arguments <<"-e" << "wine ./{path to exe}/{name}.exe"; // stuff in {} is specific to my program. the path and name is correct.
QProcess *myProcess = new QProcess(parent); // this might be unnecessarily complicated with the parent.
myProcess->start("xterm",arguments); // here the windows executable command line interface shows up on the new terminal.
myProcess->write("1\n"); // THIS AND BELOW DON'T WORK. using the wait until complete function doesn't help
myProcess->write(" {dev IP address} 0/n");
myProcess->write("19/n");
myProcess->write("20000/n");
<here I'm expecting to see data streaming on the terminal>
-------
When the terminal window opens, I am actually able to manually enter the necessary commands, and the program works fine. However, I can't figure out how to input the commands automatically with my QT code. After extensive searching online, I thought it might have something to do with not starting bash so I added that to my argument list, but with that addition, it looked like my executable didn't start and neither did the new terminal. Also, hopefully this bug isn't due to wine - I can't avoid that! Any help would be greatly appreciated!!
Thanks!
Ann
PS - I still haven't tried to collect data from the terminal and plan to do so with myProcess->readAllStandardOutput() once I can actually get data to stream. If you forsee any issues with that, please let me know!