void WaitTalkbackRecvList() { s_TalkbackRecvMutex.Lock(); if ( s_TalkbackRecvList.Size() == 0 ) s_TalkbackRecvCondition.Wait(); s_TalkbackRecvMutex.Unlock(); }
void WaitTalkbackSendList() { s_TalkbackSendMutex.Lock(); if ( s_TalkbackSendList.Size() == 0 ) s_TalkbackSendCondition.Wait(); s_TalkbackSendMutex.Unlock(); }
/* * fn: 获取rtc 时间 */ int RtcGetTime( int *pyear, int *pmonth, int *pday, int *phour, int *pminute, int *psecond, int *pweekday ) { int rtcRet = FI_FAILED; int rtcHandle = -1; struct tm tm; memset( &tm, 0x00, sizeof(tm) ); g_rtcLock.Lock(); rtcHandle = Open( RTC_DEVICE_PATH, O_RDONLY ); if( -1 == rtcHandle ) { SVPrint( "failed:can't Open rtc dev(%s)!\r\n", RTC_DEVICE_PATH ); rtcRet = FI_FAILED; } else { if( 0 == ioctl( rtcHandle, RTC_RD_TIME, &tm) ) { tm.tm_year += 1900; tm.tm_mon += 1; if( 1 == TimeIsValidDatetime(tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec) ) { if(NULL != pyear) *pyear = tm.tm_year; if(NULL != pmonth) *pmonth = tm.tm_mon; if(NULL != pday) *pday = tm.tm_mday; if(NULL != phour) *phour = tm.tm_hour; if(NULL != pminute) *pminute = tm.tm_min; if(NULL != psecond) *psecond = tm.tm_sec; if(NULL != pweekday) *pweekday = tm.tm_wday; rtcRet = FI_SUCCESSFUL; } else { SVPrint( "TimeIsValidDatetime failed!\r\n" ); } } else { SVPrint( "ioctl error:%s!\r\n", STRERROR_ERRNO ); } Close( rtcHandle ); } g_rtcLock.Unlock(); SVPrint( "%s, rtcRet(%d): %04d-%02d-%02d %02d:%02d:%02d\r\n", __FUNCTION__, rtcRet, tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec ); return rtcRet; }
/* * fn: 获取rtc 时间 */ int RtcGetTime( int *pyear, int *pmonth, int *pday, int *phour, int *pminute, int *psecond, int *pweekday ) { int rtcRet = FI_FAILED; int rtcHandle = -1; rtc_time_t_rt1307 rtcTime; g_rtcLock.Lock(); rtcHandle = Open( RTC_DEVICE_PATH, O_RDONLY ); if( -1 == rtcHandle ) { SVPrint( "failed:can't Open rtc dev(%s)!\r\n", RTC_DEVICE_PATH ); rtcRet = FI_FAILED; } else { if( 0 == ioctl( rtcHandle, RTC_RD_TIME, &rtcTime) ) { if( 1 == TimeIsValidDatetime(rtcTime.year, rtcTime.month, rtcTime.date, rtcTime.hour, rtcTime.minute, rtcTime.second) ) { if(NULL != pyear) *pyear = rtcTime.year; if(NULL != pmonth) *pmonth = rtcTime.month; if(NULL != pday) *pday = rtcTime.date; if(NULL != phour) *phour = rtcTime.hour; if(NULL != pminute) *pminute = rtcTime.minute; if(NULL != psecond) *psecond = rtcTime.second; if(NULL != pweekday) *pweekday = rtcTime.weekday; rtcRet = FI_SUCCESSFUL; } else { SVPrint( "TimeIsValidDatetime failed!\r\n" ); } } else { SVPrint( "ioctl error:%s!\r\n", STRERROR_ERRNO ); } Close( rtcHandle ); } g_rtcLock.Unlock(); SVPrint( "%s, rtcRet(%d): %04d-%02d-%02d %02d:%02d:%02d\r\n", __FUNCTION__, rtcRet, rtcTime.year, rtcTime.month, rtcTime.date, rtcTime.hour, rtcTime.minute, rtcTime.second ); return rtcRet; }
/* * fn: 设置rtc 时间 */ int RtcSetTime( int year, int month, int day, int hour, int minute, int second ) { int rtcRet = FI_FAILED; time_t utcTime; struct tm tm, *ptm; int rtcHandle; rtc_time_t_rt1307 rtcTime; g_rtcLock.Lock(); rtcHandle = Open( RTC_DEVICE_PATH, O_WRONLY ); if(-1 == rtcHandle) { SVPrint( "failed:can't Open rtc dev(%s)!\r\n", RTC_DEVICE_PATH ); } else { utcTime = FiTimeHumanToUtc( year, month, day, hour, minute, second ); ptm = gmtime_r( &utcTime, &tm ); if( NULL != ptm ) { rtcTime.year = year; rtcTime.month = month; rtcTime.date = day; rtcTime.hour = hour; rtcTime.minute = minute; rtcTime.second = second; rtcTime.weekday = tm.tm_wday; rtcRet = ioctl( rtcHandle, RTC_SET_TIME, &rtcTime ); if( 0 != rtcRet ) { SVPrint( "%s, rtcRet(%d), ioctl error:%s\r\n", __FUNCTION__, rtcRet, STRERROR_ERRNO ); } } Close ( rtcHandle ); } g_rtcLock.Unlock(); SVPrint( "%s, rtcRet(%d): %04d-%02d-%02d %02d:%02d:%02d!\r\n", __FUNCTION__, rtcRet, year, month, day, hour, minute, second, rtcRet ); return rtcRet; }
int PutTalkbackRecvList( TALKBACK_NODE *tFrame ) { int nRet = 0; TALKBACK_NODE tNode = { 0 }; if ( s_TalkbackRecvList.IsFull() ) { nRet = s_TalkbackRecvList.Pop( &tNode, NULL ); if ( nRet == 0 ) ShareFree( tNode.frameData ); // FiPrint( "Put talkback recv list is full, pop one node !\r\n" ); } if ( nRet == 0 ) { s_TalkbackRecvMutex.Lock(); nRet = s_TalkbackRecvList.Put( tFrame, sizeof(*tFrame) ); if ( nRet == 0 && s_TalkbackRecvList.Size() == 1 ) SignalTalkbackRecvList(); s_TalkbackRecvMutex.Unlock(); } return nRet; }
/* * fn: 设置rtc 时间 */ int RtcSetTime( int year, int month, int day, int hour, int minute, int second ) { int rtcRet = FI_FAILED; rtc_time_t tm; int rtcHandle; g_rtcLock.Lock(); rtcHandle = Open( RTC_DEVICE_PATH, O_WRONLY ); if(-1 == rtcHandle) { ERRORPRINT( "failed:can't Open rtc dev(%s)!\r\n", RTC_DEVICE_PATH ); } else { tm.year = year; tm.month = month; tm.date = day; tm.hour = hour; tm.minute = minute; tm.second = second; tm.weekday = 0; //add by liulu,2016-1-6;此项不设置会导致时间设置不成功 rtcRet = ioctl( rtcHandle, RTC_SET_TIME, &tm ); if(rtcRet < 0) { ERRORPRINT("RTC ioctl SET time failed.return:%d\n!!!,rtcRet"); } Close ( rtcHandle ); } g_rtcLock.Unlock(); SVPrint( "%s, rtcRet(%d): %04d-%02d-%02d %02d:%02d:%02d!\r\n", __FUNCTION__, rtcRet, year, month, day, hour, minute, second, rtcRet ); return rtcRet; }