Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to use QProcess for restarting the device
QtWS25 Last Chance

How to use QProcess for restarting the device

Scheduled Pinned Locked Moved Solved Mobile and Embedded
6 Posts 3 Posters 4.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NTCYP
    wrote on last edited by NTCYP
    #1

    Hi,

    Unlike a pc type, my device works continuesly (7/24). Somehow the user must re-start the device.
    My shotdown look like this;

    system("poweroff");
    

    Poweroff works nicely. And yesterday I use QProcess for the ping command as;

       // Create QProcess object
        proc = new QProcess();
        proc->start("ping", QStringList() << "-c" << "3" << QString(m_sHostName));
    

    For the restart first I try to use;

    system("shutdown -r 0");
    

    and nothing happened. So I decided to use QProcess for start as;

            // Create QProcess object
            procR = new QProcess();
            procR->start("shutdown" << "-r" << "0");
    

    then I get a compile error as;

    /home/ntms/Desktop/ELITCARD/mainwindow.cpp:374: error: invalid operands of types 'const char [9]' and 'const char [3]' to binary 'operator<<'
    

    Any help please,

    Kind Regards

    K 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Look again at your ping start line to build the parameters.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      N 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Look again at your ping start line to build the parameters.

        N Offline
        N Offline
        NTCYP
        wrote on last edited by
        #3

        @SGaist Thank you again.

        I forget the "reboot". My device usr/sbin had a rebboot app so simply I call as;

        system("reboot");
        

        And its works nicely. For shutdown, poweroff and the reboot doesn't need any parameters.

        Kind Regards,

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You can also use QProcess and not pass any arguments

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          N 1 Reply Last reply
          0
          • N NTCYP

            Hi,

            Unlike a pc type, my device works continuesly (7/24). Somehow the user must re-start the device.
            My shotdown look like this;

            system("poweroff");
            

            Poweroff works nicely. And yesterday I use QProcess for the ping command as;

               // Create QProcess object
                proc = new QProcess();
                proc->start("ping", QStringList() << "-c" << "3" << QString(m_sHostName));
            

            For the restart first I try to use;

            system("shutdown -r 0");
            

            and nothing happened. So I decided to use QProcess for start as;

                    // Create QProcess object
                    procR = new QProcess();
                    procR->start("shutdown" << "-r" << "0");
            

            then I get a compile error as;

            /home/ntms/Desktop/ELITCARD/mainwindow.cpp:374: error: invalid operands of types 'const char [9]' and 'const char [3]' to binary 'operator<<'
            

            Any help please,

            Kind Regards

            K Offline
            K Offline
            koahnig
            wrote on last edited by
            #5

            @NTCYP said:

                    // Create QProcess object
                    procR = new QProcess();
                    procR->start("shutdown" << "-r" << "0");
            

            Just saw that you had a C++ syntax problem. You try to stream char arrays into a char array. That is not healthy and the reason why the compiler complains.

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply
            0
            • SGaistS SGaist

              You can also use QProcess and not pass any arguments

              N Offline
              N Offline
              NTCYP
              wrote on last edited by
              #6

              @SGaist Yes both worked. It seems much faster to use system("reboot"). Device is not accessible from network. So I don't have any security concern to use "system". Thank you for your insight, appreciated.

              Kind Regards,

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved