BrianPeek.com

A Compendium of Random Uselessness
in Search
  • WiimoteLib and BSOD – Part 2

    Well, after a few survey responses and posts to my forum, it appears that everyone experiencing the BSOD issue with WiimoteLib is running the BlueSoleil stack.  I was also pointed to the following links on www.wiimoteproject.org with others having the problem and apparently BlueSoleil is aware of the issue.

    So, I guess the only solution now is to wait for BlueSoleil to issue a patch and fix the problem on their end.  If/when I get any news on this (or if someone notifies me if I miss it), I’ll be sure to post the resolution here and update the WiimoteLib docs.

    Posted Jul 23 2008, 04:05 AM by Brian Peek with no comments
    Filed under: ,

  • WiimoteLib and BSOD

    I’ve gotten a few emails of late with people getting BSODs when using WiimoteLib.  It appears most, if not everyone, experiencing this problem is using BlueSoleil.  That said, I’m still unsure what is happening, when it started happening, or what the resolution is.  Therefore, I have put together a short survey that I’m hoping anyone experiencing the issue will take the time to fill out that might help me determine what the root cause is.

    I’m looking for answers from people who are specifically having an issue where using WiimoteLib or an application using WiimoteLib is causing their computer to spontaneously BSOD and/or restart.  If that’s not you, please do not fill out the survey.

    To take the survey, please click here.  Thanks!

    Posted Jul 22 2008, 05:41 AM by Brian Peek with 1 comment(s)
    Filed under: ,

  • Windows Mobile Devices and Power States

    I’ve been doing some Windows Mobile development with the .NET Compact Framework recently and ran into a scenario where I needed the device to be in “full power” mode at all times with the back-light on.  The device is constantly powered, so battery life is not a concern.

    The obvious choice is to go into the Brightness and Power control panels and turn off the appropriate settings, but I learned that there is a way to handle this at an application level so the behavior only occurs while the application is running.

    Power State

    An application can force a specific power state using the SetPowerRequirement method, and release that state using the ReleasePowerRequirement method.  Using P/Invoke, these methods look like the following:

       1: public enum CEDevicePowerState
       2: {
       3:     D0 = 0,    // Full On
       4:     D1,        // Low On
       5:     D2,        // Standby
       6:     D3,        // Sleep
       7:     D4,        // Off
       8: }
       9:  
      10: [DllImport("coredll.dll", SetLastError=true)]
      11: static extern IntPtr SetPowerRequirement(string device, CEDevicePowerState ceDevicePowerState, uint deviceFlags, IntPtr systemState, ulong stateFlags);
      12:  
      13: [DllImport("coredll.dll", SetLastError=true)]
      14: static extern int ReleasePowerRequirement(IntPtr handle);

    SetPowerRequirement will allow you to set a specific power state on a specific device.  In my scenario, I wanted to set the back-light to full power.  The name of the back-light on most (not all) Windows Mobile devices appears to be “BKL1:”.  So, to set the back-light to full power (the D0 state), you would call the method as follows:

    IntPtr handle = SetPowerRequirement("BKL1:", CEDevicePowerState.D0, 1, IntPtr.Zero, 0);
     
    The power state will be returned to its default settings when the application exits, or you may call ReleasePowerRequirement, passing in the handle returned from the call to SetPowerRequirement to reset it yourself.
     
    Suspend
     
    The above will leave the back-light on at all times, but it will not stop the device from going into a suspended state as configured in the control panel.  To stop this from happening, simply call the SystemIdleTimerReset method at a short, regular interval:
     
       1: [DllImport("coredll.dll", SetLastError=true)]
       2: static extern void SystemIdleTimerReset();
       3:  
       4: // reset the system's idle time every 10 seconds so it doesn't suspend
       5: Timer timer = new Timer(IdleReset, null, 0, 10000);
       6:  
       7: private static void IdleReset(object state)
       8: {
       9:     // no suspend
      10:     SystemIdleTimerReset();
      11: }

    Lines 1-2 contain the P/Invoke signature.  Line 5 sets up a timer that will be called every 10 seconds (10000ms) to reset the idle timer, and lines 7-11 are the timer callback method which actually calls the SystemIdleTimerReset method.

    And that’s that.  With both of these methods in place, my application remains running with the device at full power, never suspending, and with the back-light always on.

    Posted Jul 03 2008, 06:00 AM by Brian Peek with 1 comment(s)

Copyright (C) 2008 Brian Peek
Powered by Community Server (Commercial Edition), by Telligent Systems