LINUX.ORG.RU

libsensors


0

1

Пытаюсь научиться работать с libsensors4. Написал функцию для вывода текущей температуры процессора, но код:


int
cpu_temperature ()
{
  sensors_init (NULL);
  const sensors_chip_name *name;
  const sensors_feature *feature;
  const sensors_subfeature *subfeature;
  int i = 0;
  double value = 0;
  while ((name = sensors_get_detected_chips (NULL, &i)))
  {
  	if(name == NULL)
		puts("sensors_get_detected_chips error!");
	while((feature = sensors_get_features(name, &i)))
		{
			if(feature == NULL)
				puts("sensors_get_features error!");
      			switch(feature->type)
				{
      				case SENSORS_FEATURE_TEMP:
				subfeature = sensors_get_subfeature (name, feature, SENSORS_SUBFEATURE_TEMP_INPUT);
					if(subfeature == NULL)
						puts("sensors_get_subfeature error!");
					sensors_get_value (name, subfeature->number, &value);
					if(value < 0)
						puts("sensors_get_value error!");
      		printf ("Temperature is: %f\n", &value);
				break;
				default:
				  continue;
				}
		}
    }
  sensors_cleanup ();
  return 0;

}

выводит разные отрицательные значения, вроде:

Temperature is: -0.114407
Temperature is: -0.135105

В чем ошибка?

★★

Команда sensors правильные значения показывает? Наверное драйвер у тебя не тот используется.

o
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.