Common test folder and automated testing of sensor APIs - Feature merge from devel... 65/35565/6
authorVibhor Gaur <vibhor.gaur@samsung.com>
Mon, 16 Feb 2015 12:33:49 +0000 (18:03 +0530)
committerVibhor Gaur <vibhor.gaur@samsung.com>
Wed, 18 Feb 2015 06:38:01 +0000 (22:38 -0800)
-This is last of the four patches being submitted to merge the changes from devel/tizen to tizen branch. This contains the changes for making a common test folder for all sensors and an automatic test to test sensor APIs for sensors.
-This patch also tests all the four patches submitted for merging features from devel/tizen to tizen branch.

Change-Id: I2a101d14ea2ebbb92342232f89f4f17a3889c148

16 files changed:
packaging/sensord.spec
src/sensor_fusion/orientation_filter.cpp
test/CMakeLists.txt
test/src/accelerometer.c [deleted file]
test/src/auto_test.c [new file with mode: 0644]
test/src/geomagnetic.c [deleted file]
test/src/gravity.c [deleted file]
test/src/gyro.c [deleted file]
test/src/light.c [deleted file]
test/src/linear_acceleration.c [deleted file]
test/src/orientation.c [deleted file]
test/src/pressure.c [deleted file]
test/src/proxi.c [deleted file]
test/src/rotation_vector.c [deleted file]
test/src/tc-common.c [new file with mode: 0644]
test/src/temperature.c [deleted file]

index e6d3ed6..987cb43 100755 (executable)
@@ -136,17 +136,7 @@ systemctl daemon-reload
 %if %{build_test_suite} == "ON"
 %files -n sensor-test
 %defattr(-,root,root,-)
-%{_bindir}/accelerometer
-%{_bindir}/geomagnetic
-%{_bindir}/orientation
-%{_bindir}/gravity
-%{_bindir}/linear_acceleration
-%{_bindir}/gyro
-%{_bindir}/proxi
-%{_bindir}/pressure
-%{_bindir}/temperature
-%{_bindir}/light
-%{_bindir}/rotation_vector
-%{_bindir}/geomagnetic_rv
+%{_bindir}/auto_test
+%{_bindir}/tc-common
 %license LICENSE.APLv2
 %endif
index 470946d..2bf7865 100644 (file)
@@ -227,6 +227,15 @@ inline void orientation_filter<TYPE>::time_update()
 
        m_pred_cov = (m_tran_mat * m_pred_cov * tran(m_tran_mat)) + m_driv_cov;
 
+       for (int j=0; j<M6X6C; ++j) {
+               for (int i=0; i<M6X6R; ++i)     {
+                       if (ABS(m_pred_cov.m_mat[i][j]) < NEGLIGIBLE_VAL)
+                               m_pred_cov.m_mat[i][j] = NEGLIGIBLE_VAL;
+               }
+               if (ABS(m_state_new.m_vec[j]) < NEGLIGIBLE_VAL)
+                       m_state_new.m_vec[j] = NEGLIGIBLE_VAL;
+       }
+
        if(!is_initialized(m_quat_driv.m_quat))
                m_quat_driv = m_quat_aid;
 
@@ -339,24 +348,28 @@ template <typename TYPE>
 inline void orientation_filter<TYPE>::measurement_update()
 {
        matrix<TYPE, M6X6R, M6X6C> gain;
-       TYPE iden = 0;
+       matrix<TYPE, M6X6R, M6X6C> iden;
+       iden.m_mat[0][0] = iden.m_mat[1][1] = iden.m_mat[2][2] = 1;
+       iden.m_mat[3][3] = iden.m_mat[4][4] = iden.m_mat[5][5] = 1;
 
        for (int j=0; j<M6X6C; ++j) {
-               for (int i=0; i<M6X6R; ++i)     {
+               for (int i=0; i<M6X6R; ++i) {
                        gain.m_mat[i][j] = m_pred_cov.m_mat[j][i] / (m_pred_cov.m_mat[j][j] + m_aid_cov.m_mat[j][j]);
-
                        m_state_new.m_vec[i] = m_state_new.m_vec[i] + gain.m_mat[i][j] * m_state_error.m_vec[j];
+               }
 
-                       if (i == j)
-                               iden = 1;
-                       else
-                               iden = 0;
+               matrix<TYPE, M6X6R, M6X6C> temp = iden;
 
-                       m_pred_cov.m_mat[j][i] = (iden - (gain.m_mat[i][j] * m_measure_mat.m_mat[j][i])) *
-                                       m_pred_cov.m_mat[j][i];
+               for (int i=0; i<M6X6R; ++i)
+                       temp.m_mat[i][j] = iden.m_mat[i][j] - (gain.m_mat[i][j] * m_measure_mat.m_mat[j][i]);
 
-                       if (ABS(m_pred_cov.m_mat[j][i]) < NEGLIGIBLE_VAL)
-                               m_pred_cov.m_mat[j][i] = NEGLIGIBLE_VAL;
+               m_pred_cov = temp * m_pred_cov;
+       }
+
+       for (int j=0; j<M6X6C; ++j) {
+               for (int i=0; i<M6X6R; ++i) {
+                       if (ABS(m_pred_cov.m_mat[i][j]) < NEGLIGIBLE_VAL)
+                               m_pred_cov.m_mat[i][j] = NEGLIGIBLE_VAL;
                }
        }
 
index 5d65116..9329972 100644 (file)
@@ -25,55 +25,14 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 
 link_directories(../src/libsensord/)
 
-add_executable(accelerometer src/accelerometer.c)
-add_executable(geomagnetic src/geomagnetic.c)
-add_executable(orientation src/orientation.c)
-add_executable(gravity src/gravity.c)
-add_executable(linear_acceleration src/linear_acceleration.c)
-add_executable(gyro src/gyro.c)
-add_executable(proxi src/proxi.c)
-add_executable(pressure src/pressure.c)
-add_executable(temperature src/temperature.c)
-add_executable(light src/light.c)
-add_executable(rotation_vector src/rotation_vector.c)
-add_executable(geomagnetic_rv src/geomagnetic_rv.c)
+add_executable(auto_test src/auto_test.c)
+add_executable(tc-common src/tc-common.c)
 
-SET_TARGET_PROPERTIES(accelerometer PROPERTIES LINKER_LANGUAGE C)
-SET_TARGET_PROPERTIES(geomagnetic PROPERTIES LINKER_LANGUAGE C)
-SET_TARGET_PROPERTIES(orientation PROPERTIES LINKER_LANGUAGE C)
-SET_TARGET_PROPERTIES(gravity PROPERTIES LINKER_LANGUAGE C)
-SET_TARGET_PROPERTIES(linear_acceleration PROPERTIES LINKER_LANGUAGE C)
-SET_TARGET_PROPERTIES(gyro PROPERTIES LINKER_LANGUAGE C)
-SET_TARGET_PROPERTIES(proxi PROPERTIES LINKER_LANGUAGE C)
-SET_TARGET_PROPERTIES(pressure PROPERTIES LINKER_LANGUAGE C)
-SET_TARGET_PROPERTIES(temperature PROPERTIES LINKER_LANGUAGE C)
-SET_TARGET_PROPERTIES(light PROPERTIES LINKER_LANGUAGE C)
-SET_TARGET_PROPERTIES(rotation_vector PROPERTIES LINKER_LANGUAGE C)
-SET_TARGET_PROPERTIES(geomagnetic_rv PROPERTIES LINKER_LANGUAGE C)
+SET_TARGET_PROPERTIES(auto_test PROPERTIES LINKER_LANGUAGE C)
+SET_TARGET_PROPERTIES(tc-common PROPERTIES LINKER_LANGUAGE C)
 
-target_link_libraries(accelerometer glib-2.0 dlog sensor)
-target_link_libraries(geomagnetic glib-2.0 dlog sensor)
-target_link_libraries(orientation glib-2.0 dlog sensor)
-target_link_libraries(gravity glib-2.0 dlog sensor)
-target_link_libraries(linear_acceleration glib-2.0 dlog sensor)
-target_link_libraries(gyro glib-2.0 dlog sensor)
-target_link_libraries(proxi glib-2.0 dlog sensor)
-target_link_libraries(pressure glib-2.0 dlog sensor)
-target_link_libraries(temperature glib-2.0 dlog sensor)
-target_link_libraries(light glib-2.0 dlog sensor)
-target_link_libraries(rotation_vector glib-2.0 dlog sensor)
-target_link_libraries(geomagnetic_rv glib-2.0 dlog sensor)
-
-INSTALL(TARGETS accelerometer DESTINATION /usr/bin/)
-INSTALL(TARGETS geomagnetic DESTINATION /usr/bin/)
-INSTALL(TARGETS orientation DESTINATION /usr/bin/)
-INSTALL(TARGETS gravity DESTINATION /usr/bin/)
-INSTALL(TARGETS linear_acceleration DESTINATION /usr/bin/)
-INSTALL(TARGETS gyro DESTINATION /usr/bin/)
-INSTALL(TARGETS proxi DESTINATION /usr/bin/)
-INSTALL(TARGETS pressure DESTINATION /usr/bin/)
-INSTALL(TARGETS temperature DESTINATION /usr/bin/)
-INSTALL(TARGETS light DESTINATION /usr/bin/)
-INSTALL(TARGETS rotation_vector DESTINATION /usr/bin/)
-INSTALL(TARGETS geomagnetic_rv DESTINATION /usr/bin/)
+target_link_libraries(auto_test glib-2.0 dlog sensor)
+target_link_libraries(tc-common glib-2.0 dlog sensor)
 
+INSTALL(TARGETS auto_test DESTINATION /usr/bin/)
+INSTALL(TARGETS tc-common DESTINATION /usr/bin/)
diff --git a/test/src/accelerometer.c b/test/src/accelerometer.c
deleted file mode 100644 (file)
index 9d8b667..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * sensord
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#include <time.h>
-#include <glib.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sensor_internal.h>
-#include <stdbool.h>
-#include <sensor_common.h>
-#include <unistd.h>
-#include <string.h>
-
-static GMainLoop *mainloop;
-
-void callback(unsigned int event_type, sensor_event_data_t *event, void *user_data)
-{
-       sensor_data_t *data = (sensor_data_t *)event->event_data;
-       printf("Accelerometer [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
-}
-
-void printformat()
-{
-       printf("Usage : ./accelerometer <mode>(optional) <event> <interval>(optional)\n\n");
-
-       printf("mode:");
-       printf("[-p]\n");
-       printf("p is for polling based,default mode is event driven\n");
-
-       printf("event:");
-       printf("[RAW_DATA_REPORT_ON_TIME]\n");
-
-       printf("interval:\n");
-       printf("The time interval should be entered based on the sampling frequency supported by accelerometer driver on the device in ms.If no value for sensor is entered default value by the driver will be used.\n");
-}
-
-int main(int argc,char **argv)
-{
-       int result, handle, start_handle, stop_handle;
-       unsigned int event;
-       mainloop = g_main_loop_new(NULL, FALSE);
-       event = ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME;
-       event_condition_t *event_condition = (event_condition_t*) malloc(sizeof(event_condition_t));
-       event_condition->cond_op = CONDITION_EQUAL;
-
-       sensor_type_t type = ACCELEROMETER_SENSOR;
-
-       if (argc != 2 && argc != 3 && argc!=4) {
-               printformat();
-               free(event_condition);
-               return 0;
-       }
-
-       else if (argc>=3 && strcmp(argv[1], "-p") == 0 && strcmp(argv[2], "RAW_DATA_REPORT_ON_TIME") == 0) {
-               printf("Polling based\n");
-               handle = sf_connect(type);
-               result = sf_start(handle, 1);
-
-               if (result < 0) {
-                       printf("Can't start accelerometer SENSOR\n");
-                       printf("Error\n\n\n\n");
-                       free(event_condition);
-                       return -1;
-               }
-
-               sensor_data_t data;
-
-               while(1) {
-                       result = sf_get_data(handle, ACCELEROMETER_BASE_DATA_SET , &data);
-                       printf("Accelerometer [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data.timestamp, data.values[0], data.values[1], data.values[2]);
-                       usleep(100000);
-               }
-
-               result = sf_disconnect(handle);
-
-               if (result < 0) {
-                       printf("Can't disconnect Accelerometer sensor\n");
-                       printf("Error\n\n\n\n");
-                       free(event_condition);
-                       return -1;
-               }
-       }
-
-       else if (strcmp(argv[1], "RAW_DATA_REPORT_ON_TIME") == 0) {
-               printf("Event based\n");
-
-               event_condition->cond_value1 = 100;
-               if (argc == 3)
-                       event_condition->cond_value1 = atof(argv[2]);
-
-               handle = sf_connect(type);
-               result = sf_register_event(handle, event, event_condition, callback, NULL);
-
-               if (result < 0)
-                       printf("Can't register accelerometer\n");
-
-               start_handle = sf_start(handle,0);
-
-               if (start_handle < 0) {
-                       printf("Error\n\n\n\n");
-                       sf_unregister_event(handle, event);
-                       sf_disconnect(handle);
-                       free(event_condition);
-                       return -1;
-               }
-
-               g_main_loop_run(mainloop);
-               g_main_loop_unref(mainloop);
-
-               sf_unregister_event(handle, event);
-
-               stop_handle = sf_stop(handle);
-
-               if (stop_handle < 0) {
-                       printf("Error\n\n");
-                       return -1;
-                       free(event_condition);
-               }
-
-               sf_disconnect(handle);
-               free(event_condition);
-       }
-
-       else {
-               printformat();
-       }
-
-       return 0;
-}
-
diff --git a/test/src/auto_test.c b/test/src/auto_test.c
new file mode 100644 (file)
index 0000000..e897f74
--- /dev/null
@@ -0,0 +1,235 @@
+/*
+ * sensord
+ *
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <time.h>
+#include <glib.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <sensor_internal.h>
+#include <sensor_common.h>
+#include <stdbool.h>
+#include <sensor_common.h>
+#include <unistd.h>
+
+#define DEFAULT_EVENT_INTERVAL 100
+
+static GMainLoop *mainloop;
+FILE *fp;
+
+void callback(unsigned int event_type, sensor_event_data_t *event, void *user_data)
+{
+       g_main_loop_quit(mainloop);
+}
+
+bool check_sensor_api(unsigned int event_type, int cond_value)
+{
+       int result, handle;
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+       sensor_type_t sensor_type = event_type >> 16;
+       sensor_t sensor = sensord_get_sensor(sensor_type);
+
+       handle = sensord_connect(sensor);
+
+       if (handle < 0) {
+               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_connect\n", sensor_type, event_type);
+               return false;
+       }
+
+       bool is_supported;
+       bool result_boolean = sensord_is_supported_event_type(sensor, event_type, &is_supported);
+       if (!result_boolean && !is_supported) {
+               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_is_supported_event\n", sensor_type, event_type);
+               return false;
+       }
+
+       int output;
+       result_boolean = sensord_get_min_interval(sensor, &output);
+       if (!result_boolean) {
+               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_min_interval\n", sensor_type, event_type);
+               return false;
+       }
+
+       float output3;
+       result_boolean = sensord_get_resolution(sensor, &output3);
+       if (!result_boolean) {
+               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_resolution\n", sensor_type, event_type);
+               return false;
+       }
+
+       result_boolean = sensord_get_max_range(sensor, &output3);
+       if (!result_boolean) {
+               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_max_range\n", sensor_type, event_type);
+               return false;
+       }
+
+       result_boolean = sensord_get_min_range(sensor, &output3);
+       if (!result_boolean) {
+               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_min_range\n", sensor_type, event_type);
+               return false;
+       }
+
+       sensor_privilege_t output4;
+       result_boolean = sensord_get_privilege(sensor, &output4);
+       if (!result_boolean) {
+               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_privilege\n", sensor_type, event_type);
+               return false;
+       }
+
+       const char* result_char = sensord_get_vendor(sensor);
+       if (!result_char) {
+               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_vendor\n", sensor_type, event_type);
+               return false;
+       }
+
+       result_char = sensord_get_name(sensor);
+       if (!result_char) {
+               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_name\n", sensor_type, event_type);
+               return false;
+       }
+
+       sensor_type_t output_type;
+       result_boolean = sensord_get_type(sensor, &output_type);
+       if (!result_boolean) {
+               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_type\n", sensor_type, event_type);
+               return false;
+       }
+
+       unsigned int *output2;
+       result_boolean = sensord_get_supported_event_types(sensor, &output2, &output);
+       if (!result_boolean) {
+               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_supported_event_types\n", sensor_type, event_type);
+               return false;
+       }
+
+       sensor_t *output_list;
+       result_boolean = sensord_get_sensor_list(sensor_type, &output_list, &output);
+       if (!result_boolean) {
+               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_sensor_list\n", sensor_type, event_type);
+               return false;
+       }
+
+       result = sensord_register_event(handle, event_type, cond_value, 0, callback, NULL);
+
+       if (result < 0) {
+               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_register_event\n", sensor_type, event_type);
+               return false;
+       }
+
+       result_boolean = sensord_start(handle, 1);
+
+       if (!result_boolean) {
+               sensord_unregister_event(handle, event_type);
+               sensord_disconnect(handle);
+               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_start\n", sensor_type, event_type);
+               return false;
+       }
+
+       sensor_data_t data;
+       result_boolean = sensord_get_data(handle, event_type, &data);
+       if (!result_boolean) {
+               sensord_unregister_event(handle, event_type);
+               sensord_disconnect(handle);
+               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_get_data\n", sensor_type, event_type);
+               return false;
+       }
+
+       g_main_loop_run(mainloop);
+       g_main_loop_unref(mainloop);
+
+       result_boolean = sensord_change_event_interval(handle, event_type, 101);
+       if (!result_boolean) {
+               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_change_event_interval\n", sensor_type, event_type);
+               return false;
+       }
+
+       result_boolean = sensord_set_option(handle, SENSOR_OPTION_ON_IN_SCREEN_OFF);
+       if (!result_boolean){
+               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_change_sensor_option\n", sensor_type, event_type);
+               return false;
+       }
+
+       result_boolean = sensord_unregister_event(handle, event_type);
+
+       if (!result_boolean) {
+               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_unregister_event\n", sensor_type, event_type);
+               return false;
+       }
+
+       result_boolean = sensord_stop(handle);
+
+       if (!result_boolean) {
+               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_stop\n", sensor_type, event_type);
+               return false;
+       }
+
+       result_boolean = sensord_disconnect(handle);
+
+       if (!result_boolean) {
+               fprintf(fp, "Sensor - %d, event - %d, failed at sensord_disconnect\n", sensor_type, event_type);
+               return false;
+       }
+
+       return true;
+}
+
+int main(int argc, char **argv)
+{
+       bool result;
+
+       int interval = DEFAULT_EVENT_INTERVAL;
+       if (argc == 2)
+               interval = atof(argv[1]);
+
+       fp = fopen("auto_test.output", "w+");
+
+       result = check_sensor_api(ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME, interval);
+       fprintf(fp, "Accelerometer - RAW_DATA_REPORT_ON_TIME - %d\n", result);
+
+       result = check_sensor_api(GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME, interval);
+       fprintf(fp, "Geomagnetic - RAW_DATA_REPORT_ON_TIME - %d\n", result);
+
+       result = check_sensor_api(GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME, interval);
+       fprintf(fp, "Gravity - RAW_DATA_REPORT_ON_TIME - %d\n", result);
+
+       result = check_sensor_api(GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME, interval);
+       fprintf(fp, "Gyroscope - RAW_DATA_REPORT_ON_TIME - %d\n", result);
+
+       result = check_sensor_api(LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME, interval);
+       fprintf(fp, "Light - RAW_DATA_REPORT_ON_TIME - %d\n", result);
+
+       result = check_sensor_api(LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME, interval);
+       fprintf(fp, "Linear Accel - RAW_DATA_REPORT_ON_TIME - %d\n", result);
+
+       result = check_sensor_api(ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME, interval);
+       fprintf(fp, "Orientation - RAW_DATA_REPORT_ON_TIME - %d\n", result);
+
+       result = check_sensor_api(PRESSURE_EVENT_RAW_DATA_REPORT_ON_TIME, interval);
+       fprintf(fp, "Pressure - RAW_DATA_REPORT_ON_TIME - %d\n", result);
+
+       result = check_sensor_api(ROTATION_VECTOR_EVENT_RAW_DATA_REPORT_ON_TIME, interval);
+       fprintf(fp, "Rotation Vector - RAW_DATA_REPORT_ON_TIME - %d\n", result);
+
+       result = check_sensor_api(TEMPERATURE_EVENT_RAW_DATA_REPORT_ON_TIME, interval);
+       fprintf(fp, "Temperature - RAW_DATA_REPORT_ON_TIME - %d\n", result);
+
+       printf("Logs printed in ./auto_test.output\n");
+       fclose(fp);
+       return 0;
+}
diff --git a/test/src/geomagnetic.c b/test/src/geomagnetic.c
deleted file mode 100755 (executable)
index 1d72500..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * sensord
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#include <time.h>
-#include <glib.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sensor_internal.h>
-#include <stdbool.h>
-#include <sensor_common.h>
-#include <unistd.h>
-
-static GMainLoop *mainloop;
-
-void callback(unsigned int event_type, sensor_event_data_t *event, void *user_data)
-{
-       sensor_data_t *data = (sensor_data_t *)event->event_data;
-       printf("Geomagnetic [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
-}
-
-void printformat()
-{
-       printf("Usage : ./geomagnetic <mode>(optional) <event> <interval>(optional)\n\n");
-
-       printf("mode:");
-       printf("[-p]\n");
-       printf("p is for polling based,default mode is event driven\n");
-
-       printf("event:");
-       printf("[RAW_DATA_REPORT_ON_TIME]\n");
-
-       printf("interval:\n");
-       printf("The time interval should be entered based on the sampling frequency supported by geomagnetic driver on the device in ms.If no value for sensor is entered default value by the driver will be used.\n");
-}
-
-int main(int argc,char **argv)
-{
-       int result, handle, start_handle, stop_handle;
-       unsigned int event;
-       mainloop = g_main_loop_new(NULL, FALSE);
-       event = GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME;
-       event_condition_t *event_condition = (event_condition_t*) malloc(sizeof(event_condition_t));
-       event_condition->cond_op = CONDITION_EQUAL;
-
-       sensor_type_t type = GEOMAGNETIC_SENSOR;
-
-       if (argc != 2 && argc != 3 && argc!=4) {
-               printformat();
-               free(event_condition);
-               return 0;
-       }
-
-       else if (argc>=3 && strcmp(argv[1], "-p") == 0 && strcmp(argv[2], "RAW_DATA_REPORT_ON_TIME") == 0) {
-               printf("Polling based\n");
-               handle = sf_connect(type);
-               result = sf_start(handle, 1);
-
-               if (result < 0) {
-                       printf("Can't start geomagnetic SENSOR\n");
-                       printf("Error\n\n\n\n");
-                       return -1;
-               }
-
-               sensor_data_t data;
-
-               while(1) {
-                       result = sf_get_data(handle, GEOMAGNETIC_BASE_DATA_SET , &data);
-                       printf("Geomagnetic [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data.timestamp, data.values[0], data.values[1], data.values[2]);
-                       usleep(100000);
-               }
-
-               result = sf_disconnect(handle);
-
-               if (result < 0) {
-                       printf("Can't disconnect geomagnetic sensor\n");
-                       printf("Error\n\n\n\n");
-                       return -1;
-               }
-       }
-
-       else if (strcmp(argv[1], "RAW_DATA_REPORT_ON_TIME") == 0) {
-               printf("Event based\n");
-
-               event_condition->cond_value1 = 100;
-               if (argc == 3)
-                       event_condition->cond_value1 = atof(argv[2]);
-
-               handle = sf_connect(type);
-               result = sf_register_event(handle, event, event_condition, callback, NULL);
-
-               if (result < 0)
-                       printf("Can't register geomagnetic\n");
-
-               start_handle = sf_start(handle,0);
-
-               if (start_handle < 0) {
-                       printf("Error\n\n\n\n");
-                       sf_unregister_event(handle, event);
-                       sf_disconnect(handle);
-                       return -1;
-               }
-
-               g_main_loop_run(mainloop);
-               g_main_loop_unref(mainloop);
-
-               sf_unregister_event(handle, event);
-
-               stop_handle = sf_stop(handle);
-
-               if (stop_handle < 0) {
-                       printf("Error\n\n");
-                       return -1;
-               }
-
-               sf_disconnect(handle);
-               free(event_condition);
-       }
-
-       else {
-               printformat();
-       }
-
-       return 0;
-}
-
diff --git a/test/src/gravity.c b/test/src/gravity.c
deleted file mode 100755 (executable)
index d3cba2d..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * sensord
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <time.h>
-#include <glib.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sensor_internal.h>
-#include <stdbool.h>
-#include <string.h>
-
-static GMainLoop *mainloop;
-
-void callback(unsigned int event_type, sensor_event_data_t *event, void *user_data)
-{
-       sensor_data_t *data = (sensor_data_t *)event->event_data;
-       printf("Gravity [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
-}
-
-void printformat()
-{
-       printf("Usage : ./gravity <event> <interval>(optional)\n\n");
-       printf("event:\n");
-       printf("RAW_DATA_REPORT_ON_TIME\n\n");
-       printf("interval:\n");
-       printf("The time interval should be entered based on the sampling "
-                       "frequencies supported by accelerometer, gyroscope and "
-                       "geomagnetic sensors driver on the device in ms. If no value "
-                       "for gravity sensor is entered, a default value will be used.\n");
-}
-
-int main(int argc,char **argv)
-{
-       int result, handle, start_handle, stop_handle;
-       unsigned int event;
-
-       mainloop = g_main_loop_new(NULL, FALSE);
-       sensor_type_t type = GRAVITY_SENSOR;
-       event_condition_t *event_condition = (event_condition_t*) malloc(sizeof(event_condition_t));
-       event_condition->cond_op = CONDITION_EQUAL;
-       event_condition->cond_value1 = 100;
-
-       if (argc != 2 && argc != 3) {
-               printformat();
-               free(event_condition);
-               return 0;
-       }
-       else {
-               if (strcmp(argv[1], "RAW_DATA_REPORT_ON_TIME") == 0)
-                       event = GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME;
-               else {
-                       printformat();
-                       free(event_condition);
-                       return 0;
-               }
-
-               if (argc == 3)
-                       event_condition->cond_value1 = atof(argv[2]);
-       }
-
-       handle = sf_connect(type);
-       result = sf_register_event(handle, event, event_condition, callback, NULL);
-
-       if (result < 0)
-               printf("Can't register gravity virtual sensor\n");
-
-       start_handle = sf_start(handle, 0);
-
-       if (start_handle < 0) {
-               printf("Error\n\n\n\n");
-               sf_unregister_event(handle, event);
-               sf_disconnect(handle);
-               free(event_condition);
-               return -1;
-       }
-
-       g_main_loop_run(mainloop);
-       g_main_loop_unref(mainloop);
-
-       sf_unregister_event(handle, event);
-       stop_handle = sf_stop(handle);
-
-       if (stop_handle < 0) {
-               printf("Error\n\n");
-               free(event_condition);
-               return -1;
-       }
-
-       sf_disconnect(handle);
-       free(event_condition);
-
-       return 0;
-}
diff --git a/test/src/gyro.c b/test/src/gyro.c
deleted file mode 100644 (file)
index a3332f7..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * sensord
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#include <time.h>
-#include <glib.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sensor_internal.h>
-#include <stdbool.h>
-#include <sensor_common.h>
-#include <unistd.h>
-#include <string.h>
-
-static GMainLoop *mainloop;
-
-void callback(unsigned int event_type, sensor_event_data_t *event, void *user_data)
-{
-       sensor_data_t *data = (sensor_data_t *)event->event_data;
-       printf("Gyroscope [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
-}
-
-void printformat()
-{
-       printf("Usage : ./gyro <mode>(optional) <event> <interval>(optional)\n\n");
-
-       printf("mode:");
-       printf("[-p]\n");
-       printf("p is for polling based,default mode is event driven\n");
-
-       printf("event:");
-       printf("[RAW_DATA_REPORT_ON_TIME]\n");
-
-       printf("interval:\n");
-       printf("The time interval should be entered based on the sampling frequency supported by gyroscope driver on the device in ms.If no value for sensor is entered default value by the driver will be used.\n");
-}
-
-int main(int argc,char **argv)
-{
-       int result, handle, start_handle, stop_handle;
-       unsigned int event;
-       mainloop = g_main_loop_new(NULL, FALSE);
-       event = GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME;
-       event_condition_t *event_condition = (event_condition_t*) malloc(sizeof(event_condition_t));
-       event_condition->cond_op = CONDITION_EQUAL;
-
-       sensor_type_t type = GYROSCOPE_SENSOR;
-
-       if (argc != 2 && argc != 3 && argc!=4) {
-               printformat();
-               free(event_condition);
-               return 0;
-       }
-
-       else if (argc>=3 && strcmp(argv[1], "-p") == 0 && strcmp(argv[2], "RAW_DATA_REPORT_ON_TIME") == 0) {
-               printf("Polling based\n");
-
-               handle = sf_connect(type);
-               result = sf_start(handle, 1);
-
-               if (result < 0) {
-                       printf("Can't start gyroscope SENSOR\n");
-                       printf("Error\n\n\n\n");
-                       free(event_condition);
-                       return -1;
-               }
-
-               sensor_data_t data;
-
-               while(1) {
-                       result = sf_get_data(handle, GYRO_BASE_DATA_SET , &data);
-                       printf("Gyroscope [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data.timestamp, data.values[0], data.values[1], data.values[2]);
-                       usleep(100000);
-               }
-
-               result = sf_disconnect(handle);
-
-               if (result < 0) {
-                       printf("Can't disconnect gyroscope sensor\n");
-                       printf("Error\n\n\n\n");
-                       free(event_condition);
-                       return -1;
-               }
-       }
-
-       else if (strcmp(argv[1], "RAW_DATA_REPORT_ON_TIME") == 0) {
-               printf("Event based\n");
-
-               event_condition->cond_value1 = 10.52;
-               if (argc == 3)
-                       event_condition->cond_value1 = atof(argv[2]);
-
-               handle = sf_connect(type);
-               result = sf_register_event(handle, event, event_condition, callback, NULL);
-
-               if (result < 0)
-                       printf("Can't register gyroscope\n");
-
-               start_handle = sf_start(handle,0);
-
-               if (start_handle < 0) {
-                       printf("Error\n\n\n\n");
-                       sf_unregister_event(handle, event);
-                       sf_disconnect(handle);
-                       free(event_condition);
-                       return -1;
-               }
-
-               g_main_loop_run(mainloop);
-               g_main_loop_unref(mainloop);
-
-               sf_unregister_event(handle, event);
-
-               stop_handle = sf_stop(handle);
-
-               if (stop_handle < 0) {
-                       printf("Error\n\n");
-                       free(event_condition);
-                       return -1;
-               }
-
-               sf_disconnect(handle);
-               free(event_condition);
-       }
-
-       else {
-               printformat();
-       }
-
-       return 0;
-}
-
diff --git a/test/src/light.c b/test/src/light.c
deleted file mode 100644 (file)
index ba99732..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * sensord
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#include <time.h>
-#include <glib.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sensor_internal.h>
-#include <stdbool.h>
-#include <sensor_common.h>
-#include <unistd.h>
-#include <string.h>
-
-static GMainLoop *mainloop;
-
-void callback(unsigned int event_type, sensor_event_data_t *event, void *user_data)
-{
-       sensor_data_t *data = (sensor_data_t *)event->event_data;
-       printf("Light :[%lld] [%6.6f]\n", data->timestamp, data->values[0]);
-}
-
-void printformat()
-{
-       printf("Usage : ./light <mode>(optional) <event> <interval>(optional)\n\n");
-
-       printf("mode:");
-       printf("[-p]\n");
-       printf("p is for polling based,default mode is event driven\n");
-
-       printf("event:");
-       printf("[RAW_DATA_REPORT_ON_TIME]\n");
-
-       printf("interval:\n");
-       printf("The time interval should be entered based on the sampling frequency supported by light driver on the device in ms.If no value for sensor is entered default value by the driver will be used.\n");
-}
-
-int main(int argc,char **argv)
-{
-       int result, handle, start_handle, stop_handle;
-       unsigned int event;
-       mainloop = g_main_loop_new(NULL, FALSE);
-       event = LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME;
-       event_condition_t *event_condition = (event_condition_t*) malloc(sizeof(event_condition_t));
-       event_condition->cond_op = CONDITION_EQUAL;
-
-       sensor_type_t type = LIGHT_SENSOR;
-
-       if (argc != 2 && argc != 3 && argc!=4) {
-               printformat();
-               free(event_condition);
-               return 0;
-       }
-
-       else if (argc>=3 && strcmp(argv[1], "-p") == 0 && strcmp(argv[2], "RAW_DATA_REPORT_ON_TIME") == 0) {
-               printf("Polling based\n");
-
-               handle = sf_connect(type);
-               result = sf_start(handle, 1);
-
-               if (result < 0) {
-                       printf("Can't start light SENSOR\n");
-                       printf("Error\n\n\n\n");
-                       free(event_condition);
-                       return -1;
-               }
-
-               sensor_data_t data;
-
-               while(1) {
-                       result = sf_get_data(handle, LIGHT_LUX_DATA_SET , &data);
-                       printf("Light : [%6.6f]\n", data.values[0]);
-                       usleep(100000);
-               }
-
-               result = sf_disconnect(handle);
-               if (result < 0) {
-                       printf("Can't disconnect light sensor\n");
-                       printf("Error\n\n\n\n");
-                       free(event_condition);
-                       return -1;
-               }
-       }
-
-       else if (strcmp(argv[1], "RAW_DATA_REPORT_ON_TIME") == 0) {
-               printf("Event based\n");
-
-               event_condition->cond_value1 = 100;
-               if (argc == 3)
-                       event_condition->cond_value1 = atof(argv[2]);
-
-               handle = sf_connect(type);
-               result = sf_register_event(handle, event, event_condition, callback, NULL);
-
-               if (result < 0)
-                       printf("Can't register light\n");
-
-               start_handle = sf_start(handle,0);
-
-               if (start_handle < 0) {
-                       printf("Error\n\n\n\n");
-                       sf_unregister_event(handle, event);
-                       sf_disconnect(handle);
-                       free(event_condition);
-                       return -1;
-               }
-
-               g_main_loop_run(mainloop);
-               g_main_loop_unref(mainloop);
-
-               sf_unregister_event(handle, event);
-
-               stop_handle = sf_stop(handle);
-
-               if (stop_handle < 0) {
-                       printf("Error\n\n");
-                       free(event_condition);
-                       return -1;
-               }
-
-               sf_disconnect(handle);
-               free(event_condition);
-       }
-
-       else {
-               printformat();
-       }
-
-       return 0;
-}
-
diff --git a/test/src/linear_acceleration.c b/test/src/linear_acceleration.c
deleted file mode 100755 (executable)
index f992a68..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * sensord
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <time.h>
-#include <glib.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sensor_internal.h>
-#include <stdbool.h>
-#include <string.h>
-
-static GMainLoop *mainloop;
-
-void callback(unsigned int event_type, sensor_event_data_t *event, void *user_data)
-{
-       sensor_data_t *data = (sensor_data_t *)event->event_data;
-       printf("Linear Acceleration [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
-}
-
-void printformat()
-{
-       printf("Usage : ./linear_acceleration <event> <interval>(optional)\n\n");
-       printf("event:\n");
-       printf("RAW_DATA_REPORT_ON_TIME\n\n");
-       printf("interval:\n");
-       printf("The time interval should be entered based on the sampling "
-                       "frequencies supported by accelerometer, gyroscope and "
-                       "geomagnetic sensors driver on the device in ms. If no value "
-                       "for linear acceleration sensor is entered, a default value will be used.\n");
-}
-
-int main(int argc,char **argv)
-{
-       int result, handle, start_handle, stop_handle;
-       unsigned int event;
-
-       mainloop = g_main_loop_new(NULL, FALSE);
-       sensor_type_t type = LINEAR_ACCEL_SENSOR;
-       event_condition_t *event_condition = (event_condition_t*) malloc(sizeof(event_condition_t));
-       event_condition->cond_op = CONDITION_EQUAL;
-       event_condition->cond_value1 = 100;
-
-       if (argc != 2 && argc != 3) {
-               printformat();
-               free(event_condition);
-               return 0;
-       }
-       else {
-               if (strcmp(argv[1], "RAW_DATA_REPORT_ON_TIME") == 0)
-                       event = LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME;
-               else {
-                       printformat();
-                       free(event_condition);
-                       return 0;
-               }
-
-               if (argc == 3)
-                       event_condition->cond_value1 = atof(argv[2]);
-       }
-
-       handle = sf_connect(type);
-       result = sf_register_event(handle, event, event_condition, callback, NULL);
-
-       if (result < 0)
-               printf("Can't register linear acceleration virtual sensor\n");
-
-       start_handle = sf_start(handle, 0);
-
-       if (start_handle < 0) {
-               printf("Error\n\n\n\n");
-               sf_unregister_event(handle, event);
-               sf_disconnect(handle);
-               free(event_condition);
-               return -1;
-       }
-
-       g_main_loop_run(mainloop);
-       g_main_loop_unref(mainloop);
-
-       sf_unregister_event(handle, event);
-
-       stop_handle = sf_stop(handle);
-
-       if (stop_handle < 0) {
-               printf("Error\n\n");
-               free(event_condition);
-               return -1;
-       }
-
-       sf_disconnect(handle);
-
-       free(event_condition);
-
-       return 0;
-}
diff --git a/test/src/orientation.c b/test/src/orientation.c
deleted file mode 100755 (executable)
index 57bc82b..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * sensord
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <time.h>
-#include <glib.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sensor_internal.h>
-#include <stdbool.h>
-#include <string.h>
-
-static GMainLoop *mainloop;
-
-void callback(unsigned int event_type, sensor_event_data_t *event, void *user_data)
-{
-       sensor_data_t *data = (sensor_data_t *)event->event_data;
-       printf("Orientation [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
-}
-
-void printformat()
-{
-       printf("Usage : ./orientation <event> <interval>(optional)\n\n");
-       printf("event:\n");
-       printf("RAW_DATA_REPORT_ON_TIME\n\n");
-       printf("interval:\n");
-       printf("The time interval should be entered based on the sampling "
-                       "frequencies supported by accelerometer, gyroscope and "
-                       "geomagnetic sensors driver on the device in ms. If no value "
-                       "for orientation sensor is entered, a default value will be used.\n");
-}
-
-int main(int argc,char **argv)
-{
-       int result, handle, start_handle, stop_handle;
-       unsigned int event;
-
-       mainloop = g_main_loop_new(NULL, FALSE);
-       sensor_type_t type = ORIENTATION_SENSOR;
-       event_condition_t *event_condition = (event_condition_t*) malloc(sizeof(event_condition_t));
-       event_condition->cond_op = CONDITION_EQUAL;
-       event_condition->cond_value1 = 100;
-
-       if (argc != 2 && argc != 3) {
-               printformat();
-               free(event_condition);
-               return 0;
-       }
-       else {
-               if (strcmp(argv[1], "RAW_DATA_REPORT_ON_TIME") == 0)
-                       event = ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME;
-               else {
-                       printformat();
-                       free(event_condition);
-                       return 0;
-               }
-
-               if (argc == 3)
-                       event_condition->cond_value1 = atof(argv[2]);
-       }
-
-       handle = sf_connect(type);
-       result = sf_register_event(handle, event, event_condition, callback, NULL);
-
-       if (result < 0)
-               printf("Can't register orientation virtual sensor\n");
-
-       start_handle = sf_start(handle, 0);
-
-       if (start_handle < 0) {
-               printf("Error\n\n\n\n");
-               sf_unregister_event(handle, event);
-               sf_disconnect(handle);
-               free(event_condition);
-               return -1;
-       }
-
-       g_main_loop_run(mainloop);
-       g_main_loop_unref(mainloop);
-
-       sf_unregister_event(handle, event);
-       stop_handle = sf_stop(handle);
-
-       if (stop_handle < 0) {
-               printf("Error\n\n");
-               free(event_condition);
-               return -1;
-       }
-       sf_disconnect(handle);
-
-       free(event_condition);
-
-       return 0;
-}
diff --git a/test/src/pressure.c b/test/src/pressure.c
deleted file mode 100644 (file)
index 7621160..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * sensord
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#include <time.h>
-#include <glib.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sensor_internal.h>
-#include <stdbool.h>
-#include <sensor_common.h>
-#include <unistd.h>
-#include <string.h>
-
-static GMainLoop *mainloop;
-
-void callback(unsigned int event_type, sensor_event_data_t *event, void *user_data)
-{
-       sensor_data_t *data = (sensor_data_t *)event->event_data;
-       printf("Pressure [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
-}
-
-void printformat()
-{
-       printf("Usage : ./pressure <mode>(optional) <event> <interval>(optional)\n\n");
-
-       printf("mode:");
-       printf("[-p]\n");
-       printf("p is for polling based,default mode is event driven\n");
-
-       printf("event:");
-       printf("[RAW_DATA_REPORT_ON_TIME]\n");
-
-       printf("interval:\n");
-       printf("The time interval should be entered based on the sampling frequency supported by pressure driver on the device in ms.If no value for sensor is entered default value by the driver will be used.\n");
-}
-
-int main(int argc,char **argv)
-{
-       int result, handle, start_handle, stop_handle;
-       unsigned int event;
-       mainloop = g_main_loop_new(NULL, FALSE);
-       event = PRESSURE_EVENT_RAW_DATA_REPORT_ON_TIME;
-       event_condition_t *event_condition = (event_condition_t*) malloc(sizeof(event_condition_t));
-       event_condition->cond_op = CONDITION_EQUAL;
-
-       sensor_type_t type = PRESSURE_SENSOR;
-
-       if (argc != 2 && argc != 3 && argc!=4) {
-               printformat();
-               free(event_condition);
-               return 0;
-       }
-
-       else if (argc>=3 && strcmp(argv[1], "-p") == 0 && strcmp(argv[2], "RAW_DATA_REPORT_ON_TIME") == 0) {
-               printf("Polling based\n");
-
-               handle = sf_connect(type);
-               result = sf_start(handle, 1);
-
-               if (result < 0) {
-                       printf("Can't start pressure SENSOR\n");
-                       printf("Error\n\n\n\n");
-                       free(event_condition);
-                       return -1;
-               }
-
-               sensor_data_t data;
-
-               while(1) {
-                       result = sf_get_data(handle, PRESSURE_BASE_DATA_SET , &data);
-                       printf("Pressure [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data.timestamp, data.values[0], data.values[1], data.values[2]);
-                       usleep(100000);
-               }
-
-               result = sf_disconnect(handle);
-
-               if (result < 0) {
-                       printf("Can't disconnect pressure sensor\n");
-                       printf("Error\n\n\n\n");
-                       free(event_condition);
-                       return -1;
-               }
-       }
-
-       else if (strcmp(argv[1], "RAW_DATA_REPORT_ON_TIME") == 0) {
-               printf("Event based\n");
-
-               event_condition->cond_value1 = 10.52;
-               if (argc == 3)
-                       event_condition->cond_value1 = atof(argv[2]);
-
-               handle = sf_connect(type);
-               result = sf_register_event(handle, event, event_condition, callback, NULL);
-
-               if (result < 0)
-                       printf("Can't register pressure\n");
-
-               start_handle = sf_start(handle,0);
-
-               if (start_handle < 0) {
-                       printf("Error\n\n\n\n");
-                       sf_unregister_event(handle, event);
-                       sf_disconnect(handle);
-                       free(event_condition);
-                       return -1;
-               }
-
-               g_main_loop_run(mainloop);
-               g_main_loop_unref(mainloop);
-
-               sf_unregister_event(handle, event);
-
-               stop_handle = sf_stop(handle);
-
-               if (stop_handle < 0) {
-                       printf("Error\n\n");
-                       free(event_condition);
-                       return -1;
-               }
-
-               sf_disconnect(handle);
-               free(event_condition);
-       }
-
-       else {
-               printformat();
-       }
-
-       return 0;
-}
-
diff --git a/test/src/proxi.c b/test/src/proxi.c
deleted file mode 100644 (file)
index 23da057..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * sensord
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#include <time.h>
-#include <glib.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sensor_internal.h>
-#include <stdbool.h>
-#include <sensor_common.h>
-#include <unistd.h>
-#include <string.h>
-
-static GMainLoop *mainloop;
-
-void callback(unsigned int event_type, sensor_event_data_t *event, void *user_data)
-{
-       sensor_data_t *data = (sensor_data_t *)event->event_data;
-       printf("Proximity [%lld] [%6.6f]\n\n", data->timestamp, data->values[0]);
-}
-
-void printformat()
-{
-       printf("Usage : ./proxi <mode>(optional) <event> <interval>(optional)\n\n");
-
-       printf("mode:");
-       printf("[-p]\n");
-       printf("p is for polling based,default mode is event driven\n");
-
-       printf("event:");
-       printf("[EVENT_CHANGE_STATE] ");
-       printf("[EVENT_STATE_REPORT_ON_TIME] ");
-       printf("[EVENT_DISTANCE_DATA_REPORT_ON_TIME]\n");
-
-       printf("interval:\n");
-       printf("The time interval should be entered based on the sampling frequency supported by proximity driver on the device in ms.If no value for sensor is entered default value by the driver will be used.\n");
-}
-
-int main(int argc,char **argv)
-{
-       int result, handle, start_handle, stop_handle;
-       unsigned int event;
-       mainloop = g_main_loop_new(NULL, FALSE);
-       event_condition_t *event_condition = (event_condition_t*) malloc(sizeof(event_condition_t));
-       event_condition->cond_op = CONDITION_EQUAL;
-       sensor_type_t type = PROXIMITY_SENSOR;
-
-       if (argc != 2 && argc != 3 && argc!=4) {
-               printformat();
-               free(event_condition);
-               return 0;
-       }
-
-       else if (argc>=3 && strcmp(argv[1], "-p") == 0) {
-               printf("Polling based\n");
-
-               if (strcmp(argv[2], "EVENT_CHANGE_STATE") == 0) {
-                       event = PROXIMITY_BASE_DATA_SET;
-               }
-               else if (strcmp(argv[2], "EVENT_STATE_REPORT_ON_TIME") == 0) {
-                       event = PROXIMITY_DISTANCE_DATA_SET;
-               }
-               else if (strcmp(argv[2], "EVENT_DISTANCE_DATA_REPORT_ON_TIME") == 0) {
-                       event = PROXIMITY_EVENT_DISTANCE_DATA_REPORT_ON_TIME;
-               }
-               else {
-                       printformat();
-                       free(event_condition);
-                       return 0;
-               }
-
-               handle = sf_connect(type);
-               result = sf_start(handle, 1);
-
-               if (result < 0) {
-                       printf("Can't start proximity SENSOR\n");
-                       printf("Error\n\n\n\n");
-                       free(event_condition);
-                       return -1;
-               }
-
-               sensor_data_t data;
-
-               while(1) {
-                       result = sf_get_data(handle, event , &data);
-                       printf("Proximity [%6.6f]\n\n", data.values[0]);
-                       usleep(100000);
-               }
-
-               result = sf_disconnect(handle);
-
-               if (result < 0) {
-                       printf("Can't disconnect proximity sensor\n");
-                       printf("Error\n\n\n\n");
-                       free(event_condition);
-                       return -1;
-               }
-       }
-
-       else if (argc == 2 || argc ==3) {
-               printf("Event based\n");
-
-               if (strcmp(argv[1], "EVENT_CHANGE_STATE") == 0) {
-                       event = PROXIMITY_EVENT_CHANGE_STATE;
-               }
-               else if (strcmp(argv[1], "EVENT_STATE_REPORT_ON_TIME") == 0) {
-                       event = PROXIMITY_EVENT_STATE_REPORT_ON_TIME;
-               }
-               else if (strcmp(argv[1], "EVENT_DISTANCE_DATA_REPORT_ON_TIME") == 0) {
-                       event = PROXIMITY_EVENT_DISTANCE_DATA_REPORT_ON_TIME;
-               }
-               else {
-                       printformat();
-                       free(event_condition);
-                       return 0;
-               }
-
-               event_condition->cond_value1 = 100;
-               if (argc == 3)
-                       event_condition->cond_value1 = atof(argv[2]);
-
-               handle = sf_connect(type);
-               result = sf_register_event(handle, event, event_condition, callback, NULL);
-
-               if (result < 0)
-                       printf("Can't register proximity\n");
-
-               start_handle = sf_start(handle,0);
-
-               if (start_handle < 0) {
-                       printf("Error\n\n\n\n");
-                       sf_unregister_event(handle, event);
-                       sf_disconnect(handle);
-                       free(event_condition);
-                       return -1;
-               }
-
-               g_main_loop_run(mainloop);
-               g_main_loop_unref(mainloop);
-
-               sf_unregister_event(handle, event);
-
-               stop_handle = sf_stop(handle);
-
-               if (stop_handle < 0) {
-                       printf("Error\n\n");
-                       free(event_condition);
-                       return -1;
-               }
-
-               sf_disconnect(handle);
-               free(event_condition);
-       }
-
-       else {
-               printformat();
-       }
-
-       return 0;
-}
-
diff --git a/test/src/rotation_vector.c b/test/src/rotation_vector.c
deleted file mode 100644 (file)
index be9adef..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * sensord
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#include <time.h>
-#include <glib.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sensor_internal.h>
-#include <stdbool.h>
-#include <sensor_common.h>
-#include <unistd.h>
-#include <string.h>
-
-static GMainLoop *mainloop;
-
-void callback(unsigned int event_type, sensor_event_data_t *event, void *user_data)
-{
-       sensor_data_t *data = (sensor_data_t *)event->event_data;
-       printf("Rotation Vector [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0],
-                       data->values[1], data->values[2]);
-}
-
-void printformat()
-{
-       printf("Usage : ./rotation_vector <mode>(optional) <event> <interval>(optional)\n\n");
-
-       printf("mode:");
-       printf("[-p]\n");
-       printf("p is for polling based,default mode is event driven\n");
-
-       printf("event:");
-       printf("[RAW_DATA_REPORT_ON_TIME]\n");
-
-       printf("interval:\n");
-       printf("The time interval should be entered based on the sampling frequencies supported by "
-                       "accelerometer, gyroscope and geomagnetic sensors driver on the device in ms. If "
-                       "no value for rotation vector sensor is entered, a default value will be used.\n");
-}
-
-int main(int argc,char **argv)
-{
-       int result, handle, start_handle, stop_handle;
-       unsigned int event;
-       mainloop = g_main_loop_new(NULL, FALSE);
-       event = ROTATION_VECTOR_EVENT_RAW_DATA_REPORT_ON_TIME;
-       event_condition_t *event_condition = (event_condition_t*) malloc(sizeof(event_condition_t));
-       event_condition->cond_op = CONDITION_EQUAL;
-
-       sensor_type_t type = ROTATION_VECTOR_SENSOR;
-
-       if (argc != 2 && argc != 3 && argc!=4) {
-               printformat();
-               free(event_condition);
-               return 0;
-       }
-
-       else if (argc>=3 && strcmp(argv[1], "-p") == 0 && strcmp(argv[2], "RAW_DATA_REPORT_ON_TIME") == 0) {
-               printf("Polling based\n");
-               handle = sf_connect(type);
-               result = sf_start(handle, 1);
-
-               if (result < 0) {
-                       printf("Can't start Rotation Vector SENSOR\n");
-                       printf("Error\n\n\n\n");
-                       return -1;
-               }
-
-               sensor_data_t data;
-
-               while(1) {
-                       result = sf_get_data(handle, ACCELEROMETER_BASE_DATA_SET , &data);
-                       printf("Rotation Vector [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data.timestamp, data.values[0], data.values[1], data.values[2]);
-                       usleep(100000);
-               }
-
-               result = sf_disconnect(handle);
-
-               if (result < 0) {
-                       printf("Can't disconnect ROTATION VECTOR sensor\n");
-                       printf("Error\n\n\n\n");
-                       return -1;
-               }
-       }
-
-       else if (strcmp(argv[1], "RAW_DATA_REPORT_ON_TIME") == 0) {
-               printf("Event based\n");
-
-               event_condition->cond_value1 = 100;
-               if (argc == 3)
-                       event_condition->cond_value1 = atof(argv[2]);
-
-               handle = sf_connect(type);
-               result = sf_register_event(handle, event, event_condition, callback, NULL);
-
-               if (result < 0)
-                       printf("Can't register rotation vector event\n");
-
-               start_handle = sf_start(handle,0);
-
-               if (start_handle < 0) {
-                       printf("Error\n\n\n\n");
-                       sf_unregister_event(handle, event);
-                       sf_disconnect(handle);
-                       return -1;
-               }
-
-               g_main_loop_run(mainloop);
-               g_main_loop_unref(mainloop);
-
-               sf_unregister_event(handle, event);
-
-               stop_handle = sf_stop(handle);
-
-               if (stop_handle < 0) {
-                       printf("Error\n\n");
-                       return -1;
-               }
-
-               sf_disconnect(handle);
-               free(event_condition);
-       }
-
-       else {
-               printformat();
-       }
-
-       return 0;
-}
-
diff --git a/test/src/tc-common.c b/test/src/tc-common.c
new file mode 100644 (file)
index 0000000..81d83d9
--- /dev/null
@@ -0,0 +1,294 @@
+/*
+ * sensord
+ *
+ * Copyright (c) 2014-15 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+#include <time.h>
+#include <glib.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <sensor_internal.h>
+#include <stdbool.h>
+#include <sensor_common.h>
+#include <unistd.h>
+#include <string.h>
+
+#define DEFAULT_EVENT_INTERVAL 100
+
+static GMainLoop *mainloop;
+
+void usage()
+{
+       printf("Usage : ./tc-common <Sensor_type> <event>(optional) <interval>(optional)\n\n");
+
+       printf("Sensor_type: ");
+       printf("[accelerometer] ");
+       printf("[gyroscope] ");
+       printf("[pressure] ");
+       printf("[temperature] ");
+       printf("[geomagnetic] ");
+       printf("[orientation] ");
+       printf("[gravity] ");
+       printf("[linear_accel] ");
+       printf("[rotation_vector] ");
+       printf("[gaming_rotation_vector] ");
+       printf("[light]\n");
+       printf("event:");
+       printf("[RAW_DATA_REPORT_ON_TIME]\n");
+
+       printf("Sensor_type: ");
+       printf("[proximity]\n");
+       printf("event:");
+       printf("[EVENT_CHANGE_STATE]\n");
+
+       printf("interval:\n");
+       printf("The time interval should be entered based on the sampling frequency supported by accelerometer driver on the device in ms.If no value for sensor is entered default value by the driver will be used.\n");
+}
+
+unsigned int get_event_driven(sensor_type_t sensor_type, char str[])
+{
+       switch (sensor_type) {
+       case ACCELEROMETER_SENSOR:
+               if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0)
+                       return ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME;
+               break;
+       case GYROSCOPE_SENSOR:
+               if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0)
+                       return GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME;
+               break;
+       case PRESSURE_SENSOR:
+               if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0)
+                       return PRESSURE_EVENT_RAW_DATA_REPORT_ON_TIME;
+               break;
+       case GEOMAGNETIC_SENSOR:
+               if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0)
+                       return GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME;
+               break;
+       case LIGHT_SENSOR:
+               if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0)
+                       return LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME;
+               break;
+       case TEMPERATURE_SENSOR:
+               if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0)
+                       return TEMPERATURE_EVENT_RAW_DATA_REPORT_ON_TIME;
+               break;
+       case PROXIMITY_SENSOR:
+               if (strcmp(str, "EVENT_CHANGE_STATE") == 0)
+                       return PROXIMITY_EVENT_CHANGE_STATE;
+               break;
+       case ORIENTATION_SENSOR:
+               if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0)
+                       return ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME;
+               break;
+       case GRAVITY_SENSOR:
+               if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0)
+                       return GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME;
+               break;
+       case LINEAR_ACCEL_SENSOR:
+               if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0)
+                       return LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME;
+               break;
+       case ROTATION_VECTOR_SENSOR:
+               if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0)
+                       return ROTATION_VECTOR_EVENT_RAW_DATA_REPORT_ON_TIME;
+               break;
+       case GEOMAGNETIC_RV_SENSOR:
+               if (strcmp(str, "RAW_DATA_REPORT_ON_TIME") == 0)
+                       return GEOMAGNETIC_RV_EVENT_RAW_DATA_REPORT_ON_TIME;
+               break;
+       default:
+               return -1;
+       }
+}
+
+void callback(sensor_t sensor, unsigned int event_type, sensor_data_t *data, void *user_data)
+{
+       sensor_type_t sensor_type = event_type >> 16;
+
+       switch (sensor_type) {
+       case ACCELEROMETER_SENSOR:
+               printf("Accelerometer [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
+               break;
+       case GYROSCOPE_SENSOR:
+               printf("Gyroscope [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
+               break;
+       case PRESSURE_SENSOR:
+               printf("Pressure [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
+               break;
+       case GEOMAGNETIC_SENSOR:
+               printf("Geomagnetic [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
+               break;
+       case LIGHT_SENSOR:
+               printf("Light [%lld] [%6.6f]\n\n", data->timestamp, data->values[0]);
+               break;
+       case TEMPERATURE_SENSOR :
+               printf("Temperature [%lld] [%6.6f]\n\n", data->timestamp, data->values[0]);
+               break;
+       case PROXIMITY_SENSOR:
+               printf("Proximity [%lld] [%6.6f]\n\n", data->timestamp, data->values[0]);
+               break;
+       case ORIENTATION_SENSOR :
+               printf("Orientation [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
+               break;
+       case GRAVITY_SENSOR:
+               printf("Gravity [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
+               break;
+       case LINEAR_ACCEL_SENSOR:
+               printf("Linear acceleration [%lld] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2]);
+               break;
+       case ROTATION_VECTOR_SENSOR:
+               printf("Rotation vector [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2], data->values[3]);
+               break;
+       case GEOMAGNETIC_RV_SENSOR:
+               printf("Geomagnetic rotation vector [%lld] [%6.6f] [%6.6f] [%6.6f] [%6.6f]\n\n", data->timestamp, data->values[0], data->values[1], data->values[2], data->values[3]);
+               break;
+       default:
+               return;
+       }
+}
+
+int main(int argc, char **argv)
+{
+       int result, handle, start_handle, stop_handle, interval;
+       char *end1, *end2;
+       unsigned int event;
+       bool EVENT_NOT_ENTERED = TRUE;
+       sensor_type_t sensor_type;
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+       if (argc < 2 || argc > 4) {
+               printf("Wrong number of arguments\n");
+               usage();
+               return 0;
+       }
+
+       if (strcmp(argv[1], "accelerometer") == 0) {
+                sensor_type = ACCELEROMETER_SENSOR;
+                event = ACCELEROMETER_EVENT_RAW_DATA_REPORT_ON_TIME;
+       }
+       else if (strcmp(argv[1], "gyroscope") == 0) {
+                sensor_type = GYROSCOPE_SENSOR;
+                event = GYROSCOPE_EVENT_RAW_DATA_REPORT_ON_TIME;
+       }
+       else if (strcmp(argv[1], "pressure") == 0) {
+                sensor_type = PRESSURE_SENSOR;
+                event = PRESSURE_EVENT_RAW_DATA_REPORT_ON_TIME;
+       }
+       else if (strcmp(argv[1], "temperature") == 0) {
+                sensor_type = TEMPERATURE_SENSOR;
+                event = TEMPERATURE_EVENT_RAW_DATA_REPORT_ON_TIME;
+       }
+       else if (strcmp(argv[1], "geomagnetic") == 0) {
+                sensor_type = GEOMAGNETIC_SENSOR;
+                event = GEOMAGNETIC_EVENT_RAW_DATA_REPORT_ON_TIME;
+       }
+       else if (strcmp(argv[1], "orientation") == 0) {
+                sensor_type = ORIENTATION_SENSOR;
+                event = ORIENTATION_EVENT_RAW_DATA_REPORT_ON_TIME;
+       }
+       else if (strcmp(argv[1], "gravity") == 0) {
+                sensor_type = GRAVITY_SENSOR;
+                event = GRAVITY_EVENT_RAW_DATA_REPORT_ON_TIME;
+       }
+       else if (strcmp(argv[1], "linear_accel") == 0) {
+                sensor_type = LINEAR_ACCEL_SENSOR;
+                event = LINEAR_ACCEL_EVENT_RAW_DATA_REPORT_ON_TIME;
+       }
+       else if (strcmp(argv[1], "rotation_vector") == 0) {
+                sensor_type = ROTATION_VECTOR_SENSOR;
+                event = ROTATION_VECTOR_EVENT_RAW_DATA_REPORT_ON_TIME;
+       }
+       else if (strcmp(argv[1], "gaming_rotation_vector") == 0) {
+                sensor_type = GEOMAGNETIC_RV_SENSOR;
+                event = GEOMAGNETIC_RV_EVENT_RAW_DATA_REPORT_ON_TIME;
+       }
+       else if (strcmp(argv[1], "light") == 0) {
+                sensor_type = LIGHT_SENSOR;
+                event = LIGHT_EVENT_LUX_DATA_REPORT_ON_TIME;
+       }
+       else if (strcmp(argv[1], "proximity") == 0) {
+                sensor_type = PROXIMITY_SENSOR;
+                event = PROXIMITY_EVENT_CHANGE_STATE;
+       }
+       else {
+                usage();
+       }
+
+       interval = DEFAULT_EVENT_INTERVAL;
+
+       if (argc > 2) {
+               event = get_event_driven(sensor_type, argv[2]);
+
+               if (event == -1) {
+                       usage();
+                       return -1;
+               }
+
+               EVENT_NOT_ENTERED = FALSE;
+       }
+
+       if (argc == 4) {
+               interval = strtol(argv[3], &end1, 10);
+
+               if (*end1) {
+                       printf("Conversion error, non-convertible part: %s\n", end1);
+                       return -1;
+               }
+       }
+
+       if (argc == 3 && EVENT_NOT_ENTERED) {
+               interval = strtol(argv[2], &end2, 10);
+
+               if (*end2) {
+                       printf("Conversion error, non-convertible part: %s\n", end2);
+                       return -1;
+               }
+       }
+
+       sensor_t sensor = sensord_get_sensor(sensor_type);
+       handle = sensord_connect(sensor);
+
+       result = sensord_register_event(handle, event, interval, 0, callback, NULL);
+
+       if (result < 0) {
+               printf("Can't register %s\n", argv[1]);
+               return -1;
+       }
+
+       start_handle = sensord_start(handle, 0);
+
+       if (start_handle < 0) {
+               printf("Error\n\n\n\n");
+               sensord_unregister_event(handle, event);
+               sensord_disconnect(handle);
+               return -1;
+       }
+
+       g_main_loop_run(mainloop);
+       g_main_loop_unref(mainloop);
+
+       sensord_unregister_event(handle, event);
+       stop_handle = sensord_stop(handle);
+
+       if (stop_handle < 0) {
+               printf("Error\n\n");
+               return -1;
+       }
+
+       sensord_disconnect(handle);
+
+       return 0;
+}
diff --git a/test/src/temperature.c b/test/src/temperature.c
deleted file mode 100644 (file)
index 01e6e81..0000000
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * sensord
- *
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-#include <time.h>
-#include <glib.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sensor_internal.h>
-#include <stdbool.h>
-#include <sensor_common.h>
-#include <unistd.h>
-#include <string.h>
-
-static GMainLoop *mainloop;
-
-void callback(unsigned int event_type, sensor_event_data_t *event, void *user_data)
-{
-       sensor_data_t *data = (sensor_data_t *)event->event_data;
-       printf("Temperature [%lld] [%6.6f] \n\n", data->timestamp, data->values[0]);
-}
-
-void printformat()
-{
-       printf("Usage : ./temperature <mode>(optional) <event> <interval>(optional)\n\n");
-
-       printf("mode:");
-       printf("[-p]\n");
-       printf("p is for polling based,default mode is event driven\n");
-
-       printf("event:");
-       printf("[RAW_DATA_REPORT_ON_TIME]\n");
-
-       printf("interval:\n");
-       printf("The time interval should be entered based on the sampling frequency supported by temperature driver on the device in ms.If no value for sensor is entered default value by the driver will be used.\n");
-}
-
-int main(int argc,char **argv)
-{
-       int result, handle, start_handle, stop_handle;
-       unsigned int event;
-       mainloop = g_main_loop_new(NULL, FALSE);
-       event = TEMPERATURE_EVENT_RAW_DATA_REPORT_ON_TIME;
-       event_condition_t *event_condition = (event_condition_t*) malloc(sizeof(event_condition_t));
-       event_condition->cond_op = CONDITION_EQUAL;
-
-       sensor_type_t type = TEMPERATURE_SENSOR;
-
-       if (argc != 2 && argc != 3 && argc!=4) {
-               printformat();
-               free(event_condition);
-               return 0;
-       }
-
-       else if (argc>=3 && strcmp(argv[1], "-p") == 0 && strcmp(argv[2], "RAW_DATA_REPORT_ON_TIME") == 0) {
-               printf("Polling based\n");
-               handle = sf_connect(type);
-               result = sf_start(handle, 1);
-
-               if (result < 0) {
-                       printf("Can't start temperature SENSOR\n");
-                       printf("Error\n\n\n\n");
-                       free(event_condition);
-                       return -1;
-               }
-
-               sensor_data_t data;
-
-               while(1) {
-                       result = sf_get_data(handle, TEMPERATURE_BASE_DATA_SET , &data);
-                       printf("Temperature [%6.6f] \n\n", data.values[0]);
-                       usleep(100000);
-               }
-
-               result = sf_disconnect(handle);
-
-               if (result < 0) {
-                       printf("Can't disconnect temperature sensor\n");
-                       printf("Error\n\n\n\n");
-                       free(event_condition);
-                       return -1;
-               }
-       }
-
-       else if (strcmp(argv[1], "RAW_DATA_REPORT_ON_TIME") == 0) {
-               printf("Event based\n");
-
-               event_condition->cond_value1 = 100;
-               if (argc == 3)
-                       event_condition->cond_value1 = atof(argv[2]);
-
-               handle = sf_connect(type);
-               result = sf_register_event(handle, event, event_condition, callback, NULL);
-
-               if (result < 0)
-                       printf("Can't register temperature\n");
-
-               start_handle = sf_start(handle,0);
-
-               if (start_handle < 0) {
-                       printf("Error\n\n\n\n");
-                       sf_unregister_event(handle, event);
-                       sf_disconnect(handle);
-                       free(event_condition);
-                       return -1;
-               }
-
-               g_main_loop_run(mainloop);
-               g_main_loop_unref(mainloop);
-
-               sf_unregister_event(handle, event);
-
-               stop_handle = sf_stop(handle);
-
-               if (stop_handle < 0) {
-                       printf("Error\n\n");
-                       free(event_condition);
-                       return -1;
-               }
-
-               sf_disconnect(handle);
-               free(event_condition);
-       }
-
-       else {
-               printformat();
-       }
-
-       return 0;
-}
-