![]() |
#1 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,293
Karma: 529619
Join Date: May 2007
Device: iRex iLiad, DR800SG
|
Shutdown mode - proof of concept
Before I start, standard warnings. I'm just messing around with this. I have no idea yet if there are any serious side effects (assume there are until we learn otherwise). Mostly this is just theoretical for now, so TRY AT YOUR OWN RISK
OK, on to the interesting part. Given some recent discussions about the DR800 only having a sleep mode and not a real "off" available to the user, I decided to play around on my device with some scripts. I created myShutdown.desktop in the Personal Documents folder with this: Code:
[Desktop Entry] Name=myShutdown Type=Application Exec=/media/mmcblk0p1/Programs/myShutdownScript.sh Code:
#!/bin/sh
shutdown -h -P now >> /media/mmcblk0p1/Programs/myShutdownLog.txt 2>&1
When you click on the desktop item, after 5 seconds the screen goes blank. The next press on the power switch causes a complete bootup sequence. So, I'm assuming that the device does not just go to sleep, but actually shuts down. The questions still remaining:
In theory (once it's completed and fully tested), what this will let people do is choose to power off the device instead of put it into sleep mode. The benefits are that if you know it's not going to be used for awhile, it will (theoretically, but not proven yet) preserve battery. The drawback is that when you do want to use it again you have to do a full boot, which takes 40-50 seconds. Last edited by Shaggy; 04-28-2010 at 02:56 AM. |
![]() |
![]() |
![]() |
#2 |
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 185
Karma: 119824
Join Date: Feb 2008
Device: iLiad, DR1000S, HTC Hero, DR800SG
|
you can use the rxvt terminal program from GregorRichards:
see this post to give this command manually and see what the device does. I don't think yours is a harmful script. It's just the regular shutdown command from Linux. By the way... don't use the reboot attributes (-f -F), these seem to freeze my DR800 |
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
ex-IRX developer
![]() ![]() ![]() Posts: 158
Karma: 224
Join Date: Oct 2008
Device: Irex DR800S, DR1000S, iLiad
|
Quote:
A cleaner approach would be to follow the path of SYSD's API call "sysShutdown". For DR1000 this triggers the shutdown, on DR800 it goes to standby mode. With a bit of juggling, a call could be added to do the complete shutdown for DR800. |
|
![]() |
![]() |
![]() |
#4 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 730
Karma: 72743
Join Date: Feb 2008
Location: Here or there
Device: iRex iLiad, iRex DR800S. K4NT. Kobo Aura, Aura One, Libra 2.
|
You could also use the lua-based Toolbox from https://www.mobileread.com/forums/showthread.php?t=79273 (2nd. message).
By the moment, it's the same base code as Iliad, but it does work on DR. |
![]() |
![]() |
![]() |
#5 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,293
Karma: 529619
Join Date: May 2007
Device: iRex iLiad, DR800SG
|
Quote:
I'll look into SYSD some more. This was just such a tempting shortcut though, that I couldn't resist trying it to see what would happen. Oh well. ![]() |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Connoisseur
![]() ![]() Posts: 60
Karma: 151
Join Date: Apr 2010
Device: DR800SG
|
The standard shutdown process will synchronize and unmount filesystems. After SIGTERM'ing apps of course. I would certainly hope that any builtin apps that depend on their runtime state would catch SIGTERM properly. With a quick look of the sources I happened to already have downloaded, erbrowser does in fact catch SIGTERM and handle it. I don't have the content browser or document viewer source.
|
![]() |
![]() |
![]() |
#7 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,293
Karma: 529619
Join Date: May 2007
Device: iRex iLiad, DR800SG
|
Quote:
I see there's a sysclient that can be called with sysShutdown. This in turn leads to sys_standby(). That's where we have the branch between the DR800 and DR1000. The DR800 goes to prepare_standby() and the DR1000 goes to do_poweroff(). If we add a new argument to sysclient like userShutdown, and make a clone of sys_standby(), something like user_standby() that doesn't do the branch based on the device, but just goes to do_poweroff()... I think that's what we're looking for. The only thing I've seen in do_poweroff() that is a little bit of a concern is where it unlocks/enables the DR1000 sensors. I haven't look into it deep enough to know if calling that will cause any issues on the DR800, or if we should modify on_poweroff_continue() to check for DR800 vs DR1000. Assuming all that works, we can then create a .desktop file that calls "sysclient userShutdown". |
|
![]() |
![]() |
![]() |
#8 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,293
Karma: 529619
Join Date: May 2007
Device: iRex iLiad, DR800SG
|
Quote:
The problems with doing it outside of sysd are: 1) Do the apps handle a SIGTERM in the same manner as being told by sysd that it is preparing an unmount. 2) Will they finish quick enough, or will the system shutdown send them a SIGKILL while they're still trying to gracefully exit. The system shutdown only waits X seconds before it kills them, it can't sync up with the apps like sysd does. As Gertjan says, doing it through sysd is a lot cleaner. |
|
![]() |
![]() |
![]() |
#9 | |
ex-IRX developer
![]() ![]() ![]() Posts: 158
Karma: 224
Join Date: Oct 2008
Device: Irex DR800S, DR1000S, iLiad
|
Quote:
|
|
![]() |
![]() |
![]() |
#10 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,293
Karma: 529619
Join Date: May 2007
Device: iRex iLiad, DR800SG
|
Quote:
Now I just need to setup a development environment. ![]() |
|
![]() |
![]() |
![]() |
#11 |
Connoisseur
![]() ![]() Posts: 60
Karma: 151
Join Date: Apr 2010
Device: DR800SG
|
Presumably it's preferable to avoid modifying sysd ... there is an IPC command to unmount the filesystem, I'm sure if you were careful to use daemon(3) first you could survive it (the shutdown app would have to be in C to do this of course). Without having the time right now to look through sysd, does it send all the same cleanup signals when it's asked explicitly to unmount the card, or only when it's shutting down?
|
![]() |
![]() |
![]() |
#12 |
Connoisseur
![]() ![]() Posts: 60
Karma: 151
Join Date: Apr 2010
Device: DR800SG
|
Here's a super-quick gross program that replicates sysd's shutdown procedure without requiring changes to sysd. It "seems" to work, in that it appears to shut down my DR800SG and doesn't leave it in some horrible unbootable state. This was just a quick hack
![]() |
![]() |
![]() |
![]() |
#13 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,293
Karma: 529619
Join Date: May 2007
Device: iRex iLiad, DR800SG
|
Quote:
|
|
![]() |
![]() |
![]() |
#14 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,293
Karma: 529619
Join Date: May 2007
Device: iRex iLiad, DR800SG
|
Quote:
|
|
![]() |
![]() |
![]() |
#15 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,293
Karma: 529619
Join Date: May 2007
Device: iRex iLiad, DR800SG
|
Quote:
I'm going to keep going down the path of putting it into sysd though, mostly just for the fun of doing it. ![]() |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Device shutdown | k0077 | Sony Reader | 8 | 08-27-2010 03:46 PM |
Proof of Concept: TeX-based ebook program in iPad | frabjous | General Discussions | 2 | 07-09-2010 08:46 AM |
iLiad auto shutdown | jboardman | iRex Developer's Corner | 0 | 04-29-2009 03:04 PM |
battery is used even after shutdown? | flyingtablet | iRex | 6 | 11-10-2008 02:27 PM |
Proof Of Concept - RSS->PDF | sartori | Sony Reader | 12 | 10-07-2006 03:40 PM |