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 SIGTERM(%d) from %s(%d)\n", signo, proc_name, info->si_pid);
40 server::get_instance().stop();
43 static void signal_init(void)
45 struct sigaction sig_act;
46 memset(&sig_act, 0, sizeof(struct sigaction));
48 sig_act.sa_handler = SIG_IGN;
49 sigaction(SIGCHLD, &sig_act, NULL);
50 sigaction(SIGPIPE, &sig_act, NULL);
52 sig_act.sa_handler = NULL;
53 sig_act.sa_sigaction = sig_term_handler;
54 sig_act.sa_flags = SA_SIGINFO;
55 sigaction(SIGTERM, &sig_act, NULL);
56 sigaction(SIGABRT, &sig_act, NULL);
57 sigaction(SIGINT, &sig_act, NULL);
60 static void set_cal_data(void)
62 FILE *fp = fopen(CAL_NODE_PATH, "w");
65 _I("Not support calibration_node");
69 fprintf(fp, "%d", SET_CAL);
74 _I("Succeeded to set calibration data");
79 static gboolean terminate(gpointer data)
81 std::vector<sensor_base *> sensors = sensor_loader::get_instance().get_sensors(ALL_SENSOR);
83 if (sensors.size() == 0) {
84 _I("Terminating sensord..");
85 server::get_instance().stop();
91 int main(int argc, char *argv[])
93 _I("Sensord started");
101 /* TODO: loading sequence has to be moved to server */
102 sensor_loader::get_instance().load();
103 g_timeout_add_seconds(TIMEOUT, terminate, NULL);
105 server::get_instance().run();
106 server::get_instance().stop();
110 _I("Sensord terminated");