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. Correct way to shutdown embedded device (imx6)
QtWS25 Last Chance

Correct way to shutdown embedded device (imx6)

Scheduled Pinned Locked Moved Solved Mobile and Embedded
8 Posts 4 Posters 2.6k 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.
  • M Offline
    M Offline
    mostefa
    wrote on last edited by
    #1

    Hello guys,

    I am working on Qt project using Qt 4.7.4 under imx6 card ,
    -The human machine interface of the project contain a shutdown button ,

    What is the correct way to shutdown the system ?

    For the moment i am using directly QProcess::execute("poweroff"); but with this method my Qt app is closed immediately and the user is not informed that "Shutdown is in progress..."

    Is there a best practise to :

    1. Quit the Qt app properly before running poweroff.
    2. Inform the user that "Shutdown is in progress..." , (i can not inform the user with the Qt app , since Qt app is closed before starting the shutdown)

    Thank you in advance

    jsulmJ J.HilkJ 2 Replies Last reply
    0
    • M mostefa

      Hello guys,

      I am working on Qt project using Qt 4.7.4 under imx6 card ,
      -The human machine interface of the project contain a shutdown button ,

      What is the correct way to shutdown the system ?

      For the moment i am using directly QProcess::execute("poweroff"); but with this method my Qt app is closed immediately and the user is not informed that "Shutdown is in progress..."

      Is there a best practise to :

      1. Quit the Qt app properly before running poweroff.
      2. Inform the user that "Shutdown is in progress..." , (i can not inform the user with the Qt app , since Qt app is closed before starting the shutdown)

      Thank you in advance

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @mostefa said in Correct way to shutdown embedded device (imx6):

      "Shutdown is in progress..."

      Do you really need this? How long does it take for your device to shut down?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply
      1
      • jsulmJ jsulm

        @mostefa said in Correct way to shutdown embedded device (imx6):

        "Shutdown is in progress..."

        Do you really need this? How long does it take for your device to shut down?

        M Offline
        M Offline
        mostefa
        wrote on last edited by
        #3

        @jsulm said in Correct way to shutdown embedded device (imx6):

        @mostefa said in Correct way to shutdown embedded device (imx6):

        "Shutdown is in progress..."

        Do you really need this? How long does it take for your device to shut down?

        Yes, i think so,

        It take about 9, 10 seconds, and during this time there is nothing on the screen , so the user can think that the device is already off and can for example disconnect the power supply .

        1 Reply Last reply
        0
        • M mostefa

          Hello guys,

          I am working on Qt project using Qt 4.7.4 under imx6 card ,
          -The human machine interface of the project contain a shutdown button ,

          What is the correct way to shutdown the system ?

          For the moment i am using directly QProcess::execute("poweroff"); but with this method my Qt app is closed immediately and the user is not informed that "Shutdown is in progress..."

          Is there a best practise to :

          1. Quit the Qt app properly before running poweroff.
          2. Inform the user that "Shutdown is in progress..." , (i can not inform the user with the Qt app , since Qt app is closed before starting the shutdown)

          Thank you in advance

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          hi @mostefa

          if this call

          QProcess::execute("poweroff");

          results in your Qt- Program beeing closed, I don't think you can do anything.
          Seems like the OS is shutting down all running programs, which shuts down your app. You would have to change your device settings to show some kind of image during shutdown and not simply turning the screen off.

          However you could show a small note "The device is shutting down, this may take a moment" and start the Process delayed via a QTimer. E. g.

          QLabel *lbl = new QLabel( "The device is shutting down, this may take a moment"),
          lvl->show();
          QTimer::singleShot(2000, this, [=]{QProcess::execute("poweroff");});
          

          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          2
          • Cleiton BuenoC Offline
            Cleiton BuenoC Offline
            Cleiton Bueno
            wrote on last edited by
            #5

            Are you using Graphic Server (X11) / Wayland or EGLFS?
            Have you set up some SplashScreen something like psplash?

            For example, I already used something like this using EGLFS:

            1. HMI Application Qt5 is one of the first services to come up after the Splash Screen
            2. HMI application Qt5 is one of the last applications to turn off and lastly the Splash Screen that can even customize an image / message for this.
            3. Disable bootloader(U-boot) bootcmd and even in the kernel FrameBuffer and Postscreen Console features to remove any message on the screen beyond the images

            Other ideas, for example if you have rootfs as read-only and a separate read-write partition, you can call systemd services and terminate applications / daemons like Database, Web servers, finally give a sync() and a QProcess process ; process.startDetached("shutdown -P now"); .
            And until you get to this "shutdown -P now" you can use a Timer and a ProgressBar (something similar that @J-Hilk showed) in a final screen showing the services closed and finalizing the (file descriptors) correctly, and only after that turn off " immediately".


            Cleiton Bueno

            Blog | Linkedin | B2Open

            1 Reply Last reply
            3
            • M Offline
              M Offline
              mostefa
              wrote on last edited by mostefa
              #6

              @J-Hilk

              Thank you for your answer , but i don't know how to change my device (linux imx6 card) settings to display a shutdown image or message ( i think that there is something to do with framebuffer but i don't know how)

              @Cleiton-Bueno

              Thank you for you answer:
              I am not having GraphicServer or EGLFS, but i am using QWS( when i run Qt app , i have to add -qws args)

              http://doc.qt.io/archives/qt-4.8/qt-embedded-running.html

              Yes i have a bootup splash screen , to set my bootup splashscreen i am using ptxdist

              alt text

              But there is no settings to add poweroff logo .

              So my idea for now is to have one systemd service that display my shutdown image:

              [Unit]
              Description= Poweroff image
              DefaultDependencies=no
              Before=halt.target
              
              [Service]
              ExecStart=//Here display myimage.png or myimage.jpeg or myimage.other to framebuffer
              
              
              Type=oneshot
              
              [Install]
              WantedBy=halt.target poweroff.target
              

              So do you know what is the command line on linux to display an image with framebuffer ?

              1 Reply Last reply
              0
              • Cleiton BuenoC Offline
                Cleiton BuenoC Offline
                Cleiton Bueno
                wrote on last edited by
                #7

                @mostefa said in Correct way to shutdown embedded device (imx6):

                So do you know what is the command line on linux to display an image with framebuffer ?

                @mostefa

                Ohh! That's too bad, with Yocto Project there is PSplash that already does this task.

                As you are using pxtdist, install and use fbi and add in your service something like:

                /usr/bin/fbi -d /dev/fb0 -noverbose -a image_poweroff.jpg
                

                Cleiton Bueno

                Blog | Linkedin | B2Open

                M 1 Reply Last reply
                2
                • Cleiton BuenoC Cleiton Bueno

                  @mostefa said in Correct way to shutdown embedded device (imx6):

                  So do you know what is the command line on linux to display an image with framebuffer ?

                  @mostefa

                  Ohh! That's too bad, with Yocto Project there is PSplash that already does this task.

                  As you are using pxtdist, install and use fbi and add in your service something like:

                  /usr/bin/fbi -d /dev/fb0 -noverbose -a image_poweroff.jpg
                  

                  Cleiton Bueno

                  Blog | Linkedin | B2Open

                  M Offline
                  M Offline
                  mostefa
                  wrote on last edited by mostefa
                  #8

                  @Cleiton-Bueno said in Correct way to shutdown embedded device (imx6):

                  @mostefa said in Correct way to shutdown embedded device (imx6):

                  So do you know what is the command line on linux to display an image with framebuffer ?

                  @mostefa

                  Ohh! That's too bad, with Yocto Project there is PSplash that already does this task.

                  As you are using pxtdist, install and use fbi and add in your service something like:

                  /usr/bin/fbi -d /dev/fb0 -noverbose -a image_poweroff.jpg
                  

                  Cleiton Bueno

                  Blog | Linkedin | B2Open

                  it's ok for now thank you for your answer.

                  Of course yocto is a great project , but unfortunately i can not use it for the current project :'(

                  Thank's again

                  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