4 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 #include <sensor_log.h>
23 #include <dbus_util.h>
24 #include <sensor_loader.h>
27 #define CAL_NODE_PATH "/sys/class/sensors/ssp_sensor/set_cal_data"
32 static void sig_term_handler(int signo, siginfo_t *info, void *data)
34 char proc_name[NAME_MAX];
36 get_proc_name(info->si_pid, proc_name);
38 _E("Received SIGNAL(%d) from %s(%d)\n", signo, proc_name, info->si_pid);
40 //server::get_instance().stop();
44 static void signal_init(void)
46 struct sigaction sig_act;
47 memset(&sig_act, 0, sizeof(struct sigaction));
49 sig_act.sa_handler = SIG_IGN;
50 sigaction(SIGCHLD, &sig_act, NULL);
51 sigaction(SIGPIPE, &sig_act, NULL);
53 sig_act.sa_handler = NULL;
54 sig_act.sa_sigaction = sig_term_handler;
55 sig_act.sa_flags = SA_SIGINFO;
56 sigaction(SIGTERM, &sig_act, NULL);
57 sigaction(SIGABRT, &sig_act, NULL);
58 sigaction(SIGINT, &sig_act, NULL);
61 static void set_cal_data(void)
63 FILE *fp = fopen(CAL_NODE_PATH, "w");
66 _I("Not support calibration_node");
70 fprintf(fp, "%d", SET_CAL);
75 _I("Succeeded to set calibration data");
80 static gboolean terminate(gpointer data)
82 std::vector<sensor_base *> sensors = sensor_loader::get_instance().get_sensors(ALL_SENSOR);
84 if (sensors.size() == 0) {
85 _I("Terminating sensord..");
86 server::get_instance().stop();
92 int main(int argc, char *argv[])
94 _I("Sensord started");
102 /* TODO: loading sequence has to be moved to server */
103 sensor_loader::get_instance().load();
104 g_timeout_add_seconds(TIMEOUT, terminate, NULL);
106 server::get_instance().run();
107 server::get_instance().stop();
111 _I("Sensord terminated");