Correct way to shutdown embedded device (imx6)
-
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 :
- Quit the Qt app properly before running poweroff.
- 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
-
@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?
-
@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 .
-
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");});
-
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:
- HMI Application Qt5 is one of the first services to come up after the Splash Screen
- 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.
- 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 aQProcess 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
-
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)
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
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 ?
-
@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 ?
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
-
@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 ?
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
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