2010-05-20 10:13:14 -07:00
|
|
|
#include "e.h"
|
|
|
|
#include "e_mod_main.h"
|
|
|
|
|
2016-11-30 00:06:45 -08:00
|
|
|
int
|
|
|
|
temperature_udev_get(Tempthread *tth)
|
2010-05-20 10:13:14 -07:00
|
|
|
{
|
2010-08-19 08:27:13 -07:00
|
|
|
Eina_List *l;
|
2016-11-30 00:06:45 -08:00
|
|
|
double cur, temp;
|
2010-05-20 10:13:14 -07:00
|
|
|
char *syspath;
|
|
|
|
const char *test;
|
|
|
|
char buf[256];
|
2016-11-30 00:06:45 -08:00
|
|
|
int x, y, cpus = 0;
|
2010-05-20 10:13:14 -07:00
|
|
|
|
|
|
|
temp = -999;
|
|
|
|
|
2016-11-30 00:06:45 -08:00
|
|
|
if (!tth->tempdevs)
|
|
|
|
tth->tempdevs =
|
|
|
|
eeze_udev_find_by_type(EEZE_UDEV_TYPE_IS_IT_HOT_OR_IS_IT_COLD_SENSOR,
|
|
|
|
NULL);
|
|
|
|
if (tth->tempdevs)
|
2010-05-20 10:13:14 -07:00
|
|
|
{
|
|
|
|
temp = 0;
|
2016-11-30 00:06:45 -08:00
|
|
|
EINA_LIST_FOREACH(tth->tempdevs, l, syspath)
|
2010-05-21 20:05:45 -07:00
|
|
|
{
|
2010-08-29 03:57:05 -07:00
|
|
|
for (x = 1, y = 0; x < 15; x++)
|
2010-05-20 19:00:41 -07:00
|
|
|
{
|
2010-08-19 08:27:13 -07:00
|
|
|
if (y >= 2) break;
|
2010-05-30 00:33:21 -07:00
|
|
|
sprintf(buf, "temp%d_input", x);
|
|
|
|
if ((test = eeze_udev_syspath_get_sysattr(syspath, buf)))
|
2010-05-22 17:50:36 -07:00
|
|
|
{
|
2010-05-30 00:33:21 -07:00
|
|
|
y = 0;
|
2016-11-30 00:06:45 -08:00
|
|
|
cur = atoi(test);
|
2010-05-30 00:33:21 -07:00
|
|
|
if (cur > 0)
|
|
|
|
{
|
2016-11-30 00:06:45 -08:00
|
|
|
/* udev reports temp in (celsius * 1000) */
|
|
|
|
temp += (cur / 1000);
|
2010-05-30 00:33:21 -07:00
|
|
|
cpus++;
|
|
|
|
}
|
2010-05-22 17:50:36 -07:00
|
|
|
}
|
2016-11-30 00:06:45 -08:00
|
|
|
/* keep checking for sensors until 2 in a row don't exist */
|
2010-05-30 00:33:21 -07:00
|
|
|
else y++;
|
2010-05-22 17:27:31 -07:00
|
|
|
}
|
2010-05-20 10:13:14 -07:00
|
|
|
}
|
2016-11-30 00:06:45 -08:00
|
|
|
if (cpus > 0)
|
2010-05-20 10:13:14 -07:00
|
|
|
{
|
2016-11-30 00:06:45 -08:00
|
|
|
temp /= (double)cpus;
|
|
|
|
return temp;
|
2010-05-20 10:13:14 -07:00
|
|
|
}
|
|
|
|
}
|
2016-11-30 00:06:45 -08:00
|
|
|
return -999;
|
2010-05-20 10:13:14 -07:00
|
|
|
}
|