add function: getFanStatus()

This commit is contained in:
Ferit Yiğit BALABAN 2023-09-16 21:57:19 +03:00
parent a91307202c
commit 5f56f29fda
Signed by: fyb
GPG Key ID: E21FEB2C244CB7EB

21
main.c
View File

@ -19,6 +19,8 @@
#define LOW 0
int logMessage(const char *, ...);
int getFanStatus();
int main(int argc, char **argv) {
int fd;
char buffer[6];
@ -110,4 +112,23 @@ int logMessage(const char *format, ...) {
fclose(logFile);
return 0;
}
int getFanStatus() {
int status;
FILE *file = fopen(STATUS, "r");
if (!file) {
logMessage("Error opening status file\n");
return -1;
}
if (fscanf(file, "%d", &status) != 1) {
logMessage("Error reading status file\n");
fclose(file);
return -2;
}
fclose(file);
return status;
}