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"
32 static sensor_manager *manager;
34 static void usage(void)
36 _N("usage: sensorctl <command> <sensor_type> [<args>]\n");
38 _N("The sensorctl commands are:\n");
39 _N(" test: test sensor(s)\n");
40 _N(" inject: inject the event to sensor\n");
41 _N(" info: show sensor infos\n");
44 static sensor_manager *create_manager(char *command)
46 sensor_manager *manager = NULL;
48 if (!strcmp(command, "test"))
49 manager = new(std::nothrow) tester_manager;
50 else if (!strcmp(command, "inject"))
51 manager = new(std::nothrow) injector_manager;
52 else if (!strcmp(command, "info"))
53 manager = new(std::nothrow) info_manager;
54 else if (!strcmp(command, "loopback"))
55 manager = new(std::nothrow) loopback_manager;
58 _E("failed to allocate memory for manager\n");
65 static void destroy_manager(sensor_manager *manager)
74 static void signal_handler(int signo)
76 _E("\nReceived SIGNAL(%d)\n", signo);
81 int main(int argc, char *argv[])
83 signal(SIGINT, signal_handler);
84 signal(SIGHUP, signal_handler);
85 signal(SIGTERM, signal_handler);
86 signal(SIGQUIT, signal_handler);
87 signal(SIGABRT, signal_handler);
88 signal(SIGTSTP, signal_handler);
95 manager = create_manager(argv[1]);
101 manager->run(argc, argv);
103 destroy_manager(manager);