From beb0b7958691da0c8e4466bfe37b97b4c1aadd33 Mon Sep 17 00:00:00 2001 From: Ake Hedman Date: Wed, 3 Jun 2020 22:30:58 +0200 Subject: [PATCH] Fixed problem with GUID assignment for drivers --- VERSION.m4 | 4 ++-- configure | 26 +++++++++++++------------- src/vscp/common/clientlist.cpp | 31 ++++++++++++++++++++++++++++--- src/vscp/common/clientlist.h | 9 +++++++++ src/vscp/common/controlobject.cpp | 25 +++++++++++++++++++++++++ src/vscp/common/controlobject.h | 17 +++++++++++++++-- src/vscp/common/devicethread.cpp | 2 +- src/vscp/common/version.h | 6 +++--- tests/helperlib/Makefile | 2 +- 9 files changed, 97 insertions(+), 25 deletions(-) diff --git a/VERSION.m4 b/VERSION.m4 index 56038f0f2..112c6322b 100644 --- a/VERSION.m4 +++ b/VERSION.m4 @@ -1,7 +1,7 @@ m4_define([release_debian], [1]) m4_define([major_version], [14]) m4_define([minor_version], [0]) -m4_define([release_version], [3]) -m4_define([build_version], [5]) +m4_define([release_version], [4]) +m4_define([build_version], [1]) m4_define([package_version],['major_version.minor_version.release_version']) m4_define([full_version],['major_version.minor_version.release_version.build_version']) \ No newline at end of file diff --git a/configure b/configure index 94d320e13..47afc1e87 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for vscp '14.0.3'. +# Generated by GNU Autoconf 2.69 for vscp '14.0.4'. # # Report bugs to . # @@ -580,8 +580,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='vscp' PACKAGE_TARNAME='vscp' -PACKAGE_VERSION=''14.0.3'' -PACKAGE_STRING='vscp '14.0.3'' +PACKAGE_VERSION=''14.0.4'' +PACKAGE_STRING='vscp '14.0.4'' PACKAGE_BUGREPORT='akhe@vscp.org' PACKAGE_URL='' @@ -1269,7 +1269,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures vscp '14.0.3' to adapt to many kinds of systems. +\`configure' configures vscp '14.0.4' to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1331,7 +1331,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of vscp '14.0.3':";; + short | recursive ) echo "Configuration of vscp '14.0.4':";; esac cat <<\_ACEOF @@ -1432,7 +1432,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -vscp configure '14.0.3' +vscp configure '14.0.4' generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2076,7 +2076,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by vscp $as_me '14.0.3', which was +It was created by vscp $as_me '14.0.4', which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -6725,9 +6725,9 @@ fi MAJOR_VERSION=14 MINOR_VERSION=0 -RELEASE_VERSION=3 -BUILD_VERSION=5 -RELEASE_DEBIAN=5 +RELEASE_VERSION=4 +BUILD_VERSION=1 +RELEASE_DEBIAN=1 ac_config_files="$ac_config_files Makefile m4/Makefile src/vscp/daemon/linux/Makefile src/vscp/vscp-mkpasswd/Makefile src/vscp/vscpcmd/Makefile tests/helperlib/Makefile" @@ -7241,7 +7241,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by vscp $as_me '14.0.3', which was +This file was extended by vscp $as_me '14.0.4', which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -7303,7 +7303,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -vscp config.status '14.0.3' +vscp config.status '14.0.4' configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -8024,7 +8024,7 @@ fi echo echo " VSCP configuration" echo "--------------------------------------------" -echo "VSCP version : ${PACKAGE_VERSION} (14.0.3.build_versio +echo "VSCP version : ${PACKAGE_VERSION} (14.0.4.build_versio n)" echo "System : `uname -a` " echo "Architecture : $(arch)" diff --git a/src/vscp/common/clientlist.cpp b/src/vscp/common/clientlist.cpp index 10b0cd848..4eda19764 100644 --- a/src/vscp/common/clientlist.cpp +++ b/src/vscp/common/clientlist.cpp @@ -271,11 +271,10 @@ CClientList::findFreeId(uint16_t* pid) bool CClientList::addClient(CClientItem* pClientItem, uint32_t id) { - std::deque::iterator it; - // Check pointer - if (NULL == pClientItem) + if (NULL == pClientItem) { return false; + } pClientItem->m_clientID = id ? id : 1; @@ -286,6 +285,7 @@ CClientList::addClient(CClientItem* pClientItem, uint32_t id) } // We try to assign requested id + std::deque::iterator it; for (it = m_itemList.begin(); it != m_itemList.end(); ++it) { CClientItem* pItem = *it; @@ -302,6 +302,31 @@ CClientList::addClient(CClientItem* pClientItem, uint32_t id) return true; } +/////////////////////////////////////////////////////////////////////////////// +// addClient +// + +bool +CClientList::addClient(CClientItem* pClientItem, cguid& guid) +{ + // Check pointer + if (NULL == pClientItem) { + return false; + } + + if ( !addClient(pClientItem) ) { + return false; + } + + // Set the guid + pClientItem->m_guid = guid; + + // Make sure nickname id is zero + pClientItem->m_guid.setNicknameID(0); + + return true; +} + /////////////////////////////////////////////////////////////////////////////// // removeClient // diff --git a/src/vscp/common/clientlist.h b/src/vscp/common/clientlist.h index 36b869ca5..24bcd0d9b 100644 --- a/src/vscp/common/clientlist.h +++ b/src/vscp/common/clientlist.h @@ -243,6 +243,15 @@ class CClientList */ bool addClient(CClientItem *pClientItem, uint32_t id = 0); + /*! + Add a client to the list using set GUID + @param pClientItem Client to add + @param guid The guid that is used for the client. Two least + significant bytes will be set to zero. + @return true om success. + */ + bool addClient(CClientItem* pClientItem, cguid& guid); + /*! Remove a client from the list @param pClientItem Pointer to client item diff --git a/src/vscp/common/controlobject.cpp b/src/vscp/common/controlobject.cpp index 34faff697..d7ed4deec 100644 --- a/src/vscp/common/controlobject.cpp +++ b/src/vscp/common/controlobject.cpp @@ -1485,6 +1485,11 @@ CControlObject::sendEvent(CClientItem* pClientItem, vscpEventEx* pex) bool CControlObject::addClient(CClientItem* pClientItem, uint32_t id) { + // Check pointer + if ( NULL == pClientItem ) { + return false; + } + // Add client to client list if (!m_clientList.addClient(pClientItem, id)) { return false; @@ -1500,6 +1505,26 @@ CControlObject::addClient(CClientItem* pClientItem, uint32_t id) return true; } +////////////////////////////////////////////////////////////////////////////// +// addClient - GUID (for drivers with set GUID) +// + +bool +CControlObject::addClient(CClientItem* pClientItem, cguid& guid) +{ + // Check pointer + if ( NULL == pClientItem ) { + return false; + } + + // Add client to client list + if (!m_clientList.addClient(pClientItem, guid)) { + return false; + } + + return true; +} + ////////////////////////////////////////////////////////////////////////////// // removeClient // diff --git a/src/vscp/common/controlobject.h b/src/vscp/common/controlobject.h index ed0d8d180..aed9524f7 100644 --- a/src/vscp/common/controlobject.h +++ b/src/vscp/common/controlobject.h @@ -198,15 +198,28 @@ class CControlObject { bool stopClientMsgWorkerThread(void); /*! - Add a new client to the clinet list + Add a new client to the client list @param Pointer to client that should be added. @param Normally not used but can be used to set a special client id. @return True on success. - */ + */ bool addClient(CClientItem* pClientItem, uint32_t id = 0); + /*! + Add a new client to the client list using GUID. + + This add client method is for drivers that specify a + full GUID (two lsb nilled). + + @param Pointer to client that should be added. + @param guid The guid that is used for the client. Two least + significant bytes will be set to zero. + @return True on success. + */ + bool addClient(CClientItem* pClientItem, cguid& guid); + /*! Add a known node @param guid Real GUID for node diff --git a/src/vscp/common/devicethread.cpp b/src/vscp/common/devicethread.cpp index c06778b55..0cec38eee 100644 --- a/src/vscp/common/devicethread.cpp +++ b/src/vscp/common/devicethread.cpp @@ -102,7 +102,7 @@ deviceThread(void* pData) // Add the client to the Client List pthread_mutex_lock(&pObj->m_clientList.m_mutexItemList); if (!pObj->addClient(pClientItem, - pDevItem->m_interface_guid.getClientID())) { + pDevItem->m_interface_guid) ) { // Failed to add client delete pDevItem->m_pClientItem; pDevItem->m_pClientItem = NULL; diff --git a/src/vscp/common/version.h b/src/vscp/common/version.h index 2cf6ec909..254703aa3 100644 --- a/src/vscp/common/version.h +++ b/src/vscp/common/version.h @@ -34,10 +34,10 @@ // 35/36/37/38/40/42/43 I M P O T A N T ! ! ! #define VSCPD_MAJOR_VERSION 14 #define VSCPD_MINOR_VERSION 0 -#define VSCPD_RELEASE_VERSION 3 -#define VSCPD_BUILD_VERSION 5 +#define VSCPD_RELEASE_VERSION 4 +#define VSCPD_BUILD_VERSION 1 -#define VSCPD_DISPLAY_VERSION "14.0.3-5 Silicon" +#define VSCPD_DISPLAY_VERSION "14.0.4-1 Silicon" #define VSCPD_COPYRIGHT \ "Copyright © 2000-2020 Ake Hedman, Grodans Paradis AB, " \ diff --git a/tests/helperlib/Makefile b/tests/helperlib/Makefile index 1ac8bc243..71ccdc0f2 100644 --- a/tests/helperlib/Makefile +++ b/tests/helperlib/Makefile @@ -7,7 +7,7 @@ MAJOR_VERSION=@MAJOR_VERSION@ MINOR_VERSION=@MINOR_VERSION@ RELEASE_VERSION=@RELEASE_VERSION@ BUILD_VERSION=@BUILD_VERSION@ -PACKAGE_VERSION=14.0.3 +PACKAGE_VERSION=14.0.4 # STATIC = yes if a static build is requested. STATIC=no