From f436eb959f08b8b342b0360ae439f922191638e8 Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Mon, 15 Jul 2024 12:03:20 +0200 Subject: [PATCH] fix --- README.md | 5 +++-- main.c | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 06666df..42dca31 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,10 @@ a lightweight script that logs the most important stuff about the raspberry pi CPU temperature is read from `/sys/class/thermal/thermal_zone0/temp` but that should work on every Linux computer \ Ambient temperature is read from `/sys/bus/w1/devices` so you must have 1wire enabled, if you don't have that set `SENSOR` to `0` -# compilation +# compilation and usage `make` or `gcc main.c -o measurer` \ -Should throw no warnings +Should throw no warnings \ +`./measurer ` # why like heavy ahh like databases grafana etc go away you're a performance monitor why'd you reduce performance \ No newline at end of file diff --git a/main.c b/main.c index f06573d..89ab093 100644 --- a/main.c +++ b/main.c @@ -7,7 +7,7 @@ #include #include -#define SENSOR 1 +#define SENSOR 0 int read_temperature(char *filename) { FILE *fp; @@ -70,7 +70,7 @@ int read_w1_temperature(char *w1_id) { } int main(int argc, char *argv[]) { - if (argc == 0) { + if (argc < 2) { printf("Filename required\n"); return 1; } @@ -105,14 +105,14 @@ int main(int argc, char *argv[]) { FILE *fp; - fp = fopen(argv[0], "a"); + fp = fopen(argv[1], "a"); if (fp == NULL) { - printf("Error opening output file"); + perror("Error opening output file"); return 1; } - if (fprintf(fp, line) != 0) { + if (fprintf(fp, line) < 0) { perror("Error writing to output file"); fclose(fp); return 1;