mirror of
https://github.com/eclipse-openvehicle-api/openvehicle-api.git
synced 2026-04-21 03:38:15 +00:00
update parser (#5)
This commit is contained in:
@@ -342,7 +342,8 @@ bool CConnection::AsyncConnect(sdv::IInterfaceAccess* pReceiver)
|
||||
if (m_eStatus != sdv::ipc::EConnectStatus::uninitialized)
|
||||
{
|
||||
for (auto& rprEventCallback : m_lstEventCallbacks)
|
||||
if (rprEventCallback.pCallback) rprEventCallback.pCallback->SetStatus(sdv::ipc::EConnectStatus::connection_error);
|
||||
if (rprEventCallback.pCallback && rprEventCallback.uiCookie)
|
||||
rprEventCallback.pCallback->SetStatus(sdv::ipc::EConnectStatus::connection_error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -456,6 +457,8 @@ uint64_t CConnection::RegisterStatusEventCallback(/*in*/ sdv::IInterfaceAccess*
|
||||
sdv::ipc::IConnectEventCallback* pCallback = pEventCallback->GetInterface<sdv::ipc::IConnectEventCallback>();
|
||||
if (!pCallback) return 0;
|
||||
uint64_t uiCookie = rand();
|
||||
while (!uiCookie)
|
||||
uiCookie = rand();
|
||||
std::unique_lock<std::shared_mutex> lock(m_mtxEventCallbacks);
|
||||
m_lstEventCallbacks.emplace(m_lstEventCallbacks.begin(), std::move(SEventCallback{ uiCookie, pCallback }));
|
||||
return uiCookie;
|
||||
@@ -490,7 +493,10 @@ void CConnection::DestroyObject()
|
||||
// Clear all events callbacks (if not done so already)
|
||||
std::shared_lock<std::shared_mutex> lock(m_mtxEventCallbacks);
|
||||
for (auto& rprEventCallback : m_lstEventCallbacks)
|
||||
{
|
||||
rprEventCallback.uiCookie = 0;
|
||||
rprEventCallback.pCallback = nullptr;
|
||||
}
|
||||
lock.unlock();
|
||||
|
||||
// Just in case... so no calls are made into the destructed class any more.
|
||||
@@ -519,7 +525,10 @@ void CConnection::SetStatus(sdv::ipc::EConnectStatus eStatus)
|
||||
m_eStatus = eStatus;
|
||||
std::shared_lock<std::shared_mutex> lock(m_mtxEventCallbacks);
|
||||
for (auto& rprEventCallback : m_lstEventCallbacks)
|
||||
if (rprEventCallback.pCallback) rprEventCallback.pCallback->SetStatus(eStatus);
|
||||
{
|
||||
if (rprEventCallback.pCallback && rprEventCallback.uiCookie)
|
||||
rprEventCallback.pCallback->SetStatus(eStatus);
|
||||
}
|
||||
|
||||
// If disconnected by force update the disconnect status.
|
||||
if (m_eStatus == sdv::ipc::EConnectStatus::disconnected_forced)
|
||||
@@ -554,12 +563,13 @@ void CConnection::ReceiveMessages()
|
||||
{
|
||||
SetStatus(sdv::ipc::EConnectStatus::communication_error);
|
||||
SDV_LOG_ERROR("No valid shared memory for receiving.");
|
||||
lock.unlock();
|
||||
m_cvStartConnect.notify_all();
|
||||
return;
|
||||
}
|
||||
|
||||
m_cvStartConnect.notify_all();
|
||||
lock.unlock();
|
||||
m_cvStartConnect.notify_all();
|
||||
|
||||
// Read processing
|
||||
auto tpStart = std::chrono::high_resolution_clock::time_point();
|
||||
@@ -623,8 +633,24 @@ void CConnection::ReceiveMessages()
|
||||
case EMsgType::data_fragment:
|
||||
case EMsgType::data:
|
||||
break;
|
||||
case EMsgType::sync_request:
|
||||
TRACE("Receive sync-request message of of ", message.GetSize(), " bytes");
|
||||
break;
|
||||
case EMsgType::sync_answer:
|
||||
TRACE("Receive sync-answer message of of ", message.GetSize(), " bytes");
|
||||
break;
|
||||
case EMsgType::connect_request:
|
||||
TRACE("Receive connect-request message of of ", message.GetSize(), " bytes");
|
||||
break;
|
||||
case EMsgType::connect_answer:
|
||||
TRACE("Receive connect-answer message of of ", message.GetSize(), " bytes");
|
||||
break;
|
||||
case EMsgType::connect_term:
|
||||
TRACE("Receive connect-termination message of of ", message.GetSize(), " bytes");
|
||||
break;
|
||||
default:
|
||||
TRACE("Receive raw data 0x", (void*) &message.GetMsgHdr(), " of ", message.GetSize(), " bytes");
|
||||
TRACE("Received unknown message of type ", (uint32_t) message.GetMsgHdr().eType, " of ", message.GetSize(), " bytes");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1011,7 +1037,7 @@ void CConnection::ReceiveDataFragementMessage(CMessage& rMessage, SDataContext&
|
||||
if (!rMessage.GetFragmentedHdr().uiOffset)
|
||||
{
|
||||
#if ENABLE_REPORTING >= 1
|
||||
TRACE("Start receive fragmented data message of ", rsDataCtxt.uiTotalSize, " bytes");
|
||||
TRACE("Start receive fragmented data message of ", rsDataCtxt.uiTotalSize, " bytes (following the header)");
|
||||
#endif
|
||||
// Read the data directory table...
|
||||
// Note: it is assumed that the table fits in the first message completely.
|
||||
@@ -1029,7 +1055,7 @@ void CConnection::ReceiveDataFragementMessage(CMessage& rMessage, SDataContext&
|
||||
if (!sstream.str().empty()) sstream << ", ";
|
||||
sstream << rptrData.size();
|
||||
}
|
||||
TRACE("Fragmented message has ", rsDataCtxt.seqDataChunks.size(), " of {", sstream.str(), "} bytes");
|
||||
TRACE("Fragmented message has ", rsDataCtxt.seqDataChunks.size(), " chunk of ", sstream.str(), " bytes");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
/// When put to 1, decoupling of receive data is activated (default is not activated).
|
||||
#define ENABLE_DECOUPLING 0
|
||||
|
||||
#if ENABLE_REPORTING > 0
|
||||
#if ENABLE_REPORTING > 0 && !defined(ENABLE_TRACE)
|
||||
/// Enable tracing
|
||||
#define ENABLE_TRACE 1
|
||||
#endif
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
CInProcMemBuffer(const std::string& rssConnectionString);
|
||||
|
||||
/**
|
||||
* \brief Default destructor
|
||||
* @brief Default destructor
|
||||
*/
|
||||
~CInProcMemBuffer() = default;
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
CSharedMemBuffer(CSharedMemBuffer&&) = delete;
|
||||
|
||||
/**
|
||||
* \brief Default destructor
|
||||
* @brief Default destructor
|
||||
*/
|
||||
~CSharedMemBuffer();
|
||||
|
||||
@@ -364,10 +364,15 @@ CSharedMemBuffer<TAccessor>::~CSharedMemBuffer()
|
||||
munmap(m_pBuffer, m_uiSize);
|
||||
if (m_bServer && !m_ssName.empty())
|
||||
shm_unlink((std::string("/") + m_ssName).c_str());
|
||||
if (m_iFileDescr >= 0) close(m_iFileDescr);
|
||||
if (m_bServer && m_pSemaphoreTx)
|
||||
sem_unlink(m_ssSyncTx.c_str());
|
||||
if (m_pSemaphoreTx)
|
||||
sem_close(m_pSemaphoreTx);
|
||||
if (m_bServer && m_pSemaphoreRx)
|
||||
sem_unlink(m_ssSyncRx.c_str());
|
||||
if (m_pSemaphoreRx)
|
||||
sem_close(m_pSemaphoreRx);
|
||||
}
|
||||
|
||||
template <class TAccessor>
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
CSharedMemBuffer(CSharedMemBuffer&&) = delete;
|
||||
|
||||
/**
|
||||
* \brief Default destructor
|
||||
* @brief Default destructor
|
||||
*/
|
||||
~CSharedMemBuffer();
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <thread>
|
||||
#include <queue>
|
||||
#include <condition_variable>
|
||||
#include <atomic>
|
||||
|
||||
// Forward declaration
|
||||
class CConnection;
|
||||
@@ -114,7 +115,7 @@ private:
|
||||
///< connection is scheduled for destruction.
|
||||
std::queue<std::shared_ptr<CConnection>> m_queueScheduledConnectionDestructions; ///< Scheduled connection for destruction.
|
||||
std::thread m_threadScheduledConnectionDestructions; ///< Thread processing the scheduled destructions.
|
||||
bool m_bShutdown = false; ///< Set when shutting down the watchdog
|
||||
std::atomic_bool m_bShutdown = false; ///< Set when shutting down the watchdog
|
||||
};
|
||||
|
||||
#endif // !defined WATCH_DOG_H
|
||||
Reference in New Issue
Block a user