From 4965a98c7d921dde2b9db7fd1200dad3f4293df3 Mon Sep 17 00:00:00 2001 From: Helmut Schmidt Date: Tue, 31 Mar 2015 15:54:28 +0200 Subject: GT-3165 update SensorsService version number to 3.0.1 + increase test coverage for acceleration.h --- sensors-service/api/sns-init.h | 2 +- sensors-service/src/CMakeLists.txt | 1 + sensors-service/src/acceleration.c | 127 +++++++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 sensors-service/src/acceleration.c (limited to 'sensors-service') diff --git a/sensors-service/api/sns-init.h b/sensors-service/api/sns-init.h index f409166..6c6a753 100644 --- a/sensors-service/api/sns-init.h +++ b/sensors-service/api/sns-init.h @@ -14,7 +14,7 @@ // API Version #define GENIVI_SNS_API_MAJOR 3 #define GENIVI_SNS_API_MINOR 0 -#define GENIVI_SNS_API_MICRO 0 +#define GENIVI_SNS_API_MICRO 1 #include #include diff --git a/sensors-service/src/CMakeLists.txt b/sensors-service/src/CMakeLists.txt index f0b5ea6..1abb58d 100644 --- a/sensors-service/src/CMakeLists.txt +++ b/sensors-service/src/CMakeLists.txt @@ -59,6 +59,7 @@ elseif(WITH_REPLAYER) set(LIB_SRC_USE_REPLAYER ${CMAKE_SOURCE_DIR}/src/sns-use-replayer.c ${CMAKE_SOURCE_DIR}/src/wheeltick.c ${CMAKE_SOURCE_DIR}/src/gyroscope.c + ${CMAKE_SOURCE_DIR}/src/acceleration.c ${CMAKE_SOURCE_DIR}/src/vehicle-speed.c ${CMAKE_SOURCE_DIR}/src/sns-meta-data.c) diff --git a/sensors-service/src/acceleration.c b/sensors-service/src/acceleration.c new file mode 100644 index 0000000..2dec916 --- /dev/null +++ b/sensors-service/src/acceleration.c @@ -0,0 +1,127 @@ +/************************************************************************** +* @licence app begin@ +* +* SPDX-License-Identifier: MPL-2.0 +* +* \ingroup SensorsService +* \author Marco Residori +* +* \copyright Copyright (C) 2013, XS Embedded GmbH +* +* \license +* This Source Code Form is subject to the terms of the +* Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with +* this file, You can obtain one at http://mozilla.org/MPL/2.0/. +* +* @licence end@ +**************************************************************************/ + +#include "globals.h" +#include "acceleration.h" +#include "sns-meta-data.h" + +AccelerationCallback cbAcceleration = 0; +TAccelerationData gAccelerationData; +TAccelerationConfiguration gAccelerationConfiguration; + +bool snsAccelerationInit() +{ + cbAcceleration = 0; + + //example accelerometer configuration for a 3-axis accelerometer + gAccelerationConfiguration.dist2RefPointX = 0; + gAccelerationConfiguration.dist2RefPointY = 0; + gAccelerationConfiguration.dist2RefPointZ = 0; + gAccelerationConfiguration.angleYaw = 0; + gAccelerationConfiguration.anglePitch = 0; + gAccelerationConfiguration.angleRoll = 0; + gAccelerationConfiguration.sigmaX = 0; + gAccelerationConfiguration.sigmaY = 0; + gAccelerationConfiguration.sigmaZ = 0; + gAccelerationConfiguration.typeBits = + ACCELERATION_X_PROVIDED | + ACCELERATION_Y_PROVIDED | + ACCELERATION_Z_PROVIDED; + gAccelerationConfiguration.validityBits = + ACCELERATION_CONFIG_ANGLEYAW_VALID | + ACCELERATION_CONFIG_ANGLEPITCH_VALID | + ACCELERATION_CONFIG_ANGLEROLL_VALID | + ACCELERATION_CONFIG_TYPE_VALID; + + return true; +} + +bool snsAccelerationDestroy() +{ + cbAcceleration = 0; + + return true; +} + +bool snsAccelerationGetAccelerationData(TAccelerationData * accelerationData) +{ + if(!accelerationData) + { + return false; + } + + pthread_mutex_lock(&mutexData); + *accelerationData = gAccelerationData; + pthread_mutex_unlock(&mutexData); + + return true; +} + +bool snsAccelerationRegisterCallback(AccelerationCallback callback) +{ + //printf("snsAccelerationRegisterCallback\n"); + if(cbAcceleration != 0) + { + return false; + } + + pthread_mutex_lock(&mutexCb); + cbAcceleration = callback; + pthread_mutex_unlock(&mutexCb); + + return true; +} + +bool snsAccelerationDeregisterCallback(AccelerationCallback callback) +{ + //printf("snsAccelerationDeregisterCallback\n"); + if(cbAcceleration == callback && callback != 0) + { + pthread_mutex_lock(&mutexCb); + cbAcceleration = 0; + pthread_mutex_unlock(&mutexCb); + + return true; + } + + return false; +} + +bool snsAccelerationGetMetaData(TSensorMetaData *data) +{ + if(data != 0) + { + return false; + } + + pthread_mutex_lock(&mutexData); + *data = gSensorsMetaData[3]; + pthread_mutex_unlock(&mutexData); + + return true; +} + +bool snsAccelerationGetAccelerationConfiguration(TAccelerationConfiguration* config) +{ + *config = gAccelerationConfiguration; + return true; +} + + + + -- cgit v1.2.1