Support Tizen3.0
authorNakamura Hayato <hayato.nakamura@mail.toyota-td.jp>
Wed, 17 Jul 2013 11:05:56 +0000 (20:05 +0900)
committerNakamura Hayato <hayato.nakamura@mail.toyota-td.jp>
Wed, 17 Jul 2013 11:08:28 +0000 (20:08 +0900)
Change-Id: I919e10e655388494abd315a52e042ad7fde3d1d7
Signed-off-by: Nakamura Hayato <hayato.nakamura@mail.toyota-td.jp>
14 files changed:
packaging/ico-vic-carsimulator.changes
packaging/ico-vic-carsimulator.spec
src/AmbpiComm.cpp [new file with mode: 0644]
src/AmbpiComm.h [new file with mode: 0644]
src/CAvgCar.h
src/CConf.cpp
src/CGtCtrl.cpp
src/CGtCtrl.h
src/CJoyStick.cpp
src/CJoyStickEV.cpp
src/CarSim_Daemon.cpp
src/Makefile.am
src/Websocket.cpp [deleted file]
src/Websocket.h [deleted file]

index 08a7e15..eb5bb5b 100644 (file)
@@ -1,3 +1,8 @@
+* Wed Jul 17 2013 Shibata Makoto <shibata@mac.tec.toyota.co.jp> accepted/2.0alpha-wayland/20130612.174818@8f21497
+- 0.1.4-2 release.
+- Change to ico-uxf-utilities from libwebsocket.
+- Bug fix : Compilation errors that occur when updating version of Tizen.
+
 * Thu Jun 06 2013 Shibata Makoto <shibata@mac.tec.toyota.co.jp> submit/2.0alpha-wayland/20130426.192225@29e931f
 - 0.1.3 release
 - Organize unnecessary files.
index 88a9b85..4859190 100644 (file)
@@ -1,7 +1,7 @@
 Name:       ico-vic-carsimulator
 Summary:    CarSimulator
-Version:    0.1.3
-Release:    1
+Version:    0.1.4
+Release:    2
 Group:      System Environment/Daemons
 License:    Apache 2.0
 Source0:    %{name}-%{version}.tar.bz2
@@ -9,12 +9,15 @@ Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
 Requires:       glib2 
 Requires:       ico-vic-amb-plugin 
+Requires:       ico-uxf-utilities
 BuildRequires:  make
 BuildRequires:  automake
 BuildRequires:  boost-devel
-BuildRequires:  libwebsockets-devel
+#BuildRequires:  libwebsockets-devel
 BuildRequires:  glib2-devel
 BuildRequires:  json-glib-devel
+#BuildRequires:  ico-uxf-utilities
+BuildRequires:  ico-uxf-utilities-devel
 
 %description 
 CarSimulator is simulated driving software
diff --git a/src/AmbpiComm.cpp b/src/AmbpiComm.cpp
new file mode 100644 (file)
index 0000000..8b3c043
--- /dev/null
@@ -0,0 +1,369 @@
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * 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
+ *
+ */
+/**
+ * @brief   AMB plug-inn Communication I/F
+ *
+ */
+
+#include <string.h>
+#include <iostream>
+#include <vector>
+#include <unistd.h>
+#include "AmbpiComm.h"
+using namespace std;
+
+static vector<AmbpiCommIF*> _commList;
+
+bool _addAmbCommIFList(AmbpiCommIF* comm);
+void _eraseAmbCommIFList(const AmbpiCommIF* comm);
+static void _icoUwsCallback(const struct ico_uws_context *context,
+                           const ico_uws_evt_e event, const void *id,
+                           const ico_uws_detail *detail, void *user_data);
+
+
+AmbpiCommRecvQueue::AmbpiCommRecvQueue()
+: msize(0), maxqueuesize(10)
+{
+    init();
+}
+
+AmbpiCommRecvQueue::AmbpiCommRecvQueue(int queuesize)
+: msize(0)
+{
+    maxqueuesize = queuesize;
+    init();
+}
+
+AmbpiCommRecvQueue::~AmbpiCommRecvQueue()
+{
+    delete[] mdata;
+    delete[] mdatasize;
+}
+
+bool AmbpiCommRecvQueue::push(char *data, int datasize)
+{
+    if (datasize > maxdatasize || (msize + 1) > maxqueuesize) {
+        return false;
+    }
+    memset(mdata[msize], 0, maxdatasize);
+    memcpy(mdata[msize], data, datasize);
+    mdatasize[msize] = datasize;
+    msize++;
+    return true;
+}
+
+bool AmbpiCommRecvQueue::front(char *buf) const
+{
+    if (msize == 0) {
+        return false;
+    }
+    memcpy(buf, mdata[0], mdatasize[0]);
+    return true;
+}
+
+bool AmbpiCommRecvQueue::empty() const
+{
+    return (msize == 0);
+}
+
+void AmbpiCommRecvQueue::pop()
+{
+    if (msize > 0) {
+        msize--;
+        for (int i = 0; i < msize; i++) {
+            memset(mdata[i], 0, maxdatasize);
+            memcpy(mdata[i], mdata[i + 1], mdatasize[i + 1]);
+            mdatasize[i] = mdatasize[i + 1];
+        }
+        memset(mdata[msize], 0, maxdatasize);
+        mdatasize[msize] = 0;
+    }
+}
+
+int AmbpiCommRecvQueue::size() const
+{
+    return msize;
+}
+
+void AmbpiCommRecvQueue::init()
+{
+    mdata = new char[maxqueuesize][maxdatasize];
+    memset((void *) mdata, 0, maxqueuesize * maxdatasize);
+
+    mdatasize = new int[maxqueuesize];
+
+    memset(mdatasize, 0, maxqueuesize);
+}
+
+AmbpiCommIF::AmbpiCommIF()
+{
+    isready = false;
+    m_threadid = 0;
+    m_mutex = PTHREAD_MUTEX_INITIALIZER;
+    m_cond = PTHREAD_COND_INITIALIZER;
+    m_id = NULL;
+    m_context = NULL;
+    reset_ercode();
+}
+
+AmbpiCommIF::AmbpiCommIF(const char* uri, const char* protocolName)
+{
+    isready = false;
+    m_threadid = 0;
+    m_mutex = PTHREAD_MUTEX_INITIALIZER;
+    m_cond = PTHREAD_COND_INITIALIZER;
+    m_id = NULL;
+    m_context = NULL;
+    reset_ercode();
+    start(uri, protocolName);
+}
+
+AmbpiCommIF::~AmbpiCommIF()
+{
+    if (isready) {
+        int ret;
+        if (m_threadid != 0) {
+            ret = pthread_cancel(m_threadid);
+            if (ret != 0) {
+                cerr << m_pNm << ":Failed to pthread_cancel" << endl;
+            }
+        }
+        ret = pthread_join(m_threadid, NULL);
+        if (ret != 0) {
+            cerr << m_pNm << ":Failed to pthread_join" << endl;
+        }
+        if (m_context != NULL) {
+            ico_uws_close(m_context);
+            m_context = NULL;
+        }
+        _eraseAmbCommIFList(this);
+    }
+}
+
+bool AmbpiCommIF::start(const char* uri, const char* protocolName)
+{
+    if (isready) {
+        return isready;
+    }
+    isready = init(uri, protocolName);
+    return isready;
+}
+
+bool AmbpiCommIF::send(const char *msg, const int size)
+{
+    if (!isready) {
+        return isready;
+    }
+    reset_ercode();
+    ico_uws_send(m_context, m_id, (unsigned char*)msg, (size_t)size);
+    if ((ICO_UWS_ERR_UNKNOWN != m_ercode) && (ICO_UWS_ERR_NONE != m_ercode)) {
+        return false;
+    }
+    return true;
+}
+
+bool AmbpiCommIF::recv(char *msg, bool fblocking)
+{
+    if (!isready) {
+        return isready;
+    }
+
+    if (fblocking) {
+        if (m_queue.empty()) {
+            if (pthread_cond_wait(&m_cond, &m_mutex) != 0) {
+                cerr << m_pNm << ":Failed to wait signal" << endl;
+            }
+        }
+        m_queue.front(msg);
+        m_queue.pop();
+    }
+    else {
+        if (m_queue.empty()) {
+            return false;
+        }
+        else {
+            m_queue.front(msg);
+            m_queue.pop();
+        }
+    }
+    return true;
+}
+
+bool AmbpiCommIF::poll()
+{
+    if (!isready) {
+        return isready;
+    }
+
+    while (true) {
+        ico_uws_service(m_context);
+        usleep(100000);
+    }
+}
+
+void *AmbpiCommIF::loop(void *arg)
+{
+    AmbpiCommIF *src = reinterpret_cast < AmbpiCommIF * >(arg);
+    return (void *) src->poll();
+}
+
+bool AmbpiCommIF::init(const char* uri, const char* protocolName)
+{
+    if (NULL == uri) {
+        cerr << "Failed create context param" << endl;
+        return false;
+    }
+    if (NULL == protocolName) {
+        cerr << "Failed create context param 2" << endl;
+        return false;
+    }
+    m_uri = uri;
+    m_pNm = protocolName;
+    m_context = ico_uws_create_context(uri, protocolName);
+    if (NULL == m_context) {
+        cerr << m_pNm << ":Failed to create context." << endl;
+        return false;
+    }
+    int r = ico_uws_set_event_cb(m_context, _icoUwsCallback, (void*)this);
+    if (ICO_UWS_ERR_NONE != r) {
+        cerr << m_pNm << ":Failed to callback entry(" << r << ")." << endl;
+        return false;
+    }
+    _addAmbCommIFList(this);
+    if (pthread_create(&m_threadid, NULL, AmbpiCommIF::loop,
+                       (void *) this) != 0) {
+        cerr << m_pNm << ":Failed to create thread." << endl;
+        return false;
+    }
+    return true;
+}
+
+/**
+ * @brief event
+ * @param event ico_uws_evt_e event code
+ * @param id unique id
+ * @param detail infomation or data detail
+ * @param user_data added user data
+ */
+void AmbpiCommIF::event_cb(const ico_uws_evt_e event, const void *id,
+                           const ico_uws_detail *d, void *user_data)
+{
+    switch (event) {
+    case ICO_UWS_EVT_RECEIVE:
+    {
+        if (NULL == d) {
+            cerr << m_pNm << ":Failed Receive event" << endl;
+            break;
+        }
+        if (0 != pthread_mutex_lock(&m_mutex)) {
+            cerr << m_pNm << ":Failed to lock mutex" << endl;
+        }
+        char buf[sizeof(KeyDataMsg_t) + MsgQueueMaxMsgSize];
+        memset(buf, 0, sizeof(buf));
+        memcpy(buf, reinterpret_cast<char*>(d->_ico_uws_message.recv_data),
+               d->_ico_uws_message.recv_len);
+        m_queue.push((&buf[0]), sizeof(buf));
+        pthread_cond_signal(&m_cond);
+        if (0 != pthread_mutex_unlock(&m_mutex)) {
+            cerr << m_pNm << ":Failed to unlock mutex" << endl;
+        }
+        break;
+    }
+    case ICO_UWS_EVT_OPEN:
+    {
+        m_id = (void*)id;
+        if (0 != pthread_mutex_lock(&m_mutex)) {
+            cerr << m_pNm << ":Failed to lock mutex" << endl;
+        }
+        if (0 != pthread_cond_signal(&m_cond)) {
+            cerr << m_pNm << ":Failed to issue cond_signal" << endl;
+        }
+        if (0 != pthread_mutex_unlock(&m_mutex)) {
+            cerr << m_pNm << ":Failed to unlock mutex" << endl;
+        }
+        break;
+    }
+    case ICO_UWS_EVT_ERROR:
+    {
+        if (NULL == d) {
+            cerr << m_pNm << ":Failed ERROR event" << endl;
+            break;
+        }
+        m_ercode = d->_ico_uws_error.code;
+        break;
+    }
+    default:
+        break;
+    }
+    return;
+}
+
+/**
+ * @brief _addAmbCommIFList
+ * @param comm entry item address
+ * @return true:succes false:fail
+ */
+bool _addAmbCommIFList(AmbpiCommIF* comm)
+{
+    if (NULL == comm) {
+        return false;
+    }
+    _commList.push_back(comm);
+    return true;
+}
+
+/**
+ * @brief _eraseAmbCommIFList
+ * @param comm erase target
+ */
+void _eraseAmbCommIFList(const AmbpiCommIF* comm)
+{
+    bool bMatch = false;
+    for (int i = 0; i < _commList.size(); i++) {
+        if (_commList[i] == comm) {
+            bMatch = true;
+            break; // break of for i
+        }
+    }
+    if (false == bMatch) {
+        return;
+    }
+    vector<AmbpiCommIF*> v_tmp(_commList);
+    _commList.clear();
+    for (int i = 0; i < v_tmp.size(); i++) {
+        if (v_tmp[i] != comm) {
+            _commList.push_back(v_tmp[i]);
+        }
+    }
+    return;
+}
+
+/**
+ * @brief _icoUwsCallback
+ * @param context identify connect
+ * @param event ico_uws_evt_e event code
+ * @param id unique id
+ * @param detail infomation or data detail
+ * @param user_data added user data
+ */
+static void _icoUwsCallback(const struct ico_uws_context *context,
+                           const ico_uws_evt_e event, const void *id,
+                           const ico_uws_detail *detail, void *user_data)
+{
+    for (int i = 0; i < _commList.size(); i++) {
+        AmbpiCommIF* comm = _commList[i];
+        if (NULL == comm) {
+            continue;
+        }
+        if (false == comm->isContextMatch(context)) {
+            continue;
+        }
+        comm->event_cb(event, id, detail, user_data);
+    }
+}
diff --git a/src/AmbpiComm.h b/src/AmbpiComm.h
new file mode 100644 (file)
index 0000000..f15bea9
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
+ *
+ * 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
+ *
+ */
+/**
+ * @brief   AMB plug-in communication I/F
+ */
+
+#ifndef _ICO_VIC_AMBPICOMM_H_
+#define _ICO_VIC_AMBPICOMM_H_
+
+#include <sys/time.h>
+#include <string>
+#include "ico-util/ico_uws.h"
+
+const int MsgQueueMaxMsgSize = 128;
+
+struct KeyEventOptMsg_t
+{
+    char KeyEventType[64];
+    struct timeval recordtime;
+    struct KeyEventOpt
+    {
+        int common;
+        int sense;
+        int event_mask;
+    } eventopt;
+};
+
+struct KeyDataMsg_t
+{
+    char KeyEventType[64];
+    struct timeval recordtime;
+    struct KeyData
+    {
+        int common_status;
+        char status[];
+    } data;
+};
+
+class AmbpiCommRecvQueue
+{
+  public:
+        AmbpiCommRecvQueue();
+        AmbpiCommRecvQueue(int queuesize);
+        ~AmbpiCommRecvQueue();
+    bool push(char *data, int datasize);
+    bool front(char *buf) const;
+    bool empty() const;
+    void pop();
+    int size() const;
+
+    static const int maxdatasize = sizeof(KeyDataMsg_t) + MsgQueueMaxMsgSize;
+  private:
+    void init();
+
+    int maxqueuesize;
+    int msize;
+    char (*mdata)[maxdatasize];
+    int *mdatasize;
+};
+
+class AmbpiCommIF
+{
+  public:
+    AmbpiCommIF();
+    AmbpiCommIF(const char* uri, const char* protocolName);
+    ~AmbpiCommIF();
+    bool start(const char* uri, const char* protocolName);
+    bool send(const char *msg, const int size);
+    bool recv(char *msg, bool fbolcking);
+    bool poll();
+    static void *loop(void *arg);
+    bool isContextMatch(const ico_uws_context* context) const;
+    bool threadCondWait();
+    void event_cb(const ico_uws_evt_e event, const void *id,
+                  const ico_uws_detail *detail, void *user_data);
+    void reset_ercode();
+  private:
+    bool init(const char* uri, const char* protocolName);
+
+    bool isready;
+    ico_uws_context* m_context;
+    pthread_t  m_threadid;
+    pthread_mutex_t m_mutex;
+    pthread_cond_t m_cond;
+    char m_sendbuf[AmbpiCommRecvQueue::maxdatasize];
+    AmbpiCommRecvQueue m_queue;
+    std::string m_uri; // URI
+    std::string m_pNm; // protocol name
+    ico_uws_error_e m_ercode;
+    void* m_id;
+};
+
+/**
+ * @brief context compare
+ * @param context 
+ * @return true:agree / false:not agree
+ */
+inline bool AmbpiCommIF::isContextMatch(const ico_uws_context* context) const
+{
+    if (context == m_context) {
+        return true;
+    }
+    return false;
+}
+
+/**
+ * @brief thread wait
+ * @return true:success / false:fail
+ */
+inline bool AmbpiCommIF::threadCondWait()
+{
+    if (0 != pthread_cond_wait(&m_cond, &m_mutex)) {
+        return false;
+    }
+    return true;
+}
+
+/**
+ * @brief reset error code
+ */
+inline void AmbpiCommIF::reset_ercode()
+{
+    m_ercode = ICO_UWS_ERR_UNKNOWN;
+}
+
+#endif //#ifndef _ICO_VIC_AMBPICOMM_H_
index f062867..68dda27 100644 (file)
@@ -110,7 +110,7 @@ inline int iAverageMachine::getIAvg() const
 }
 
 /**
- * @breif getPrevValue
+ * @brief getPrevValue
  * @return prev sample value
  */
 inline int iAverageMachine::getPrevValue() const
@@ -194,7 +194,7 @@ protected:
 };
 
 /**
- * @breif isOnBrake
+ * @brief isOnBrake
  * @return true:on brake false:no brake
  */
 inline bool CAvgBrake::isOnBrake() const
@@ -203,7 +203,7 @@ inline bool CAvgBrake::isOnBrake() const
 }
 
 /**
- * @breif
+ * @brief
  * @return
  */
 inline int CAvgBrake::getBrakeAvg() const
@@ -410,7 +410,7 @@ private:
 };
 
 /**
- * @breif getRPM
+ * @brief getRPM
  * @return RPM
  */
 inline double CAvgCar::getRPM() const
@@ -491,7 +491,7 @@ inline int CAvgCar::calcAccPedalOpen() const
     return  (int)(x*100.0);
 }
 /**
- * @breif get Tripmeter
+ * @brief get Tripmeter
  * @return trip meter value
  */
 inline double CAvgCar::getTripmeter() const
@@ -499,7 +499,7 @@ inline double CAvgCar::getTripmeter() const
     return m_tripmeter;
 }
 /**
- * @breif tripmeterReset
+ * @brief tripmeterReset
  *        tripmeter reset
  */
 inline void CAvgCar::tripmeterReset()
index 80bb884..983f335 100644 (file)
@@ -12,6 +12,8 @@
  *
  */
 
+#include <unistd.h>
+
 #include "CConf.h"
 
 CConf::CConf()
index 95015f7..8b3d2b0 100644 (file)
@@ -26,25 +26,9 @@ bool g_bStopFlag;
 std::queue < geoData > routeList;
 std::string msgQueue;
 int Daemon_MS;
-pthread_mutex_t m_websocket_mutex[] = {
-    PTHREAD_MUTEX_INITIALIZER,
-    PTHREAD_MUTEX_INITIALIZER,
-    PTHREAD_MUTEX_INITIALIZER,
-    PTHREAD_MUTEX_INITIALIZER
-};
-
-pthread_cond_t m_websocket_cond[] = {
-    PTHREAD_COND_INITIALIZER,
-    PTHREAD_COND_INITIALIZER,
-    PTHREAD_COND_INITIALIZER,
-    PTHREAD_COND_INITIALIZER
-};
-
-WebsocketRecvQueue m_websocket_queue[4];
 int nClient = 0;
 int nDelayedCallback = 0;
 
-int ViaSocket = -1;
 
 int ReadPriv = 0;
 int WritePriv = 0;
@@ -72,43 +56,16 @@ double g_GoalLatitude     =  35.49746;
 double g_GoalLongitude    = 139.40504;
 
 using namespace std;
-static int callback_data_def(libwebsocket_context *context,
-                             struct libwebsocket *wsi,
-                             enum libwebsocket_callback_reasons reason,
-                             void *user, void *in, size_t len);
-static int callback_ctrl_def(libwebsocket_context *context,
-                             struct libwebsocket *wsi,
-                             enum libwebsocket_callback_reasons reason,
-                             void *user, void *in, size_t len);
-static int callback_data_cust(libwebsocket_context *context,
-                              struct libwebsocket *wsi,
-                              enum libwebsocket_callback_reasons reason,
-                              void *user, void *in, size_t len);
-static int callback_ctrl_cust(libwebsocket_context *context,
-                              struct libwebsocket *wsi,
-                              enum libwebsocket_callback_reasons reason,
-                              void *user, void *in, size_t len);
-libwebsocket_protocols protocols[] = {
-    {"standarddatamessage-only", callback_data_def, 0},
-    {NULL, NULL, -1}
+#define _D_URI_FORM "ws://%s:%d"
+#define _D_HOST_STR "127.0.0.1"
+const int protocols_sz = 4;
+const char* protocolsName[protocols_sz] = {
+    "standarddatamessage-only",
+    "standardcontrolmessage-only",
+    "customdatamessage-only",
+    "customcontrolmessage-only"
 };
 
-libwebsocket_protocols protocols2[] = {
-    {"standardcontrolmessage-only", callback_ctrl_def, 0},
-    {NULL, NULL, -1}
-};
-
-libwebsocket_protocols protocols3[] = {
-    {"customdatamessage-only", callback_data_cust, 0},
-    {NULL, NULL, -1}
-};
-
-libwebsocket_protocols protocols4[] = {
-    {"customcontrolmessage-only", callback_ctrl_cust, 0},
-    {NULL, NULL, -1}
-};
-
-/* Modify I/F MessageQueue -> Websocket End */
 
 CGtCtrl::CGtCtrl()
 {
@@ -192,46 +149,15 @@ bool CGtCtrl::Initialize()
         return false;
     }
 
-    /* Modify I/F MessageQueue -> Websocket Start */
-    if (!m_websocket_client[0].start(m_websocket_port[0], "lo",
-                                     protocols,
-                                     &m_websocket_mutex[0],
-                                     &m_websocket_cond[0],
-                                     &m_websocket_queue[0])) {
-        return false;
-    }
-    if (pthread_cond_wait(&m_websocket_cond[0], &m_websocket_mutex[0]) != 0) {
-        std::cerr << "Failed to wait signal" << std::endl;
-    }
-    if (!m_websocket_client[1].start(m_websocket_port[1], "lo",
-                                     protocols2,
-                                     &m_websocket_mutex[1],
-                                     &m_websocket_cond[1],
-                                     &m_websocket_queue[1])) {
-        return false;
-    }
-    if (pthread_cond_wait(&m_websocket_cond[1], &m_websocket_mutex[1]) != 0) {
-        std::cerr << "Failed to wait signal" << std::endl;
-    }
-    if (!m_websocket_client[2].start(m_websocket_port[2], "lo",
-                                     protocols3,
-                                     &m_websocket_mutex[2],
-                                     &m_websocket_cond[2],
-                                     &m_websocket_queue[2])) {
-        return false;
-    }
-    if (pthread_cond_wait(&m_websocket_cond[2], &m_websocket_mutex[2]) != 0) {
-        std::cerr << "Failed to wait signal" << std::endl;
-    }
-    if (!m_websocket_client[3].start(m_websocket_port[3], "lo",
-                                     protocols4,
-                                     &m_websocket_mutex[3],
-                                     &m_websocket_cond[3],
-                                     &m_websocket_queue[3])) {
-        return false;
-    }
-    if (pthread_cond_wait(&m_websocket_cond[3], &m_websocket_mutex[3]) != 0) {
-        std::cerr << "Failed to wait signal" << std::endl;
+    char uri[128];
+    for (int i = 0; i < protocols_sz; i++) {
+        sprintf(uri, _D_URI_FORM, _D_HOST_STR, m_ambpicomm_port[i]);
+        if (false == m_ambpicomm_client[i].start(uri, protocolsName[i])) {
+            return false;   // connect fail
+        }
+        if (false == m_ambpicomm_client[i].threadCondWait()) {
+            std::cerr << "Failed to wait signal (" << i << ")" << std::endl;
+        }
     }
 
     const char *vi = "LOCATION";
@@ -257,6 +183,7 @@ bool CGtCtrl::Terminate()
 #define sDIRECTION      "DIRECTION"
 #define sLOCATION       "LOCATION"
 #define sSHIFT          "SHIFT"
+#define sLIGHTSTATUS    "LIGHTSTATUS"
 void CGtCtrl::Run()
 {
     g_bStopFlag = true;
@@ -347,11 +274,15 @@ void CGtCtrl::Run()
                     shiftpos = pmCar.getValue();
                 }
             }
-
+            /**
+             * TURN SIGNAL(WINKER) & LIGHTSTATUS
+             */
+            bool bTurnSignal = false;
             if (number == myConf.m_nWinkR) {
                 if (value != 0) {
 
                     m_stVehicleInfo.bWinkR = !m_stVehicleInfo.bWinkR;
+                    m_stVehicleInfo.bWinkL = false;
                     if (m_stVehicleInfo.bWinkR)
                         m_stVehicleInfo.nWinkerPos = WINKER_RIGHT;
                     else
@@ -361,12 +292,14 @@ void CGtCtrl::Run()
                     int wpos =
                         m_stVehicleInfo.nWinkerPos == WINKER_RIGHT ? 1 : 0;
                     SendVehicleInfo(dataport_def, vi, wpos);
+                    bTurnSignal = true;
                 }
             }
 
             if (number == myConf.m_nWinkL) {
                 if (value != 0) {
                     m_stVehicleInfo.bWinkL = !m_stVehicleInfo.bWinkL;
+                    m_stVehicleInfo.bWinkR = false;
                     if (m_stVehicleInfo.bWinkL)
                         m_stVehicleInfo.nWinkerPos = WINKER_LEFT;
                     else
@@ -376,9 +309,23 @@ void CGtCtrl::Run()
                     int wpos =
                         m_stVehicleInfo.nWinkerPos == WINKER_LEFT ? 2 : 0;
                     SendVehicleInfo(dataport_def, vi, wpos);
+                    bTurnSignal = true;
                 }
             }
 
+            if (true == bTurnSignal) {
+                const size_t LSsz = 8;                                                              
+                char data[LSsz];                                                                    
+                memset(data, 0, sizeof(data));
+                if (WINKER_LEFT == m_stVehicleInfo.nWinkerPos) {
+                    data[1] = 1;
+                }
+                else if (WINKER_RIGHT == m_stVehicleInfo.nWinkerPos) {
+                    data[2] = 1;
+                }
+                SendVehicleInfo(dataport_def, sLIGHTSTATUS, &data[0], LSsz);
+            }
+
             break;
         }
         pmCar.updateAvg();
@@ -1006,7 +953,7 @@ bool CGtCtrl::sendVehicleInfo( /*int & send_id, long priority, */
     SetMQKeyData(&mqMsg[0], sizeof(mqMsg), priority, key, adata,
                  sizeof(adata));
 
-    if (!m_websocket_client[type].
+    if (!m_ambpicomm_client[type].
         send(reinterpret_cast < char *>(mqMsg), sizeof(mqMsg)))
     {
         std::cerr << "Failed to send data(" << errno << ")." << std::endl;
@@ -1335,7 +1282,7 @@ bool CGtCtrl::LoadConfigJsonCommon(JsonReader *reader)
                            subkey1, confreaderror->message);
                     return false;
                 }
-                m_websocket_port[i * 2] = json_reader_get_int_value(reader);
+                m_ambpicomm_port[i * 2] = json_reader_get_int_value(reader);
                 json_reader_end_member(reader);
 
                 if (!json_reader_read_member(reader, subkey2)) {
@@ -1351,7 +1298,7 @@ bool CGtCtrl::LoadConfigJsonCommon(JsonReader *reader)
                            subkey2, confreaderror->message);
                     return false;
                 }
-                m_websocket_port[i * 2 + 1] =
+                m_ambpicomm_port[i * 2 + 1] =
                     json_reader_get_int_value(reader);
                 json_reader_end_member(reader);
                 json_reader_end_member(reader);
@@ -1530,161 +1477,6 @@ void CGtCtrl::CheckSendResult(int mqid)
     }
 }
 
-/* Modify I/F MessageQueue -> Websocket Start */
-static int callback_data_def(libwebsocket_context * context,
-                             struct libwebsocket *wsi,
-                             enum libwebsocket_callback_reasons reason,
-                             void *user, void *in, size_t len)
-{
-    switch (reason) {
-    case LWS_CALLBACK_CLIENT_RECEIVE:{
-            if (pthread_mutex_lock(&m_websocket_mutex[dataport_def]) != 0) {
-                std::cerr << "Failed to lock mutex" << std::endl;
-            }
-            char recvDataMsgBuf[sizeof(KeyDataMsg_t) + MsgQueueMaxMsgSize];
-            memset(&recvDataMsgBuf, 0, sizeof(recvDataMsgBuf));
-            memcpy(&recvDataMsgBuf, reinterpret_cast < char *>(in), len);
-            m_websocket_queue[dataport_def].push((&recvDataMsgBuf[0]),
-                                                 sizeof(recvDataMsgBuf));
-            pthread_cond_signal(&m_websocket_cond[dataport_def]);
-            if (pthread_mutex_unlock(&m_websocket_mutex[dataport_def]) != 0) {
-                std::cerr << "Failed to unlock mutex" << std::endl;
-            }
-            break;
-        }
-    case LWS_CALLBACK_CLIENT_ESTABLISHED:
-        if (pthread_mutex_lock(&m_websocket_mutex[dataport_def]) != 0) {
-            std::cerr << "Failed to lock mutex" << std::endl;
-        }
-        if (pthread_cond_signal(&m_websocket_cond[dataport_def]) != 0) {
-            std::cerr << "Failed to issue cond_signal" << std::endl;
-        }
-        if (pthread_mutex_unlock(&m_websocket_mutex[dataport_def]) != 0) {
-            std::cerr << "Failed to unlock mutex" << std::endl;
-        }
-        break;
-    default:
-        break;
-    }
-    return 0;
-}
-
-static int callback_ctrl_def(libwebsocket_context * context,
-                             struct libwebsocket *wsi,
-                             enum libwebsocket_callback_reasons reason,
-                             void *user, void *in, size_t len)
-{
-    switch (reason) {
-    case LWS_CALLBACK_CLIENT_RECEIVE:{
-            if (pthread_mutex_lock(&m_websocket_mutex[ctrlport_def]) != 0) {
-                std::cerr << "Failed to lock mutex" << std::endl;
-            }
-            char recvDataMsgBuf[sizeof(KeyDataMsg_t) + MsgQueueMaxMsgSize];
-            memset(&recvDataMsgBuf, 0, sizeof(recvDataMsgBuf));
-            memcpy(&recvDataMsgBuf, reinterpret_cast < char *>(in), len);
-            m_websocket_queue[ctrlport_def].push((&recvDataMsgBuf[0]),
-                                                 sizeof(recvDataMsgBuf));
-            pthread_cond_signal(&m_websocket_cond[ctrlport_def]);
-            if (pthread_mutex_unlock(&m_websocket_mutex[ctrlport_def]) != 0) {
-                std::cerr << "Failed to unlock mutex" << std::endl;
-            }
-            break;
-        }
-    case LWS_CALLBACK_CLIENT_ESTABLISHED:
-        if (pthread_mutex_lock(&m_websocket_mutex[ctrlport_def]) != 0) {
-            std::cerr << "Failed to lock mutex" << std::endl;
-        }
-        if (pthread_cond_signal(&m_websocket_cond[ctrlport_def]) != 0) {
-            std::cerr << "Failed to issue cond_signal" << std::endl;
-        }
-        if (pthread_mutex_unlock(&m_websocket_mutex[ctrlport_def]) != 0) {
-            std::cerr << "Failed to unlock mutex" << std::endl;
-        }
-        break;
-    default:
-        break;
-    }
-    return 0;
-}
-
-static int callback_data_cust(libwebsocket_context * context,
-                              struct libwebsocket *wsi,
-                              enum libwebsocket_callback_reasons reason,
-                              void *user, void *in, size_t len)
-{
-    switch (reason) {
-    case LWS_CALLBACK_CLIENT_RECEIVE:{
-            if (pthread_mutex_lock(&m_websocket_mutex[dataport_cust]) != 0) {
-                std::cerr << "Failed to lock mutex" << std::endl;
-            }
-            char recvDataMsgBuf[sizeof(KeyDataMsg_t) + MsgQueueMaxMsgSize];
-            memset(&recvDataMsgBuf, 0, sizeof(recvDataMsgBuf));
-            memcpy(&recvDataMsgBuf, reinterpret_cast < char *>(in), len);
-            m_websocket_queue[dataport_cust].push((&recvDataMsgBuf[0]),
-                                                  sizeof(recvDataMsgBuf));
-            pthread_cond_signal(&m_websocket_cond[dataport_cust]);
-            if (pthread_mutex_unlock(&m_websocket_mutex[dataport_cust]) != 0) {
-                std::cerr << "Failed to unlock mutex" << std::endl;
-            }
-            break;
-        }
-    case LWS_CALLBACK_CLIENT_ESTABLISHED:
-        if (pthread_mutex_lock(&m_websocket_mutex[dataport_cust]) != 0) {
-            std::cerr << "Failed to lock mutex" << std::endl;
-        }
-        if (pthread_cond_signal(&m_websocket_cond[dataport_cust]) != 0) {
-            std::cerr << "Failed to issue cond_signal" << std::endl;
-        }
-        if (pthread_mutex_unlock(&m_websocket_mutex[dataport_cust]) != 0) {
-            std::cerr << "Failed to unlock mutex" << std::endl;
-        }
-        break;
-    default:
-        break;
-    }
-    return 0;
-}
-
-static int callback_ctrl_cust(libwebsocket_context * context,
-                              struct libwebsocket *wsi,
-                              enum libwebsocket_callback_reasons reason,
-                              void *user, void *in, size_t len)
-{
-    switch (reason) {
-    case LWS_CALLBACK_CLIENT_RECEIVE:{
-            if (pthread_mutex_lock(&m_websocket_mutex[ctrlport_cust]) != 0) {
-                std::cerr << "Failed to lock mutex" << std::endl;
-            }
-            char recvDataMsgBuf[sizeof(KeyDataMsg_t) + MsgQueueMaxMsgSize];
-            memset(&recvDataMsgBuf, 0, sizeof(recvDataMsgBuf));
-            memcpy(&recvDataMsgBuf, reinterpret_cast < char *>(in), len);
-            m_websocket_queue[ctrlport_cust].push((&recvDataMsgBuf[0]),
-                                                  sizeof(recvDataMsgBuf));
-            pthread_cond_signal(&m_websocket_cond[ctrlport_cust]);
-            if (pthread_mutex_unlock(&m_websocket_mutex[ctrlport_cust]) != 0) {
-                std::cerr << "Failed to unlock mutex" << std::endl;
-            }
-            break;
-        }
-    case LWS_CALLBACK_CLIENT_ESTABLISHED:
-        if (pthread_mutex_lock(&m_websocket_mutex[ctrlport_cust]) != 0) {
-            std::cerr << "Failed to lock mutex" << std::endl;
-        }
-        if (pthread_cond_signal(&m_websocket_cond[ctrlport_cust]) != 0) {
-            std::cerr << "Failed to issue cond_signal" << std::endl;
-        }
-        if (pthread_mutex_unlock(&m_websocket_mutex[ctrlport_cust]) != 0) {
-            std::cerr << "Failed to unlock mutex" << std::endl;
-        }
-        break;
-    default:
-        break;
-    }
-    return 0;
-}
-
-/* Modify I/F MessageQueue -> Websocket End */
-
 /**
  * End of File. (CGtCtrl.cpp)
  */
index 0b64343..1f47617 100644 (file)
@@ -39,7 +39,8 @@
 #include <glib-object.h>
 #include <json-glib/json-glib.h>
 
-#include "Websocket.h"
+
+#include "AmbpiComm.h"
 #if 1
 #define MAX_SPEED   199
 #else
@@ -77,7 +78,6 @@ void MakeFdSet(void);
 void FullMakeFdSet(void);
 
 void DaemonTerminate(int SigNo);
-void CloseAllSocket(void);
 
 
 struct VehicleInfoNameList
@@ -279,8 +279,8 @@ class CGtCtrl
 
     VehicleInfo m_stVehicleInfo;
 
-    int m_websocket_port[4];
-    WebsocketIF m_websocket_client[4];
+    int m_ambpicomm_port[4];
+    AmbpiCommIF m_ambpicomm_client[4];
     KeyEventOptMsg_t m_msgOpt;
     KeyDataMsg_t m_msgDat;
 
index 0041466..d5d7ae5 100644 (file)
@@ -26,7 +26,7 @@
 using namespace std;
 
 /**
- * @breif constructor
+ * @brief constructor
  */
 CJoyStick::CJoyStick()
 {
index badf446..092c05e 100644 (file)
@@ -180,7 +180,7 @@ int CJoyStickEV::ReadData()
 }
 
 /**
- * @breif change input_event value to js_event value
+ * @brief change input_event value to js_event value
  */
 int CJoyStickEV::getJS_EVENT_BUTTON(int& num, int& val,
                                     const struct input_event& s)
@@ -194,7 +194,7 @@ int CJoyStickEV::getJS_EVENT_BUTTON(int& num, int& val,
 }
 
 /**
- * @breif change input_event value to js_event value
+ * @brief change input_event value to js_event value
  */
 int CJoyStickEV::getJS_EVENT_AXIS(int& num, int& val,
                                   const struct input_event& s)
@@ -227,7 +227,7 @@ int CJoyStickEV::getJS_EVENT_AXIS(int& num, int& val,
     return r;
 }
 /**
- * @breif calc value case 1
+ * @brief calc value case 1
  */
 int CJoyStickEV::calc1pm32767(int val, const struct input_absinfo& ai)
 {
@@ -237,7 +237,7 @@ int CJoyStickEV::calc1pm32767(int val, const struct input_absinfo& ai)
     return c;
 }
 /**
- * @breif calc value case 2
+ * @brief calc value case 2
  */
 int CJoyStickEV::calc2pm32767(int val, const struct input_absinfo& ai)
 {
@@ -261,7 +261,7 @@ bool CJoyStickEV::getDeviceName(int fd, char* devNM, size_t sz)
 }
 
 /**
- * @breif device grab
+ * @brief device grab
  */
 bool CJoyStickEV::deviceGrab(int fd)
 {
@@ -276,7 +276,7 @@ bool CJoyStickEV::deviceGrab(int fd)
 }
 
 /**
- * @breif device grab relese
+ * @brief device grab relese
  */
 bool CJoyStickEV::deviceGrabRelese(int fd)
 {
index 295f842..074031f 100644 (file)
@@ -48,7 +48,7 @@ int main(int argc, char **argv)
             bUseGps = true;
             break;
         case 'c':
-            printf("Using WebSocket\n");
+            printf("Using amb plug-in I/F\n");
             comFlg = true;
             break;
         case 't':
index fff0d82..5c98052 100644 (file)
@@ -1,6 +1,6 @@
 bin_PROGRAMS = carsim
 
-carsim_SOURCES = Websocket.h Websocket.cpp CJoyStick.h CJoyStick.cpp CJoyStickEV.h CJoyStickEV.cpp CConf.h CConf.cpp CGtCtrl.h CGtCtrl.cpp CCalc.h CCalc.cpp CAvgCar.h CAvgCar.cpp CarSim_Daemon.cpp
-carsim_LDADD = 
-carsim_CPPFLAGS = -I/usr/include/glib-2.0 -I/usr/include/json-glib-1.0 -I/usr/lib/glib-2.0/include
-carsim_LDFLAGS = -lpthread -ljson-glib-1.0 -lgobject-2.0 -lglib-2.0 -lwebsockets -lrt
+carsim_SOURCES = AmbpiComm.h AmbpiComm.cpp CJoyStick.h CJoyStick.cpp CJoyStickEV.h CJoyStickEV.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-com
+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 = 
diff --git a/src/Websocket.cpp b/src/Websocket.cpp
deleted file mode 100644 (file)
index 194d3fb..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * 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
- *
- */
-/**
- * @brief   websocket I/F
- *
- */
-
-#include <string.h>
-
-#include <iostream>
-
-#include "Websocket.h"
-
-WebsocketRecvQueue::WebsocketRecvQueue()
-: msize(0), maxqueuesize(10)
-{
-    init();
-}
-
-WebsocketRecvQueue::WebsocketRecvQueue(int queuesize)
-: msize(0)
-{
-    maxqueuesize = queuesize;
-    init();
-}
-
-WebsocketRecvQueue::~WebsocketRecvQueue()
-{
-    delete[] mdata;
-    delete[] mdatasize;
-}
-
-bool WebsocketRecvQueue::push(char *data, int datasize)
-{
-    if (datasize > maxdatasize || (msize + 1) > maxqueuesize) {
-        return false;
-    }
-    memset(mdata[msize], 0, maxdatasize);
-    memcpy(mdata[msize], data, datasize);
-    mdatasize[msize] = datasize;
-    msize++;
-    return true;
-}
-
-bool WebsocketRecvQueue::front(char *buf) const
-{
-    if (msize == 0) {
-        return false;
-    }
-    memcpy(buf, mdata[0], mdatasize[0]);
-    return true;
-}
-
-bool WebsocketRecvQueue::empty() const
-{
-    return (msize == 0);
-}
-
-void WebsocketRecvQueue::pop()
-{
-    if (msize > 0) {
-        msize--;
-        for (int i = 0; i < msize; i++) {
-            memset(mdata[i], 0, maxdatasize);
-            memcpy(mdata[i], mdata[i + 1], mdatasize[i + 1]);
-            mdatasize[i] = mdatasize[i + 1];
-        }
-        memset(mdata[msize], 0, maxdatasize);
-        mdatasize[msize] = 0;
-    }
-}
-
-int WebsocketRecvQueue::size() const
-{
-    return msize;
-}
-
-void WebsocketRecvQueue::init()
-{
-    mdata = new char[maxqueuesize][maxdatasize];
-    memset((void *) mdata, 0, maxqueuesize * maxdatasize);
-
-    mdatasize = new int[maxqueuesize];
-
-    memset(mdatasize, 0, maxqueuesize);
-}
-
-WebsocketIF::WebsocketIF()
-:  isready(false), threadid(0)
-{
-}
-
-WebsocketIF::WebsocketIF(int port, char *interface,
-                         libwebsocket_protocols * protocols,
-                         pthread_mutex_t * mtx,
-                         pthread_cond_t * cnd, WebsocketRecvQueue * recvqueue)
-:threadid(0), mutex(mtx), cond(cnd), queue(recvqueue)
-{
-    isready = init(port, interface, protocols, mtx, cnd, recvqueue);
-}
-
-WebsocketIF::~WebsocketIF()
-{
-    if (isready) {
-        int ret;
-        if (threadid != 0) {
-            ret = pthread_cancel(threadid);
-            if (ret != 0) {
-                std::cerr << "Failed to pthread_cancel" << std::endl;
-            }
-        }
-        ret = pthread_join(threadid, NULL);
-        if (ret != 0) {
-            std::cerr << "Failed to pthread_join" << std::endl;
-        }
-        if (context != NULL) {
-            libwebsocket_context_destroy(context);
-            context = NULL;
-        }
-    }
-}
-
-bool WebsocketIF::start(int port, char *interface,
-                        libwebsocket_protocols * protocols,
-                        pthread_mutex_t * mtx,
-                        pthread_cond_t * cnd, WebsocketRecvQueue * recvqueue)
-{
-    if (isready) {
-        return isready;
-    }
-    mutex = mtx;
-    cond = cnd;
-    queue = recvqueue;
-    isready = init(port, interface, protocols, mtx, cnd, recvqueue);
-    return isready;
-}
-
-bool WebsocketIF::send(char *msg, int size)
-{
-    if (!isready) {
-        return isready;
-    }
-
-    char *buf;
-    memset(sendbuf, 0, sizeof(sendbuf));
-    buf = &sendbuf[LWS_SEND_BUFFER_PRE_PADDING];
-    memcpy(buf, msg, size);
-    int ret = libwebsocket_write(websocket,
-                                 reinterpret_cast < unsigned char *>(buf),
-                                 size, LWS_WRITE_BINARY);
-    return (ret == 0);
-}
-
-bool WebsocketIF::recv(char *msg, bool fblocking)
-{
-    if (!isready) {
-        return isready;
-    }
-
-    if (fblocking) {
-        if (queue->empty()) {
-            if (pthread_cond_wait(cond, mutex) != 0) {
-                std::cerr << "Failed to wait signal" << std::endl;
-            }
-        }
-        queue->front(msg);
-        queue->pop();
-    }
-    else {
-        if (queue->empty()) {
-            return false;
-        }
-        else {
-            queue->front(msg);
-            queue->pop();
-        }
-    }
-    return true;
-}
-
-bool WebsocketIF::poll()
-{
-    if (!isready) {
-        return isready;
-    }
-
-    int ret = 0;
-    while (true) {
-        ret = libwebsocket_service(context, 100);
-    }
-}
-
-void *WebsocketIF::loop(void *arg)
-{
-    WebsocketIF *src = reinterpret_cast < WebsocketIF * >(arg);
-    return (void *) src->poll();
-}
-
-bool WebsocketIF::init(int port, char *interface,
-                       libwebsocket_protocols * protocols,
-                       pthread_mutex_t * mtx,
-                       pthread_cond_t * cnd, WebsocketRecvQueue * recvqueue)
-{
-    context = libwebsocket_create_context(CONTEXT_PORT_NO_LISTEN,
-                                          interface, protocols,
-                                          libwebsocket_internal_extensions,
-                                          NULL, NULL, -1, -1, 0);
-    if (context == NULL) {
-        std::cerr << "Failed to create context." << std::endl;
-        return false;
-    }
-    websocket = libwebsocket_client_connect(context, "127.0.0.1", port,
-                                            0, "/", "localhost", "websocket",
-                                            protocols[0].name, -1);
-    if (websocket == NULL) {
-        std::cerr << "Failed to connect server." << std::endl;
-        return false;
-    }
-    if (pthread_create(&threadid, NULL, WebsocketIF::loop,
-                       (void *) this) != 0) {
-        std::cerr << "Failed to create thread." << std::endl;
-        return false;
-    }
-    return true;
-}
diff --git a/src/Websocket.h b/src/Websocket.h
deleted file mode 100644 (file)
index 49749f6..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
- *
- * 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
- *
- */
-/**
- * @brief   websocket I/F
- */
-
-#ifndef _ICO_VIC_WEBSOCKET_H_
-#define _ICO_VIC_WEBSOCKET_H_
-
-#include <sys/time.h>
-
-#include <libwebsockets.h>
-
-const int MsgQueueMaxMsgSize = 128;
-
-struct KeyEventOptMsg_t
-{
-    char KeyEventType[64];
-    struct timeval recordtime;
-    struct KeyEventOpt
-    {
-        int common;
-        int sense;
-        int event_mask;
-    } eventopt;
-};
-
-struct KeyDataMsg_t
-{
-    char KeyEventType[64];
-    struct timeval recordtime;
-    struct KeyData
-    {
-        int common_status;
-        char status[];
-    } data;
-};
-
-class WebsocketRecvQueue
-{
-  public:
-        WebsocketRecvQueue();
-        WebsocketRecvQueue(int queuesize);
-        ~WebsocketRecvQueue();
-    bool push(char *data, int datasize);
-    bool front(char *buf) const;
-    bool empty() const;
-    void pop();
-    int size() const;
-
-    static const int maxdatasize = sizeof(KeyDataMsg_t) + MsgQueueMaxMsgSize;
-  private:
-    void init();
-
-    int maxqueuesize;
-    int msize;
-    char (*mdata)[maxdatasize];
-    int *mdatasize;
-};
-
-class WebsocketIF
-{
-  public:
-    WebsocketIF();
-    WebsocketIF(int port, char *interface, libwebsocket_protocols *protocol,
-                pthread_mutex_t *mtx, pthread_cond_t *cnd,
-                WebsocketRecvQueue *recvqueue);
-        ~WebsocketIF();
-    bool start(int port, char *interface, libwebsocket_protocols *protocol,
-               pthread_mutex_t *mtx, pthread_cond_t *cnd,
-               WebsocketRecvQueue *recvqueue);
-    bool send(char *msg, int size);
-    bool recv(char *msg, bool fbolcking);
-    bool poll();
-    static void *loop(void *arg);
-  private:
-    bool init(int port, char *interface,
-              libwebsocket_protocols *protocol, pthread_mutex_t *mtx,
-              pthread_cond_t *cnd, WebsocketRecvQueue *recvqueue);
-
-    bool isready;
-    libwebsocket_context *context;
-    libwebsocket *websocket;
-    pthread_t threadid;
-    pthread_mutex_t *mutex;
-    pthread_cond_t *cond;
-    char sendbuf[LWS_SEND_BUFFER_PRE_PADDING +
-                 WebsocketRecvQueue::maxdatasize +
-                 LWS_SEND_BUFFER_POST_PADDING];
-    WebsocketRecvQueue *queue;
-};
-
-#endif //#ifndef _ICO_VIC_WEBSOCKET_H_