Move service file from systemd/system to systemd/user. 65/10265/2 accepted/tizen/ivi/genivi accepted/tizen/ivi/milestone accepted/tizen/ivi/stable tizen_ivi_genivi tizen_ivi_milestone accepted/tizen/20131003.164231 accepted/tizen/20131003.220216 accepted/tizen/ivi/genivi/20140131.070507 accepted/tizen_ivi_milestone/20131113.053400 accepted/tizen_ivi_milestone/20131113.054103 accepted/tizen_ivi_stable/20131116.012218 ivi_oct_m2 submit/tizen/20131003.014552 submit/tizen_ivi_generic/20140131.065434 submit/tizen_ivi_genivi/20140131.070614 submit/tizen_ivi_milestone/20131113.052536 submit/tizen_ivi_milestone/20131113.053337 submit/tizen_ivi_milestone/20131113.054037 submit/tizen_ivi_stable/20131116.010021
authorHayato Nakamura <hayato.nakamura@mail.toyota-td.jp>
Thu, 26 Sep 2013 04:04:54 +0000 (13:04 +0900)
committerHayato Nakamura <hayato.nakamura@mail.toyota-td.jp>
Wed, 2 Oct 2013 06:39:36 +0000 (15:39 +0900)
Change-Id: I5717470154e8d82a9f15feaa0bb44aad90ba66d2
Signed-off-by: Hayato Nakamura <hayato.nakamura@mail.toyota-td.jp>
configure.ac
ico-vic-carsim.service [moved from carsim.service with 61% similarity]
packaging/ico-vic-carsimulator.changes
packaging/ico-vic-carsimulator.spec
src/CGtCtrl.cpp
src/CGtCtrl.h
src/CJoyStick.cpp
src/CJoyStickEV.cpp
src/CJoyStickEV.h
src/CarSim_Daemon.cpp
src/Makefile.am

index 34e4058..384d754 100644 (file)
@@ -2,7 +2,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ([2.68])
-AC_INIT([carsim], [0.0.1], [shibata@mac.tec.toyota.co.jp])
+AC_INIT([ico-vic-carsim], [0.0.9], [shibata@mac.tec.toyota.co.jp])
 AM_INIT_AUTOMAKE([1.11 foreign])
 AC_CONFIG_SRCDIR([config.h.in])
 AC_CONFIG_HEADERS([config.h])
similarity index 61%
rename from carsim.service
rename to ico-vic-carsim.service
index 111d946..85aa087 100644 (file)
@@ -7,10 +7,4 @@ Description=Carsimulator supported by G25 and G27.
 After=ambd.service
 
 [Service]
-Type=oneshot
-ExecStart=/usr/bin/carsim
-
-[Install]
-WantedBy=multi-user.target
-
-
+ExecStart=/usr/bin/ico-vic-carsim
index 82dccd8..3673f91 100644 (file)
@@ -1,3 +1,10 @@
+* Thu Sep 26 2013 Shibata Makoto <shibata@mac.tec.toyota.co.jp> accepted/tizen/20130919.204144@1135dfb
+- 0.9.05 release.
+-- the program name is changed to "ico-vic-carsim" from "carsim".
+-- a service file is moved from systemd/system to systemd/user.
+-- the start method is changed to the Wants target of the service file of ico-uxf-homescreen
+-- internal bug fix
+
 * Thu Sep 19 2013 Shibata Makoto <shibata@mac.tec.toyota.co.jp> accepted/tizen/20130917.224135@6e9f63d
 - 0.9.04 release.
 -- Coexistence with ico-uxf-device-input-controller(for GTForce).
index 4097377..3b98b3e 100644 (file)
@@ -1,6 +1,6 @@
 Name:       ico-vic-carsimulator
 Summary:    CarSimulator
-Version:    0.9.04
+Version:    0.9.05
 Release:    1.1
 Group:      System Environment/Daemons
 License:    Apache 2.0
@@ -36,20 +36,18 @@ rm -rf %{buildroot}
 %make_install
 
 # configurations
-%define carsim_conf /usr/bin/
-mkdir -p %{buildroot}/etc/carsim/
-mkdir -p %{buildroot}/usr/lib/systemd/system/
-#install -m 0644 src/CarSim_Daemon.conf %{buildroot}%{carsim_conf}
-install -m 0644 G25.conf %{buildroot}/etc/carsim/
-install -m 0644 G27.conf %{buildroot}/etc/carsim/
-install -m 0644 carsim.service %{buildroot}/usr/lib/systemd/system/
+mkdir -p %{buildroot}/etc/ico-vic-carsim/
+mkdir -p %{buildroot}/usr/lib/systemd/user/
+install -m 0644 G25.conf %{buildroot}/etc/ico-vic-carsim/
+install -m 0644 G27.conf %{buildroot}/etc/ico-vic-carsim/
+install -m 0644 ico-vic-carsim.service %{buildroot}%{_unitdir_user}/ico-vic-carsim.service
 
 %post -p /sbin/ldconfig
 %postun -p /sbin/ldconfig
 
 %files
+%attr(4755root,root,-) %{_bindir}/ico-vic-carsim
 %defattr(-,root,root,-)
 %{_bindir}/*
-/etc/carsim/*
-/usr/lib/systemd/system/carsim.service
-#%{carsim_conf}/CarSim_Daemon.conf
+/etc/ico-vic-carsim/*
+/usr/lib/systemd/user/ico-vic-carsim.service
index f7fe957..fe52fe2 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
  *
- * This program is licensed under the terms and conditions of the 
+ * This program is licensed under the terms and conditions of the
  * Apache License, version 2.0.  The full text of the Apache License is at
  * http://www.apache.org/licenses/LICENSE-2.0
  *
@@ -49,8 +49,8 @@ short g_BREAKE_SAMPLE_SPACE_SIZE = 10;
 bool   g_bSentInMileage   = true;
 bool   g_bSentInChgLngLat = true;
 double g_SentInMileage    = 3.0;  // 3 meter
-double g_StartLatitude    =  35.47945; 
-double g_StartLongitude   = 139.40026; 
+double g_StartLatitude    =  35.47945;
+double g_StartLongitude   = 139.40026;
 double g_GoalLatitude     =  35.49746;
 double g_GoalLongitude    = 139.40504;
 
@@ -126,7 +126,6 @@ bool CGtCtrl::Initialize()
     m_stVehicleInfo.bHeadLight = false; // HEAD LIGHT OFF(false)
 
     m_bFirstOpen = true;
-
     if (true == gbDevJs) {
         myJS = new CJoyStick;
         int nRet = myJS->Open();
@@ -162,6 +161,7 @@ bool CGtCtrl::Initialize()
                 break;
             }
             delete myJS;
+            myJS = NULL;
         } while ((++i) < g_JoyStickTypeNum);
         if (myJS == NULL) {
             return false;
@@ -463,7 +463,7 @@ void CGtCtrl::Run()
             }
 
             if (true == bLIGHTSTATUS) {
-                const size_t LSsz = 8;                                                              
+                const size_t LSsz = 8;
                 char data[LSsz];
                     // 0:LIGHT HEAD STATUS ON(1)/OFF(0)
                     // 1:LEFT WINKER STATUS ON(1)/OFF(0)
@@ -535,8 +535,8 @@ void CGtCtrl::Run()
          * SHIFT
          */
         if (nShiftPosBK != m_stVehicleInfo.nShiftPos) {
-            const size_t ShiftSz = 3;                                                              
-            int data[ShiftSz];                                                                    
+            const size_t ShiftSz = 3;
+            int data[ShiftSz];
             int val = pmCar.getValue();
             data[0] = pmCar.getSelectGear();
             if (data[0] > 10) {
@@ -1099,7 +1099,7 @@ void CGtCtrl::SetMQKeyData(char *buf, unsigned int bufsize, long &mtype,
  * @return  bool    true:success,false:failure
  */
 /*--------------------------------------------------------------------------*/
-bool CGtCtrl::sendVehicleInfo( /*int & send_id, long priority, */ 
+bool CGtCtrl::sendVehicleInfo( /*int & send_id, long priority, */
                               ProtocolType type, const char *key, void *data,
                               unsigned int unit_size, int unit_cnt)
 {
index cb57ac2..e436800 100644 (file)
@@ -51,8 +51,8 @@
 
 const useconds_t g_sleeptime = 10000; // = 10milli sec = 0.01 sec
 const int g_JoyStickTypeNum = 3;
-const std::string g_ConfPathG25 = "/etc/carsim/G25.conf";
-const std::string g_ConfPathG27 = "/etc/carsim/G27.conf";
+const std::string g_ConfPathG25 = "/etc/ico-vic-carsim/G25.conf";
+const std::string g_ConfPathG27 = "/etc/ico-vic-carsim/G27.conf";
 #define D_RUNLOOP_INTERVAL_COUNT  5
 #define D_RUNLOOP_INTERVAL_COUNT2 50
 
index d5d7ae5..c1def11 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
  *
- * This program is licensed under the terms and conditions of the 
+ * This program is licensed under the terms and conditions of the
  * Apache License, version 2.0.  The full text of the Apache License is at
  * http://www.apache.org/licenses/LICENSE-2.0
  *
@@ -58,7 +58,7 @@ int CJoyStick::Open()
             ioctl(m_nJoyStickID, JSIOCGAXES, &m_ucAxes);
             ioctl(m_nJoyStickID, JSIOCGBUTTONS, &m_ucButtons);
             ioctl(m_nJoyStickID, JSIOCGNAME(sizeof(m_strDevName)),
-                  &m_strDevName);
+                  m_strDevName);
 
             printf
                 ("JoyStick ID[%d], JoyStick Name[%s], Axis[%d], Buttons[%d]\n",
@@ -178,8 +178,10 @@ int CJoyStick::deviceOpen(const std::string& dirNM,
     }
     int r = -1;
     for (size_t i = 0; i < sz; i++) {
-        int fd = open(files[i].c_str(), O_RDWR | O_NONBLOCK);
+        int fd = open(files[i].c_str(), O_RDONLY | O_NONBLOCK);
         if (0 > fd) { /* open error */
+            fprintf(stderr,"CJoyStick::deviceOpen: Event Device.%d(%s) Open Error<%d>\n",
+                    i, files[i].c_str(), errno);
             continue; /* next device */
         }
         char sDevNm[128];
@@ -225,10 +227,10 @@ void CJoyStick::getDevices(const std::string& dir,
         do {
             dent = readdir(dp);
             if (dent != NULL) {
-                bool bMatching = true;
+                bool bMatching = false;
                 for (int i = 0; i < mssz; i++) {
-                    if (0 == strstr(dent->d_name, matching[i].c_str())) {
-                        bMatching = false;
+                    if (strstr(dent->d_name, matching[i].c_str())) {
+                        bMatching = true;
                         break;  /* break of for */
                     }
                 }
index dcc16f6..b846b53 100644 (file)
@@ -41,7 +41,6 @@ CJoyStickEV::CJoyStickEV()
 {
     // TODO Auto-generated constructor stub
     memset(m_absInf, 0, sizeof(m_absInf));
-    m_grab = false;
     m_devName = std::string(D_DEV_NAME_G27);
 }
 
@@ -62,22 +61,13 @@ int CJoyStickEV::Open()
     /**
      * get device file
      */
-    printf("Open Device Name is %s\n", m_devName.c_str());
+    printf("Open Device Name is <%s>\n", m_devName.c_str());
     int rfd = deviceOpen(dirpath, nameparts, m_devName, devPath);
     if (0 > rfd) {
         printf("Can't open device.\n");
         return rfd;
     }
     m_nJoyStickID = rfd;
-    /**
-     * set grab
-     */
-    printf("Check Grab is %s(%d)\n", m_devName.c_str(), rfd);
-    if (false == deviceGrab(rfd)) {
-        printf("Can't get grab.\n");
-        Close();
-        return -1;
-    }
 
     fds.fd = m_nJoyStickID;
     return m_nJoyStickID;
@@ -92,11 +82,6 @@ int CJoyStickEV::Close()
     if (0 > m_nJoyStickID) {
         return 0;
     }
-    if (true == m_grab) {
-        if (false == deviceGrabRelese(m_nJoyStickID)) {
-            cerr << "EVENT device GRAB Relese Fail" << endl;
-        }
-    }
     return CJoyStick::Close();
 }
 
@@ -302,42 +287,5 @@ bool CJoyStickEV::getDeviceName(int fd, char* devNM, size_t sz)
 }
 
 /**
- * @brief device grab
- */
-bool CJoyStickEV::deviceGrab(int fd)
-{
-    if (0 > fd) {
-        return false;
-    }
-#if 0           /* no need grab on weston-1.2.x */
-    if (0 > ioctl(fd, EVIOCGRAB, 1)) {
-         return false;
-    }
-#endif
-    m_grab = true;
-    return true;
-}
-
-/**
- * @brief device grab relese
- */
-bool CJoyStickEV::deviceGrabRelese(int fd)
-{
-    if (0 > fd) {
-        return false;
-    }
-    if (false == m_grab) {
-        return false;
-    }
-#if 0           /* no need grab on weston-1.2.x */
-    if (0 > ioctl(fd, EVIOCGRAB, 0)) {
-        return false;
-    }
-#endif
-    m_grab = false;
-    return true;
-}
-
-/**
  * End of File.(CJoyStickEV.cpp)
  */
index 802ce71..04d10a5 100644 (file)
@@ -36,8 +36,6 @@ class CJoyStickEV : public CJoyStick
     virtual int Read(int *number, int *value);
     virtual int ReadData();
     virtual bool getDeviceName(int fd, char* devNM, size_t sz);
-    bool deviceGrab(int fd);
-    bool deviceGrabRelese(int fd);
     int getJS_EVENT_BUTTON(int& num, int& val, const struct input_event& s);
     int getJS_EVENT_AXIS(int& num, int& val, const struct input_event& s);
     int calc1pm32767(int val, const struct input_absinfo& ai);
@@ -54,7 +52,6 @@ class CJoyStickEV : public CJoyStick
         E_ABSMAX    /* */
     };
     struct input_absinfo m_absInf[E_ABSMAX];
-    bool m_grab;
     std::string m_devName;
   private:
 };
index 074031f..ad20514 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
  *
- * This program is licensed under the terms and conditions of the 
+ * This program is licensed under the terms and conditions of the
  * Apache License, version 2.0.  The full text of the Apache License is at
  * http://www.apache.org/licenses/LICENSE-2.0
  *
@@ -11,7 +11,7 @@
  * @brief   main entry point
  */
 
-
+#include <sys/types.h>
 #include <iostream>
 #include <unistd.h>
 #include <getopt.h>
@@ -24,7 +24,6 @@ bool gbDevJs = false;
 
 int main(int argc, char **argv)
 {
-
     // parse cmd line
     int result = 0;
     bool bUseGps = false;
@@ -102,6 +101,11 @@ int main(int argc, char **argv)
         }
     }
     else {
+        // change to super user
+        if (setuid(0) < 0)  {
+            printf("can not set super user\n");
+        }
+
         CGtCtrl myGtCtrl;
         b = myGtCtrl.Initialize();
 
@@ -109,13 +113,10 @@ int main(int argc, char **argv)
             myGtCtrl.m_bUseGps = bUseGps;
 
             myGtCtrl.Run();
-
-            myGtCtrl.Terminate();
-        }
-        else {
-            myGtCtrl.Terminate();
         }
+        myGtCtrl.Terminate();
     }
+    return 0;
 }
 
 /**
index c9a8cd1..e9762ca 100644 (file)
@@ -1,6 +1,6 @@
-bin_PROGRAMS = carsim
+bin_PROGRAMS = ico-vic-carsim
 
-carsim_SOURCES = AmbpiComm.h AmbpiComm.cpp CJoyStick.h CJoyStick.cpp CJoyStickEV.h CJoyStickEV.cpp CJoyStickG25.h CJoyStickG25.cpp CJoyStickG27.h CJoyStickG27.cpp CConf.h CConf.cpp CGtCtrl.h CGtCtrl.cpp CCalc.h CCalc.cpp CAvgCar.h CAvgCar.cpp CarSim_Daemon.cpp
-carsim_LDADD = -lpthread -ljson-glib-1.0 -lgobject-2.0 -lglib-2.0 -lrt -lico-util
-carsim_CPPFLAGS = -I/usr/include/glib-2.0 -I/usr/include/json-glib-1.0 -I/usr/lib/glib-2.0/include -std=c++0x
-carsim_LDFLAGS = 
+ico_vic_carsim_SOURCES = AmbpiComm.h AmbpiComm.cpp CJoyStick.h CJoyStick.cpp CJoyStickEV.h CJoyStickEV.cpp CJoyStickG25.h CJoyStickG25.cpp CJoyStickG27.h CJoyStickG27.cpp CConf.h CConf.cpp CGtCtrl.h CGtCtrl.cpp CCalc.h CCalc.cpp CAvgCar.h CAvgCar.cpp CarSim_Daemon.cpp
+ico_vic_carsim_LDADD = -lpthread -ljson-glib-1.0 -lgobject-2.0 -lglib-2.0 -lrt -lico-util
+ico_vic_carsim_CPPFLAGS = -I/usr/include/glib-2.0 -I/usr/include/json-glib-1.0 -I/usr/lib/glib-2.0/include -std=c++0x
+ico_vic_carsim_LDFLAGS =