I’m reading the Jetson Xavier nx’s GPU & CPU temperature using the files “/sys/devices/virtual/thermal/thermal_zone*/temp” in a frequent interval (once every 50ms). It works fine in regular conditions but when the setup is taken to an elevated temperature (around 60deg C), my custom s/w starts to give absurd behavior. Xavier is installed on a custom board (not on devkit).
Any clues about it ? What could be the reason of the s/w misbehaving at elevated temperature due to file I/O ?
I am attaching the function I’m calling every 50ms to check the temperature
int32_t api_readJetsonTemperature(float32_t *f_cputemp, float32_t *f_gputemp,
)
{
int32_t xw_status = 0;
FILE *fd_cpu = NULL;
FILE *fd_gpu = NULL;
fd_cpu = fopen("/sys/devices/virtual/thermal/thermal_zone0/temp", "r");
fd_gpu = fopen("/sys/devices/virtual/thermal/thermal_zone1/temp", "r");
int temp;
if (fd_cpu != NULL)
{
fscanf(fd_cpu, "%d", &temp);
*f_cputemp = temp / 1000.0;
fflush(fd_cpu);
fclose(fd_cpu);
}
else
{
INFO_LOG(
"Failed to open /sys/devices/virtual/thermal/thermal_zone0/temp, reason: {}", strerror(
errno));
xw_status = ECPUTEMP;
}
if (fd_gpu != NULL)
{
fscanf(fd_gpu, "%d", &temp);
*f_gputemp = temp / 1000.0;
fflush(fd_gpu);
fclose(fd_gpu);
}
else
{
INFO_LOG(
"Failed to open /sys/devices/virtual/thermal/thermal_zone1/temp, reason: {}", strerror(
errno));
xw_status = ECPUTEMP;
}
return xw_status;
}