tstatus/thermal.c

29 lines
643 B
C

/* see LICENSE file for details on license */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "module.h"
#include "file.h"
#include "thermal.h"
int convert_milli_to_reg(int millidegree) {
return millidegree / 1000;
}
int thermal_update(struct module *module) {
char *filepath = THERMAL_PRE THERMAL_DIR THERMAL_TMP;
int i;
i = read_file_into_buffer(filepath, (char *)&module->buffer, MODULE_BUFFER_LEN);
if(i == -1) return i; /* indicate an error */
i = atoi((char *)&module->buffer);
if(!i) return -1;
i = convert_milli_to_reg(i);
snprintf((char *)&module->buffer, MODULE_BUFFER_LEN, "%i", i);
return 0;
}