Skip to content

Commit

Permalink
Merge branch 'harmattan'
Browse files Browse the repository at this point in the history
Conflicts:
	adaptors/accelerometeradaptor/accelerometeradaptor.cpp
	adaptors/alsadaptor/alsadaptor.cpp
	adaptors/alsadaptor/alsadaptor.h
	adaptors/kbslideradaptor/kbslideradaptor.cpp
	adaptors/magnetometeradaptor-ascii/magnetometeradaptor-ascii.cpp
	adaptors/magnetometeradaptor/magnetometeradaptor.cpp
	adaptors/magnetometeradaptor/magnetometeradaptor.h
	adaptors/mrstaccelerometer/mrstaccelerometeradaptor.cpp
	adaptors/mrstaccelerometer/mrstaccelerometeradaptor.h
	adaptors/proximityadaptor-ascii/proximityadaptor-ascii.cpp
	adaptors/proximityadaptor-ascii/proximityadaptor-ascii.h
	adaptors/proximityadaptor-evdev/proximityadaptor-evdev.cpp
	adaptors/proximityadaptor-evdev/proximityadaptor-evdev.h
	adaptors/proximityadaptor/proximityadaptor.cpp
	adaptors/tapadaptor/tapadaptor.cpp
	adaptors/touchadaptor/touchadaptor.cpp
	chains/accelerometerchain/accelerometerchain.cpp
	config/90-sensord-default.conf
	core/deviceadaptor.h
	core/inputdevadaptor.cpp
	core/inputdevadaptor.h
	core/loader.cpp
	core/logging.h
	core/nodebase.h
	core/sensormanager.h
	core/sysfsadaptor.cpp
	core/sysfsadaptor.h
	datatypes/orientationdata.h
	debian/changelog
	filters/orientationinterpreter/orientationinterpreter.cpp
	sensord.pc
	sensord/calibrationhandler.cpp
	sensors/gyroscopesensor/gyroscopesensor.cpp
	sensors/proximitysensor/proximitysensor.cpp
	tests/adaptors/adaptortest.cpp
	tests/client/clientapitest.cpp
  • Loading branch information
Antti Virtanen committed Apr 20, 2011
2 parents e126f2a + b104f1e commit 580ac94
Show file tree
Hide file tree
Showing 220 changed files with 7,352 additions and 2,474 deletions.
16 changes: 7 additions & 9 deletions adaptors/accelerometeradaptor/accelerometeradaptor.cpp
Expand Up @@ -8,6 +8,7 @@
@author Timo Rongas <ext-timo.2.rongas@nokia.com>
@author Ustun Ergenoglu <ext-ustun.ergenoglu@nokia.com>
@author Antti Virtanen <antti.i.virtanen@nokia.com>
@author Shenghua <ext-shenghua.1.liu@nokia.com>
This file is part of Sensord.
Expand Down Expand Up @@ -40,7 +41,6 @@
AccelerometerAdaptor::AccelerometerAdaptor(const QString& id) :
InputDevAdaptor(id, 1)
{

accelerometerBuffer_ = new DeviceAdaptorRingBuffer<OrientationData>(1);
setAdaptedSensor("accelerometer", "Internal accelerometer coordinates", accelerometerBuffer_);
setDescription("Input device accelerometer adaptor (lis302d)");
Expand Down Expand Up @@ -69,7 +69,6 @@ void AccelerometerAdaptor::interpretEvent(int src, struct input_event *ev)
break;
}
break;

}
}

Expand All @@ -81,32 +80,31 @@ void AccelerometerAdaptor::interpretSync(int src, struct input_event *ev)

void AccelerometerAdaptor::commitOutput(struct input_event *ev)
{
OrientationData* d = accelerometerBuffer_->nextSlot();
AccelerationData* d = accelerometerBuffer_->nextSlot();

d->timestamp_ = Utils::getTimeStamp(&(ev->time));
d->x_ = orientationValue_.x_;
d->y_ = orientationValue_.y_;
d->z_ = orientationValue_.z_;

sensordLogT() << "Accelerometer reading: " << d->x_ << ", " << d->y_ << ", " << d->z_;

accelerometerBuffer_->commit();
accelerometerBuffer_->wakeUpReaders();
}

unsigned int AccelerometerAdaptor::evaluateIntervalRequests(int& sessionId) const
{
unsigned int highestValue = 0;
int winningSessionId = -1;

if (m_intervalMap.size() == 0)
{
sessionId = winningSessionId;
sessionId = -1;
return defaultInterval();
}

// Get the smallest positive request, 0 is reserved for HW wakeup
QMap<int, unsigned int>::const_iterator it = m_intervalMap.constBegin();
highestValue = it.value();
winningSessionId = it.key();
unsigned int highestValue = it.value();
int winningSessionId = it.key();

for (++it; it != m_intervalMap.constEnd(); ++it)
{
Expand Down
4 changes: 2 additions & 2 deletions adaptors/accelerometeradaptor/accelerometeradaptor.h
Expand Up @@ -70,8 +70,8 @@ class AccelerometerAdaptor : public InputDevAdaptor
virtual unsigned int evaluateIntervalRequests(int& sessionId) const;

private:
DeviceAdaptorRingBuffer<OrientationData>* accelerometerBuffer_;
OrientationData orientationValue_;
DeviceAdaptorRingBuffer<AccelerationData>* accelerometerBuffer_;
AccelerationData orientationValue_;

void interpretEvent(int src, struct input_event *ev);
void commitOutput(struct input_event *ev);
Expand Down
4 changes: 2 additions & 2 deletions adaptors/alsadaptor-sysfs/alsadaptor-sysfs.cpp
Expand Up @@ -37,7 +37,7 @@
#include <linux/types.h>

ALSAdaptorSysfs::ALSAdaptorSysfs(const QString& id) :
SysfsAdaptor(id, SysfsAdaptor::IntervalMode, true, Config::configuration()->value("als-sysfs_path").toString())
SysfsAdaptor(id, SysfsAdaptor::IntervalMode, true)
{
alsBuffer_ = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
setAdaptedSensor("als", "Internal ambient light sensor lux values", alsBuffer_);
Expand All @@ -61,7 +61,7 @@ void ALSAdaptorSysfs::processSample(int pathId, int fd)
idata = atoi(asciidata);

if (bytesRead <= 0) {
sensordLogW() << "read():" << strerror(errno);
sensordLogW() << "read(): " << strerror(errno);
return;
}

Expand Down
16 changes: 7 additions & 9 deletions adaptors/alsadaptor/alsadaptor.cpp
Expand Up @@ -11,6 +11,7 @@
@author Tapio Rantala <ext-tapio.rantala@nokia.com>
@author Lihan Guo <lihan.guo@digia.com>
@author Antti Virtanen <antti.i.virtanen@nokia.com>
@author Shenghua <ext-shenghua.1.liu@nokia.com>
This file is part of Sensord.
Expand Down Expand Up @@ -49,15 +50,16 @@ struct bh1770glc_als {
__u16 lux;
} __attribute__((packed));


ALSAdaptor::ALSAdaptor(const QString& id):
SysfsAdaptor(id, SysfsAdaptor::SelectMode, false)
SysfsAdaptor(id, SysfsAdaptor::SelectMode, false),
deviceType_(DeviceUnknown)
{
alsBuffer_ = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
setAdaptedSensor("als", "Internal ambient light sensor lux values", alsBuffer_);
setDescription("Ambient light");
deviceType_ = (DeviceType)Config::configuration()->value("als/driver_type", "0").toInt();
deviceType_ = (DeviceType)Config::configuration()->value<int>("als/driver_type", DeviceUnknown);
powerStatePath_ = Config::configuration()->value("als/powerstate_path").toByteArray();

#ifdef SENSORFW_MCE_WATCHER
dbusIfc = new QDBusInterface(MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF,
QDBusConnection::systemBus(), this);
Expand Down Expand Up @@ -93,16 +95,14 @@ void ALSAdaptor::stopSensor()
SysfsAdaptor::stopSensor();
}


bool ALSAdaptor::startAdaptor()
{
if (deviceType_ == RM696 || deviceType_ == RM680)
{
#ifdef SENSORFW_MCE_WATCHER
dbusIfc -> call(QDBus::NoBlock, "req_als_enable");
dbusIfc->call(QDBus::NoBlock, "req_als_enable");
#endif
}

return SysfsAdaptor::startAdaptor();
}

Expand All @@ -111,14 +111,12 @@ void ALSAdaptor::stopAdaptor()
if (deviceType_ == RM696 || deviceType_ == RM680)
{
#ifdef SENSORFW_MCE_WATCHER
dbusIfc -> call(QDBus::NoBlock, "req_als_disable");
dbusIfc->call(QDBus::NoBlock, "req_als_disable");
#endif
}
SysfsAdaptor::stopAdaptor();
}



void ALSAdaptor::processSample(int pathId, int fd)
{
Q_UNUSED(pathId);
Expand Down
10 changes: 4 additions & 6 deletions adaptors/alsadaptor/alsadaptor.h
Expand Up @@ -9,6 +9,7 @@
@author Ustun Ergenoglu <ext-ustun.ergenoglu@nokia.com>
@author Lihan Guo <lihan.guo@digia.com>
@author Antti Virtanen <antti.i.virtanen@nokia.com>
@author Shenghua <ext-shenghua.1.liu@nokia.com>
This file is part of Sensord.
Expand Down Expand Up @@ -40,7 +41,6 @@
#include <mce/dbus-names.h>
#endif


/**
* @brief Adaptor for internal ambient light sensor.
*
Expand Down Expand Up @@ -72,15 +72,16 @@ class ALSAdaptor : public SysfsAdaptor
{
return new ALSAdaptor(id);
}

/**
* Start measuring loop. Opens file descriptors and set streaming mode
*/
bool startAdaptor();
virtual bool startAdaptor();

/**
* Stop measuring loop. Closes file descriptors and removes streaming mode
*/
void stopAdaptor();
virtual void stopAdaptor();

virtual bool startSensor();

Expand All @@ -94,8 +95,6 @@ class ALSAdaptor : public SysfsAdaptor
ALSAdaptor(const QString& id);
~ALSAdaptor();



private:

/**
Expand All @@ -114,7 +113,6 @@ class ALSAdaptor : public SysfsAdaptor
#ifdef SENSORFW_MCE_WATCHER
QDBusInterface *dbusIfc;
#endif

};

#endif
3 changes: 1 addition & 2 deletions adaptors/kbslideradaptor/kbslideradaptor.cpp
Expand Up @@ -7,6 +7,7 @@
@author Timo Rongas <ext-timo.2.rongas@nokia.com>
@author Ustun Ergenoglu <ext-ustun.ergenoglu@nokia.com>
@author Shenghua <ext-shenghua.1.liu@nokia.com>
This file is part of Sensord.
Expand All @@ -24,7 +25,6 @@
</p>
*/

#include <QtDebug>
#include <errno.h>
#include <fcntl.h>
#include <linux/input.h>
Expand Down Expand Up @@ -88,7 +88,6 @@ void KeyboardSliderAdaptor::interpretSync(int src, struct input_event *ev)

void KeyboardSliderAdaptor::commitOutput()
{

sensordLogD() << "KB Slider state change detected: " << currentState_;

KeyboardSliderState *state = kbstateBuffer_->nextSlot();
Expand Down
2 changes: 0 additions & 2 deletions adaptors/kbslideradaptor/kbslideradaptor.h
Expand Up @@ -36,8 +36,6 @@
* Events are received through @e gpio-keys input layer.
*
* Listening clients are notified whenever the state has changed.
*
* @todo Move definition of \e KeyboardSliderState to filters/kbsliderstate.
*/
class KeyboardSliderAdaptor : public InputDevAdaptor
{
Expand Down
Expand Up @@ -51,7 +51,7 @@ MagnetometerAdaptorAscii::~MagnetometerAdaptorAscii()
delete magnetBuffer_;
}

void MagnetometerAdaptorAscii::processSample(int pathId, int fd)
void MagnetometerAdaptorAscii::processSample(int, int fd)
{
unsigned short x, y, z;

Expand Down
Expand Up @@ -33,9 +33,9 @@ MagnetometerAdaptorNCDK::MagnetometerAdaptorNCDK(const QString& id) :
SysfsAdaptor(id, SysfsAdaptor::IntervalMode),
powerState_(false)
{
intervalCompensation_ = Config::configuration()->value("magnetometer/interval_compensation", "0").toInt();
powerStateFilePath_ = Config::configuration()->value("magnetometer/path_power_state", "").toByteArray();
sensAdjFilePath_ = Config::configuration()->value("magnetometer/path_sens_adjust", "").toByteArray();
intervalCompensation_ = Config::configuration()->value<int>("magnetometer/interval_compensation", 0);
powerStateFilePath_ = Config::configuration()->value<QByteArray>("magnetometer/path_power_state", "");
sensAdjFilePath_ = Config::configuration()->value<QByteArray>("magnetometer/path_sens_adjust", "");
magnetometerBuffer_ = new DeviceAdaptorRingBuffer<TimedXyzData>(128);
setAdaptedSensor("magnetometer", "Internal magnetometer coordinates", magnetometerBuffer_);
setDescription("Magnetometer adaptor (ak8975) for NCDK");
Expand Down
4 changes: 2 additions & 2 deletions adaptors/magnetometeradaptor/magnetometeradaptor.cpp
Expand Up @@ -44,7 +44,7 @@ struct ak8974_data {
MagnetometerAdaptor::MagnetometerAdaptor(const QString& id) :
SysfsAdaptor(id, SysfsAdaptor::IntervalMode, false)
{
intervalCompensation_ = Config::configuration()->value("magnetometer/interval_compensation", "0").toInt();
intervalCompensation_ = Config::configuration()->value<int>("magnetometer/interval_compensation", 0);
magnetometerBuffer_ = new DeviceAdaptorRingBuffer<TimedXyzData>(1);
setAdaptedSensor("magnetometer", "Internal magnetometer coordinates", magnetometerBuffer_);
setDescription("Input device Magnetometer adaptor (ak897x)");
Expand Down Expand Up @@ -73,7 +73,7 @@ void MagnetometerAdaptor::processSample(int pathId, int fd)
sensordLogD() << "Invalid sample received from magnetometer";
}

sensordLogT() << "Magnetometer Reading: " << mag_data.x << ", " << mag_data.y << ", " << mag_data.z;
sensordLogT() << "Magnetometer reading: " << mag_data.x << ", " << mag_data.y << ", " << mag_data.z;

TimedXyzData* sample = magnetometerBuffer_->nextSlot();

Expand Down
3 changes: 1 addition & 2 deletions adaptors/mrstaccelerometer/mrstaccelerometeradaptor.cpp
Expand Up @@ -26,7 +26,6 @@
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>

#include "config.h"
#include "mrstaccelerometeradaptor.h"
#include "logging.h"
Expand All @@ -44,7 +43,7 @@ MRSTAccelAdaptor::~MRSTAccelAdaptor () {
delete buffer;
}

void MRSTAccelAdaptor::processSample (int pathId, int fd) {
void MRSTAccelAdaptor::processSample (int, int fd) {
char buf[32];
int x, y, z;

Expand Down
3 changes: 0 additions & 3 deletions adaptors/mrstaccelerometer/mrstaccelerometeradaptor.h
Expand Up @@ -26,9 +26,6 @@
#define MRSTACCELEROMETERADPTOR_H

#include "sysfsadaptor.h"
#include <QString>
#include <QStringList>
#include <linux/input.h>
#include "deviceadaptorringbuffer.h"

#include "datatypes/orientationdata.h"
Expand Down
11 changes: 6 additions & 5 deletions adaptors/proximityadaptor-ascii/proximityadaptor-ascii.cpp
Expand Up @@ -13,6 +13,7 @@
@author Tapio Rantala <ext-tapio.rantala@nokia.com>
@author Antti Virtanen <antti.i.virtanen@nokia.com>
@author Lihan Guo <ext-lihan.4.guo@nokia.com>
@author Antti Virtanen <antti.i.virtanen@nokia.com>
This file is part of Sensord.
Expand Down Expand Up @@ -40,8 +41,7 @@
ProximityAdaptorAscii::ProximityAdaptorAscii(const QString& id) :
SysfsAdaptor(id, SysfsAdaptor::IntervalMode)
{
memset(buf, 0x0, 16);
proximityBuffer_ = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
proximityBuffer_ = new DeviceAdaptorRingBuffer<ProximityData>(1);
setAdaptedSensor("proximity", "apds9802ps ascii", proximityBuffer_);
}

Expand All @@ -50,18 +50,19 @@ ProximityAdaptorAscii::~ProximityAdaptorAscii()
delete proximityBuffer_;
}

void ProximityAdaptorAscii::processSample(int pathId, int fd)
void ProximityAdaptorAscii::processSample(int, int fd)
{
char buf[16];
lseek(fd, 0, SEEK_SET);
if (read(fd, buf, sizeof(buf)) <= 0) {
sensordLogW() << "read(): " << strerror(errno);
return;
}
sensordLogT() << "Proximity output value: " << buf;

TimedUnsigned* proximity = proximityBuffer_->nextSlot();
ProximityData* proximity = proximityBuffer_->nextSlot();
sscanf(buf, "%d", &proximity->value_);

proximity->withinProximity_ = proximity->value_;
proximity->timestamp_ = Utils::getTimeStamp();
proximityBuffer_->commit();
proximityBuffer_->wakeUpReaders();
Expand Down
5 changes: 2 additions & 3 deletions adaptors/proximityadaptor-ascii/proximityadaptor-ascii.h
Expand Up @@ -34,7 +34,7 @@

#include "sysfsadaptor.h"
#include "deviceadaptorringbuffer.h"
#include "datatypes/timedunsigned.h"
#include "datatypes/orientationdata.h"

class ProximityAdaptorAscii : public SysfsAdaptor
{
Expand All @@ -51,9 +51,8 @@ class ProximityAdaptorAscii : public SysfsAdaptor

private:
void processSample(int pathId, int fd);
char buf[16];

DeviceAdaptorRingBuffer<TimedUnsigned>* proximityBuffer_;
DeviceAdaptorRingBuffer<ProximityData>* proximityBuffer_;
};

#endif
6 changes: 3 additions & 3 deletions adaptors/proximityadaptor-evdev/proximityadaptor-evdev.cpp
Expand Up @@ -43,7 +43,7 @@ ProximityAdaptorEvdev::ProximityAdaptorEvdev(const QString& id) :
InputDevAdaptor(id, 1),
currentState_(ProximityStateUnknown)
{
proximityBuffer_ = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
proximityBuffer_ = new DeviceAdaptorRingBuffer<ProximityData>(1);
setAdaptedSensor("proximity", "Proximity state", proximityBuffer_);
}

Expand Down Expand Up @@ -94,10 +94,10 @@ void ProximityAdaptorEvdev::commitOutput(struct input_event *ev)
if (currentState_ != oldState) {
sensordLogD() << "Proximity state change detected: " << currentState_;

TimedUnsigned *proximityData = proximityBuffer_->nextSlot();
ProximityData *proximityData = proximityBuffer_->nextSlot();

proximityData->timestamp_ = Utils::getTimeStamp(&(ev->time));
proximityData->value_ = currentState_;
proximityData->withinProximity_ = currentState_;

oldState = currentState_;

Expand Down

0 comments on commit 580ac94

Please sign in to comment.