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.
25 #include <sensorctl_log.h>
26 #include "sensor_manager.h"
27 #include "tester_manager.h"
28 #include "injector_manager.h"
29 #include "info_manager.h"
31 static void good_bye(void)
35 static void signal_handler(int signo)
37 _E("\nReceived SIGNAL(%d)\n", signo);
45 PRINT("usage: sensorctl <command> <sensor_type> [<args>]\n");
47 PRINT("The sensorctl commands are:\n");
48 PRINT(" test: test sensor(s)\n");
49 PRINT(" inject: inject the event to sensor\n");
50 PRINT(" info: show sensor infos\n");
53 sensor_manager *create_manager(int argc, char *argv[2])
55 sensor_manager *manager = NULL;
57 if (!strcmp(argv[1], "test"))
58 manager = new(std::nothrow) tester_manager;
59 if (!strcmp(argv[1], "inject"))
60 manager = new(std::nothrow) injector_manager;
61 if (!strcmp(argv[1], "info"))
62 manager = new(std::nothrow) info_manager;
65 _E("failed to allocate memory for manager");
72 int main(int argc, char *argv[])
76 signal(SIGINT, signal_handler);
77 signal(SIGHUP, signal_handler);
78 signal(SIGTERM, signal_handler);
79 signal(SIGQUIT, signal_handler);
80 signal(SIGABRT, signal_handler);
87 sensor_manager *manager = create_manager(argc, argv);
93 manager->process(argc, argv);