* [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-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
2 siblings, 0 replies; 5+ messages in thread
From: Matt Roberds @ 2008-11-10 18:38 UTC (permalink / raw)
To: lm-sensors
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
_______________________________________________
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
* Re: [lm-sensors] a problem with lm-sensor 2.10.7.
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
2 siblings, 0 replies; 5+ messages in thread
From: Jean Delvare @ 2008-11-11 9:31 UTC (permalink / raw)
To: lm-sensors
Hi Sergio,
On Mon, 10 Nov 2008 19:20:05 +0100, Sergio Gutierrez Verde wrote:
> 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.
If I can allow myself a side comment, writing code for libsensors 2.x
today is a bit odd. The libsensors 3.x API is perfectly stable by now
and it is much better than 2.x so you should really use 3.x for new
applications.
> Could anyone find the wrong in my code?
Did you try building it with -Wall -W? In many cases it is sufficient
to point you to the problematic code.
--
Jean Delvare
_______________________________________________
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-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
2 siblings, 0 replies; 5+ messages in thread
From: Sergio Gutierrez Verde @ 2008-11-11 10:22 UTC (permalink / raw)
To: lm-sensors
[-- Attachment #1.1: Type: text/plain, Size: 1672 bytes --]
Yes, I use -Wall -W and -pedantic compiling options, and there aren't any problems, in compiling time.
Ok, I have read the 3.x API and you have reason, it's easier than 2.x. but in the computer is installed the older version.
I accept more suggestions... If I can't find the problem I'll change the version and I'll do a new code.
Thanks for your helpful information.
> Date: Tue, 11 Nov 2008 10:31:55 +0100
> From: khali@linux-fr.org
> To: 513172@unizar.es
> CC: lm-sensors@lm-sensors.org
> Subject: Re: [lm-sensors] a problem with lm-sensor 2.10.7.
>
> Hi Sergio,
>
> On Mon, 10 Nov 2008 19:20:05 +0100, Sergio Gutierrez Verde wrote:
> > 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.
>
> If I can allow myself a side comment, writing code for libsensors 2.x
> today is a bit odd. The libsensors 3.x API is perfectly stable by now
> and it is much better than 2.x so you should really use 3.x for new
> applications.
>
> > Could anyone find the wrong in my code?
>
> Did you try building it with -Wall -W? In many cases it is sufficient
> to point you to the problematic code.
>
> --
> Jean Delvare
_________________________________________________________________
Los más de lo más, Especial Rankings
http://events.es.msn.com/dinero/listas/default.aspx
[-- Attachment #1.2: Type: text/html, Size: 2025 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.