2 * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
10 * @file CarSim_Daemon.cpp
11 * @brief main entry point
14 #include <sys/types.h>
22 #include "ico-util/ico_log.h"
26 #define VERSION "0.1.2"
30 int main(int argc, char **argv)
34 bool bTestMode = false;
37 bool bDemoRunning = false;
40 // printf("ico-vic-carsim: userid='%s', uid=%d, euid=%d)\n", cuserid(NULL), getuid(), geteuid());
42 for (ii = 1; ii < argc; ii++) {
43 if (strcmp( argv[ii], "-h") == 0) {
44 printf("Usage: CarSim_Daemon [-g]\n");
45 printf(" -g\t Get GPS form smartphone\n");
48 else if (strcmp( argv[ii], "-v") == 0) {
49 printf("CarSim_Daemon version:%s\n", VERSION);
52 else if (strcmp( argv[ii], "-g") == 0) {
55 else if (strcmp( argv[ii], "-c") == 0) {
56 printf("Using amb plug-in I/F\n");
59 else if (strcmp( argv[ii], "-t") == 0) {
62 else if (strcmp( argv[ii], "-j") == 0) {
65 else if (strcmp( argv[ii], "-r") == 0) {
68 else if (strcasecmp( argv[ii], "--user") == 0) {
71 if (strcmp(argv[ii], cuserid(NULL)) != 0) {
72 printf("ico-vic-carsim: abort(cannot run in a '%s' [uid=%d, euid=%d])\n", cuserid(NULL), getuid(), geteuid());
77 else if (strcasecmp( argv[ii], "--uid") == 0) {
80 if (strtol(argv[ii], NULL, 10) != (long)getuid()) {
81 printf("ico-vic-carsim: abort(cannot run in a '%s' [uid=%d, euid=%d])\n", cuserid(NULL), getuid(), geteuid());
88 ico_log_open("ico-vic-carsim");
89 ICO_INF( "START_MODULE ico-vic-carsim" );
94 b = myGtCtrl.Initialize();
97 myGtCtrl.m_bUseGps = bUseGps;
101 myGtCtrl.Terminate();
104 ICO_INF( "END_MODULE ico-vic-carsim" );
113 ("Carsim_Daemon Test mode...\n Press Ctrl+C to close program...\n");
119 type = cjs.Read(&number, &value);
122 printf("type=%d, number=%d, value=%d\n", type, number,
130 printf("joystick open error(test mode)\n");
134 // change to super user
136 printf("can not set super user [errno=%d]\n", errno);
140 myGtCtrl.m_bUseGps = bUseGps;
141 myGtCtrl.m_bDemoRunning = bDemoRunning;
142 b = myGtCtrl.Initialize();
147 myGtCtrl.Terminate();
150 ICO_INF( "END_MODULE ico-vic-carsim" );
155 * End of File.(CarSim_Daemon)