/* Copyright -20220809- shen All Rights Reserved. */#include <stdio.h>#include <stdlib.h>#include <stdint.h>#include <stdbool.h>#include <string.h>#include <getopt.h>#include <signal.h>#include <unistd.h>#include <errno.h>#include <libgen.h>#include<time.h>/* Get array size */#define ARRAY_SIZE(array) sizeof(array) / sizeof(array[0])/* Exit flag */volatile bool g_quit = false;/* User-operable LEDs */static char *g_leds[1] = { "cat /sys/class/thermal/thermal_zone0/temp\n"};void sig_handle(int arg) { g_quit = true;}int main(int argc, char **argv) { int i = 0; int c = 0; int num = 0; int flag = 0; char cmd[96] = {0}; time_t timep; while (!g_quit) {/* time (&timep); sprintf(cmd,30,"s%",ctime(&timep)); fprintf(stderr, "s%",cmd);*/ /* Turn on LEDs */ { /* Set the LED brightness value to 0 to turn on the led */ snprintf(cmd, 96, "%s", g_leds[0]); if (system(cmd) != 0) { fprintf(stderr, "Error:Get Temp err \n"); exit(EXIT_FAILURE); } } /* Keep the LEDs off for 1000 ms */ usleep(1000 * 1000); } printf("Exit\n"); return 0;}复制代码 温度源码:
温度测试源码.rar
(5.21 KB, 下载次数: 0)