May 23, 2012

bluscape bluscape
Lab Rat
6 posts

Qt embedded console commands request and reply

 

I’m using Qt embedded on linux.
From the console (serial console) I use the following command to get status on my ppp:

/etc/rc.d/S09pppd status

The ppp will reply with “pppd running” or “pppd not running”

I would like to execute this request from my Qt application and read the reply from my Qt application.

How can I do this?

4 replies

May 23, 2012

bluscape bluscape
Lab Rat
6 posts

So I execute the command with a QProcess for example:

  1. QProcess qpCommand;
  2.  
  3. qpCommand.execute("/etc/rc.d/S09pppd status");

which is creating the desired effect.

Now how do I read the response?

May 23, 2012

Blizzard Blizzard
Lab Rat
67 posts

  1. qpCommand.readData(char * data, qint64 maxlen)

 Signature 

Software Engineer | Aerospace & Defence

June 19, 2012

bluscape bluscape
Lab Rat
6 posts

But readData is a protected function?

June 23, 2012

Volker Volker
Robot Herder
5428 posts

QProcess::execute() is a static method. It does not return any output of the started command/executable. You will have to use the non-static methods in order to ready any data.

  1. p.start("/etc/rc.d/S09pppd status");
  2. p.waitForFinished(); // blocks!
  3. QByteArray output = p.readAllStandardOutput();

 
  ‹‹ Mixing C and C++/Qt code      The mouse move between two frame buffer sometimes will have error. ››

You must log in to post a reply. Not a member yet? Register here!