#include "ComputerBoardInterface.h" #include "defines.h" #include "AxUfiAPI.h" #include "GeneralMessagesLogDispatcher.h" #include "CPUWatchdogConfig.h" CComputerBoardInterface::CComputerBoardInterface() { mWatchdogTimeout = CPU_DEFAULT_WATCHDOG_TIMEOUT; mWatchdogEnabled = false; } int CComputerBoardInterface::Init() { if(LoadLibrary() == RET_OK) { CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Librairie Axiomtek chargée avec succès"),"CComputerBoardInterface",true,1,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_SUCCESS_STATUS); StopCPUWatchdog(); return RET_OK; } else { CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Impossible de charger la librairie Axiomtek"),"CComputerBoardInterface",true,1,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_ERROR_STATUS); } return RET_OK; } int CComputerBoardInterface::LoadLibrary() { int result; char libname[] = CPU_LIBRARY_NAME; result = AxBoardLoadLibrary(libname); if(result) return RET_OK; return RET_GENERAL_ERROR; } int CComputerBoardInterface::UnloadLibrary() { if(AxBoardReleaseLibrary() != 0) { return RET_OK; } return RET_GENERAL_ERROR; } int CComputerBoardInterface::DeInit() { return RET_OK; } int CComputerBoardInterface::StartCPUWatchdog() { // if(TimeoutInSeconds > (255*60) ) //Max of 255 minutes // { // return RET_GENERAL_ERROR; // } if(mWatchdogEnabled == false) return RET_GENERAL_ERROR; int Ret; quint16 RawTimeout = bWDT_SECOND; if(mWatchdogTimeout <= 60) { RawTimeout = mWatchdogTimeout; } else { RawTimeout = mWatchdogTimeout/60; RawTimeout |= bWDT_MINUTE; //set the counter time base in minutes (high byte = 1) } if(AxWDTSetCounter(RawTimeout) != true) { Ret = RET_GENERAL_ERROR; } else { if(AxWDTexec(bWDT_ENABLE) == true) { CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Watchdog CPU démarré. Timeout: %1 secondes").arg(mWatchdogTimeout),"CComputerBoardInterface"); Ret = RET_OK; } else { Ret = RET_GENERAL_ERROR; } } return Ret; } int CComputerBoardInterface::StopCPUWatchdog() { int Ret = RET_OK; if(AxWDTexec(bWDT_DISABLE) == false) { Ret = RET_GENERAL_ERROR; } else { CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Watchdog CPU arrêté"),"CComputerBoardInterface"); } return Ret; } int CComputerBoardInterface::KickCPUWatchdog() { AxWDTexec(bWDT_RELOAD); return RET_OK; } int CComputerBoardInterface::SetWatchdogSettings(CCPUWatchdogConfig *Settings) { mWatchdogEnabled = Settings->mWatchdogEnabled; mWatchdogTimeout = Settings->mWatchdogTimeout; return RET_OK; } CComputerBoardState CComputerBoardInterface::GetComputerBoardState() { CComputerBoardState CPUState; float tmp; AxGetCPUTemp(&CPUState.mSystemTemperature); // qDebug("CPUState.mSystemTemperature %f",CPUState.mSystemTemperature); AxGetSYSTemp(&CPUState.mSystemTemperature); // qDebug("CPUState.mSystemTemperature %f",CPUState.mSystemTemperature); // AxGetGMCHTemp(&tmp); // qDebug("AxGetGMCHTemp %f",tmp); AxGetCPUVcore(&CPUState.mCPUVcore); // qDebug("CPUState.mCPUVcore %f",CPUState.mCPUVcore); // AxGetNBVTT(&tmp); // qDebug("NBVTT %f",tmp); AxGet3V(&CPUState.mSystem3V3); // qDebug("CPUState.mSystem3V3 %f",CPUState.mSystem3V3); AxGet5V(&CPUState.mSystem5V); // qDebug("CPUState.mSystem5V %f",CPUState.mSystem5V); // AxGet12V(&tmp); // qDebug("AxGet12V %f",tmp); // AxGetNeg5V(&tmp); // qDebug("AxGetNeg5V %f",tmp); // AxGetNeg12V(&tmp); // qDebug("AxGetNeg12V %f",tmp); // AxGetVbat(&tmp); // qDebug("AxGetVbat %f",tmp); return CPUState; }