p26001-store-acs-soc-fw-app/util/Temperature.cpp
2026-09-28 21:33:04 +08:00

38 lines
902 B
C++

/*
*******************************************************************************
* INCLUDE
*******************************************************************************
*/
#include "Temperature.h"
#include "Device.h"
#include "Application.h"
namespace Util
{
/*
*******************************************************************************
* CLASS DEFINE
*******************************************************************************
*/
float Temperature::read()
{
Device device("/sys/devices/virtual/mstar/msys/TEMP_R");
try
{
device.open();
char str[64];
device.read((uint8_t*)str, sizeof(str));
int temp;
sscanf(str, "Temperature %d", &temp);
device.close();
return temp;
}
catch (const std::exception& e)
{
}
return 0.0f;
}
}