|
|
|
@ -30,25 +30,74 @@ LMSensor::LMSensor(SensorsList *parent): Sensor(parent)
|
|
|
|
|
LMSensor::~LMSensor(){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
|
|
|
|
|
bool LMSensor::init(const sensors_feature_data **data, int *nr1,int *nr2)
|
|
|
|
|
#else
|
|
|
|
|
bool LMSensor::init(const sensors_feature **data, int *nr1, int *nr2)
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
double min,max;
|
|
|
|
|
|
|
|
|
|
const sensors_chip_name *chip_name= getChipName();
|
|
|
|
|
const char* main_name = (*data)->name;
|
|
|
|
|
feature= (*data)->number;
|
|
|
|
|
char *label = NULL;
|
|
|
|
|
QString uniqueSensorName;
|
|
|
|
|
|
|
|
|
|
#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
|
|
|
|
|
uniqueSensorName.sprintf("%s_%d_%d.%s", chip_name->prefix, chip_name->bus, chip_name->addr, main_name);
|
|
|
|
|
#else
|
|
|
|
|
uniqueSensorName.sprintf("%s_%d_%d.%s", chip_name->prefix, chip_name->bus.nr, chip_name->addr, main_name);
|
|
|
|
|
#endif
|
|
|
|
|
setName(uniqueSensorName.latin1());
|
|
|
|
|
|
|
|
|
|
#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
|
|
|
|
|
bool min_found=false;
|
|
|
|
|
bool max_found=false;
|
|
|
|
|
while( (*data= sensors_get_all_features(*chip_name, nr1, nr2)) && (*data)->mapping!=SENSORS_NO_MAPPING) {
|
|
|
|
|
int len = strlen((*data)->name);
|
|
|
|
|
const char *postfix = (*data)->name + len - 4;
|
|
|
|
|
|
|
|
|
|
if (len < 5)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if((!strcmp(postfix, "_min") || !strcmp(postfix, "_low")) &&
|
|
|
|
|
!sensors_get_feature(*chip_name, (*data)->number, &valMin))
|
|
|
|
|
min_found=true;
|
|
|
|
|
|
|
|
|
|
if(!strcmp(postfix, "_max") &&
|
|
|
|
|
!sensors_get_feature(*chip_name, (*data)->number, &valMax)) {
|
|
|
|
|
max_found=true;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
postfix--;
|
|
|
|
|
|
|
|
|
|
if (strstr((*data)->name, "temp"))
|
|
|
|
|
if((!strcmp(postfix, "_over") || !strcmp(postfix, "_high")) &&
|
|
|
|
|
!sensors_get_feature(*chip_name, (*data)->number, &valMax))
|
|
|
|
|
max_found=true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double newVal;
|
|
|
|
|
if ((sensors_get_ignored(*chip_name, feature) != 1) || (sensors_get_feature(*chip_name, feature, &newVal) != 0)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strstr(main_name, "temp"))
|
|
|
|
|
{
|
|
|
|
|
setType(lmTemp);
|
|
|
|
|
max= 65;
|
|
|
|
|
min= 0;
|
|
|
|
|
}
|
|
|
|
|
else if (strstr((*data)->name, "fan"))
|
|
|
|
|
else if (strstr(main_name, "fan"))
|
|
|
|
|
{
|
|
|
|
|
setType(lmFan);
|
|
|
|
|
max= 10000;
|
|
|
|
|
min= 3000;
|
|
|
|
|
}
|
|
|
|
|
else if (strstr(main_name, "alarm") || strstr(main_name, "sensor") || strstr(main_name, "vrm"))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
setType(lmVoltage);
|
|
|
|
@ -56,47 +105,129 @@ double min,max;
|
|
|
|
|
min= -16;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
feature= (*data)->number;
|
|
|
|
|
|
|
|
|
|
QString str;
|
|
|
|
|
str.sprintf("%s.%s", chip_name->prefix, (*data)->name );
|
|
|
|
|
setName( str.latin1() );
|
|
|
|
|
|
|
|
|
|
char *label;
|
|
|
|
|
sensors_get_label(*chip_name,feature,&label);
|
|
|
|
|
if (label)
|
|
|
|
|
{
|
|
|
|
|
setDescription(QString(label));
|
|
|
|
|
delete label;
|
|
|
|
|
label = NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
setDescription(uniqueSensorName.latin1());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool valid= false;
|
|
|
|
|
while( (*data= sensors_get_all_features(*chip_name, nr1, nr2)) && (*data)->mapping!=SENSORS_NO_MAPPING) {
|
|
|
|
|
str= (*data)->name;
|
|
|
|
|
if(str.find("_min")>=0 || str.find("_low")>=0) {
|
|
|
|
|
sensors_get_feature(*chip_name, (*data)->number, &valMin);
|
|
|
|
|
valid= true;
|
|
|
|
|
} else
|
|
|
|
|
if(str.find("_max")>=0 || str.find("_over")>=0 || str.find("_high")>=0) {
|
|
|
|
|
sensors_get_feature(*chip_name, (*data)->number, &valMax);
|
|
|
|
|
valid= true;
|
|
|
|
|
if(min_found)
|
|
|
|
|
min = valMin;
|
|
|
|
|
|
|
|
|
|
if(max_found)
|
|
|
|
|
max = valMax;
|
|
|
|
|
|
|
|
|
|
#else /* libsensors4 code */
|
|
|
|
|
|
|
|
|
|
const sensors_subfeature *sub_feature;
|
|
|
|
|
const sensors_feature *feature_data = *data;
|
|
|
|
|
|
|
|
|
|
/* Move to next feature for the loop in LMSensorsChip::createSensors() */
|
|
|
|
|
*data = sensors_get_features(chip_name, nr1);
|
|
|
|
|
|
|
|
|
|
switch(feature_data->type)
|
|
|
|
|
{
|
|
|
|
|
case SENSORS_FEATURE_IN:
|
|
|
|
|
sub_feature = sensors_get_subfeature(chip_name, feature_data,
|
|
|
|
|
SENSORS_SUBFEATURE_IN_INPUT);
|
|
|
|
|
|
|
|
|
|
if (!sub_feature)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
feature = sub_feature->number;
|
|
|
|
|
|
|
|
|
|
if (!(sub_feature = sensors_get_subfeature(chip_name, feature_data,
|
|
|
|
|
SENSORS_SUBFEATURE_IN_MIN)) ||
|
|
|
|
|
sensors_get_value(chip_name, sub_feature->number, &min))
|
|
|
|
|
min = -16;
|
|
|
|
|
|
|
|
|
|
if (!(sub_feature = sensors_get_subfeature(chip_name, feature_data,
|
|
|
|
|
SENSORS_SUBFEATURE_IN_MAX)) ||
|
|
|
|
|
sensors_get_value(chip_name, sub_feature->number, &max))
|
|
|
|
|
max = 16;
|
|
|
|
|
|
|
|
|
|
setType(lmVoltage);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SENSORS_FEATURE_FAN:
|
|
|
|
|
sub_feature = sensors_get_subfeature(chip_name, feature_data,
|
|
|
|
|
SENSORS_SUBFEATURE_FAN_INPUT);
|
|
|
|
|
|
|
|
|
|
if (!sub_feature)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
feature = sub_feature->number;
|
|
|
|
|
|
|
|
|
|
if (!(sub_feature = sensors_get_subfeature(chip_name, feature_data,
|
|
|
|
|
SENSORS_SUBFEATURE_FAN_MIN)) ||
|
|
|
|
|
sensors_get_value(chip_name, sub_feature->number, &min))
|
|
|
|
|
min = 3000;
|
|
|
|
|
|
|
|
|
|
max = 10000;
|
|
|
|
|
|
|
|
|
|
setType(lmFan);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case SENSORS_FEATURE_TEMP:
|
|
|
|
|
sub_feature = sensors_get_subfeature(chip_name, feature_data,
|
|
|
|
|
SENSORS_SUBFEATURE_TEMP_INPUT);
|
|
|
|
|
|
|
|
|
|
if (!sub_feature)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
feature = sub_feature->number;
|
|
|
|
|
|
|
|
|
|
if (!(sub_feature = sensors_get_subfeature(chip_name, feature_data,
|
|
|
|
|
SENSORS_SUBFEATURE_TEMP_MIN)) ||
|
|
|
|
|
sensors_get_value(chip_name, sub_feature->number, &min))
|
|
|
|
|
min = 0;
|
|
|
|
|
|
|
|
|
|
if ((!(sub_feature = sensors_get_subfeature(chip_name, feature_data,
|
|
|
|
|
SENSORS_SUBFEATURE_TEMP_MAX)) &&
|
|
|
|
|
!(sub_feature = sensors_get_subfeature(chip_name, feature_data,
|
|
|
|
|
SENSORS_SUBFEATURE_TEMP_CRIT))) ||
|
|
|
|
|
sensors_get_value(chip_name, sub_feature->number, &max))
|
|
|
|
|
max = 65;
|
|
|
|
|
|
|
|
|
|
setType(lmTemp);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
label = sensors_get_label(chip_name, feature_data);
|
|
|
|
|
if (label)
|
|
|
|
|
{
|
|
|
|
|
setDescription(QString(label));
|
|
|
|
|
delete label;
|
|
|
|
|
label = NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
setDescription( uniqueSensorName.latin1() );
|
|
|
|
|
|
|
|
|
|
#endif /* libsensors3 / libsensors4 code */
|
|
|
|
|
|
|
|
|
|
if(valid) {
|
|
|
|
|
double newVal;
|
|
|
|
|
valid= (sensors_get_feature(*chip_name, feature, &newVal)==0);
|
|
|
|
|
if(valid) {
|
|
|
|
|
if(min>max) {
|
|
|
|
|
double pivot= valMin;
|
|
|
|
|
double pivot= min;
|
|
|
|
|
min= max;
|
|
|
|
|
max= pivot;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setValueMax(max,dgCelsius);
|
|
|
|
|
setValueMin(min,dgCelsius);
|
|
|
|
|
setValue((max+min)/2,dgCelsius);
|
|
|
|
|
|
|
|
|
|
readConfig();
|
|
|
|
|
updateValue();
|
|
|
|
|
setValueIdeal(getValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return valid;
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LMSensor::updateValue()
|
|
|
|
@ -108,7 +239,11 @@ double LMSensor::readSensorValue()
|
|
|
|
|
{
|
|
|
|
|
double newVal;
|
|
|
|
|
const sensors_chip_name *chip_name= getChipName();
|
|
|
|
|
#if SENSORS_API_VERSION < 0x400 /* libsensor 3 code */
|
|
|
|
|
sensors_get_feature(*chip_name, feature, &newVal);
|
|
|
|
|
#else
|
|
|
|
|
sensors_get_value(chip_name, feature, &newVal);
|
|
|
|
|
#endif
|
|
|
|
|
return newVal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|