sensors: Fix power interval output
PATCH 1/1 sensors: Fix power interval output
Power interval is measured in seconds, not Watt.
---
Untested. Maybe a bit kludgy but should work.
prog/sensors/chips.c | 22 ++++++++++++++++++---- 1 files changed, 18 insertions(+), 4 deletions(-)
prog/sensors/chips.c +18 -4
@@ -574,11 +574,25 @@ static void print_chip_power(const sensors_chip_name *name, }else printf (" N/A " ); -for (i =0 ; i < sensor_count; i++) -scale_value (&sensors[i].value, &sensors[i].unit); - +for (i =0 ; i < sensor_count; i++) { +/* +* Unit is W and needs to be scaled for all attributes except +* interval, which does not need to be scaled and is reported in +* seconds. +*/ +if (strcmp (sensors[i].name,"interval" )) { +char *tmpstr; + + tmpstr =alloca (4 ); +scale_value (&sensors[i].value, &unit); +snprintf (tmpstr,4 ,"%sW" , unit); + sensors[i].unit = tmpstr; + }else { + sensors[i].unit ="s" ; + } + }print_limits (sensors, sensor_count, alarms, alarm_count, - label_size,"%s = %6.2f %sW" ); + label_size,"%s = %6.2f %s" );printf ("\n" ); }
Signature · 7 lines
1.7.5.4 _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 33 lines · Guenter Roeck
Power interval is measured in seconds, not Watt.
Signed-off-by Guenter Roeck <[email protected]>---
Untested. Maybe a bit kludgy but should work.prog/sensors/chips.c | 22 ++++++++++++++++++---- 1 files changed, 18 insertions(+), 4 deletions(-)prog/sensors/chips.c +13
-3@@ -574,11 +574,25 @@ static void print_chip_power(const sensors_chip_name *name, }else printf (" N/A " ); -for (i =0 ; i < sensor_count; i++) -scale_value (&sensors[i].value, &sensors[i].unit); - +for (i =0 ; i < sensor_count; i++) { +/* +* Unit is W and needs to be scaled for all attributes except +* interval, which does not need to be scaled and is reported in +* seconds. +*/ +if (strcmp (sensors[i].name,"interval" )) { +char *tmpstr; + + tmpstr =alloca (4 ); +scale_value (&sensors[i].value, &unit); +snprintf (tmpstr,4 ,"%sW" , unit); + sensors[i].unit = tmpstr;
prog/sensors/chips.c static void print_chip_power(const sensors_chip_name *name, · line 598
Quoted 10 lines
prog/sensors/chips.c +5
-1+ }else { + sensors[i].unit ="s" ; + } + }print_limits (sensors, sensor_count, alarms, alarm_count, - label_size,"%s = %6.2f %sW" ); + label_size,"%s = %6.2f %s" );printf ("\n" ); }
Side note: Another more generic option would have been to add a "unit" field to struct sensor_subfeature_list, but that seemed to be (much) more expensive.
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi Guenter,
Sorry for the very late reply. D'oh, I can't believe it has been 7 weeks already :(
Quoted 5 lines · Guenter Roeck
Power interval is measured in seconds, not Watt.
Signed-off-by Guenter Roeck <[email protected]>---
Untested. Maybe a bit kludgy but should work.
I recall testing it with a fake driver and it was working. But I don't like it much. It's sad to have defined data structures to abstract things as much as possible and then end up with a hack like this one. I would prefer a more generic solution if we can come up with one. OTOH delaying lm-sensors 3.3.2 further just for this makes little sense. So, if you don't hear from me in the next 2 days, please just commit this fix and I'll release 3.3.2.
Quoted 14 lines
prog/sensors/chips.c | 22 ++++++++++++++++++---- 1 files changed, 18 insertions(+), 4 deletions(-)prog/sensors/chips.c +0
-3@@ -574,11 +574,25 @@ static void print_chip_power(const sensors_chip_name *name, }else printf (" N/A " ); -for (i =0 ; i < sensor_count; i++) -scale_value (&sensors[i].value, &sensors[i].unit); -
prog/sensors/chips.c static void print_chip_power(const sensors_chip_name *name, · line 586
Quoted 10 lines
prog/sensors/chips.c +10
-0+for (i =0 ; i < sensor_count; i++) { +/* +* Unit is W and needs to be scaled for all attributes except +* interval, which does not need to be scaled and is reported in +* seconds. +*/ +if (strcmp (sensors[i].name,"interval" )) { +char *tmpstr; + + tmpstr =alloca (4 );
I didn't even know about this function. Interesting one. I'm not sure how portable it is, but that shouldn't be an issue for lm-sensors.
Quoted 13 lines
prog/sensors/chips.c +8
-1+scale_value (&sensors[i].value, &unit); +snprintf (tmpstr,4 ,"%sW" , unit); + sensors[i].unit = tmpstr; + }else { + sensors[i].unit ="s" ; + } + }print_limits (sensors, sensor_count, alarms, alarm_count, - label_size,"%s = %6.2f %sW" ); + label_size,"%s = %6.2f %s" );printf ("\n" ); }
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 5 lines · Jean Delvare
Hi Guenter,
Sorry for the very late reply. D'oh, I can't believe it has been 7 weeks already :(
Time goes by ...
Quoted 7 lines · Guenter Roeck
Quoted 5 lines
Power interval is measured in seconds, not Watt.
Signed-off-by Guenter Roeck <[email protected]>---
Untested. Maybe a bit kludgy but should work.
Quoted 8 lines
I recall testing it with a fake driver and it was working. But I don't like it much. It's sad to have defined data structures to abstract things as much as possible and then end up with a hack like this one. I would prefer a more generic solution if we can come up with one. OTOH delaying lm-sensors 3.3.2 further just for this makes little sense. So, if you don't hear from me in the next 2 days, please just commit this fix and I'll release 3.3.2.
Ok. I wasn't too happy with it either, but I didn't find a better solution.
Quoted 11 lines
Quoted 11 lines
prog/sensors/chips.c | 22 ++++++++++++++++++---- 1 files changed, 18 insertions(+), 4 deletions(-)prog/sensors/chips.c +0
-0@@ -574,11 +574,25 @@ static void print_chip_power(const sensors_chip_name *name, }else printf (" N/A " );
Quoted 17 lines
prog/sensors/chips.c static void print_chip_power(const sensors_chip_name *name, · line 586
Quoted 13 lines
prog/sensors/chips.c +10
-3-for (i =0 ; i < sensor_count; i++) -scale_value (&sensors[i].value, &sensors[i].unit); - +for (i =0 ; i < sensor_count; i++) { +/* +* Unit is W and needs to be scaled for all attributes except +* interval, which does not need to be scaled and is reported in +* seconds. +*/ +if (strcmp (sensors[i].name,"interval" )) { +char *tmpstr; + + tmpstr =alloca (4 );I didn't even know about this function. Interesting one. I'm not sure how portable it is, but that shouldn't be an issue for lm-sensors.
Been there forever. I didn't know that its usage is discouraged nowadays. Looks like it was in C90, but was removed from C99. It is perfect for situations like this, but one has to be careful (which I guess is why its use is discouraged).
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi Jean,
Quoted 12 lines · Jean Delvare
Hi Guenter,
Sorry for the very late reply. D'oh, I can't believe it has been 7 weeks already :(
Quoted 5 lines · Guenter Roeck
Power interval is measured in seconds, not Watt.
Signed-off-by Guenter Roeck <[email protected]>---
Untested. Maybe a bit kludgy but should work.
Quoted 8 lines
I recall testing it with a fake driver and it was working. But I don't like it much. It's sad to have defined data structures to abstract things as much as possible and then end up with a hack like this one. I would prefer a more generic solution if we can come up with one. OTOH delaying lm-sensors 3.3.2 further just for this makes little sense. So, if you don't hear from me in the next 2 days, please just commit this fix and I'll release 3.3.2.
More than two days, and I didn't hear anything, so I went ahead and committed it.
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 11 lines · Guenter Roeck
Quoted 7 lines · Jean Delvare
I recall testing it with a fake driver and it was working. But I don't like it much. It's sad to have defined data structures to abstract things as much as possible and then end up with a hack like this one. I would prefer a more generic solution if we can come up with one. OTOH delaying lm-sensors 3.3.2 further just for this makes little sense. So, if you don't hear from me in the next 2 days, please just commit this fix and I'll release 3.3.2.
More than two days, and I didn't hear anything, so I went ahead and committed it.
Thanks. This means we're about ready to release lm-sensors 3.3.2. If you have more pending patches, please commit them today. Tomorrow the repository will be considered frozen and we start the testing phase. Let's schedule the release for Monday, March 12th if this is OK with you.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 10 lines · Jean Delvare
Quoted 9 lines · Guenter Roeck
Quoted 7 lines · Jean Delvare
I recall testing it with a fake driver and it was working. But I don't like it much. It's sad to have defined data structures to abstract things as much as possible and then end up with a hack like this one. I would prefer a more generic solution if we can come up with one. OTOH delaying lm-sensors 3.3.2 further just for this makes little sense. So, if you don't hear from me in the next 2 days, please just commit this fix and I'll release 3.3.2.
Quoted 8 lines
Quoted 2 lines
More than two days, and I didn't hear anything, so I went ahead and committed it.
Thanks. This means we're about ready to release lm-sensors 3.3.2. If you have more pending patches, please commit them today. Tomorrow the repository will be considered frozen and we start the testing phase. Let's schedule the release for Monday, March 12th if this is OK with you.
Hi Jean,
I am all done with commits, and March 12 is definitely ok with me.
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors