More I2C work. Made the temperature sensor scanning more generic, but only

increased the limit to nine.  A better way would be to do an ls and check
for all temp*_input.  Next time I will do it this way.

I still haven't tracked down the sensor name information.  It's out there
somewhere, I'll have to look at the source code for lm_sensors to see how
they do it.


SVN revision: 28133
This commit is contained in:
David Walter Seikel 2007-01-27 06:21:07 +00:00
parent de7e05e8c5
commit b438740bc8
2 changed files with 29 additions and 11 deletions

View File

@ -72,6 +72,7 @@ _fill_data(E_Config_Dialog_Data *cfdata)
double p;
Ecore_List *therms;
char *name;
char path[PATH_MAX];
cfdata->units = cfdata->inst->units;
if (cfdata->inst->units == CELCIUS)
@ -124,10 +125,29 @@ _fill_data(E_Config_Dialog_Data *cfdata)
case SENSOR_TYPE_LINUX_MACMINI:
break;
case SENSOR_TYPE_LINUX_I2C:
ecore_list_append(cfdata->sensors, strdup("temp1"));
ecore_list_append(cfdata->sensors, strdup("temp2"));
ecore_list_append(cfdata->sensors, strdup("temp3"));
ecore_list_append(cfdata->sensors, strdup("temp4"));
therms = ecore_file_ls("/sys/bus/i2c/devices");
if (therms)
{
char *therm_name;
while ((therm_name = ecore_list_next(therms)))
{
int i;
/* If there are ever more than 9 temperatures, then just increase this number. */
for (i = 0; i < 9; i++)
{
sprintf(path, "/sys/bus/i2c/devices/%s/temp%d_input", therm_name, i);
if (ecore_file_exists(path))
{
sprintf(path, "temp%d", i);
ecore_list_append(cfdata->sensors, strdup(path));
}
}
}
ecore_list_destroy(therms);
}
ecore_list_goto_first(cfdata->sensors);
while ((name = ecore_list_next(cfdata->sensors)))
{

View File

@ -238,8 +238,6 @@ _temperature_sensor_init(Config_Face *inst)
}
else
{
/* TODO: Is there I2C devices with more than 3 temperature sensors? Yes, mine has 4. */
/* TODO: What to do when there is more than one tempX? */
therms = ecore_file_ls("/sys/bus/i2c/devices");
if (therms)
{
@ -247,17 +245,17 @@ _temperature_sensor_init(Config_Face *inst)
while ((name = ecore_list_next(therms)))
{
char *sensors[] = { "temp1", "temp2", "temp3", "temp4" };
int i;
for (i = 0; i < 4; i++)
/* If there are ever more than 9 temperatures, then just increase this number. */
for (i = 0; i < 9; i++)
{
sprintf(path, "/sys/bus/i2c/devices/%s/%s_input",
name, sensors[i]);
sprintf(path, "/sys/bus/i2c/devices/%s/temp%d_input", name, i);
if (ecore_file_exists(path))
{
sprintf(path, "temp%d", i);
inst->sensor_type = SENSOR_TYPE_LINUX_I2C;
inst->sensor_name = evas_stringshare_add(sensors[i]);
inst->sensor_name = evas_stringshare_add(path);
break;
}
}