Search

Technical Discussion Group Forum

This forum is provided for user discussion. While Beacon EmbeddedWorks support staff and engineers participate, Beacon EmbeddedWorks does not guarantee the accuracy of all information within in the Technical Discussion Group (TDG).

The "Articles" forums provide brief Articles written by Beacon EmbeddedWorks engineers that address the most frequently asked technical questions.

To receive email notifications when updates are posted for a Beacon EmbeddedWorks product download, please subscribe to the TDG Forum of interest.

TDG Forum

PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 02 Mar 2016 10:15 AM by  mvly
prevent autosleeping when waked? android
 9 Replies
Sort:
You are not authorized to post a reply.
Author Messages
mvly
Basic Member
Basic Member
Posts:104


--
08 Oct 2015 05:17 PM

    So I sucessfully got the UART to work on the Development board and on android. Sending characters to the board when it's sleeping will wake up the board. But the device goes back to sleep right away. Is there a way to keep it on for a longer period of time?

     

    The reason I ask is I have an android app that monitors and process the UART port. It is able to capture it because I can echo the characters back fine. however because processing it takes more time, the device goes to sleep before it can properly respond. 

    Adam Ford
    Advanced Member
    Advanced Member
    Posts:794


    --
    09 Oct 2015 07:06 AM
    Under Settings->Display, you can increase the screen timeout. I have the same issue when I'm running tests using the terminal prompt.

    adam
    bradb
    Basic Member
    Basic Member
    Posts:203


    --
    09 Oct 2015 08:29 AM
    Another option is to disable sleep by selecting the the following option.
    Settings > Applications > Development > Stay awake
    mvly
    Basic Member
    Basic Member
    Posts:104


    --
    09 Oct 2015 10:25 AM
    Well I cannot disable the auto-sleep completely. Remember I am only waking the CPU, not the LCD when I send data through its UART pins. I just want to delay the auto-sleep part a bit longer. Either that or allow me to control it in software manually. i.e. in android software, I say I need to stay awake mode and when I finish doing what I need to do, I say auto-sleep mode again.

    mvly
    Basic Member
    Basic Member
    Posts:104


    --
    09 Oct 2015 10:55 AM
    OK I solved the problem.

    I used this:

    https://developer.android.com/training/scheduling/wakelock.html
    mvly
    Basic Member
    Basic Member
    Posts:104


    --
    18 Feb 2016 02:24 PM
    Sorry to bring this topic back up, but it seems like the wakelock in the android code doesn't work if the device is battery powered. I have tested and verified that when the device is USB powered, then it artificially keeps the device on even if I press the power button to put it to sleep. But when I power the device from battery, this does not work.

    The quick solution was to disable the sleep in the init.rc, but that will result in high power consumption during sleep when the screen is off.

    Is there another solution? Do I write some other values to the /sys/power/wake_lock?

    Again I am using Android 2.3.4.
    Adam Ford
    Advanced Member
    Advanced Member
    Posts:794


    --
    18 Feb 2016 02:34 PM
    Having the wake locks keep the system on when connected by USB is normal because it detects the USB cable and that prevents it from sleeping. The device is supposed to sleep when running off the battery. Are you saying you would like to disable the sleeping when running for the battery even when the USB cable is disconnected?

    adam
    Adam Ford
    Advanced Member
    Advanced Member
    Posts:794


    --
    18 Feb 2016 03:13 PM
    One of my colleagues suggested this link:

    http://elinux.org/Android...lock_from_user_space

    You can write to a file and have it prevent sleeping.
    mvly
    Basic Member
    Basic Member
    Posts:104


    --
    22 Feb 2016 12:34 PM
    Thanks Adam and your colleagues who recommended the link. I will look into that. Worst case, I might have to write to the powerlock file manually.
    mvly
    Basic Member
    Basic Member
    Posts:104


    --
    02 Mar 2016 10:15 AM
    OK so I tested this and it doesn't not quite work. I think it has to do with how long the ARM is awake after the UART port wakes it up. Sending 1 character is not sufficient to keep it awake long enough for my service in my app to handle and process the other UART characters. KeyEvents and mmc_ wakelock is set, but they are cleared too quickly before my service can run. If I send quickly in succession, then my service has a chance to run and analyze the UART message.

    Note my service writes to the wakelock so this does indeed keep the ARM awake until I finish my process, which is nice to know the wakelock method works... provided you get to that point to write to it before it goes to sleep again.

    Obviously we lose the first character that goes to the UART. I will try to send a few UART characters spaced out to determine what the spacing is and the number of characters required to wait it up properly to keep it awake.
    You are not authorized to post a reply.