Index: DeviceHandler.cpp =================================================================== --- DeviceHandler.cpp (revision 5413) +++ DeviceHandler.cpp (working copy) @@ -1124,7 +1124,16 @@ CDevice* pcDevCon = pcChannel->m_pcDevice; CDataLayer* pcDataLayer = pcDevCon->m_pcEndpoint->m_pcDefaultDataLayer; CPhysicalInterface* pcInterface = pcDevCon->m_pcEndpoint->m_pcInterface; + bool fExpectReconnect; + if(pcDataLayer->GetTransportLayer()->GetServerInfo()->ulFeatures & HIL_TRANSPORT_FEATURES_PERMANENT_CONNECTION) + { + fExpectReconnect = false; + } else + { + fExpectReconnect = true; + } + /* Query interface name */ std::string szInterface; pcInterface->GetInterfaceName(szInterface); @@ -1167,6 +1176,7 @@ lRet = pcDataLayer->xChannelReset(pcChannel->m_hChannel, CIFX_CHANNELINIT, CIFX_TO_SEND_PACKET); + fExpectReconnect = false; break; default: @@ -1174,25 +1184,32 @@ break; } - - /* No Answer returned, so we expect to reconnect. Use interface specific reset timeout */ - if(::WaitForSingleObject(hReconnect, ulTimeout) != WAIT_OBJECT_0) + + /* ATTENTION: Some devices drop connection on channelinit too (if remote device is TCP/IP + based and the channel being reset also reset TCP/IP stack) */ + if( fExpectReconnect || + (CIFX_TRANSPORT_ABORTED == lRet) || + (CIFX_TRANSPORT_RECV_TIMEOUT == lRet) ) { - /* we need to reconnect manually */ - CDeviceHandler::NOTIFICATION_DATA_T tNotify; + /* No Answer returned, so we expect to reconnect. Use interface specific reset timeout */ + if(::WaitForSingleObject(hReconnect, ulTimeout) != WAIT_OBJECT_0) + { + /* we need to reconnect manually */ + CDeviceHandler::NOTIFICATION_DATA_T tNotify; - tNotify.eNotify = eDETACHED; - tNotify.pcLayer = pcInterface->GetPhysicalLayer(); - tNotify.szInterface = szInterface; + tNotify.eNotify = eDETACHED; + tNotify.pcLayer = pcInterface->GetPhysicalLayer(); + tNotify.szInterface = szInterface; - lRet = ProcessNotification(&tNotify); - TRACE("%s: Reset timeout expired..disconnect from device (Error: 0x%x)", szInterface.c_str(), lRet); + lRet = ProcessNotification(&tNotify); + TRACE("%s: Reset timeout expired..disconnect from device (Error: 0x%x)", szInterface.c_str(), lRet); - tNotify.eNotify = eATTACHED; + tNotify.eNotify = eATTACHED; - lRet = ProcessNotification(&tNotify); - TRACE("%s: Reset timeout expired..connect to device (Error: 0x%x)", szInterface.c_str(), lRet); + lRet = ProcessNotification(&tNotify); + TRACE("%s: Reset timeout expired..connect to device (Error: 0x%x)", szInterface.c_str(), lRet); + } } if(!pcDevCon->IsAvailable()) Index: HilTransport.h =================================================================== --- HilTransport.h (revision 5413) +++ HilTransport.h (working copy) @@ -22,6 +22,7 @@ Version Date Author Description --------------------------------------------------------------------------- + 9 02.10.2013 MT Added HIL_TRANSPORT_FEATURES_PERMANENT_CONNECTION 8 24.06.2009 MT HIL_TRANSPORT_BASIC_FEATURES_U structure changed data type from unsigned long to unsigned int 7 22.07.2008 PL New transport type HIL_TRANSPORT_TYPE_KEEP_ALIVE added @@ -98,8 +99,9 @@ #define HIL_ADMIN_S_OK 0 /*!< No error */ /* Features flag definition (used in QueryServer command) */ -#define HIL_TRANSPORT_FEATURES_KEEPALIVE 0x00000001 /*!< Device supports keep-alive */ -#define HIL_TRANSPORT_FEATURES_NXAPI 0x00000002 /*!< Device supports NXAPI marshalling */ +#define HIL_TRANSPORT_FEATURES_KEEPALIVE 0x00000001 /*!< Device supports keep-alive */ +#define HIL_TRANSPORT_FEATURES_NXAPI 0x00000002 /*!< Device supports NXAPI marshalling */ +#define HIL_TRANSPORT_FEATURES_PERMANENT_CONNECTION 0x80000000 /*!< Device has a steady connection (does not drop on remote device resets) */ #define HIL_TRANSPORT_QUERYSERVER_NAMELEN 32 /*****************************************************************************/ Index: TransportLayer.cpp =================================================================== --- TransportLayer.cpp (revision 5413) +++ TransportLayer.cpp (working copy) @@ -989,6 +989,7 @@ TRACE("Structure version: %d", ptServerInfo->ulStructVersion); TRACE("Supported Datatypes:"); // Clear supported features list + m_tServerInfo.ulFeatures = ptServerInfo->ulFeatures; m_tServerInfo.ulBufferSize = ptServerInfo->ulBufferSize; m_tServerInfo.ulParallelServices = ptServerInfo->ulParallelServices; m_tServerInfo.cvSupportedDataTypes.clear(); Index: TransportLayer.h =================================================================== --- TransportLayer.h (revision 5413) +++ TransportLayer.h (working copy) @@ -83,8 +83,9 @@ typedef struct TARGET_SERVER_INFO_Ttag { std::string szServerName; - uint32_t ulParallelServices; - uint32_t ulBufferSize; + uint32_t ulParallelServices; + uint32_t ulBufferSize; + uint32_t ulFeatures; bool fIgnoreSequenceNr; std::vector cvSupportedDataTypes;