打开电源的操作也仅在没有电源时执行

streaming
Matthew 4 months ago
parent a98dc5126c
commit 856c1a8b10

@ -32,22 +32,21 @@ bool GpioControl::m_cameraPowerStatus = false;
size_t GpioControl::turnOnImpl(const IOT_PARAM& param)
{
size_t oldRef = 0;
size_t references = 1;
std::vector<ITEM>::iterator it;
int res = 0;
int fd = -1;
time_t now = time(NULL);
fd = open(GPIO_NODE_MP, O_RDONLY);
if( fd > 0 )
{
res = ioctl(fd, IOT_PARAM_WRITE, &param);
close(fd);
// check res???
m_locker.lock();
// check res???
for (it = m_items.begin(); it != m_items.end(); ++it)
{
if (it->cmd == param.cmd)
{
oldRef = it->references;
it->references++;
// it->closeTime = 0;
references = it->references;
@ -59,15 +58,31 @@ size_t GpioControl::turnOnImpl(const IOT_PARAM& param)
}
if (it == m_items.end())
{
oldRef = 0;
ITEM item = {param.cmd, references, 0, 0, now};
m_items.push_back(item);
SetCamerastatus(param.cmd, true);
}
m_locker.unlock();
if (oldRef == 0)
{
fd = open(GPIO_NODE_MP, O_RDONLY);
if( fd > 0 )
{
res = ioctl(fd, IOT_PARAM_WRITE, &param);
close(fd);
#ifdef OUTPUT_DBG_INFO
XYLOG(XYLOG_SEVERITY_INFO, "setInt cmd=%d,value=%d,result=%d\r\n",param.cmd, param.value, param.result);
#endif
}
#ifdef _DEBUG
ALOGI("PWR TurnOn cmd=%d,result=%d ref=%u\r\n",param.cmd, param.result, (uint32_t)references);
#endif
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
return references;
}
@ -81,10 +96,11 @@ void GpioControl::setInt(int cmd, int value)
if (fd > 0)
{
int res = ioctl(fd, IOT_PARAM_WRITE, &param);
close(fd);
#ifdef OUTPUT_DBG_INFO
XYLOG(XYLOG_SEVERITY_DEBUG, "setInt cmd=%d,value=%d,result=%d\r\n",param.cmd, param.value, param.result);
int realVal = getInt(param.cmd);
XYLOG(XYLOG_SEVERITY_INFO, "setInt cmd=%d,value=%d,result=%d RealVal=%d",param.cmd, param.value, param.result, realVal);
#endif
close(fd);
}
}

Loading…
Cancel
Save