//--------------------------------------------------------------------------- // // Function: EplSdoUdpuAddInstance // // Description: init additional instance of the module // înit socket and start Listen-Thread // // // // Parameters: pReceiveCb_p = functionpointer to Sdo-Sequence layer // callback-function // // // Returns: tEplKernel = Errorcode // // // State: // //--------------------------------------------------------------------------- tEplKernel EplSdoUdpuAddInstance(tEplSequLayerReceiveCb fpReceiveCb_p) { tEplKernel Ret; // set instance variables to 0 EPL_MEMSET(&SdoUdpInstance_g, 0x00, sizeof(SdoUdpInstance_g)); Ret = kEplSuccessful; // save pointer to callback-function if (fpReceiveCb_p != NULL) { SdoUdpInstance_g.m_fpSdoAsySeqCb = fpReceiveCb_p; } else { Ret = kEplSdoUdpMissCb; goto Exit; } init_completion(&SdoUdpInstance_g.m_CompletionUdpThread); SdoUdpInstance_g.m_iTerminateThread = 0; SdoUdpInstance_g.m_ThreadHandle = 0; SdoUdpInstance_g.m_UdpSocket = INVALID_SOCKET; Ret = EplSdoUdpuConfig(INADDR_ANY, 0); Exit: return Ret; }
//--------------------------------------------------------------------------- // // Function: EplSdoUdpuAddInstance // // Description: init additional instance of the module // init socket and start Listen-Thread // // // // Parameters: pReceiveCb_p = functionpointer to Sdo-Sequence layer // callback-function // // // Returns: tEplKernel = Errorcode // // // State: // //--------------------------------------------------------------------------- tEplKernel PUBLIC EplSdoUdpuAddInstance(tEplSequLayerReceiveCb fpReceiveCb_p) { tEplKernel Ret; #if (TARGET_SYSTEM == _WIN32_) int iError; WSADATA Wsa; #endif // set instance variables to 0 EPL_MEMSET(&SdoUdpInstance_g, 0x00, sizeof(SdoUdpInstance_g)); Ret = kEplSuccessful; // save pointer to callback-function if (fpReceiveCb_p != NULL) { SdoUdpInstance_g.m_fpSdoAsySeqCb = fpReceiveCb_p; } else { Ret = kEplSdoUdpMissCb; goto Exit; } #if (TARGET_SYSTEM == _WIN32_) // start winsock2 for win32 // windows specific start of socket iError = WSAStartup(MAKEWORD(2,0),&Wsa); if (iError != 0) { Ret = kEplSdoUdpNoSocket; goto Exit; } // create critical section for access of instance variables SdoUdpInstance_g.m_pCriticalSection = &SdoUdpInstance_g.m_CriticalSection; InitializeCriticalSection(SdoUdpInstance_g.m_pCriticalSection); #endif SdoUdpInstance_g.m_ThreadHandle = 0; SdoUdpInstance_g.m_UdpSocket = INVALID_SOCKET; Ret = EplSdoUdpuConfig(INADDR_ANY, 0); Exit: return Ret; }