All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] a problem with lm-sensor 2.10.7.
@ 2008-11-10 18:20 Sergio Gutierrez Verde
  2008-11-10 18:38 ` Matt Roberds
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Sergio Gutierrez Verde @ 2008-11-10 18:20 UTC (permalink / raw)
  To: lm-sensors


[-- Attachment #1.1: Type: text/plain, Size: 1841 bytes --]


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/

[-- Attachment #1.2: Type: text/html, Size: 3637 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: [lm-sensors] a problem with lm-sensor 2.10.7.
@ 2008-11-11  7:56 Sergio Gutierrez Verde
  0 siblings, 0 replies; 5+ messages in thread
From: Sergio Gutierrez Verde @ 2008-11-11  7:56 UTC (permalink / raw)
  To: lm-sensors


[-- Attachment #1.1: Type: text/plain, Size: 1165 bytes --]


It's a fail in the transcription, the sensors_chip_name is the same in the two calls, sorry.
The right code is the yesterday's code changing this extract:

double w83781d(const sensors_chip_name *chip_name)

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

Moreover, with this error, the compiler, I think, would show at least a warning message, and the problem it's in execution time, not in compiler time.
Thanks!

> On Mon, 10 Nov 2008, Sergio Gutierrez Verde wrote:
> > double w83781d(const sensors_chip_name *name)
> > {> > double cur;
> >> > sensors_get_feature(*chip_name,SENSORS_W83781D_TEMP2,&cur)
> > return(cur);
> > }
>> Since you used "*name" in the argument, probably
>> sensors_get_feature(*name,SENSORS_W83781D_TEMP2,&cur)
>> would work better. What you are doing now is probably equal to>> sensors_get_feature(NULL,SENSORS_W83781D_TEMP2,&cur)
>> which would likely cause the error.
>> Matt Roberds
> 

_________________________________________________________________
 Ahora con Internet Explorer 7, llévate gratis un guiño personalizado
http://www.vivelive.com/ieak7/

[-- Attachment #1.2: Type: text/html, Size: 1488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 153 bytes --]

_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-11-11 10:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-10 18:20 [lm-sensors] a problem with lm-sensor 2.10.7 Sergio Gutierrez Verde
2008-11-10 18:38 ` Matt Roberds
2008-11-11  9:31 ` Jean Delvare
2008-11-11 10:22 ` Sergio Gutierrez Verde
  -- strict thread matches above, loose matches on Subject: below --
2008-11-11  7:56 Sergio Gutierrez Verde

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.