From 55f5652a9a064ae08d623273c7a49511228a67a2 Mon Sep 17 00:00:00 2001 From: Frodo Looijaard Date: Thu, 24 Dec 1998 20:29:29 +0000 Subject: [PATCH] prog/sensors now supports GL518SM. Please test! A configuration entry for VDD (+5V) is added. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@111 7894878c-1315-0410-8ee3-d5d059ff63e0 --- etc/sensors.conf.eg | 10 +++- prog/sensors/chips.c | 123 +++++++++++++++++++++++++++++++++++++++++++ prog/sensors/chips.h | 1 + prog/sensors/main.c | 3 ++ 4 files changed, 136 insertions(+), 1 deletion(-) diff --git a/etc/sensors.conf.eg b/etc/sensors.conf.eg index e518bd39..ea0db5ba 100644 --- a/etc/sensors.conf.eg +++ b/etc/sensors.conf.eg @@ -1,6 +1,6 @@ # Hardware sensors configuration file -# This configuration file will be used by all applcations linked to +# This configuration file will be used by all applications linked to # libsensors. # Hash marks introduce comments, which continue until the end of a line @@ -119,3 +119,11 @@ chip "lm75-i2c-0-*" # You should really use the output of /proc/bus/chips to generate bus lines, # because one mistyped characted will inhibit the match. Wildcards are not # yet supported; spaces at the end are ignored, though. + + +chip "gl518sm-r00-*" "gl518sm-r80-*" + +# The below declaration is from the data sheet. We have no idea how these +# chips are typically used. Please contact us if you own one. + label vdd "+5V" + compute vdd @ * 2.5, @ / 2.5 diff --git a/prog/sensors/chips.c b/prog/sensors/chips.c index 116f83b8..4a7c42ea 100644 --- a/prog/sensors/chips.c +++ b/prog/sensors/chips.c @@ -218,6 +218,129 @@ void print_lm78(const sensors_chip_name *name) free_the_label(&label); } +void print_gl518(const sensors_chip_name *name) +{ + char *label = NULL; + double cur,min,max,fdiv; + int alarms; + int is_r00; + + is_r00 = !strcmp(name->prefix,"gl518sm-r00"); + if (!sensors_get_feature(*name,SENSORS_GL518R00_ALARMS,&cur)) + alarms = cur + 0.5; + else { + printf("ERROR: Can't get alarm data!\n"); + alarms = 0; + } + + if (!sensors_get_label(*name,SENSORS_GL518R00_VDD,&label) && + !sensors_get_feature(*name,SENSORS_GL518R00_VDD,&cur) && + !sensors_get_feature(*name,SENSORS_GL518R00_VDD_MIN,&min) && + !sensors_get_feature(*name,SENSORS_GL518R00_VDD_MAX,&max)) { + print_label(label,10); + printf("%+6.2f V (min = %+6.2f V, max = %+6.2f V) %s\n", + cur,min,max,alarms&GL518_ALARM_VDD?"ALARM":""); + } else + printf("ERROR: Can't get VDD data!\n"); + free_the_label(&label); + + /* We need special treatment for the R00 chips, because they can't display + actual readings! We hardcode this, as this is the easiest way. */ + if (is_r00) { + if (!sensors_get_label(*name,SENSORS_GL518R00_VIN1,&label) && + !sensors_get_feature(*name,SENSORS_GL518R00_VIN1_MIN,&min) && + !sensors_get_feature(*name,SENSORS_GL518R00_VIN1_MAX,&max)) { + print_label(label,10); + printf(" (min = %+6.2f V, max = %+6.2f V) %s\n", + min,max,alarms&GL518_ALARM_VIN1?"ALARM":""); + } else + printf("ERROR: Can't get VIN1 data!\n"); + free_the_label(&label); + + if (!sensors_get_label(*name,SENSORS_GL518R00_VIN2,&label) && + !sensors_get_feature(*name,SENSORS_GL518R00_VIN2_MIN,&min) && + !sensors_get_feature(*name,SENSORS_GL518R00_VIN2_MAX,&max)) { + print_label(label,10); + printf(" (min = %+6.2f V, max = %+6.2f V) %s\n", + min,max,alarms&GL518_ALARM_VIN2?"ALARM":""); + } else + printf("ERROR: Can't get VIN2 data!\n"); + free_the_label(&label); + if (!sensors_get_label(*name,SENSORS_GL518R00_VIN3,&label) && + !sensors_get_feature(*name,SENSORS_GL518R00_VIN3_MIN,&min) && + !sensors_get_feature(*name,SENSORS_GL518R00_VIN3_MAX,&max)) { + print_label(label,10); + printf(" (min = %+6.2f V, max = %+6.2f V) %s\n", + min,max,alarms&GL518_ALARM_VIN3?"ALARM":""); + } else + printf("ERROR: Can't get IN3 data!\n"); + free_the_label(&label); + } else { + if (!sensors_get_label(*name,SENSORS_GL518R00_VIN1,&label) && + !sensors_get_feature(*name,SENSORS_GL518R00_VIN1,&cur) && + !sensors_get_feature(*name,SENSORS_GL518R00_VIN1_MIN,&min) && + !sensors_get_feature(*name,SENSORS_GL518R00_VIN1_MAX,&max)) { + print_label(label,10); + printf("%+6.2f V (min = %+6.2f V, max = %+6.2f V) %s\n", + cur,min,max,alarms&GL518_ALARM_VIN1?"ALARM":""); + } else + printf("ERROR: Can't get VIN1 data!\n"); + free_the_label(&label); + if (!sensors_get_label(*name,SENSORS_GL518R00_VIN2,&label) && + !sensors_get_feature(*name,SENSORS_GL518R00_VIN2,&cur) && + !sensors_get_feature(*name,SENSORS_GL518R00_VIN2_MIN,&min) && + !sensors_get_feature(*name,SENSORS_GL518R00_VIN2_MAX,&max)) { + print_label(label,10); + printf("%+6.2f V (min = %+6.2f V, max = %+6.2f V) %s\n", + cur,min,max,alarms&GL518_ALARM_VIN2?"ALARM":""); + } else + printf("ERROR: Can't get VIN2 data!\n"); + free_the_label(&label); + if (!sensors_get_label(*name,SENSORS_GL518R00_VIN3,&label) && + !sensors_get_feature(*name,SENSORS_GL518R00_VIN3,&cur) && + !sensors_get_feature(*name,SENSORS_GL518R00_VIN3_MIN,&min) && + !sensors_get_feature(*name,SENSORS_GL518R00_VIN3_MAX,&max)) { + print_label(label,10); + printf("%+6.2f V (min = %+6.2f V, max = %+6.2f V) %s\n", + cur,min,max,alarms&GL518_ALARM_VIN3?"ALARM":""); + } else + printf("ERROR: Can't get IN3 data!\n"); + free_the_label(&label); + } + + if (!sensors_get_label(*name,SENSORS_GL518R00_FAN1,&label) && + !sensors_get_feature(*name,SENSORS_GL518R00_FAN1,&cur) && + !sensors_get_feature(*name,SENSORS_GL518R00_FAN1_DIV,&fdiv) && + !sensors_get_feature(*name,SENSORS_GL518R00_FAN1_MIN,&min)) { + print_label(label,10); + printf("%4.0f RPM (min = %4.0f RPM, div = %1.0f) %s\n", + cur,min,fdiv, alarms&GL518_ALARM_FAN1?"ALARM":""); + } else + printf("ERROR: Can't get FAN1 data!\n"); + free_the_label(&label); + if (!sensors_get_label(*name,SENSORS_GL518R00_FAN2,&label) && + !sensors_get_feature(*name,SENSORS_GL518R00_FAN2,&cur) && + !sensors_get_feature(*name,SENSORS_GL518R00_FAN2_DIV,&fdiv) && + !sensors_get_feature(*name,SENSORS_GL518R00_FAN2_MIN,&min)) { + print_label(label,10); + printf("%4.0f RPM (min = %4.0f RPM, div = %1.0f) %s\n", + cur,min,fdiv, alarms&GL518_ALARM_FAN2?"ALARM":""); + } else + printf("ERROR: Can't get FAN2 data!\n"); + free_the_label(&label); + + if (!sensors_get_label(*name,SENSORS_GL518R00_TEMP,&label) && + !sensors_get_feature(*name,SENSORS_GL518R00_TEMP,&cur) && + !sensors_get_feature(*name,SENSORS_GL518R00_TEMP_HYST,&min) && + !sensors_get_feature(*name,SENSORS_GL518R00_TEMP_OVER,&max)) { + print_label(label,10); + printf("%+3.0f C (limit = %+3.0f C, hysteris = %+3.0f C) %s\n", + cur,max,min, alarms&GL518_ALARM_TEMP?"ALARM":""); + } else + printf("ERROR: Can't get TEMP data!\n"); + free_the_label(&label); +} + void print_unknown_chip(const sensors_chip_name *name) { int a,b; diff --git a/prog/sensors/chips.h b/prog/sensors/chips.h index 33f96f84..4acbfdd8 100644 --- a/prog/sensors/chips.h +++ b/prog/sensors/chips.h @@ -26,5 +26,6 @@ extern void print_unknown_chip(const sensors_chip_name *name); extern void print_lm75(const sensors_chip_name *name); extern void print_lm78(const sensors_chip_name *name); +extern void print_gl518(const sensors_chip_name *name); #endif /* def PROG_SENSORS_CHIPS_H */ diff --git a/prog/sensors/main.c b/prog/sensors/main.c index 145587a6..a154498f 100644 --- a/prog/sensors/main.c +++ b/prog/sensors/main.c @@ -184,6 +184,9 @@ int main (int argc, char *argv[]) else if (!strcmp(chip->prefix,"lm78") || !strcmp(chip->prefix,"lm78-j") || !strcmp(chip->prefix,"lm79")) print_lm78(chip); + else if (!strcmp(chip->prefix,"gl518sm-r00") || + !strcmp(chip->prefix,"gl518sm-r80")) + print_gl518(chip); else print_unknown_chip(chip); printf("\n");