diff options
author | Helmut Schmidt <Helmut.3.Schmidt@continental-corporation.com> | 2015-03-31 15:54:28 +0200 |
---|---|---|
committer | Helmut Schmidt <Helmut.3.Schmidt@continental-corporation.com> | 2015-03-31 15:54:28 +0200 |
commit | 4965a98c7d921dde2b9db7fd1200dad3f4293df3 (patch) | |
tree | 1da33f07bd243112294528e2cf81c781d96e069c /sensors-service | |
parent | 10de3de6319c7224c2a19af78f103a4d69d318f9 (diff) | |
download | positioning-4965a98c7d921dde2b9db7fd1200dad3f4293df3.tar.gz |
GT-3165 update SensorsService version number to 3.0.1 + increase test coverage for acceleration.h
Diffstat (limited to 'sensors-service')
-rw-r--r-- | sensors-service/api/sns-init.h | 2 | ||||
-rw-r--r-- | sensors-service/src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | sensors-service/src/acceleration.c | 127 |
3 files changed, 129 insertions, 1 deletions
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 <stdint.h> #include <stdbool.h> 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 <marco.residori@xse.de> +* +* \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; +} + + + + |