Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Kobo Reader > Kobo Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 04-30-2020, 11:48 AM   #1
KristianR
Member
KristianR began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Feb 2016
Device: none
How to exit a "suspended" script (loop)?

Hi there,

if one is running a script without user interaction (e.g. picture frame, dashboard, weather-display ...) what is the best way to return to the ebook reader application without resetting the device?

Example "picture frame":
Current implementation is to have a "while true" loop that updates the image and then sends the reader to "suspend to ram" via rtcwake (e.g. for half an hour - so essentially the reader is in suspend to ram most of the time). What I noticed is that the reader wakes up from suspend to ram when the power button is pressed. I could use this to trigger the script to exit but I am not sure wether the wake up was due to power button press or just at the scheduled time.

I came up with the following ideas:
  • remember the scheduled wake-up-time, compare to actual-wake-up-time. If it differs by more than say 5s assume wake up was due to press of power button -> exit script, restart nickel etc.
  • Monitor /dev/input/event0 in some way
    Code:
    cat /dev/input/event0 | hexdump
    E.g. pipe to file and evaluate if file is empty or not (Was not able to use output of evtest). If file is not empty -> exit script, restart nickel etc.


Which would be the recommended way to implement this? Any other ideas to implement this - is there a way to detect the reason for wake up (i.e. scheduled time reached or power button)?


To restart nickel could this script be used? https://github.com/koreader/koreader...kobo/nickel.sh

Kind regards
KristianR
KristianR is offline   Reply With Quote
Old 04-30-2020, 12:15 PM   #2
NiLuJe
BLAM!
NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.NiLuJe ought to be getting tired of karma fortunes by now.
 
NiLuJe's Avatar
 
Posts: 13,506
Karma: 26047202
Join Date: Jun 2010
Location: Paris, France
Device: Kindle 2i, 3g, 4, 5w, PW, PW2, PW5; Kobo H2O, Forma, Elipsa, Sage, C2E
KOReader goes with the first approach, which has the advantage of not requiring anything new, because your script is already expecting to resume from an rtc wakeup. It may require some fun (not) roundtrips between UTC and local time, though.

As for the second, you can't even listen to event0 without a patch while Nickel is running, and you'd need to be listening *before* the button press comes in. Without thinking too much about it, this would be messy in shell. And, yes, the evtest shipped by default is broke as hell. I ship the real deal in my stuff, and @frostchutz implemented a minimal solution in C for MiniClock.

Be aware that to properly restart Nickel, you have to match its env & PWD. So you'll also also have to handle the env slurping done by KOReader's startup script *before* killing Nickel.

Last edited by NiLuJe; 04-30-2020 at 04:36 PM.
NiLuJe is offline   Reply With Quote
Advert
Old 04-30-2020, 04:11 PM   #3
KristianR
Member
KristianR began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Feb 2016
Device: none
Thanks for the recommendation - then I will follow the first approach. I already noticed that it is a bit tricky with rtcwake and system- vs. hardwareclock.

In the next step I plan to install your kobo-stuff and kfmon.

Kimd regards
KristianR
KristianR is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
"Username/password required, retrying..." Loop stio Related Tools 4 12-22-2019 11:45 AM
KV KV stuck on "DIAGS EXIT Please use serial port" page oumlaut Kindle Developer's Corner 23 05-17-2019 06:57 AM
Troubleshooting Kindle PW3 bricked "DIAGS EXIT Please use serial port" neverthesane Amazon Kindle 2 05-20-2018 02:27 PM
In case your PW got "bricked" / stuck in Diags Exit please use serial port justaheadsup Kindle Developer's Corner 1 05-02-2017 07:40 PM
"Updating your Story HD... Please wait" loop mzecher iRiver Story 27 08-17-2012 07:22 AM


All times are GMT -4. The time now is 07:10 PM.


MobileRead.com is a privately owned, operated and funded community.