Hi Timo,
I added configurable paths for both range and lux sysfile in the
alsadaptor. If you want to merge the alsadaptor-ascii and
alsadaptor-sysfs, you can use this patch:)
BTW, Philippe and Christophex are in charge of the sensorfw validation
on Intel's platform, they are interested in these messages.
Thanks,
Leo
On Wed, 2010-09-29 at 19:47 +0800, Rongas Timo wrote:
> Hi Leo, sorry for the delay.
>
> I just pushed magnetometer-ascii and proximity-ascii to gitorious (with a few
> really minor beauty tweaks). Let's see if we can reach a conclusion on how to
> continue with the alsadaptor merging.
>
> About libcompasschain.so. We are figuring out if and how to get it added to
> Meego as a binary plugin and how to maintain it. It's bit of a tricky deal,
> but hopefully we manage to solve it.
>
> // Timo
>
> >-----Original Message-----
> >From: Yan, Leo [mailto:[email protected]]
> >Sent: Monday, September 27, 2010 10:08 AM
> >To: [email protected]; Rongas Timo
> >Cc: [email protected]
> >Subject: RE: [MeeGo-dev] ALS, Proximity and Magnetometer
> >Adaptors of sensor framework on Medfield
> >
> >Thanks, Markus. If it needs, I will add configurable path in
> >the adaptor.
> >
> >Thanks,
> >Leo
> >
> >-----Original Message-----
> >From: [email protected] [mailto:[email protected]]
> >Sent: Monday, September 27, 2010 2:51 PM
> >To: Yan, Leo; [email protected]
> >Cc: [email protected]
> >Subject: RE: [MeeGo-dev] ALS, Proximity and Magnetometer
> >Adaptors of sensor framework on Medfield
> >
> >On 2010-09-25 at 05:38:31, ext Yan Leo wrote:
> >>
> >> I modified the adaptors as you suggested, and removed the
> >> setStandbyOverride function.
> >> All of the sensor drivers on Medfield can output data correctly when
> >> the screen is blanked.
> >
> >Hi,
> >
> >The alsadaptor-ascii is very very similar to the existing
> >alsadaptor-sysfs
> >(http://gitorious.org/sensorfw/sensorfw/trees/master/adaptors/a
> >lsadaptor-sysfs). Basically, the only real difference seems to
> >be that your alsadaptor-ascii can read the data range from a
> >file. I suggest merging the two, either:
> >a) patch alsadaptor-sysfs to include functionality of alsadaptor-ascii
> >b) increase the configurability of alsadaptor-ascii
> >(configurable file paths, configurable range if no file is
> >available), so that alsadaptor-sysfs can be dropped
> >
> >
> >> Magnetometer adaptor is also added. It seems that libcompasschain.so
> >> is needed when testing the magnetometer in clientapitest,
> >where can I
> >> get it?
> >
> >The compasschain library is not currently available in MeeGo
> >:( Timo would probably know more of future plans regarding it,
> >or how magnetometer could be tested without it. As a last
> >resort, we could include it as a binary only package in Trunk:non-oss.
> >
> >--
> > Markus
> >
diff --git a/adaptors/adaptors.pro b/adaptors/adaptors.pro
index 744309a..ac17489 100644
--- a/adaptors/adaptors.pro
+++ b/adaptors/adaptors.pro
@@ -5,6 +5,7 @@ include( ../common-config.pri )
internal {
SUBDIRS = alsadaptor \
alsadaptor-sysfs \
+ alsadaptor-ascii \
tapadaptor \
accelerometeradaptor \
magnetometeradaptor \
diff --git a/adaptors/alsadaptor-ascii/alsadaptor-ascii.cpp b/adaptors/alsadaptor-ascii/alsadaptor-ascii.cpp
new file mode 100644
index 0000000..947e058
--- /dev/null
+++ b/adaptors/alsadaptor-ascii/alsadaptor-ascii.cpp
@@ -0,0 +1,103 @@
+/**
+ @file alsadaptor-ascii.cpp
+ @brief ALSAdaptor that reads lux value from ascii interface
+
+ <p>
+ Copyright (C) 2009-2010 Intel Corporation
+ Copyright (C) 2009-2010 Nokia Corporation
+
+ @author Leo Yan <[email protected]>
+ @author Timo Rongas <[email protected]>
+ @author Ustun Ergenoglu <[email protected]>
+ @author Matias Muhonen <[email protected]>
+ @author Tapio Rantala <[email protected]>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <QFile>
+
+#include "logging.h"
+#include "config.h"
+#include "alsadaptor-ascii.h"
+#include "filters/utils.h"
+
+#define SYSFS_RANGE_PATH "/sys/bus/i2c/devices/5-0029/apds9802als/sensing_range"
+#define SYSFS_LUX_PATH "/sys/bus/i2c/devices/5-0029/apds9802als/lux_output"
+#define DEFAULT_RANGE 65535
+
+ALSAdaptorAscii::ALSAdaptorAscii(const QString& id) : SysfsAdaptor(id, SysfsAdaptor::IntervalMode)
+{
+ int range;
+ QFile sysFile;
+ QString devPath;
+
+ if (Config::configuration()->value("als_range_sysfs_path").toString().size() > 0) {
+ sysFile.setFileName(Config::configuration()->value("als_range_sysfs_path").toString());
+ } else {
+ sysFile.setFileName(SYSFS_RANGE_PATH);
+ }
+ if (!(sysFile.exists() && sysFile.open(QIODevice::ReadOnly))) {
+ sensordLogW() << "Unable to config range from sysfs, use default value: " << DEFAULT_RANGE;
+ range = DEFAULT_RANGE;
+ } else {
+ sysFile.readLine(buf, sizeof(buf));
+ range = QString(buf).toInt();
+ }
+ sensordLogT() << "Ambient light range: " << range;
+ introduceAvailableDataRange(DataRange(0, range, 1));
+
+ devPath = Config::configuration()->value("als_lux_sysfs_path").toString();
+ if (devPath.isEmpty()) {
+ sensordLogW() << "Configuration als_lux_sysfs_path not found, use default path: " <<
+ SYSFS_LUX_PATH;
+ devPath = SYSFS_LUX_PATH;
+ }
+
+ devId = 0;
+ addPath(devPath, devId);
+ alsBuffer_ = new DeviceAdaptorRingBuffer<TimedUnsigned>(16);
+ addAdaptedSensor("als", "apds9802als ascii", alsBuffer_);
+}
+
+ALSAdaptorAscii::~ALSAdaptorAscii()
+{
+ delete alsBuffer_;
+}
+
+void ALSAdaptorAscii::processSample(int pathId, int fd) {
+ if (pathId != devId) {
+ sensordLogW() << "pathId != devId";
+ return;
+ }
+
+ lseek(fd, 0, SEEK_SET);
+ if (read(fd, buf, sizeof(buf)) <= 0) {
+ sensordLogW() << "read():" << strerror(errno);
+ return;
+ }
+ sensordLogT() << "Ambient light value: " << buf;
+
+ TimedUnsigned* lux = alsBuffer_->nextSlot();
+ sscanf(buf, "%d", &lux->value_);
+
+ lux->timestamp_ = Utils::getTimeStamp();
+ alsBuffer_->commit();
+ alsBuffer_->wakeUpReaders();
+}
diff --git a/adaptors/alsadaptor-ascii/alsadaptor-ascii.h b/adaptors/alsadaptor-ascii/alsadaptor-ascii.h
new file mode 100644
index 0000000..36e25c6
--- /dev/null
+++ b/adaptors/alsadaptor-ascii/alsadaptor-ascii.h
@@ -0,0 +1,64 @@
+/**
+ @file alsadaptor-ascii.h
+ @brief ALSAdaptor that reads lux value from ascii interface
+
+ <p>
+ Copyright (C) 2009-2010 Intel Corporation
+ Copyright (C) 2009-2010 Nokia Corporation
+
+ @author Leo Yan <[email protected]>
+ @author Timo Rongas <[email protected]>
+ @author Ustun Ergenoglu <[email protected]>
+ @author Matias Muhonen <[email protected]>
+ @author Tapio Rantala <[email protected]>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#ifndef ALSADAPTOR_ASCII_H
+#define ALSADAPTOR_ASCII_H
+
+#include "sysfsadaptor.h"
+#include "sensord/deviceadaptorringbuffer.h"
+#include "filters/timedunsigned.h"
+#include <QTime>
+
+
+class ALSAdaptorAscii : public SysfsAdaptor
+{
+ Q_OBJECT;
+public:
+ static DeviceAdaptor* factoryMethod(const QString& id)
+ {
+ return new ALSAdaptorAscii(id);
+ }
+
+protected:
+ ALSAdaptorAscii(const QString& id);
+ ~ALSAdaptorAscii();
+
+ virtual bool setStandbyOverride(const bool override) { Q_UNUSED(override); return false; }
+private:
+
+ void processSample(int pathId, int fd);
+ int devId;
+ char buf[16];
+
+ DeviceAdaptorRingBuffer<TimedUnsigned>* alsBuffer_;
+};
+
+#endif
+
diff --git a/adaptors/alsadaptor-ascii/alsadaptor-ascii.pro b/adaptors/alsadaptor-ascii/alsadaptor-ascii.pro
new file mode 100644
index 0000000..4c2fcb1
--- /dev/null
+++ b/adaptors/alsadaptor-ascii/alsadaptor-ascii.pro
@@ -0,0 +1,27 @@
+TEMPLATE = lib
+CONFIG += plugin
+
+TARGET = alsadaptor-ascii
+
+include( ../../common-config.pri )
+
+HEADERS += alsadaptor-ascii.h \
+ alsadaptor-asciiplugin.h
+
+SOURCES += alsadaptor-ascii.cpp \
+ alsadaptor-asciiplugin.cpp
+
+SENSORFW_INCLUDEPATHS = ../.. \
+ ../../include \
+ ../../sensord \
+ ../../datatypes \
+ ../../filters
+
+DEPENDPATH += $$SENSORFW_INCLUDEPATHS
+INCLUDEPATH += $$SENSORFW_INCLUDEPATHS
+
+include(../../common-install.pri)
+publicheaders.files += $$HEADERS
+target.path = $$PLUGINPATH
+
+INSTALLS += target
diff --git a/adaptors/alsadaptor-ascii/alsadaptor-asciiplugin.cpp b/adaptors/alsadaptor-ascii/alsadaptor-asciiplugin.cpp
new file mode 100644
index 0000000..13973ae
--- /dev/null
+++ b/adaptors/alsadaptor-ascii/alsadaptor-asciiplugin.cpp
@@ -0,0 +1,43 @@
+/**
+ @file alsadaptor-asciiplugin.cpp
+ @brief Plugin for ALSAdaptorAscii
+
+ <p>
+ Copyright (C) 2009-2010 Intel Corporation
+ Copyright (C) 2009-2010 Nokia Corporation
+
+ @author Leo Yan <[email protected]>
+ @author Timo Rongas <[email protected]>
+ @author Ustun Ergenoglu <[email protected]>
+ @author Matias Muhonen <[email protected]>
+ @author Tapio Rantala <[email protected]>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#include "alsadaptor-asciiplugin.h"
+#include "alsadaptor-ascii.h"
+#include "sensormanager.h"
+
+void ALSAdaptorAsciiPlugin::Register(class Loader&)
+{
+ sensordLogW() << "registering alsadaptor-ascii";
+ SensorManager& sm = SensorManager::instance();
+ sm.registerDeviceAdaptor<ALSAdaptorAscii>("alsadaptor");
+}
+
+Q_EXPORT_PLUGIN2(alsadaptor, ALSAdaptorAsciiPlugin)
+
diff --git a/adaptors/alsadaptor-ascii/alsadaptor-asciiplugin.h b/adaptors/alsadaptor-ascii/alsadaptor-asciiplugin.h
new file mode 100644
index 0000000..97cba9c
--- /dev/null
+++ b/adaptors/alsadaptor-ascii/alsadaptor-asciiplugin.h
@@ -0,0 +1,42 @@
+/**
+ @file alsadaptor-asciiplugin.h
+ @brief Plugin for ALSAdaptorAscii
+
+ <p>
+ Copyright (C) 2009-2010 Intel Corporation
+ Copyright (C) 2009-2010 Nokia Corporation
+
+ @author Leo Yan <[email protected]>
+ @author Timo Rongas <[email protected]>
+ @author Ustun Ergenoglu <[email protected]>
+ @author Matias Muhonen <[email protected]>
+ @author Tapio Rantala <[email protected]>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#ifndef ALSADAPTOR_ASCIIPLUGIN_H
+#define ALSADAPTOR_ASCIIPLUGIN_H
+
+#include "plugin.h"
+
+class ALSAdaptorAsciiPlugin : public Plugin
+{
+ private:
+ void Register(class Loader& l);
+};
+
+#endif
_______________________________________________
MeeGo-dev mailing list
[email protected]
http://lists.meego.com/listinfo/meego-dev