|
@@ -72,11 +72,9 @@
|
|
|
|
|
|
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDO_UDP)) != 0)
|
|
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDO_UDP)) != 0)
|
|
|
|
|
|
-#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
|
|
|
|
#include "SocketLinuxKernel.h"
|
|
#include "SocketLinuxKernel.h"
|
|
#include <linux/completion.h>
|
|
#include <linux/completion.h>
|
|
#include <linux/sched.h>
|
|
#include <linux/sched.h>
|
|
-#endif
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
/***************************************************************************/
|
|
/* */
|
|
/* */
|
|
@@ -110,12 +108,9 @@ typedef struct {
|
|
tEplSequLayerReceiveCb m_fpSdoAsySeqCb;
|
|
tEplSequLayerReceiveCb m_fpSdoAsySeqCb;
|
|
SOCKET m_UdpSocket;
|
|
SOCKET m_UdpSocket;
|
|
|
|
|
|
-#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
|
|
|
|
struct completion m_CompletionUdpThread;
|
|
struct completion m_CompletionUdpThread;
|
|
int m_ThreadHandle;
|
|
int m_ThreadHandle;
|
|
int m_iTerminateThread;
|
|
int m_iTerminateThread;
|
|
-#endif
|
|
|
|
-
|
|
|
|
} tEplSdoUdpInstance;
|
|
} tEplSdoUdpInstance;
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------
|
|
@@ -128,9 +123,7 @@ static tEplSdoUdpInstance SdoUdpInstance_g;
|
|
// local function prototypes
|
|
// local function prototypes
|
|
//---------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
-#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
|
|
|
|
static int EplSdoUdpThread(void *pArg_p);
|
|
static int EplSdoUdpThread(void *pArg_p);
|
|
-#endif
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
/***************************************************************************/
|
|
/* */
|
|
/* */
|
|
@@ -214,11 +207,8 @@ tEplKernel EplSdoUdpuAddInstance(tEplSequLayerReceiveCb fpReceiveCb_p)
|
|
goto Exit;
|
|
goto Exit;
|
|
}
|
|
}
|
|
|
|
|
|
-#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
|
|
|
|
init_completion(&SdoUdpInstance_g.m_CompletionUdpThread);
|
|
init_completion(&SdoUdpInstance_g.m_CompletionUdpThread);
|
|
SdoUdpInstance_g.m_iTerminateThread = 0;
|
|
SdoUdpInstance_g.m_iTerminateThread = 0;
|
|
-#endif
|
|
|
|
-
|
|
|
|
SdoUdpInstance_g.m_ThreadHandle = 0;
|
|
SdoUdpInstance_g.m_ThreadHandle = 0;
|
|
SdoUdpInstance_g.m_UdpSocket = INVALID_SOCKET;
|
|
SdoUdpInstance_g.m_UdpSocket = INVALID_SOCKET;
|
|
|
|
|
|
@@ -254,13 +244,10 @@ tEplKernel EplSdoUdpuDelInstance(void)
|
|
|
|
|
|
if (SdoUdpInstance_g.m_ThreadHandle != 0) { // listen thread was started
|
|
if (SdoUdpInstance_g.m_ThreadHandle != 0) { // listen thread was started
|
|
// close thread
|
|
// close thread
|
|
-#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
|
|
|
|
SdoUdpInstance_g.m_iTerminateThread = 1;
|
|
SdoUdpInstance_g.m_iTerminateThread = 1;
|
|
/* kill_proc(SdoUdpInstance_g.m_ThreadHandle, SIGTERM, 1 ); */
|
|
/* kill_proc(SdoUdpInstance_g.m_ThreadHandle, SIGTERM, 1 ); */
|
|
send_sig(SIGTERM, SdoUdpInstance_g.m_ThreadHandle, 1);
|
|
send_sig(SIGTERM, SdoUdpInstance_g.m_ThreadHandle, 1);
|
|
wait_for_completion(&SdoUdpInstance_g.m_CompletionUdpThread);
|
|
wait_for_completion(&SdoUdpInstance_g.m_CompletionUdpThread);
|
|
-#endif
|
|
|
|
-
|
|
|
|
SdoUdpInstance_g.m_ThreadHandle = 0;
|
|
SdoUdpInstance_g.m_ThreadHandle = 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -307,14 +294,11 @@ tEplKernel EplSdoUdpuConfig(unsigned long ulIpAddr_p, unsigned int uiPort_p)
|
|
if (SdoUdpInstance_g.m_ThreadHandle != 0) { // listen thread was started
|
|
if (SdoUdpInstance_g.m_ThreadHandle != 0) { // listen thread was started
|
|
|
|
|
|
// close old thread
|
|
// close old thread
|
|
-#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
|
|
|
|
SdoUdpInstance_g.m_iTerminateThread = 1;
|
|
SdoUdpInstance_g.m_iTerminateThread = 1;
|
|
/* kill_proc(SdoUdpInstance_g.m_ThreadHandle, SIGTERM, 1 ); */
|
|
/* kill_proc(SdoUdpInstance_g.m_ThreadHandle, SIGTERM, 1 ); */
|
|
send_sig(SIGTERM, SdoUdpInstance_g.m_ThreadHandle, 1);
|
|
send_sig(SIGTERM, SdoUdpInstance_g.m_ThreadHandle, 1);
|
|
wait_for_completion(&SdoUdpInstance_g.m_CompletionUdpThread);
|
|
wait_for_completion(&SdoUdpInstance_g.m_CompletionUdpThread);
|
|
SdoUdpInstance_g.m_iTerminateThread = 0;
|
|
SdoUdpInstance_g.m_iTerminateThread = 0;
|
|
-#endif
|
|
|
|
-
|
|
|
|
SdoUdpInstance_g.m_ThreadHandle = 0;
|
|
SdoUdpInstance_g.m_ThreadHandle = 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -349,15 +333,12 @@ tEplKernel EplSdoUdpuConfig(unsigned long ulIpAddr_p, unsigned int uiPort_p)
|
|
goto Exit;
|
|
goto Exit;
|
|
}
|
|
}
|
|
// create Listen-Thread
|
|
// create Listen-Thread
|
|
-#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
|
|
|
|
-
|
|
|
|
SdoUdpInstance_g.m_ThreadHandle =
|
|
SdoUdpInstance_g.m_ThreadHandle =
|
|
kernel_thread(EplSdoUdpThread, &SdoUdpInstance_g, CLONE_KERNEL);
|
|
kernel_thread(EplSdoUdpThread, &SdoUdpInstance_g, CLONE_KERNEL);
|
|
if (SdoUdpInstance_g.m_ThreadHandle == 0) {
|
|
if (SdoUdpInstance_g.m_ThreadHandle == 0) {
|
|
Ret = kEplSdoUdpThreadError;
|
|
Ret = kEplSdoUdpThreadError;
|
|
goto Exit;
|
|
goto Exit;
|
|
}
|
|
}
|
|
-#endif
|
|
|
|
|
|
|
|
Exit:
|
|
Exit:
|
|
return Ret;
|
|
return Ret;
|
|
@@ -573,13 +554,11 @@ static int EplSdoUdpThread(void *pArg_p)
|
|
unsigned int uiSize;
|
|
unsigned int uiSize;
|
|
tEplSdoConHdl SdoConHdl;
|
|
tEplSdoConHdl SdoConHdl;
|
|
|
|
|
|
-#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
|
|
|
|
pInstance = (tEplSdoUdpInstance *) pArg_p;
|
|
pInstance = (tEplSdoUdpInstance *) pArg_p;
|
|
daemonize("EplSdoUdpThread");
|
|
daemonize("EplSdoUdpThread");
|
|
allow_signal(SIGTERM);
|
|
allow_signal(SIGTERM);
|
|
|
|
|
|
for (; pInstance->m_iTerminateThread == 0;)
|
|
for (; pInstance->m_iTerminateThread == 0;)
|
|
-#endif
|
|
|
|
|
|
|
|
{
|
|
{
|
|
// wait for data
|
|
// wait for data
|
|
@@ -590,11 +569,9 @@ static int EplSdoUdpThread(void *pArg_p)
|
|
0, // flags
|
|
0, // flags
|
|
(struct sockaddr *)&RemoteAddr,
|
|
(struct sockaddr *)&RemoteAddr,
|
|
(int *)&uiSize);
|
|
(int *)&uiSize);
|
|
-#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
|
|
|
|
if (iError == -ERESTARTSYS) {
|
|
if (iError == -ERESTARTSYS) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
-#endif
|
|
|
|
if (iError > 0) {
|
|
if (iError > 0) {
|
|
// get handle for higher layer
|
|
// get handle for higher layer
|
|
iCount = 0;
|
|
iCount = 0;
|
|
@@ -663,10 +640,7 @@ static int EplSdoUdpThread(void *pArg_p)
|
|
} // end of if(iError!=SOCKET_ERROR)
|
|
} // end of if(iError!=SOCKET_ERROR)
|
|
} // end of for(;;)
|
|
} // end of for(;;)
|
|
|
|
|
|
-#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
|
|
|
|
complete_and_exit(&SdoUdpInstance_g.m_CompletionUdpThread, 0);
|
|
complete_and_exit(&SdoUdpInstance_g.m_CompletionUdpThread, 0);
|
|
-#endif
|
|
|
|
-
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|