|
From: <cza...@us...> - 2009-06-08 21:26:18
|
Revision: 511
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=511&view=rev
Author: czarnyckm
Date: 2009-06-08 21:25:10 +0000 (Mon, 08 Jun 2009)
Log Message:
-----------
- Improved sensor's autodetect
- Clean up
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/g15stats.c
trunk/g15daemon-clients/g15stats/g15stats.h
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-07 18:42:32 UTC (rev 510)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-08 21:25:10 UTC (rev 511)
@@ -16,5 +16,8 @@
SVN 509:
- Temperature sensors depends on the lmsensors sysfs filesystem
SVN 510:
-- Temperature sensor autodetect
-- Force user sensor id with the option -s id (The id should point to sysfs path /sys/class/hwmon/hwmon[id]/device/temp1_input)
\ No newline at end of file
+- Temperature sensor's autodetect
+- Force user sensor id with the option -s id (The id should point to sysfs path /sys/class/hwmon/hwmon[id]/device/temp1_input)
+SVN 511:
+- Improved sensor's autodetect
+- Clean up
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-07 18:42:32 UTC (rev 510)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-08 21:25:10 UTC (rev 511)
@@ -749,47 +749,43 @@
void draw_temp_screen(g15canvas *canvas, int all) {
g15_stats_temp_info temps[NUM_TEMP];
- long tot_max_temp = 1;
+ float tot_max_temp = 1;
- FILE *fd_input;
- FILE *fd_max;
- char line [MAX_LINES];
+ FILE *fd_main;
char tmpstr [MAX_LINES];
int i = 0;
int j = 0;
for (i = 0; i < NUM_TEMP; i++)
{
- char filename[128];
-
// Initialize temperature state
temps[i].max_temp = 1;
temps[i].cur_temp = 1;
/* /sys/class/hwmon/hwmon0/temp1_input */
/* /sys/class/hwmon/hwmon1/device/temp1_input */
- sprintf(filename, "/sys/class/hwmon/hwmon%d/device/temp%d_input",sensorId, i+1);
- fd_input=fopen (filename,"r");
- if (fd_input!=NULL)
+ sprintf(tmpstr, "/sys/class/hwmon/hwmon%d/device/temp%d_input",sensorId, i+1);
+ fd_main=fopen (tmpstr,"r");
+ if (fd_main!=NULL)
{
- if (fgets (line,MAX_LINES,fd_input)!=NULL)
+ if (fgets (tmpstr,MAX_LINES,fd_main)!=NULL)
{
- temps[i].cur_temp=atoi (line) / 1000;
+ temps[i].cur_temp=atoi (tmpstr) / 1000;
}
- fclose (fd_input);
+ fclose (fd_main);
} else {
break;
}
- sprintf(filename, "/sys/class/hwmon/hwmon%d/device/temp%d_max",sensorId, i+1);
- fd_max=fopen (filename,"r");
- if (fd_max!=NULL)
+ sprintf(tmpstr, "/sys/class/hwmon/hwmon%d/device/temp%d_max",sensorId, i+1);
+ fd_main=fopen (tmpstr,"r");
+ if (fd_main!=NULL)
{
- if (fgets (line,MAX_LINES,fd_max)!=NULL)
+ if (fgets (tmpstr,MAX_LINES,fd_main)!=NULL)
{
- temps[i].max_temp=atoi (line) / 1000;
+ temps[i].max_temp=atoi (tmpstr) / 1000;
}
- fclose (fd_max);
+ fclose (fd_main);
}
if(tot_max_temp < temps[i].max_temp) {
@@ -798,11 +794,16 @@
}
if (i == 0) {
- if (sensorId < 3) {
+ if (sensorId < MAX_SENSOR) {
+ printf("Temperature sensor doesn't appear to exist with id=%d . ",sensorId);
sensorId++;
+ printf("Let's try id=%d.\n",sensorId);
+ draw_temp_screen(canvas, all);
} else {
+ printf("Temperature sensor doesn't appear to exist. Temperature screen will be disabled.\n");
have_sensor = 0;
}
+ return;
}
if((i+1) >= NUM_TEMP) {
i = NUM_TEMP;
@@ -831,7 +832,7 @@
}
}
- char extension[11];
+ char extension[16];
sprintf(tmpstr, " ");
for (j = 0; j < i; j++) {
if ((j + 1) != i) {
Modified: trunk/g15daemon-clients/g15stats/g15stats.h
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.h 2009-06-07 18:42:32 UTC (rev 510)
+++ trunk/g15daemon-clients/g15stats/g15stats.h 2009-06-08 21:25:10 UTC (rev 511)
@@ -1,6 +1,7 @@
#define TEXT_LEFT 1
#define NUM_BATS 3
#define NUM_TEMP 3
+#define MAX_SENSOR 3
#define MAX_SCREENS 5
#define MAX_MODE 3
#define MAX_SUB_MODE 1
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|