Browse Source

Thermal Zones Read Added

AGP
Evgeny Gagua 2 years ago
parent
commit
6d92829a5a
  1. 2
      Projects/la_mojo/build
  2. 29
      lib/App/common/hardwareManager.cpp

2
Projects/la_mojo/build

@ -4,7 +4,7 @@
#make clean -e "CFG=Debug"
#make -e "CFG=Debug" -j6
make clean -e "CFG=Debug86"
#make clean -e "CFG=Debug86"
make -e "CFG=Debug86" -j4
#make clean -e "CFG=Release86"

29
lib/App/common/hardwareManager.cpp

@ -1417,9 +1417,32 @@ bool hardwareManager::updateSysInfo( DBC_SYS_LOAD_INFO *ptr ){
} else {
LOG_ERROR("Error while getting Disk Info!");
};
//FILE *fd = popen("","r");
ptr->temperature = 46.7;
//Temperature reading
ptr->temperature = -1;
if( fileExist( "/sys/class/thermal" ) ) {
char tB[128];
// Check first 8 zones to find CPU one
for ( uint8_t i = 0; i < 8; i++ ) {
sprintf( tB, "/sys/class/thermal/thermal_zone%d", i );
if ( fileExist( tB ) ) {
sprintf( tB, "/sys/class/thermal/thermal_zone%d/type", i );
if ( fileExist( tB ) ) {
FILE *fd = fopen( tB, "r" );
readLine( fd, tB, 128 );
fclose(fd);
if ( strcasestr(tB,"cpu")!=NULL || strcasestr(tB,"x86_pkg")!=NULL) {
sprintf( tB, "/sys/class/thermal/thermal_zone%d/temp", i );
FILE *fd = fopen( tB, "r" );
readLine( fd, tB, 128 );
fclose(fd);
ptr->temperature = ((float) atoll( tB )) / 1000.0f;
break;
};
} else continue;
} else break;
};
};
return m_pDBC->updateServerUtilisation( ptr );
};

Loading…
Cancel
Save