Skip to content

Commit

Permalink
tcpip interface used wrong obid
Browse files Browse the repository at this point in the history
  • Loading branch information
grodansparadis committed Mar 9, 2020
1 parent e36927e commit d36656c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 64 deletions.
4 changes: 3 additions & 1 deletion src/vscp/common/controlobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,9 @@ CControlObject::sendEvent(CClientItem* pClientItem, vscpEvent* peventToSend)

// Save the originating clients id so
// this client don't get the message back
pEvent->obid = pClientItem->m_clientID;
if ( 0 == pEvent->obid) {
pEvent->obid = pClientItem->m_clientID;
}

// Level II events between 512-1023 is recognised by the daemon and
// sent to the correct interface as Level I events if the interface
Expand Down
97 changes: 39 additions & 58 deletions src/vscp/common/retired_functionality/vscpclientthreads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ TXWorkerThread::Entry()
m_pCtrlObject->m_ifVSCP.m_port,
m_pCtrlObject->m_ifVSCP.m_strUser,
m_pCtrlObject->m_ifVSCP.m_strPassword)) {
//::wxGetApp().logMsg ( _("VSCP TX thread - Unable to connect to
syslog( LOG_ERR, ( _("VSCP TX thread - Unable to connect to
//server."), DAEMON_LOGMSG_CRITICAL );
m_pCtrlObject->m_errorControl = VSCP_SESSION_ERROR_UNABLE_TO_CONNECT;
wxPostEvent(m_pCtrlObject->m_pWnd, eventConnectionLost);
Expand Down Expand Up @@ -325,7 +325,7 @@ RXWorkerThread::Entry()
m_pCtrlObject->m_ifVSCP.m_port,
m_pCtrlObject->m_ifVSCP.m_strUser,
m_pCtrlObject->m_ifVSCP.m_strPassword)) {
//::wxGetApp().logMsg ( _("VSCP Receive thread - Unable to connect to
syslog( LOG_ERR, ( _("VSCP Receive thread - Unable to connect to
//server."), DAEMON_LOGMSG_CRITICAL );
m_pCtrlObject->m_errorReceive = VSCP_SESSION_ERROR_UNABLE_TO_CONNECT;
wxPostEvent(m_pCtrlObject->m_pWnd, eventConnectionLost);
Expand Down Expand Up @@ -419,8 +419,7 @@ deviceThread::Entry()

// Load dynamic library
if (!m_wxdll.Load(m_pCtrlObject->m_ifCANAL.m_strPath, wxDL_LAZY)) {
//::wxGetApp().logMsg ( _T ( "vscpd: Unable to load dynamic library." ),
//DAEMON_LOGMSG_CRITICAL );
syslog( LOG_ERR, "vscpd: Unable to load dynamic library." );
return NULL;
}

Expand All @@ -430,8 +429,7 @@ deviceThread::Entry()
if (NULL == (m_pCtrlObject->m_proc_CanalOpen =
(LPFNDLL_CANALOPEN)m_wxdll.GetSymbol(_T ( "CanalOpen" )))) {
// Free the library
//::wxGetApp().logMsg ( _T ( "Unable to get dl entry for CanalOpen." ),
//DAEMON_LOGMSG_CRITICAL );
syslog( LOG_ERR, "Unable to get dl entry for CanalOpen." );
return NULL;
}

Expand All @@ -440,8 +438,7 @@ deviceThread::Entry()
(m_pCtrlObject->m_proc_CanalClose =
(LPFNDLL_CANALCLOSE)m_wxdll.GetSymbol(_T ( "CanalClose" )))) {
// Free the library
//::wxGetApp().logMsg ( _T ( "Unable to get dl entry for CanalClose." ),
//DAEMON_LOGMSG_CRITICAL );
syslog( LOG_ERR, "Unable to get dl entry for CanalClose." );
return NULL;
}

Expand All @@ -450,17 +447,15 @@ deviceThread::Entry()
(m_pCtrlObject->m_proc_CanalGetLevel =
(LPFNDLL_CANALGETLEVEL)m_wxdll.GetSymbol(_T ( "CanalGetLevel" )))) {
// Free the library
//::wxGetApp().logMsg ( _T ( "Unable to get dl entry for CanalGetLevel."
//), DAEMON_LOGMSG_CRITICAL );
syslog( LOG_ERR, "Unable to get dl entry for CanalGetLevel.");
return NULL;
}

// * * * * CANAL SEND * * * *
if (NULL == (m_pCtrlObject->m_proc_CanalSend =
(LPFNDLL_CANALSEND)m_wxdll.GetSymbol(_T ( "CanalSend" )))) {
// Free the library
//::wxGetApp().logMsg ( _T ( "Unable to get dl entry for CanalSend." ),
//DAEMON_LOGMSG_CRITICAL );
syslog( LOG_ERR, "Unable to get dl entry for CanalSend." );
return NULL;
}

Expand All @@ -469,8 +464,7 @@ deviceThread::Entry()
(LPFNDLL_CANALDATAAVAILABLE)m_wxdll.GetSymbol(
_T ( "CanalDataAvailable" )))) {
// Free the library
//::wxGetApp().logMsg ( _T ( "Unable to get dl entry for
//CanalDataAvailable." ), DAEMON_LOGMSG_CRITICAL );
syslog( LOG_ERR,"Unable to get dl entry for CanalDataAvailable.");
return NULL;
}

Expand All @@ -479,8 +473,7 @@ deviceThread::Entry()
(m_pCtrlObject->m_proc_CanalReceive =
(LPFNDLL_CANALRECEIVE)m_wxdll.GetSymbol(_T ( "CanalReceive" )))) {
// Free the library
//::wxGetApp().logMsg ( _T ( "Unable to get dl entry for CanalReceive."
//), DAEMON_LOGMSG_CRITICAL );
syslog( LOG_ERR, "Unable to get dl entry for CanalReceive.");
return NULL;
}

Expand All @@ -489,8 +482,7 @@ deviceThread::Entry()
(LPFNDLL_CANALGETSTATUS)m_wxdll.GetSymbol(
_T ( "CanalGetStatus" )))) {
// Free the library
//::wxGetApp().logMsg ( _T ( "Unable to get dl entry for
//CanalGetStatus." ), DAEMON_LOGMSG_CRITICAL );
syslog( LOG_ERR, "Unable to get dl entry for CanalGetStatus.");
return NULL;
}

Expand All @@ -499,8 +491,8 @@ deviceThread::Entry()
(LPFNDLL_CANALGETSTATISTICS)m_wxdll.GetSymbol(
_T ( "CanalGetStatistics" )))) {
// Free the library
//::wxGetApp().logMsg ( _T ( "Unable to get dl entry for
//CanalGetStatistics." ), DAEMON_LOGMSG_CRITICAL );
syslog( LOG_ERR, "Unable to get dl entry for
CanalGetStatistics.");
return NULL;
}

Expand All @@ -509,8 +501,8 @@ deviceThread::Entry()
(LPFNDLL_CANALSETFILTER)m_wxdll.GetSymbol(
_T ( "CanalSetFilter" )))) {
// Free the library
//::wxGetApp().logMsg ( _T ( "Unable to get dl entry for
//CanalSetFilter." ), DAEMON_LOGMSG_CRITICAL );
syslog( LOG_ERR, "Unable to get dl entry for
CanalSetFilter." );
return NULL;
}

Expand All @@ -519,8 +511,7 @@ deviceThread::Entry()
(m_pCtrlObject->m_proc_CanalSetMask =
(LPFNDLL_CANALSETMASK)m_wxdll.GetSymbol(_T ( "CanalSetMask" )))) {
// Free the library
//::wxGetApp().logMsg ( _T ( "Unable to get dl entry for CanalSetMask."
//), DAEMON_LOGMSG_CRITICAL );
syslog( LOG_ERR, "Unable to get dl entry for CanalSetMask.");
return NULL;
}

Expand All @@ -529,8 +520,7 @@ deviceThread::Entry()
(LPFNDLL_CANALGETVERSION)m_wxdll.GetSymbol(
_T ( "CanalGetVersion" )))) {
// Free the library
//::wxGetApp().logMsg ( _T ( "Unable to get dl entry for
//CanalGetVersion." ), DAEMON_LOGMSG_CRITICAL );
syslog( LOG_ERR, "Unable to get dl entry for CanalGetVersion.");
return NULL;
}

Expand All @@ -539,8 +529,7 @@ deviceThread::Entry()
(LPFNDLL_CANALGETDLLVERSION)m_wxdll.GetSymbol(
_T ( "CanalGetDllVersion" )))) {
// Free the library
//::wxGetApp().logMsg ( _T ( "Unable to get dl entry for
//CanalGetDllVersion." ), DAEMON_LOGMSG_CRITICAL );
syslog( LOG_ERR, "Unable to get dl entry for CanalGetDllVersion.");
return NULL;
}

Expand All @@ -549,8 +538,7 @@ deviceThread::Entry()
(LPFNDLL_CANALGETVENDORSTRING)m_wxdll.GetSymbol(
_T ( "CanalGetVendorString" )))) {
// Free the library
//::wxGetApp().logMsg ( _T ( "Unable to get dl entry for
//CanalGetVendorString." ), DAEMON_LOGMSG_CRITICAL );
syslog( LOG_ERR, ( "Unable to get dl entry for CanalGetVendorString.");
return NULL;
}

Expand All @@ -564,32 +552,26 @@ deviceThread::Entry()
if (NULL == (m_pCtrlObject->m_proc_CanalBlockingSend =
(LPFNDLL_CANALBLOCKINGSEND)m_wxdll.GetSymbol(
_T ( "CanalBlockingSend" )))) {
//::wxGetApp().logMsg ( _T ( "Unable to get dl entry for
//CanalBlockingSend. Probably Generation 1 driver." ),
// DAEMON_LOGMSG_CRITICAL
//);
syslog( LOG_ERR, "Unable to get dl entry for
CanalBlockingSend. Probably Generation 1 driver." );
m_pCtrlObject->m_proc_CanalBlockingSend = NULL;
}

// * * * * CANAL BLOCKING RECEIVE * * * *
if (NULL == (m_pCtrlObject->m_proc_CanalBlockingReceive =
(LPFNDLL_CANALBLOCKINGRECEIVE)m_wxdll.GetSymbol(
_T ( "CanalBlockingReceive" )))) {
//::wxGetApp().logMsg ( _T ( "Unable to get dl entry for
//CanalBlockingReceive. Probably Generation 1 driver." ),
// DAEMON_LOGMSG_CRITICAL
//);
syslog( LOG_ERR, "Unable to get dl entry for
CanalBlockingReceive. Probably Generation 1 driver." );
m_pCtrlObject->m_proc_CanalBlockingReceive = NULL;
}

// * * * * CANAL GET DRIVER INFO * * * *
if (NULL == (m_pCtrlObject->m_proc_CanalGetdriverInfo =
(LPFNDLL_CANALGETDRIVERINFO)m_wxdll.GetSymbol(
_T ( "CanalGetDriverInfo" )))) {
//::wxGetApp().logMsg ( _T ( "Unable to get dl entry for
//CanalGetDriverInfo. Probably Generation 1 driver." ),
// DAEMON_LOGMSG_CRITICAL
//);
syslog( LOG_ERR, ( "Unable to get dl entry for
CanalGetDriverInfo. Probably Generation 1 driver.");
m_pCtrlObject->m_proc_CanalGetdriverInfo = NULL;
}

Expand All @@ -604,8 +586,7 @@ deviceThread::Entry()

// Check if the driver opened properly
if (0 == m_pCtrlObject->m_openHandle) {
//::wxGetApp().logMsg ( _T ( "Driver failed to open." ),
//DAEMON_LOGMSG_CRITICAL );
syslog( LOG_ERR, "Driver failed to open.");
return NULL;
}

Expand Down Expand Up @@ -637,16 +618,16 @@ deviceThread::Entry()
if (wxTHREAD_NO_ERROR == (err = m_pwriteThread->Create())) {
m_pwriteThread->SetPriority(WXTHREAD_MAX_PRIORITY);
if (wxTHREAD_NO_ERROR != (err = m_pwriteThread->Run())) {
//::wxGetApp().logMsg ( _("Unable to run device write
//worker thread."), DAEMON_LOGMSG_CRITICAL );
syslog( LOG_ERR,"Unable to run device write
worker thread.");
}
} else {
//::wxGetApp().logMsg ( _("Unable to create device write
//worker thread."), DAEMON_LOGMSG_CRITICAL );
syslog( LOG_ERR, "Unable to create device write
worker thread.");
}
} else {
//::wxGetApp().logMsg ( _("Unable to allocate memory for device
//write worker thread."), DAEMON_LOGMSG_CRITICAL );
syslog( LOG_ERR, "Unable to allocate memory for device
write worker thread.");
}

/////////////////////////////////////////////////////////////////////////////
Expand All @@ -660,16 +641,16 @@ deviceThread::Entry()
if (wxTHREAD_NO_ERROR == (err = m_preceiveThread->Create())) {
m_preceiveThread->SetPriority(WXTHREAD_MAX_PRIORITY);
if (wxTHREAD_NO_ERROR != (err = m_preceiveThread->Run())) {
//::wxGetApp().logMsg ( _("Unable to run device receive
//worker thread."), DAEMON_LOGMSG_CRITICAL );
syslog( LOG_ERR, "Unable to run device receive
worker thread.");
}
} else {
//::wxGetApp().logMsg ( _("Unable to create device receive
//worker thread."), DAEMON_LOGMSG_CRITICAL );
syslog( LOG_ERR, "Unable to create device receive
worker thread.");
}
} else {
//::wxGetApp().logMsg ( _("Unable to allocate memory for device
//receive worker thread."), DAEMON_LOGMSG_CRITICAL );
syslog( LOG_ERR, "Unable to allocate memory for device
receive worker thread.");
}

// Just sit and wait until the end
Expand All @@ -690,8 +671,8 @@ deviceThread::Entry()

bActivity = false;
/////////////////////////////////////////////////////////////////////////////
// Receive from device
// //
// Receive from device
//
/////////////////////////////////////////////////////////////////////////////
canalMsg msg;
if (m_pCtrlObject->m_proc_CanalDataAvailable(
Expand Down
1 change: 1 addition & 0 deletions src/vscp/common/tcpipsrv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,7 @@ tcpipClientObj::handleClientSend(void)
// Get GUID
std::string strGUID;
if (!tokens.empty()) {

strGUID = tokens.front();
tokens.pop_front();

Expand Down
6 changes: 2 additions & 4 deletions src/vscp/common/vscphelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2752,13 +2752,11 @@ vscp_setEventGuidFromString(vscpEvent* pEvent, const std::string& strGUID)
} else {
std::deque<std::string> tokens;
vscp_split(tokens, strGUID, ":");
for (int i = 0; i < (int)MIN(16, tokens.size()); i++) {
size_t cnt = tokens.size();
for (int i = 0; i < (int)MIN(16, cnt); i++) {
pEvent->GUID[i] =
(uint8_t)stol(tokens.front().c_str(), nullptr, 16);
tokens.pop_front();
// If no tokens left no use to continue
if (tokens.size())
break;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/vscp/daemon/linux/vscpd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ getDebugValues(const char* optarg)
std::string attribute = optarg;
std::deque<std::string> tokens;
vscp_split(tokens, attribute, ",");
for (size_t idx = 0; idx < MIN(8, tokens.size()); idx++) {
size_t cnt = tokens.size();
for (size_t idx = 0; idx < MIN(8, cnt); idx++) {
if (tokens.size()) {
uint32_t val = vscp_readStringValue(tokens.front());
m_gdebugArray[idx] = val;
Expand Down

0 comments on commit d36656c

Please sign in to comment.