Hello Everyone,
This is my first time posting, so bear with me as I get used to the format.
I am using Qt 5.4.2 and red hat Linux 7.2
Description:
1. I am creating a GUI that basically has some buttons to turn some relays on and off. (I'm done with the gui part)
2 . Now this device is on the network and is user/password protected which I know both.
3. I am creating a QProcess to communicate through Telnet and pass commands to turn on/off or enter credentials.
This is what I am doing (please assume I call this in the main):
void Example::process()
{
QString prog = "telnet";
QStringList arguments;
arguments << "123.456.78.90" << "23"; // ip and port
QProcess telnet;
telnet.start(program, arguments);
if(telnet.waitForStarted())
telnet.write("set 8 1");// which sets relay on
telnet.closeWriteChannel();
if(telnet.waitForFinished())
qDebug() << telnet.readAllStardardOutput();
}
//-------------------------Output--------------------------
Trying 123.456.78.90
Connected to 123.456.78.90
Escape Character is '^]'
"
//-----------------------------end of output ------------
Now if I put telnet.execute(...) instead of telnet.start(...)
//-------------------------Output--------------------------
Trying 123.456.78.90
Connected to 123.456.78.90
Escape Character is '^]'
Synacces Inc. Telnet Session V6.1
//-----------------------------end of output ------------
which is how it looks when I do that in the terminal, but program hangs waiting.
Now my question is:
How can I make it that it can receive more commands without closing that process? I don't want to close telnet because I have to tell it the ip and port again.
Mainly notice that when I say telnet.write(command) it doesn't do anything. and I have put that line outside of the if and nothing.
I would be running the terminal in the background while GUI is displaying buttons, but like I said GUI part is done.
Thanks for any help and I hope it makes sense what I'm trying to accomplish
Bookmarks