无法将电源状态从POWER_STATE_SUSPEND转换为POWER_STATE_ON [英] Not able to transition power state from POWER_STATE_SUSPEND to POWER_STATE_ON

查看:112
本文介绍了无法将电源状态从POWER_STATE_SUSPEND转换为POWER_STATE_ON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我需要通过应用程序将基于Windows Embedded Compact 7的系统置于挂起模式,并在特定时间唤醒它。我正在使用SetSystemPowerState()将电源状态从IDLE转换为SUSPEND,但只要系统
进入SUSPEND模式,应用程序就会暂停并且不会触发下一个从SUSPEND恢复的SetSystemPowerState()函数。


根据MSDN文档,我正在配置应用程序通知  CeRunAppAtTime()和  SystemIdleTimerReset()以通知系统唤醒但它无法正常工作。我的系统没有触摸/键盘接口或按下电源按钮
即可恢复。我可以使用的唯一方法是通过申请。 


有人可以帮助建议什么是最好的方式来通过。以下是我正在使用的代码 -  


int _tmain(int argc,_TCHAR * argv [])

{

// * ************************************************** *****************************
$
//本地变量声明

DWORD res;

BOOL结果;

SYSTEMTIME st1;

// wchar_t pBuffer [2048];

DWORD pFlags;

CEDEVICE_POWER_STATE状态; // =(DWORD)POWER_STATE_OFF;

// *********************** ************************************************** *******

$
st1.wYear = 2017;

st1.wMonth = 4;

st1 .wDay = 19;

st1.wHour = 10;

st1.wMinute = 7;

st1.wSecond = 20;
$


result = CeRunAppAtTime(L" \ \ nbspows \\ MyTestApp.exe",& st1);

if(result == TRUE)

{

RETAILMSG(1 ,(TEXT("[低功耗模式] MyTestApp设置为唤醒\\\\ nn")));

}
其他

{

RETAILMSG(1,(TEXT(" [低功率模式] MyTestApp未设置为唤醒\ rr \\ n")));

}

// RETAILMSG(1,(TEXT(" [低功耗模式] GwesPowerOffSystem:进入su spended mode \r\\\
")));
$
// GwesPowerOffSystem();

RETAILMSG(1,(TEXT(" [低功率模式] SetSystemPowerState:进入悬挂模式\\\\ nn")));

res = SetSystemPowerState(NULL,POWER_STATE_SUSPEND,POWER_FORCE);

Sleep(5000);

SystemIdleTimerReset();

RETAILMSG(1,(TEXT(" [低功率模式] SystemIdleTimerReset:从挂起模式唤醒\\\\ nn")));


res = SetSystemPowerState(NULL,POWER_STATE_IDLE,POWER_FORCE);

if(ERROR_SUCCESS == res)

{

RETAILMSG(1,(TEXT("[LOW POWER MODE] Se tSystemPowerState:POWER_STATE = D%d \\ nn"",(DWORD)POWER_STATE_IDLE));

}

返回0;

}


< hr>

PS

解决方案

SystemIdleTimerReset不会启用一个定时器,它会将你从挂起模式唤醒。正好相反。在正在运行的系统中,
会重置一个定时器,以防止你进入挂起状态,请参阅  https://msdn.microsoft.com/en-us/library/ee502574 .aspx


你需要设置一个SOC /处理器定时器,允许CPU在SOC /处理器支持的情况下退出暂停!所以它取决于
BSP / SOC的实现如何以及如果你可以醒来......



你在使用什么平台? 



Hi,

I have a requirement to put my Windows Embedded Compact 7 based system into suspended mode through application and wake it up on specific time. I am using SetSystemPowerState() to transition power state from IDLE to SUSPEND, but as soon as the system goes into SUSPEND mode, the application halts and does not trigger the next SetSystemPowerState() function to resume from SUSPEND.

As per MSDN documentation, I am configuring application notification CeRunAppAtTime() and SystemIdleTimerReset() to notify system to wake up but it is not working. My system would not have a touch / keypad interface or a power button to be pressed to resume. The only way I can use is through application. 

Can someone please help to suggest what could be the best way to get through. Below is the code I am using - 

int _tmain(int argc, _TCHAR* argv[])
{
//********************************************************************************
//Local Variable Declaration
DWORD res;
BOOL result;
SYSTEMTIME st1;
//wchar_t pBuffer[2048];
DWORD pFlags;
CEDEVICE_POWER_STATE State;// = (DWORD)POWER_STATE_OFF;
//********************************************************************************

st1.wYear = 2017;
st1.wMonth = 4;
st1.wDay = 19;
st1.wHour = 10;
st1.wMinute = 7;
st1.wSecond = 20;

result = CeRunAppAtTime(L"\\windows\\MyTestApp.exe", &st1);
if (result == TRUE)
{
RETAILMSG(1,(TEXT("[LOW POWER MODE] MyTestApp set for wake up \r\n")));
}
else
{
RETAILMSG(1,(TEXT("[LOW POWER MODE] MyTestApp NOT set for wake up \r\n")));
}
//RETAILMSG(1,(TEXT("[LOW POWER MODE] GwesPowerOffSystem: Going in suspended mode \r\n")));
//GwesPowerOffSystem();
RETAILMSG(1,(TEXT("[LOW POWER MODE] SetSystemPowerState: Going in suspended mode \r\n")));
res = SetSystemPowerState(NULL, POWER_STATE_SUSPEND, POWER_FORCE);
Sleep(5000);
SystemIdleTimerReset();
RETAILMSG(1,(TEXT("[LOW POWER MODE] SystemIdleTimerReset: Waking up from suspended mode \r\n")));
res = SetSystemPowerState(NULL, POWER_STATE_IDLE, POWER_FORCE);
if (ERROR_SUCCESS == res)
{
RETAILMSG(1,(TEXT("[LOW POWER MODE] SetSystemPowerState: POWER_STATE = D%d \r\n"),(DWORD)POWER_STATE_IDLE));
}
return 0;
}


PS

解决方案

SystemIdleTimerReset will not enable a timer which will wake you up from suspend mode. It is just the opposite. In a running system it will reset a timer to prevent you from going into suspend state, see https://msdn.microsoft.com/en-us/library/ee502574.aspx

You will need to set a SOC/processor timer which allows the CPU to get out of suspend IF the SOC/processor supports it! So it depends on the BSP/SOC implementation how and if you are able to wake up...

What platform are you using? 


这篇关于无法将电源状态从POWER_STATE_SUSPEND转换为POWER_STATE_ON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆