linux c 读取imx6q cpu温度

2019-07-13 09:03发布

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