Commit ed673e9f authored by Micha Mueller's avatar Micha Mueller
Browse files

Minor improvements to sysfs plugin

parent 921d5591
......@@ -7,6 +7,13 @@
#include "SysfsConfigurator.h"
SysfsConfigurator::SysfsConfigurator() {
_groupName = "group";
_baseName = "sensor";
}
SysfsConfigurator::~SysfsConfigurator() {}
void SysfsConfigurator::sensorBase(SysfsSensorBase& s, CFG_VAL config) {
ADD {
ATTRIBUTE("path", setPath)
......@@ -15,5 +22,7 @@ void SysfsConfigurator::sensorBase(SysfsSensorBase& s, CFG_VAL config) {
}
void SysfsConfigurator::sensorGroup(SysfsSensorGroup& s, CFG_VAL config) {
//no group attributes currently
ADD {
//no group attributes currently
}
}
......@@ -14,12 +14,8 @@
class SysfsConfigurator : public ConfiguratorTemplate<SysfsSensorBase, SysfsSensorGroup> {
public:
SysfsConfigurator() {
_groupName = "group";
_baseName = "sensor";
}
virtual ~SysfsConfigurator() {}
SysfsConfigurator();
virtual ~SysfsConfigurator();
protected:
/* Overwritten from ConfiguratorTemplate */
......
......@@ -61,6 +61,7 @@ void SysfsSensorGroup::read() {
reading.timestamp = getTimestamp();
for(auto s : _sensors) {
reading.value = 0;
fseek(s->getFile(), 0, SEEK_SET);
size_t nelem = fread(buf, 1, 1024, s->getFile());
if (nelem) {
......@@ -77,16 +78,15 @@ void SysfsSensorGroup::read() {
reading.value = stoll(buf);
}
} catch (const std::exception& e) {
#ifdef DEBUG
LOG(warning) << "SysfsSensor " << _groupName << "::" << s->getName() << " could not read value!";
#endif
return;
LOG(error) << _groupName << "::" << s->getName() << " could not read value!";
//dummy value
reading.value = 0;
}
#ifdef DEBUG
LOG(debug) << _groupName << "::" << s->getName() << ": \"" << reading.value << "\"";
#endif
}
#ifdef DEBUG
LOG(debug) << _groupName << "::" << s->getName() << ": \"" << reading.value << "\"";
#endif
//to keep the _cacheIndex uniform for all sensors store value in every case
s->storeReading(reading, _cacheIndex);
}
_cacheIndex = (_cacheIndex + 1) % _cacheSize;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment