merge with master
authorJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:12:08 +0000 (01:12 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Fri, 15 Mar 2013 16:12:08 +0000 (01:12 +0900)
CMakeLists.txt
packaging/capi-system-sensor.spec
test/CMakeLists.txt [new file with mode: 0755]
test/accelerometer-gravity-with-linear-acceleration.c [new file with mode: 0644]
test/gyroscope-calc-anger.c [new file with mode: 0644]
test/rotation.c [new file with mode: 0644]
test/supported-sensor.c [new file with mode: 0644]
test/system-sensor.c [new file with mode: 0644]

index 2e1b0404ddb58a7c2495718dfa60861e4ba172d6..e65dd12c44dd7884575d5eb17cf6ecc8f220edcd 100644 (file)
@@ -29,7 +29,7 @@ ENDIF("${ARCH}" STREQUAL "arm")
 ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
 ADD_DEFINITIONS("-DTIZEN_DEBUG")
 
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
 
 aux_source_directory(src SOURCES)
 ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
@@ -43,7 +43,7 @@ SET_TARGET_PROPERTIES(${fw_name}
     CLEAN_DIRECT_OUTPUT 1
 )
 
-INSTALL(TARGETS ${fw_name} DESTINATION lib)
+INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR})
 INSTALL(
         DIRECTORY ${INC_DIR}/ DESTINATION include/system
         FILES_MATCHING
@@ -60,7 +60,7 @@ CONFIGURE_FILE(
     ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
     @ONLY
 )
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
 
 IF(UNIX)
 
index d513d22de3adf882a88680977702b9f20fb90e3e..5a08984c60b24b53c2f957be4b282f37d4d1f645 100644 (file)
@@ -1,23 +1,21 @@
 Name:       capi-system-sensor
 Summary:    A Sensor library in TIZEN C API
-Version: 0.1.17
-Release:    10
-Group:      TO_BE/FILLED_IN
+Version:    0.1.17
+Release:    1
+Group:      framework/system
 License:    Apache 2.0
 Source0:    %{name}-%{version}.tar.gz
 BuildRequires:  cmake
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(sensor)
 BuildRequires:  pkgconfig(capi-base-common)
-Requires(post): /sbin/ldconfig  
-Requires(postun): /sbin/ldconfig
 
 %description
 
 
 %package devel
 Summary:  A Sensor library in TIZEN C API (Development)
-Group:    TO_BE/FILLED_IN
+Group:    framework/system
 Requires: %{name} = %{version}-%{release}
 
 %description devel
@@ -30,7 +28,7 @@ Requires: %{name} = %{version}-%{release}
 
 %build
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
 
 
 make %{?jobs:-j%jobs}
@@ -56,4 +54,3 @@ cp LICENSE %{buildroot}/usr/share/license/%{name}
 %{_libdir}/pkgconfig/*.pc
 %{_libdir}/libcapi-system-sensor.so
 /usr/share/license/%{name}
-
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..1f8cbcd
--- /dev/null
@@ -0,0 +1,54 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(fw_name "capi-system-sensor")
+SET(fw_test "${fw_name}-test")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_test} REQUIRED glib-2.0)
+FOREACH(flag ${${fw_test}_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall")
+INCLUDE_DIRECTORIES(../include)
+
+#ADD_EXECUTABLE("system-sensor" system-sensor.c)
+#TARGET_LINK_LIBRARIES("system-sensor" ${fw_name} ${${fw_test}_LDFLAGS})
+
+aux_source_directory(. sources)
+FOREACH(src ${sources})
+    GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
+    MESSAGE("${src_name}")
+    ADD_EXECUTABLE(${src_name} ${src})
+    TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS} ${fw_name} -lm)
+ENDFOREACH()
+
+IF(UNIX)
+
+ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
+ADD_CUSTOM_COMMAND(
+        DEPENDS clean 
+        COMMENT "distribution clean"
+        COMMAND find
+        ARGS    . 
+        -not -name config.cmake -and \(
+        -name tester.c -or
+        -name Testing -or
+        -name CMakeFiles -or
+        -name cmake.depends -or
+        -name cmake.check_depends -or
+        -name CMakeCache.txt -or
+        -name cmake.check_cache -or
+        -name *.cmake -or
+        -name Makefile -or
+        -name core -or
+        -name core.* -or
+        -name gmon.out -or
+        -name install_manifest.txt -or
+        -name *.pc -or
+        -name *~ \)
+        | grep -v TC | xargs rm -rf
+        TARGET  distclean
+        VERBATIM
+)
+
+ENDIF(UNIX)
diff --git a/test/accelerometer-gravity-with-linear-acceleration.c b/test/accelerometer-gravity-with-linear-acceleration.c
new file mode 100644 (file)
index 0000000..d3ec69c
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * 
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * PROPRIETARY/CONFIDENTIAL
+ * 
+ * This software is the confidential and proprietary information of SAMSUNG 
+ * ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
+ * this software is owned by Samsung and you shall not disclose such 
+ * Confidential Information and shall use it only in accordance with the terms 
+ * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG 
+ * make no representations or warranties about the suitability of the software, 
+ * either express or implied, including but not limited to the implied 
+ * warranties of merchantability, fitness for a particular purpose, or 
+ * non-infringement. SAMSUNG shall not be liable for any damages suffered by 
+ * licensee arising out of or related to this software.
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <sensors.h>
+
+static GMainLoop *mainloop;
+
+const float Alpha = 0.8;
+
+struct three_axis_s{
+    float x,y,z;
+};
+
+struct three_axis_s gravitys = {0,0,0};
+struct three_axis_s linear_accelation = {0,0,0};
+
+static void test_accelerometer_cb(sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
+{
+    gravitys.x = Alpha * gravitys.x + ( 1 - Alpha ) * x;
+    gravitys.y = Alpha * gravitys.y + ( 1 - Alpha ) * y;
+    gravitys.z = Alpha * gravitys.z + ( 1 - Alpha ) * z;
+
+    linear_accelation.x = x - gravitys.x;
+    linear_accelation.y = y - gravitys.y;
+    linear_accelation.z = z - gravitys.z;
+
+       printf("[gravitys x=%f y=%f z=%f] [linear acc x=%f y=%f z=%f]\n", 
+            gravitys.x, gravitys.y, gravitys.z, 
+            linear_accelation.x, linear_accelation.y, linear_accelation.z);
+}
+
+static void sig_quit(int signo)
+{
+       if(mainloop)
+       {
+               g_main_loop_quit(mainloop);
+       }
+}
+
+int main(int argc, char *argv[])
+{
+       int type = SENSOR_ACCELEROMETER;
+       sensor_h handle;
+    bool is_supported;
+       
+       float max = 0, min = 0, res = 0;
+
+       if(sensor_is_supported(type, &is_supported) != SENSOR_ERROR_NONE){
+               printf("unknown error\n");
+               return 0;
+       }
+    if(!is_supported){
+               printf("unsupported sensor\n");
+               return 0;
+    }
+
+       signal(SIGINT, sig_quit);
+       signal(SIGTERM, sig_quit);
+       signal(SIGQUIT, sig_quit);
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+       if(sensor_get_spec(type, &max, &min, &res) == SENSOR_ERROR_NONE){
+               printf("max=%f, min=%f, res=%f\n", max, min, res);
+    }else{
+        printf("Error!!!!\n");
+    }
+
+       sensor_create(&handle);
+
+    sensor_accelerometer_set_cb(handle, 0, test_accelerometer_cb, NULL);
+
+       if(sensor_start(handle, type) == SENSOR_ERROR_NONE)
+               printf("Success start \n");
+
+       g_main_loop_run(mainloop);
+       g_main_loop_unref(mainloop);
+
+    sensor_accelerometer_unset_cb(handle);
+
+       if(sensor_stop(handle, type) == SENSOR_ERROR_NONE)
+               printf("Success stop \n");
+
+       sensor_destroy(handle);
+       return 0;
+}
diff --git a/test/gyroscope-calc-anger.c b/test/gyroscope-calc-anger.c
new file mode 100644 (file)
index 0000000..9dfa9b7
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * 
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * PROPRIETARY/CONFIDENTIAL
+ * 
+ * This software is the confidential and proprietary information of SAMSUNG 
+ * ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
+ * this software is owned by Samsung and you shall not disclose such 
+ * Confidential Information and shall use it only in accordance with the terms 
+ * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG 
+ * make no representations or warranties about the suitability of the software, 
+ * either express or implied, including but not limited to the implied 
+ * warranties of merchantability, fitness for a particular purpose, or 
+ * non-infringement. SAMSUNG shall not be liable for any damages suffered by 
+ * licensee arising out of or related to this software.
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <sensors.h>
+#include <time.h>
+
+struct xyz_axis {
+    float x,y,z;
+};
+
+static struct xyz_axis angles = {0,0,0};
+static time_t timestamp = 0;
+
+static GMainLoop *mainloop;
+
+static void test_gyroscope_cb(sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
+{
+    time_t current_timestamp = time(0);
+    if(timestamp != 0){
+        const float dT = difftime(current_timestamp, timestamp);
+        angles.x += x * dT;
+        angles.y += y * dT;
+        angles.z += z * dT;
+        printf("angle x=%f y=%f z=%f\n", angles.x, angles.y, angles.z);
+    }
+    timestamp = current_timestamp;
+}
+
+static void sig_quit(int signo)
+{
+       if(mainloop)
+       {
+               g_main_loop_quit(mainloop);
+       }
+}
+
+int main(int argc, char *argv[])
+{
+       int type = SENSOR_GYROSCOPE;
+       sensor_h handle;
+    bool is_supported;
+       
+       float max = 0, min = 0, res = 0;
+
+       if(sensor_is_supported(type, &is_supported) != SENSOR_ERROR_NONE){
+               printf("unknown error\n");
+               return 0;
+       }
+    if(!is_supported){
+               printf("unsupported sensor\n");
+               return 0;
+    }
+
+       signal(SIGINT, sig_quit);
+       signal(SIGTERM, sig_quit);
+       signal(SIGQUIT, sig_quit);
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+       if(sensor_get_spec(type, &max, &min, &res) == SENSOR_ERROR_NONE){
+               printf("max=%f, min=%f, res=%f\n", max, min, res);
+    }else{
+        printf("Error!!!!\n");
+    }
+
+       sensor_create(&handle);
+
+    sensor_gyroscope_set_cb(handle, 0, test_gyroscope_cb, NULL);
+
+       if(sensor_start(handle, type) == SENSOR_ERROR_NONE)
+               printf("Success start \n");
+
+       g_main_loop_run(mainloop);
+       g_main_loop_unref(mainloop);
+
+    sensor_gyroscope_unset_cb(handle);
+
+       if(sensor_stop(handle, type) == SENSOR_ERROR_NONE)
+               printf("Success stop \n");
+
+       sensor_destroy(handle);
+       return 0;
+}
diff --git a/test/rotation.c b/test/rotation.c
new file mode 100644 (file)
index 0000000..2d40b49
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * 
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * PROPRIETARY/CONFIDENTIAL
+ * 
+ * This software is the confidential and proprietary information of SAMSUNG 
+ * ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
+ * this software is owned by Samsung and you shall not disclose such 
+ * Confidential Information and shall use it only in accordance with the terms 
+ * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG 
+ * make no representations or warranties about the suitability of the software, 
+ * either express or implied, including but not limited to the implied 
+ * warranties of merchantability, fitness for a particular purpose, or 
+ * non-infringement. SAMSUNG shall not be liable for any damages suffered by 
+ * licensee arising out of or related to this software.
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <sensors.h>
+#include <math.h>
+
+#define RADIAN_VALUE (57.2957)
+#define PITCH_MIN       35
+#define PITCH_MAX       145
+
+
+static GMainLoop *mainloop;
+
+const float Alpha = 0.8;
+
+struct three_axis_s{
+    float x,y,z;
+};
+
+struct three_axis_s gravitys = {0,0,0};
+struct three_axis_s linear_accelation = {0,0,0};
+
+enum {
+    ROTATE_0,
+    ROTATE_90,
+    ROTATE_180,
+    ROTATE_270,
+    ROTATE_ERROR
+};
+
+static int current_rotate = -1;
+
+static void test_accelerometer_cb(sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
+{
+    double atan_v, norm_z, raw_z;
+    int acc_theta, acc_pitch;
+    int rotate;
+
+    atan_v = atan2(y, x);
+    acc_theta = (int)(atan_v * (RADIAN_VALUE) + 270)%360;
+    raw_z = (double)(z/(0.004 * 9.81));
+
+    if(raw_z > 250){
+        norm_z = 1.0;
+    }else if(raw_z < -250){
+        norm_z = -1.0;
+    }else{
+        norm_z = ((double)raw_z)/250;
+    }
+
+    acc_pitch = (int)( acos(norm_z) *(RADIAN_VALUE));
+
+    if( (acc_pitch>35) && (acc_pitch<145) ) {
+        if ((acc_theta >= 315 && acc_theta <=359) || (acc_theta >=0 && acc_theta < 45)){
+            rotate = ROTATE_0;
+        }
+        else if(acc_theta >= 45 && acc_theta < 135){
+            rotate = ROTATE_90;
+        }
+        else if(acc_theta >=135 && acc_theta < 225){
+            rotate = ROTATE_180;
+        }
+        else if(acc_theta >=225 && acc_theta < 315){
+            rotate = ROTATE_270;
+        }
+        else {
+            rotate = ROTATE_ERROR;
+        }
+    }else{
+        rotate = ROTATE_ERROR;
+    }
+
+    if(rotate != ROTATE_ERROR && current_rotate != rotate){
+        current_rotate = rotate;
+        printf("rotation is %d\n", rotate * 90);
+    }
+}
+
+static void sig_quit(int signo)
+{
+       if(mainloop)
+       {
+               g_main_loop_quit(mainloop);
+       }
+}
+
+int main(int argc, char *argv[])
+{
+       int type = SENSOR_ACCELEROMETER;
+       sensor_h handle;
+    bool is_supported;
+       
+       float max = 0, min = 0, res = 0;
+
+       if(sensor_is_supported(type, &is_supported) != SENSOR_ERROR_NONE){
+               printf("unknown error\n");
+               return 0;
+       }
+    if(!is_supported){
+               printf("unsupported sensor\n");
+               return 0;
+    }
+
+       signal(SIGINT, sig_quit);
+       signal(SIGTERM, sig_quit);
+       signal(SIGQUIT, sig_quit);
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+       if(sensor_get_spec(type, &max, &min, &res) == SENSOR_ERROR_NONE){
+               printf("max=%f, min=%f, res=%f\n", max, min, res);
+    }else{
+        printf("Error!!!!\n");
+    }
+
+       sensor_create(&handle);
+
+    sensor_accelerometer_set_cb(handle, 0, test_accelerometer_cb, NULL);
+
+       if(sensor_start(handle, type) == SENSOR_ERROR_NONE)
+               printf("Success start \n");
+
+       g_main_loop_run(mainloop);
+       g_main_loop_unref(mainloop);
+
+    sensor_accelerometer_unset_cb(handle);
+
+       if(sensor_stop(handle, type) == SENSOR_ERROR_NONE)
+               printf("Success stop \n");
+
+       sensor_destroy(handle);
+       return 0;
+}
diff --git a/test/supported-sensor.c b/test/supported-sensor.c
new file mode 100644 (file)
index 0000000..739dadc
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * 
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * PROPRIETARY/CONFIDENTIAL
+ * 
+ * This software is the confidential and proprietary information of SAMSUNG 
+ * ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
+ * this software is owned by Samsung and you shall not disclose such 
+ * Confidential Information and shall use it only in accordance with the terms 
+ * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG 
+ * make no representations or warranties about the suitability of the software, 
+ * either express or implied, including but not limited to the implied 
+ * warranties of merchantability, fitness for a particular purpose, or 
+ * non-infringement. SAMSUNG shall not be liable for any damages suffered by 
+ * licensee arising out of or related to this software.
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sensors.h>
+
+static char* TYPE_NAME[] = {
+       "ACCELEROMETER",
+       "MAGNETIC",
+       "ORIENTATION",
+       "GYROSCOPE",
+       "LIGHT",
+       "PROXIMITY",
+       "MOTION_SNAP",
+       "MOTION_SHAKE",
+       "MOTION_DOUBLETAP",
+       "MOTION_PANNING",
+       "MOTION_FACEDOWN"
+};
+
+int main(int argc, char *argv[])
+{
+       int err;
+    sensor_type_e type;
+    bool is_supported;
+    char* supported_msg;
+       
+    for(type=0; type<=SENSOR_MOTION_FACEDOWN; type++){
+        err = sensor_is_supported(type, &is_supported);
+
+        supported_msg = err < 0 ? "error" : (is_supported ? "support" : "not support");
+
+        printf("%d : %s [%s]\n", type, TYPE_NAME[type], supported_msg);
+    }
+    return 0;
+
+}
diff --git a/test/system-sensor.c b/test/system-sensor.c
new file mode 100644 (file)
index 0000000..5a29ed7
--- /dev/null
@@ -0,0 +1,270 @@
+/*
+ * 
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * PROPRIETARY/CONFIDENTIAL
+ * 
+ * This software is the confidential and proprietary information of SAMSUNG 
+ * ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
+ * this software is owned by Samsung and you shall not disclose such 
+ * Confidential Information and shall use it only in accordance with the terms 
+ * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG 
+ * make no representations or warranties about the suitability of the software, 
+ * either express or implied, including but not limited to the implied 
+ * warranties of merchantability, fitness for a particular purpose, or 
+ * non-infringement. SAMSUNG shall not be liable for any damages suffered by 
+ * licensee arising out of or related to this software.
+ * 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <sensors.h>
+
+static GMainLoop *mainloop;
+
+static char* TYPE_NAME[] = {
+       "ACCELEROMETER",
+       "MAGNETIC",
+       "ORIENTATION",
+       "GYROSCOPE",
+       "LIGHT",
+       "PROXIMITY",
+       "MOTION_SNAP",
+       "MOTION_SHAKE",
+       "MOTION_DOUBLETAP",
+       "MOTION_PANNING",
+       "MOTION_FACEDOWN"
+};
+
+static char* SNAP[] = {
+       "NONE",
+    "LEFT",
+    "RIGHT"
+};
+
+static char* SHAKE[] = {
+       "NONE",
+       "DETECTION",
+       "CONTINUING",
+       "FINISH",
+       "BREAK"
+};
+
+static void test_calibration_cb(void *user_data)
+{
+    char* xx = (char*)user_data;
+       printf("%s sensor is calibration needed!!!!!!!!!!!!!!!!!!\n", xx);
+}
+
+static void test_accelerometer_cb(sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
+{
+       printf("ACCELEROMETER sensor acc=%d x=%f y=%f z=%f\n", accuracy, x, y, z);
+}
+
+static void test_magnetic_cb(sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
+{
+       printf("MAGNETIC sensor acc=%d x=%f y=%f z=%f\n", accuracy, x, y, z);
+}
+
+static void test_orientation_cb(sensor_data_accuracy_e accuracy, float azimuth, float pitch, float roll, void *user_data)
+{
+       printf("ORIENTATION sensor acc=%d azimuth=%f pitch=%f roll=%f\n", accuracy, azimuth, pitch, roll);
+}
+
+static void test_gyroscope_cb(sensor_data_accuracy_e accuracy, float x, float y, float z, void *user_data)
+{
+       printf("GYROSCOPE sensor acc=%d x=%f y=%f z=%f\n", accuracy, x, y, z);
+}
+
+static void test_light_cb(sensor_data_accuracy_e accuracy, float lux, void *user_data)
+{
+       printf("LIGHT sensor acc=%d lux=%f\n", accuracy, lux);
+}
+
+static void test_proximity_cb(sensor_data_accuracy_e accuracy, float distance, void *user_data)
+{
+       printf("PROXIMITY sensor distance = %fcm\n", distance);
+}
+
+static void test_motion_snap_cb        (sensor_motion_snap_e snap, void *user_data)
+{
+       printf("MOTION_SNAP [%s]\n", SNAP[snap]);
+}
+
+static void test_motion_shake_cb       (sensor_motion_shake_e shake, void *user_data)
+{
+       printf("MOTION_SHAKE [%s]\n", SHAKE[shake]);
+}
+
+static void test_motion_doubletap_cb   (void *user_data)
+{
+       printf("MOTION_DOUBLETAP \n");
+}
+
+static void test_motion_panning_cb (int x, int y, void *user_data)
+{
+       printf("MOTION_PANNING x=[%5d] y=[%5d]\n", x, y);
+}
+
+static void test_motion_facedown_cb (void *user_data)
+{
+       printf("MOTION_FACEDOWN \n");
+}
+
+static void sig_quit(int signo)
+{
+       if(mainloop)
+       {
+               g_main_loop_quit(mainloop);
+       }
+}
+
+int main(int argc, char *argv[])
+{
+       int i;
+       int type;
+       sensor_h handle;
+    bool is_supported;
+       
+       float max = 0, min = 0, res = 0;
+
+       if(argc < 2)
+       {
+               printf("input sensor type\n");
+               for(i=0; i<=SENSOR_MOTION_FACEDOWN; i++){
+                       printf("%d : %s\n", i, TYPE_NAME[i]);
+               }
+               return 0;
+       }
+
+       type = atoi(argv[1]);
+    /*
+       if(sensor_is_supported(type, &is_supported) != SENSOR_ERROR_NONE){
+               printf("unknown error\n");
+               return 0;
+       }
+    if(!is_supported){
+               printf("unsupported sensor\n");
+               return 0;
+    }
+    */
+
+    if(type < 0 || type > SENSOR_MOTION_FACEDOWN)
+               printf("unknown sensor!\n");
+    else
+               printf("selected sensor is (%d)%s\n", type, TYPE_NAME[type]);
+
+       signal(SIGINT, sig_quit);
+       signal(SIGTERM, sig_quit);
+       signal(SIGQUIT, sig_quit);
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+
+    if(type < SENSOR_MOTION_SNAP){
+        if(sensor_get_spec(type, &max, &min, &res) == SENSOR_ERROR_NONE){
+            printf("max=%f, min=%f, res=%f\n", max, min, res);
+        }else{
+            printf("Error!!!!\n");
+        }
+    }
+
+       sensor_create(&handle);
+
+       switch(type){
+               case SENSOR_ACCELEROMETER:
+                       sensor_accelerometer_set_cb(handle, 0, test_accelerometer_cb, TYPE_NAME[type]);
+                       break;
+               case SENSOR_MAGNETIC:
+                       sensor_magnetic_set_cb(handle, 0, test_magnetic_cb, TYPE_NAME[type]);
+                       sensor_magnetic_set_calibration_cb(handle, test_calibration_cb, TYPE_NAME[type]);
+                       break;
+               case SENSOR_ORIENTATION:
+                       sensor_orientation_set_cb(handle, 0, test_orientation_cb, TYPE_NAME[type]);
+                       sensor_orientation_set_calibration_cb(handle, test_calibration_cb, TYPE_NAME[type]);
+                       break;
+               case SENSOR_GYROSCOPE:
+                       sensor_gyroscope_set_cb(handle, 0, test_gyroscope_cb, TYPE_NAME[type]);
+                       break;
+               case SENSOR_LIGHT:
+                       sensor_light_set_cb(handle, 0, test_light_cb, TYPE_NAME[type]);
+                       break;
+               case SENSOR_PROXIMITY:
+                       sensor_proximity_set_cb(handle, 0, test_proximity_cb, TYPE_NAME[type]);
+                       break;
+               case SENSOR_MOTION_SNAP:
+                       sensor_motion_snap_set_cb(handle, test_motion_snap_cb, TYPE_NAME[type]);
+                       break;
+               case SENSOR_MOTION_SHAKE:
+                       sensor_motion_shake_set_cb(handle, test_motion_shake_cb, TYPE_NAME[type]);
+                       break;
+               case SENSOR_MOTION_DOUBLETAP:
+                       sensor_motion_doubletap_set_cb(handle, test_motion_doubletap_cb, TYPE_NAME[type]);
+                       break;
+               case SENSOR_MOTION_PANNING:
+            sensor_motion_panning_set_cb(handle, test_motion_panning_cb, TYPE_NAME[type]);
+                       break;
+               case SENSOR_MOTION_FACEDOWN:
+            sensor_motion_facedown_set_cb(handle, test_motion_facedown_cb, TYPE_NAME[type]);
+                       break;
+               default:
+                       goto _ending;
+       }
+
+    printf("Success register callback \n");
+
+       if(sensor_start(handle, type) == SENSOR_ERROR_NONE)
+               printf("Success start \n");
+
+       g_main_loop_run(mainloop);
+       g_main_loop_unref(mainloop);
+
+       switch(type){
+               case SENSOR_ACCELEROMETER:
+            sensor_accelerometer_unset_cb(handle);
+                       break;
+               case SENSOR_MAGNETIC:
+            sensor_magnetic_unset_calibration_cb(handle);
+            sensor_magnetic_unset_cb(handle);
+                       break;
+               case SENSOR_ORIENTATION:
+                       sensor_orientation_unset_calibration_cb(handle);
+            sensor_orientation_unset_cb(handle);
+                       break;
+               case SENSOR_GYROSCOPE:
+            sensor_gyroscope_unset_cb(handle);
+                       break;
+               case SENSOR_LIGHT:
+            sensor_light_unset_cb(handle);
+                       break;
+               case SENSOR_PROXIMITY:
+            sensor_proximity_unset_cb(handle);
+                       break;
+               case SENSOR_MOTION_SNAP:
+            sensor_motion_snap_unset_cb(handle);
+                       break;
+               case SENSOR_MOTION_SHAKE:
+            sensor_motion_shake_unset_cb(handle);
+                       break;
+               case SENSOR_MOTION_DOUBLETAP:
+            sensor_motion_doubletap_unset_cb(handle);
+                       break;
+               case SENSOR_MOTION_PANNING:
+            sensor_motion_panning_unset_cb(handle);
+                       break;
+               case SENSOR_MOTION_FACEDOWN:
+            sensor_motion_facedown_unset_cb(handle);
+                       break;
+
+               default:
+                       goto _ending;
+       }
+
+       if(sensor_stop(handle, type) == SENSOR_ERROR_NONE)
+               printf("Success stop \n");
+
+_ending:
+       sensor_destroy(handle);
+       return 0;
+}