4 * Copyright (c) 2015 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.
26 #include "sensor_manager.h"
31 #include "sensor_adapter.h"
33 static sensor_manager *manager;
35 static void usage(void)
37 _N("usage: sensorctl <command> <sensor_type> [<args>]\n");
39 _N("The sensorctl commands are:\n");
40 _N(" test: test sensor(s)\n");
41 _N(" inject: inject the event to sensor\n");
42 _N(" info: show sensor infos\n");
45 static sensor_manager *create_manager(char *command)
47 sensor_manager *manager = NULL;
49 if (!strcmp(command, "test")) {
50 manager = new(std::nothrow) tester_manager;
51 } else if (!strcmp(command, "batch_mode_test")) {
52 sensor_adapter::is_batch_mode = true;
53 manager = new(std::nothrow) tester_manager;
54 } else if (!strcmp(command, "inject")) {
55 manager = new(std::nothrow) injector_manager;
56 } else if (!strcmp(command, "info")) {
57 manager = new(std::nothrow) info_manager;
58 } else if (!strcmp(command, "loopback")) {
59 manager = new(std::nothrow) loopback_manager;
63 _E("failed to allocate memory for manager\n");
70 static void destroy_manager(sensor_manager *manager)
79 static void signal_handler(int signo)
81 _E("\nReceived SIGNAL(%d)\n", signo);
86 int main(int argc, char *argv[])
88 signal(SIGINT, signal_handler);
89 signal(SIGHUP, signal_handler);
90 signal(SIGTERM, signal_handler);
91 signal(SIGQUIT, signal_handler);
92 signal(SIGABRT, signal_handler);
93 signal(SIGTSTP, signal_handler);
100 manager = create_manager(argv[1]);
106 manager->run(argc, argv);
108 destroy_manager(manager);