a problem with lm-sensor 2.10.7.

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

 



All,

I have a problem using a function of lm-sensors 2.10.7.

In the next extract of code I try to get the CPU TEMP of a certain chip. But when  'sensors_get_feature' is called, there is a problem, a Segmentation fault.
I also try to use the most part of the code of lm-sensors 2.10.7 (like main.c, chips.c and so on), but the problem persists.
The chip and the sensors are the right.

Could anyone find the wrong in my code?

Regards,
Sergio

CODE:

void init_temp (){


   FILE *config_file;

        sensors_cleanup();
        config_file = fopen("/etc/sensors.conf", "r");
        if (config_file ==NULL){
                fprintf(stderr, "FAIL! reading file\n");
                exit(1);
        }
        else{
                if (sensors_init(config_file)!=0) {
                        fprintf(stderr,"FAIL!! sensor not init\n");
                        exit(1);
                }
                else{
                        fprintf(stderr,"OK\n");
                        fclose(config_file);
                }
        }
}
double read_temp (){

    sensors_chip_name chip_name;

        fprintf(stderr,"Reading temperature\n");

        if(sensors_parse_chip_name("w83627thf-isa-0290",&chip_name)!=0){
                fprintf(stderr, "ERROR!!! chip not found\n");
                exit(1);
        }

        return(w83781d (&chip_name));

}

double w83781d(const sensors_chip_name *name)
{

  double cur;

  sensors_get_feature(*chip_name,SENSORS_W83781D_TEMP2,&cur)
  return(cur);
}

void main (){
   double temp;
   init_temp();
   temp = read_temp();
   fprintf(stderr,"Temp: %f\n",temp);
}
_________________________________________________________________
 Ahora con Internet Explorer 7, ll?vate gratis un gui?o personalizado
http://www.vivelive.com/ieak7/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20081110/61b14f13/attachment.html 


[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux