美文网首页
2021-06-032021-05-15 [RK3399][An

2021-06-032021-05-15 [RK3399][An

作者: fjasmin | 来源:发表于2021-06-07 17:13 被阅读0次

linux下获取CPU 温度的节点:

cat /sys/class/thermal/thermal_zone0/temp
输出:53333,代表 53.333 度

android java代码

读取节点的方法

public static String readGpioPGForLong(String path) {
        String str = "";
        File file = new File(path);

        try {
            FileInputStream fileInputStream = new FileInputStream(file);
            byte[] buffer = new byte[1024];
            fileInputStream.read(buffer);
            fileInputStream.close();
            str = new String(buffer);
        } catch (FileNotFoundException var5) {
            var5.printStackTrace();
        } catch (UnsupportedEncodingException var6) {
            var6.printStackTrace();
        } catch (IOException var7) {
            var7.printStackTrace();
        }

        return str;
    }

获取CPU 温度

//获取CPU 温度
    public double getCPUTempe() {
        String s = readGpioPGForLong("/sys/class/thermal/thermal_zone0/temp");
        int temp = Integer.parseInt(s.substring(0, 5));
        return temp / 1000;
    }

相关文章

网友评论

      本文标题:2021-06-032021-05-15 [RK3399][An

      本文链接:https://www.haomeiwen.com/subject/oswzsltx.html