linux c 读取imx6q cpu温度

FILE *fp_fan=NULL;
char shu_fan[2]={0};
if((fp_fan=fopen("/sys/devices/virtual/thermal/thermal_zone0/temp","rb"))==NULL)
printf("ddd\n");
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

你可能感兴趣的:(ubuntu,imx6q)