0

According to this, I'm using the system() (QProcess) function from inside my program to call the gpio program.

It works. But I've noticed I need to run my app two times, in fact it only works at the second time. It seems the call to gpio must be done in another process, as pointed here.

Should this problem be approached with QProcess::setupChildProcess()?

I extended QProcess overwriting setupChildProcess and then just instanciated SandboxProcess in the constructor of my app. Unfortunately, this didn't worked.

class SandboxProcess : public QProcess
{
 protected:
     void setupChildProcess();
};
void SandboxProcess::setupChildProcess()
{
    QString program = "/usr/local/bin/gpio";
    QStringList arguments;
    arguments << "export" << QString::number(4) << "out";
    start(program, arguments);
}
Community
  • 1
  • 1
KcFnMi
  • 5,516
  • 10
  • 62
  • 136

1 Answers1

0

I guess QProcess::setupChildProcess() doesn't help because it's own process starts after the main app proccess. So the main app still fells like the export command was not executed.

At this point I see two options:

  1. To make a ManagerApp, which call gpio (to do the exports) and then call (another) MyApp which will actually access the exported devices.
  2. Use the gpio app directly and listen to their stdout via signal/slot, using QProcess.
KernelPanic
  • 2,328
  • 7
  • 47
  • 90
KcFnMi
  • 5,516
  • 10
  • 62
  • 136