FILE *fp_fan=NULL;
char shu_fan[2]={0};
if((fp_fan=fopen("/sys/devices/virtual/thermal/thermal_zone0/temp","rb"))==NULL)
printf("ddd
");
fread(shu_fan,sizeof(shu_fan),1,fp_fan);
fclose(fp_fan);
fan_switch=atoi(shu_fan);
free(fp_fan);
Ubuntu shell下,使用如下命令可以读取CPU温度数据:
cat /sys/devices/virtual/thermal/thermal_zone0/temp