[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: therm_adt746x



* Elimar Riesebieter said:
> is there a tool to check /sys/devices/temperatures?
> I just created a primitive shell script as attached.

Hi,

I've created a patch for Tormso (http://torsmo.sourceforge.net/) to show
the cpu temperature and fan speed.

patch is attached. (use at your own risc) :P

Apply the patch and put $adt746xcpu and $adt746xfan in your ~/.torsmorc
--- torsmo-0.17-orig/torsmo.c	2004-08-11 04:08:25.000000000 +0200
+++ torsmo-0.17/torsmo.c	2004-08-11 14:27:19.630737176 +0200
@@ -419,6 +419,8 @@
 
 enum text_object_type {
   OBJ_acpiacadapter,
+  OBJ_adt746xcpu,
+  OBJ_adt746xfan,
   OBJ_acpifan,
   OBJ_acpitemp,
   OBJ_battery,
@@ -570,6 +572,10 @@
   END
   OBJ(acpiacadapter)
   END
+  OBJ(adt746xcpu)
+  END
+  OBJ(adt746xfan)
+  END
   OBJ(acpifan)
   END
   OBJ(battery)
@@ -1000,6 +1006,12 @@
       /* does anyone have decimals in acpi temperature? */
       snprintf(p, n, "%d", (int) get_acpi_temperature(obj->data.i));
     }
+    OBJ(adt746xcpu) {
+      snprintf(p, n, "%s", get_adt746x_cpu());
+    }
+    OBJ(adt746xfan) {
+      snprintf(p, n, "%s", get_adt746x_fan());
+    }
     OBJ(acpifan) {
       snprintf(p, n, "%s", get_acpi_fan());
     }
--- torsmo-0.17-orig/torsmo.h	2004-08-11 04:08:25.000000000 +0200
+++ torsmo-0.17/torsmo.h	2004-08-11 14:27:44.657932464 +0200
@@ -40,6 +40,9 @@
 int open_i2c_sensor(const char *dev, const char *type, int n, int *div);
 double get_i2c_info(int fd, int arg);
 
+char* get_adt746x_cpu(void);
+char* get_adt746x_fan(void);
+
 int open_acpi_temperature(const char *name);
 double get_acpi_temperature(int fd);
 char* get_acpi_ac_adapter(void);
--- torsmo-0.17-orig/linux.c	2004-08-11 04:08:25.000000000 +0200
+++ torsmo-0.17/linux.c	2004-08-11 14:25:51.905073504 +0200
@@ -330,6 +330,50 @@
 #endif
 }
 
+#define ADT746X_FAN "/sys/devices/temperatures/cpu_fan_speed"
+
+static char *adt746x_fan_state;
+
+char* get_adt746x_fan() {
+  static int rep;
+  FILE *fp;
+
+  if (adt746x_fan_state == NULL) {
+    adt746x_fan_state = (char*)malloc(100);
+    assert(adt746x_fan_state!=NULL);
+  }
+
+  fp = open_file(ADT746X_FAN, &rep);
+  if (!fp) {
+    strcpy(adt746x_fan_state,"No fan found! Hey, you don't have one?");
+    return adt746x_fan_state;
+  }
+  fscanf(fp, "%s", adt746x_fan_state);
+  fclose(fp);
+
+  return adt746x_fan_state;
+}
+
+#define ADT746X_CPU "/sys/devices/temperatures/cpu_temperature"
+
+static char *adt746x_cpu_state;
+
+char* get_adt746x_cpu() {
+  static int rep;
+  FILE *fp;
+
+  if (adt746x_cpu_state == NULL) {
+    adt746x_cpu_state = (char*)malloc(100);
+    assert(adt746x_cpu_state!=NULL);
+  }
+
+  fp = open_file(ADT746X_CPU, &rep);
+  fscanf(fp, "%s", adt746x_cpu_state);
+  fclose(fp);
+
+  return adt746x_cpu_state;
+}
+
 #define ACPI_FAN "/proc/acpi/fan/FAN/state"
 
 static char *acpi_fan_state;
--- torsmo-0.17-orig/torsmorc.sample	2004-08-11 04:08:25.000000000 +0200
+++ torsmo-0.17/torsmorc.sample	2004-08-11 14:21:23.680849784 +0200
@@ -69,6 +69,8 @@
 #  acpiacadapter                     ACPI ac adapter state.                   
 #  acpifan                           ACPI fan state                           
 #  acpitemp                          ACPI temperature.                        
+#  adt746x_cpu                       CPU temperature from therm_adt746x       
+#  adt746x_fan                       Fan speed from therm_adt746x             
 #  battery           (num)           Remaining capasity in ACPI or APM        
 #                                    battery. ACPI battery number can be      
 #                                    given as argument (default is BAT0).     

Attachment: pgpaMMNorNHTf.pgp
Description: PGP signature


Reply to: