2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-19 18:53:52 +08:00

Staging: epl: run Lindent on *.c files

It's a start, still a mess...

Cc: Daniel Krueger <daniel.krueger@systec-electronic.com>
Cc: Ronald Sieber <Ronald.Sieber@systec-electronic.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Greg Kroah-Hartman 2008-12-19 17:11:52 -08:00
parent e0ca059588
commit 833dfbe746
41 changed files with 23128 additions and 23337 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -75,7 +75,6 @@
#include <asm/uaccess.h>
#endif
/***************************************************************************/
/* */
/* */
@ -100,7 +99,6 @@
// local function prototypes
//---------------------------------------------------------------------------
/***************************************************************************/
/* */
/* */
@ -114,7 +112,6 @@
//
/***************************************************************************/
//=========================================================================//
// //
// P R I V A T E D E F I N I T I O N S //
@ -130,36 +127,33 @@
//---------------------------------------------------------------------------
#if ((EPL_API_PROCESS_IMAGE_SIZE_IN > 0) || (EPL_API_PROCESS_IMAGE_SIZE_OUT > 0))
typedef struct
{
#if EPL_API_PROCESS_IMAGE_SIZE_IN > 0
BYTE m_abProcessImageInput[EPL_API_PROCESS_IMAGE_SIZE_IN];
#endif
#if EPL_API_PROCESS_IMAGE_SIZE_OUT > 0
BYTE m_abProcessImageOutput[EPL_API_PROCESS_IMAGE_SIZE_OUT];
#endif
typedef struct {
#if EPL_API_PROCESS_IMAGE_SIZE_IN > 0
BYTE m_abProcessImageInput[EPL_API_PROCESS_IMAGE_SIZE_IN];
#endif
#if EPL_API_PROCESS_IMAGE_SIZE_OUT > 0
BYTE m_abProcessImageOutput[EPL_API_PROCESS_IMAGE_SIZE_OUT];
#endif
} tEplApiProcessImageInstance;
} tEplApiProcessImageInstance;
//---------------------------------------------------------------------------
// local vars
//---------------------------------------------------------------------------
static tEplApiProcessImageInstance EplApiProcessImageInstance_g;
static tEplApiProcessImageInstance EplApiProcessImageInstance_g;
#endif
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplApiProcessImageSetup()
@ -177,125 +171,101 @@ static tEplApiProcessImageInstance EplApiProcessImageInstance_g;
tEplKernel PUBLIC EplApiProcessImageSetup(void)
{
tEplKernel Ret = kEplSuccessful;
tEplKernel Ret = kEplSuccessful;
#if ((EPL_API_PROCESS_IMAGE_SIZE_IN > 0) || (EPL_API_PROCESS_IMAGE_SIZE_OUT > 0))
unsigned int uiVarEntries;
tEplObdSize ObdSize;
unsigned int uiVarEntries;
tEplObdSize ObdSize;
#endif
#if EPL_API_PROCESS_IMAGE_SIZE_IN > 0
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN;
ObdSize = 1;
Ret = EplApiLinkObject(
0x2000,
EplApiProcessImageInstance_g.m_abProcessImageInput,
&uiVarEntries,
&ObdSize,
1);
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN;
ObdSize = 1;
Ret = EplApiLinkObject(0x2000,
EplApiProcessImageInstance_g.
m_abProcessImageInput, &uiVarEntries, &ObdSize,
1);
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN;
ObdSize = 1;
Ret = EplApiLinkObject(
0x2001,
EplApiProcessImageInstance_g.m_abProcessImageInput,
&uiVarEntries,
&ObdSize,
1);
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN;
ObdSize = 1;
Ret = EplApiLinkObject(0x2001,
EplApiProcessImageInstance_g.
m_abProcessImageInput, &uiVarEntries, &ObdSize,
1);
ObdSize = 2;
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
Ret = EplApiLinkObject(
0x2010,
EplApiProcessImageInstance_g.m_abProcessImageInput,
&uiVarEntries,
&ObdSize,
1);
ObdSize = 2;
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
Ret = EplApiLinkObject(0x2010,
EplApiProcessImageInstance_g.
m_abProcessImageInput, &uiVarEntries, &ObdSize,
1);
ObdSize = 2;
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
Ret = EplApiLinkObject(
0x2011,
EplApiProcessImageInstance_g.m_abProcessImageInput,
&uiVarEntries,
&ObdSize,
1);
ObdSize = 2;
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
Ret = EplApiLinkObject(0x2011,
EplApiProcessImageInstance_g.
m_abProcessImageInput, &uiVarEntries, &ObdSize,
1);
ObdSize = 4;
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
Ret = EplApiLinkObject(
0x2020,
EplApiProcessImageInstance_g.m_abProcessImageInput,
&uiVarEntries,
&ObdSize,
1);
ObdSize = 4;
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
Ret = EplApiLinkObject(0x2020,
EplApiProcessImageInstance_g.
m_abProcessImageInput, &uiVarEntries, &ObdSize,
1);
ObdSize = 4;
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
Ret = EplApiLinkObject(
0x2021,
EplApiProcessImageInstance_g.m_abProcessImageInput,
&uiVarEntries,
&ObdSize,
1);
ObdSize = 4;
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_IN / ObdSize;
Ret = EplApiLinkObject(0x2021,
EplApiProcessImageInstance_g.
m_abProcessImageInput, &uiVarEntries, &ObdSize,
1);
#endif
#if EPL_API_PROCESS_IMAGE_SIZE_OUT > 0
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT;
ObdSize = 1;
Ret = EplApiLinkObject(
0x2030,
EplApiProcessImageInstance_g.m_abProcessImageOutput,
&uiVarEntries,
&ObdSize,
1);
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT;
ObdSize = 1;
Ret = EplApiLinkObject(0x2030,
EplApiProcessImageInstance_g.
m_abProcessImageOutput, &uiVarEntries, &ObdSize,
1);
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT;
ObdSize = 1;
Ret = EplApiLinkObject(
0x2031,
EplApiProcessImageInstance_g.m_abProcessImageOutput,
&uiVarEntries,
&ObdSize,
1);
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT;
ObdSize = 1;
Ret = EplApiLinkObject(0x2031,
EplApiProcessImageInstance_g.
m_abProcessImageOutput, &uiVarEntries, &ObdSize,
1);
ObdSize = 2;
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
Ret = EplApiLinkObject(
0x2040,
EplApiProcessImageInstance_g.m_abProcessImageOutput,
&uiVarEntries,
&ObdSize,
1);
ObdSize = 2;
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
Ret = EplApiLinkObject(0x2040,
EplApiProcessImageInstance_g.
m_abProcessImageOutput, &uiVarEntries, &ObdSize,
1);
ObdSize = 2;
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
Ret = EplApiLinkObject(
0x2041,
EplApiProcessImageInstance_g.m_abProcessImageOutput,
&uiVarEntries,
&ObdSize,
1);
ObdSize = 2;
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
Ret = EplApiLinkObject(0x2041,
EplApiProcessImageInstance_g.
m_abProcessImageOutput, &uiVarEntries, &ObdSize,
1);
ObdSize = 4;
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
Ret = EplApiLinkObject(
0x2050,
EplApiProcessImageInstance_g.m_abProcessImageOutput,
&uiVarEntries,
&ObdSize,
1);
ObdSize = 4;
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
Ret = EplApiLinkObject(0x2050,
EplApiProcessImageInstance_g.
m_abProcessImageOutput, &uiVarEntries, &ObdSize,
1);
ObdSize = 4;
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
Ret = EplApiLinkObject(
0x2051,
EplApiProcessImageInstance_g.m_abProcessImageOutput,
&uiVarEntries,
&ObdSize,
1);
ObdSize = 4;
uiVarEntries = EPL_API_PROCESS_IMAGE_SIZE_OUT / ObdSize;
Ret = EplApiLinkObject(0x2051,
EplApiProcessImageInstance_g.
m_abProcessImageOutput, &uiVarEntries, &ObdSize,
1);
#endif
return Ret;
return Ret;
}
//----------------------------------------------------------------------------
@ -310,26 +280,29 @@ tEplObdSize ObdSize;
// State:
//----------------------------------------------------------------------------
tEplKernel PUBLIC EplApiProcessImageExchangeIn(tEplApiProcessImage* pPI_p)
tEplKernel PUBLIC EplApiProcessImageExchangeIn(tEplApiProcessImage * pPI_p)
{
tEplKernel Ret = kEplSuccessful;
tEplKernel Ret = kEplSuccessful;
#if EPL_API_PROCESS_IMAGE_SIZE_IN > 0
#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
copy_to_user(pPI_p->m_pImage,
EplApiProcessImageInstance_g.m_abProcessImageInput,
min(pPI_p->m_uiSize, sizeof (EplApiProcessImageInstance_g.m_abProcessImageInput)));
#else
EPL_MEMCPY(pPI_p->m_pImage,
EplApiProcessImageInstance_g.m_abProcessImageInput,
min(pPI_p->m_uiSize, sizeof (EplApiProcessImageInstance_g.m_abProcessImageInput)));
#endif
#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
copy_to_user(pPI_p->m_pImage,
EplApiProcessImageInstance_g.m_abProcessImageInput,
min(pPI_p->m_uiSize,
sizeof(EplApiProcessImageInstance_g.
m_abProcessImageInput)));
#else
EPL_MEMCPY(pPI_p->m_pImage,
EplApiProcessImageInstance_g.m_abProcessImageInput,
min(pPI_p->m_uiSize,
sizeof(EplApiProcessImageInstance_g.
m_abProcessImageInput)));
#endif
#endif
return Ret;
return Ret;
}
//----------------------------------------------------------------------------
// Function: EplApiProcessImageExchangeOut()
//
@ -342,33 +315,33 @@ tEplKernel Ret = kEplSuccessful;
// State:
//----------------------------------------------------------------------------
tEplKernel PUBLIC EplApiProcessImageExchangeOut(tEplApiProcessImage* pPI_p)
tEplKernel PUBLIC EplApiProcessImageExchangeOut(tEplApiProcessImage * pPI_p)
{
tEplKernel Ret = kEplSuccessful;
tEplKernel Ret = kEplSuccessful;
#if EPL_API_PROCESS_IMAGE_SIZE_OUT > 0
#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
copy_from_user(EplApiProcessImageInstance_g.m_abProcessImageOutput,
pPI_p->m_pImage,
min(pPI_p->m_uiSize, sizeof (EplApiProcessImageInstance_g.m_abProcessImageOutput)));
#else
EPL_MEMCPY(EplApiProcessImageInstance_g.m_abProcessImageOutput,
pPI_p->m_pImage,
min(pPI_p->m_uiSize, sizeof (EplApiProcessImageInstance_g.m_abProcessImageOutput)));
#endif
#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
copy_from_user(EplApiProcessImageInstance_g.m_abProcessImageOutput,
pPI_p->m_pImage,
min(pPI_p->m_uiSize,
sizeof(EplApiProcessImageInstance_g.
m_abProcessImageOutput)));
#else
EPL_MEMCPY(EplApiProcessImageInstance_g.m_abProcessImageOutput,
pPI_p->m_pImage,
min(pPI_p->m_uiSize,
sizeof(EplApiProcessImageInstance_g.
m_abProcessImageOutput)));
#endif
#endif
return Ret;
return Ret;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
// EOF

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -78,7 +78,6 @@
#include "kernel/EplDllkCal.h"
#endif
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
/***************************************************************************/
@ -105,7 +104,6 @@
// local function prototypes
//---------------------------------------------------------------------------
/***************************************************************************/
/* */
/* */
@ -119,7 +117,6 @@
//
/***************************************************************************/
//=========================================================================//
// //
// P R I V A T E D E F I N I T I O N S //
@ -134,9 +131,8 @@
// local types
//---------------------------------------------------------------------------
typedef struct
{
tEplDlluCbAsnd m_apfnDlluCbAsnd[EPL_DLL_MAX_ASND_SERVICE_ID];
typedef struct {
tEplDlluCbAsnd m_apfnDlluCbAsnd[EPL_DLL_MAX_ASND_SERVICE_ID];
} tEplDlluCalInstance;
@ -146,13 +142,15 @@ typedef struct
// if no dynamic memory allocation shall be used
// define structures statically
static tEplDlluCalInstance EplDlluCalInstance_g;
static tEplDlluCalInstance EplDlluCalInstance_g;
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
static tEplKernel EplDlluCalSetAsndServiceIdFilter(tEplDllAsndServiceId ServiceId_p, tEplDllAsndFilter Filter_p);
static tEplKernel EplDlluCalSetAsndServiceIdFilter(tEplDllAsndServiceId
ServiceId_p,
tEplDllAsndFilter Filter_p);
//=========================================================================//
// //
@ -177,12 +175,12 @@ static tEplKernel EplDlluCalSetAsndServiceIdFilter(tEplDllAsndServiceId ServiceI
tEplKernel EplDlluCalAddInstance()
{
tEplKernel Ret = kEplSuccessful;
tEplKernel Ret = kEplSuccessful;
// reset instance structure
EPL_MEMSET(&EplDlluCalInstance_g, 0, sizeof (EplDlluCalInstance_g));
// reset instance structure
EPL_MEMSET(&EplDlluCalInstance_g, 0, sizeof(EplDlluCalInstance_g));
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -202,15 +200,14 @@ tEplKernel Ret = kEplSuccessful;
tEplKernel EplDlluCalDelInstance()
{
tEplKernel Ret = kEplSuccessful;
tEplKernel Ret = kEplSuccessful;
// reset instance structure
EPL_MEMSET(&EplDlluCalInstance_g, 0, sizeof (EplDlluCalInstance_g));
// reset instance structure
EPL_MEMSET(&EplDlluCalInstance_g, 0, sizeof(EplDlluCalInstance_g));
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplDlluCalProcess
@ -228,37 +225,40 @@ tEplKernel Ret = kEplSuccessful;
tEplKernel EplDlluCalProcess(tEplEvent * pEvent_p)
{
tEplKernel Ret = kEplSuccessful;
tEplMsgType MsgType;
unsigned int uiAsndServiceId;
tEplFrameInfo FrameInfo;
tEplKernel Ret = kEplSuccessful;
tEplMsgType MsgType;
unsigned int uiAsndServiceId;
tEplFrameInfo FrameInfo;
if (pEvent_p->m_EventType == kEplEventTypeAsndRx)
{
FrameInfo.m_pFrame = (tEplFrame*) pEvent_p->m_pArg;
FrameInfo.m_uiFrameSize = pEvent_p->m_uiSize;
// extract NetTime
FrameInfo.m_NetTime = pEvent_p->m_NetTime;
if (pEvent_p->m_EventType == kEplEventTypeAsndRx) {
FrameInfo.m_pFrame = (tEplFrame *) pEvent_p->m_pArg;
FrameInfo.m_uiFrameSize = pEvent_p->m_uiSize;
// extract NetTime
FrameInfo.m_NetTime = pEvent_p->m_NetTime;
MsgType = (tEplMsgType)AmiGetByteFromLe(&FrameInfo.m_pFrame->m_le_bMessageType);
if (MsgType != kEplMsgTypeAsnd)
{
Ret = kEplInvalidOperation;
goto Exit;
}
MsgType =
(tEplMsgType) AmiGetByteFromLe(&FrameInfo.m_pFrame->
m_le_bMessageType);
if (MsgType != kEplMsgTypeAsnd) {
Ret = kEplInvalidOperation;
goto Exit;
}
uiAsndServiceId = (unsigned int) AmiGetByteFromLe(&FrameInfo.m_pFrame->m_Data.m_Asnd.m_le_bServiceId);
if (uiAsndServiceId < EPL_DLL_MAX_ASND_SERVICE_ID)
{ // ASnd service ID is valid
if (EplDlluCalInstance_g.m_apfnDlluCbAsnd[uiAsndServiceId] != NULL)
{ // handler was registered
Ret = EplDlluCalInstance_g.m_apfnDlluCbAsnd[uiAsndServiceId](&FrameInfo);
}
}
}
uiAsndServiceId =
(unsigned int)AmiGetByteFromLe(&FrameInfo.m_pFrame->m_Data.
m_Asnd.m_le_bServiceId);
if (uiAsndServiceId < EPL_DLL_MAX_ASND_SERVICE_ID) { // ASnd service ID is valid
if (EplDlluCalInstance_g.m_apfnDlluCbAsnd[uiAsndServiceId] != NULL) { // handler was registered
Ret =
EplDlluCalInstance_g.
m_apfnDlluCbAsnd[uiAsndServiceId]
(&FrameInfo);
}
}
}
Exit:
return Ret;
Exit:
return Ret;
}
//---------------------------------------------------------------------------
@ -279,26 +279,26 @@ Exit:
//
//---------------------------------------------------------------------------
tEplKernel EplDlluCalRegAsndService(tEplDllAsndServiceId ServiceId_p, tEplDlluCbAsnd pfnDlluCbAsnd_p, tEplDllAsndFilter Filter_p)
tEplKernel EplDlluCalRegAsndService(tEplDllAsndServiceId ServiceId_p,
tEplDlluCbAsnd pfnDlluCbAsnd_p,
tEplDllAsndFilter Filter_p)
{
tEplKernel Ret = kEplSuccessful;
tEplKernel Ret = kEplSuccessful;
if (ServiceId_p < tabentries (EplDlluCalInstance_g.m_apfnDlluCbAsnd))
{
// memorize function pointer
EplDlluCalInstance_g.m_apfnDlluCbAsnd[ServiceId_p] = pfnDlluCbAsnd_p;
if (ServiceId_p < tabentries(EplDlluCalInstance_g.m_apfnDlluCbAsnd)) {
// memorize function pointer
EplDlluCalInstance_g.m_apfnDlluCbAsnd[ServiceId_p] =
pfnDlluCbAsnd_p;
if (pfnDlluCbAsnd_p == NULL)
{ // close filter
Filter_p = kEplDllAsndFilterNone;
}
if (pfnDlluCbAsnd_p == NULL) { // close filter
Filter_p = kEplDllAsndFilterNone;
}
// set filter in DLL module in kernel part
Ret = EplDlluCalSetAsndServiceIdFilter(ServiceId_p, Filter_p);
// set filter in DLL module in kernel part
Ret = EplDlluCalSetAsndServiceIdFilter(ServiceId_p, Filter_p);
}
}
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -319,21 +319,21 @@ tEplKernel Ret = kEplSuccessful;
//
//---------------------------------------------------------------------------
tEplKernel EplDlluCalAsyncSend(tEplFrameInfo * pFrameInfo_p, tEplDllAsyncReqPriority Priority_p)
tEplKernel EplDlluCalAsyncSend(tEplFrameInfo * pFrameInfo_p,
tEplDllAsyncReqPriority Priority_p)
{
tEplKernel Ret = kEplSuccessful;
tEplKernel Ret = kEplSuccessful;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
pFrameInfo_p->m_uiFrameSize += 14; // add size of ethernet header
Ret = EplDllkCalAsyncSend(pFrameInfo_p, Priority_p);
pFrameInfo_p->m_uiFrameSize += 14; // add size of ethernet header
Ret = EplDllkCalAsyncSend(pFrameInfo_p, Priority_p);
#else
Ret = kEplSuccessful;
Ret = kEplSuccessful;
#endif
return Ret;
return Ret;
}
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
//---------------------------------------------------------------------------
@ -354,43 +354,42 @@ tEplKernel Ret = kEplSuccessful;
//
//---------------------------------------------------------------------------
tEplKernel EplDlluCalIssueRequest(tEplDllReqServiceId Service_p, unsigned int uiNodeId_p, BYTE bSoaFlag1_p)
tEplKernel EplDlluCalIssueRequest(tEplDllReqServiceId Service_p,
unsigned int uiNodeId_p, BYTE bSoaFlag1_p)
{
tEplKernel Ret = kEplSuccessful;
tEplKernel Ret = kEplSuccessful;
// add node to appropriate request queue
switch (Service_p)
{
case kEplDllReqServiceIdent:
case kEplDllReqServiceStatus:
{
tEplEvent Event;
tEplDllCalIssueRequest IssueReq;
// add node to appropriate request queue
switch (Service_p) {
case kEplDllReqServiceIdent:
case kEplDllReqServiceStatus:
{
tEplEvent Event;
tEplDllCalIssueRequest IssueReq;
Event.m_EventSink = kEplEventSinkDllkCal;
Event.m_EventType = kEplEventTypeDllkIssueReq;
IssueReq.m_Service = Service_p;
IssueReq.m_uiNodeId = uiNodeId_p;
IssueReq.m_bSoaFlag1 = bSoaFlag1_p;
Event.m_pArg = &IssueReq;
Event.m_uiSize = sizeof (IssueReq);
Event.m_EventSink = kEplEventSinkDllkCal;
Event.m_EventType = kEplEventTypeDllkIssueReq;
IssueReq.m_Service = Service_p;
IssueReq.m_uiNodeId = uiNodeId_p;
IssueReq.m_bSoaFlag1 = bSoaFlag1_p;
Event.m_pArg = &IssueReq;
Event.m_uiSize = sizeof(IssueReq);
Ret = EplEventuPost(&Event);
break;
}
Ret = EplEventuPost(&Event);
break;
}
default:
{
Ret = kEplDllInvalidParam;
goto Exit;
}
}
default:
{
Ret = kEplDllInvalidParam;
goto Exit;
}
}
Exit:
return Ret;
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplDlluCalAddNode()
@ -408,20 +407,19 @@ Exit:
tEplKernel EplDlluCalAddNode(tEplDllNodeInfo * pNodeInfo_p)
{
tEplKernel Ret = kEplSuccessful;
tEplEvent Event;
tEplKernel Ret = kEplSuccessful;
tEplEvent Event;
Event.m_EventSink = kEplEventSinkDllkCal;
Event.m_EventType = kEplEventTypeDllkAddNode;
Event.m_pArg = pNodeInfo_p;
Event.m_uiSize = sizeof (tEplDllNodeInfo);
Event.m_EventSink = kEplEventSinkDllkCal;
Event.m_EventType = kEplEventTypeDllkAddNode;
Event.m_pArg = pNodeInfo_p;
Event.m_uiSize = sizeof(tEplDllNodeInfo);
Ret = EplEventuPost(&Event);
Ret = EplEventuPost(&Event);
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplDlluCalDeleteNode()
@ -439,20 +437,19 @@ tEplEvent Event;
tEplKernel EplDlluCalDeleteNode(unsigned int uiNodeId_p)
{
tEplKernel Ret = kEplSuccessful;
tEplEvent Event;
tEplKernel Ret = kEplSuccessful;
tEplEvent Event;
Event.m_EventSink = kEplEventSinkDllkCal;
Event.m_EventType = kEplEventTypeDllkDelNode;
Event.m_pArg = &uiNodeId_p;
Event.m_uiSize = sizeof (uiNodeId_p);
Event.m_EventSink = kEplEventSinkDllkCal;
Event.m_EventType = kEplEventTypeDllkDelNode;
Event.m_pArg = &uiNodeId_p;
Event.m_uiSize = sizeof(uiNodeId_p);
Ret = EplEventuPost(&Event);
Ret = EplEventuPost(&Event);
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplDlluCalSoftDeleteNode()
@ -470,23 +467,21 @@ tEplEvent Event;
tEplKernel EplDlluCalSoftDeleteNode(unsigned int uiNodeId_p)
{
tEplKernel Ret = kEplSuccessful;
tEplEvent Event;
tEplKernel Ret = kEplSuccessful;
tEplEvent Event;
Event.m_EventSink = kEplEventSinkDllkCal;
Event.m_EventType = kEplEventTypeDllkSoftDelNode;
Event.m_pArg = &uiNodeId_p;
Event.m_uiSize = sizeof (uiNodeId_p);
Event.m_EventSink = kEplEventSinkDllkCal;
Event.m_EventType = kEplEventTypeDllkSoftDelNode;
Event.m_pArg = &uiNodeId_p;
Event.m_uiSize = sizeof(uiNodeId_p);
Ret = EplEventuPost(&Event);
Ret = EplEventuPost(&Event);
return Ret;
return Ret;
}
#endif // (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
@ -509,26 +504,26 @@ tEplEvent Event;
//
//---------------------------------------------------------------------------
static tEplKernel EplDlluCalSetAsndServiceIdFilter(tEplDllAsndServiceId ServiceId_p, tEplDllAsndFilter Filter_p)
static tEplKernel EplDlluCalSetAsndServiceIdFilter(tEplDllAsndServiceId
ServiceId_p,
tEplDllAsndFilter Filter_p)
{
tEplKernel Ret = kEplSuccessful;
tEplEvent Event;
tEplDllCalAsndServiceIdFilter ServFilter;
tEplKernel Ret = kEplSuccessful;
tEplEvent Event;
tEplDllCalAsndServiceIdFilter ServFilter;
Event.m_EventSink = kEplEventSinkDllkCal;
Event.m_EventType = kEplEventTypeDllkServFilter;
ServFilter.m_ServiceId = ServiceId_p;
ServFilter.m_Filter = Filter_p;
Event.m_pArg = &ServFilter;
Event.m_uiSize = sizeof (ServFilter);
Event.m_EventSink = kEplEventSinkDllkCal;
Event.m_EventType = kEplEventTypeDllkServFilter;
ServFilter.m_ServiceId = ServiceId_p;
ServFilter.m_Filter = Filter_p;
Event.m_pArg = &ServFilter;
Event.m_uiSize = sizeof(ServFilter);
Ret = EplEventuPost(&Event);
Ret = EplEventuPost(&Event);
return Ret;
return Ret;
}
#endif // (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
// EOF

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -77,9 +77,9 @@
#include "Benchmark.h"
#ifdef EPL_NO_FIFO
#include "kernel/EplEventk.h"
#include "kernel/EplEventk.h"
#else
#include "SharedBuff.h"
#include "SharedBuff.h"
#endif
/***************************************************************************/
@ -96,28 +96,27 @@
// TracePoint support for realtime-debugging
#ifdef _DBG_TRACE_POINTS_
void PUBLIC TgtDbgSignalTracePoint (BYTE bTracePointNumber_p);
void PUBLIC TgtDbgPostTraceValue (DWORD dwTraceValue_p);
#define TGT_DBG_SIGNAL_TRACE_POINT(p) TgtDbgSignalTracePoint(p)
#define TGT_DBG_POST_TRACE_VALUE(v) TgtDbgPostTraceValue(v)
void PUBLIC TgtDbgSignalTracePoint(BYTE bTracePointNumber_p);
void PUBLIC TgtDbgPostTraceValue(DWORD dwTraceValue_p);
#define TGT_DBG_SIGNAL_TRACE_POINT(p) TgtDbgSignalTracePoint(p)
#define TGT_DBG_POST_TRACE_VALUE(v) TgtDbgPostTraceValue(v)
#else
#define TGT_DBG_SIGNAL_TRACE_POINT(p)
#define TGT_DBG_POST_TRACE_VALUE(v)
#define TGT_DBG_SIGNAL_TRACE_POINT(p)
#define TGT_DBG_POST_TRACE_VALUE(v)
#endif
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
typedef struct
{
typedef struct {
#ifndef EPL_NO_FIFO
tShbInstance m_pShbKernelToUserInstance;
tShbInstance m_pShbUserToKernelInstance;
tShbInstance m_pShbKernelToUserInstance;
tShbInstance m_pShbUserToKernelInstance;
#endif
tEplProcessEventCb m_pfnApiProcessEventCb;
tEplProcessEventCb m_pfnApiProcessEventCb;
}tEplEventuInstance;
} tEplEventuInstance;
//---------------------------------------------------------------------------
// modul globale vars
@ -133,9 +132,8 @@ static tEplEventuInstance EplEventuInstance_g;
#ifndef EPL_NO_FIFO
// callback function for incomming events
static void EplEventuRxSignalHandlerCb (
tShbInstance pShbRxInstance_p,
unsigned long ulDataSize_p);
static void EplEventuRxSignalHandlerCb(tShbInstance pShbRxInstance_p,
unsigned long ulDataSize_p);
#endif
/***************************************************************************/
@ -176,17 +174,14 @@ static void EplEventuRxSignalHandlerCb (
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplEventuInit(tEplProcessEventCb pfnApiProcessEventCb_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = EplEventuAddInstance(pfnApiProcessEventCb_p);
Ret = EplEventuAddInstance(pfnApiProcessEventCb_p);
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplEventuAddInstance
@ -204,62 +199,67 @@ return Ret;
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplEventuAddInstance(tEplProcessEventCb pfnApiProcessEventCb_p)
tEplKernel PUBLIC EplEventuAddInstance(tEplProcessEventCb
pfnApiProcessEventCb_p)
{
tEplKernel Ret;
tEplKernel Ret;
#ifndef EPL_NO_FIFO
tShbError ShbError;
unsigned int fShbNewCreated;
tShbError ShbError;
unsigned int fShbNewCreated;
#endif
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// init instance variables
EplEventuInstance_g.m_pfnApiProcessEventCb = pfnApiProcessEventCb_p;
// init instance variables
EplEventuInstance_g.m_pfnApiProcessEventCb = pfnApiProcessEventCb_p;
#ifndef EPL_NO_FIFO
// init shared loop buffer
// kernel -> user
ShbError = ShbCirAllocBuffer (EPL_EVENT_SIZE_SHB_KERNEL_TO_USER,
EPL_EVENT_NAME_SHB_KERNEL_TO_USER,
&EplEventuInstance_g.m_pShbKernelToUserInstance,
&fShbNewCreated);
if(ShbError != kShbOk)
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventuAddInstance(): ShbCirAllocBuffer(K2U) -> 0x%X\n", ShbError);
Ret = kEplNoResource;
goto Exit;
}
// init shared loop buffer
// kernel -> user
ShbError = ShbCirAllocBuffer(EPL_EVENT_SIZE_SHB_KERNEL_TO_USER,
EPL_EVENT_NAME_SHB_KERNEL_TO_USER,
&EplEventuInstance_g.
m_pShbKernelToUserInstance,
&fShbNewCreated);
if (ShbError != kShbOk) {
EPL_DBGLVL_EVENTK_TRACE1
("EplEventuAddInstance(): ShbCirAllocBuffer(K2U) -> 0x%X\n",
ShbError);
Ret = kEplNoResource;
goto Exit;
}
// user -> kernel
ShbError = ShbCirAllocBuffer(EPL_EVENT_SIZE_SHB_USER_TO_KERNEL,
EPL_EVENT_NAME_SHB_USER_TO_KERNEL,
&EplEventuInstance_g.
m_pShbUserToKernelInstance,
&fShbNewCreated);
if (ShbError != kShbOk) {
EPL_DBGLVL_EVENTK_TRACE1
("EplEventuAddInstance(): ShbCirAllocBuffer(U2K) -> 0x%X\n",
ShbError);
Ret = kEplNoResource;
goto Exit;
}
// register eventhandler
ShbError =
ShbCirSetSignalHandlerNewData(EplEventuInstance_g.
m_pShbKernelToUserInstance,
EplEventuRxSignalHandlerCb,
kShbPriorityNormal);
if (ShbError != kShbOk) {
EPL_DBGLVL_EVENTK_TRACE1
("EplEventuAddInstance(): ShbCirSetSignalHandlerNewData(K2U) -> 0x%X\n",
ShbError);
Ret = kEplNoResource;
goto Exit;
}
// user -> kernel
ShbError = ShbCirAllocBuffer (EPL_EVENT_SIZE_SHB_USER_TO_KERNEL,
EPL_EVENT_NAME_SHB_USER_TO_KERNEL,
&EplEventuInstance_g.m_pShbUserToKernelInstance,
&fShbNewCreated);
if(ShbError != kShbOk)
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventuAddInstance(): ShbCirAllocBuffer(U2K) -> 0x%X\n", ShbError);
Ret = kEplNoResource;
goto Exit;
}
// register eventhandler
ShbError = ShbCirSetSignalHandlerNewData (EplEventuInstance_g.m_pShbKernelToUserInstance,
EplEventuRxSignalHandlerCb,
kShbPriorityNormal);
if(ShbError != kShbOk)
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventuAddInstance(): ShbCirSetSignalHandlerNewData(K2U) -> 0x%X\n", ShbError);
Ret = kEplNoResource;
goto Exit;
}
Exit:
Exit:
#endif
return Ret;
return Ret;
}
@ -282,51 +282,52 @@ Exit:
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplEventuDelInstance()
{
tEplKernel Ret;
tEplKernel Ret;
#ifndef EPL_NO_FIFO
tShbError ShbError;
tShbError ShbError;
#endif
Ret = kEplSuccessful;
Ret = kEplSuccessful;
#ifndef EPL_NO_FIFO
// set eventhandler to NULL
ShbError = ShbCirSetSignalHandlerNewData (EplEventuInstance_g.m_pShbKernelToUserInstance,
NULL,
kShbPriorityNormal);
if(ShbError != kShbOk)
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventuDelInstance(): ShbCirSetSignalHandlerNewData(K2U) -> 0x%X\n", ShbError);
Ret = kEplNoResource;
}
// set eventhandler to NULL
ShbError =
ShbCirSetSignalHandlerNewData(EplEventuInstance_g.
m_pShbKernelToUserInstance, NULL,
kShbPriorityNormal);
if (ShbError != kShbOk) {
EPL_DBGLVL_EVENTK_TRACE1
("EplEventuDelInstance(): ShbCirSetSignalHandlerNewData(K2U) -> 0x%X\n",
ShbError);
Ret = kEplNoResource;
}
// free buffer User -> Kernel
ShbError =
ShbCirReleaseBuffer(EplEventuInstance_g.m_pShbUserToKernelInstance);
if ((ShbError != kShbOk) && (ShbError != kShbMemUsedByOtherProcs)) {
EPL_DBGLVL_EVENTK_TRACE1
("EplEventuDelInstance(): ShbCirReleaseBuffer(U2K) -> 0x%X\n",
ShbError);
Ret = kEplNoResource;
} else {
EplEventuInstance_g.m_pShbUserToKernelInstance = NULL;
}
// free buffer User -> Kernel
ShbError = ShbCirReleaseBuffer (EplEventuInstance_g.m_pShbUserToKernelInstance);
if((ShbError != kShbOk) && (ShbError != kShbMemUsedByOtherProcs))
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventuDelInstance(): ShbCirReleaseBuffer(U2K) -> 0x%X\n", ShbError);
Ret = kEplNoResource;
}
else
{
EplEventuInstance_g.m_pShbUserToKernelInstance = NULL;
}
// free buffer Kernel -> User
ShbError = ShbCirReleaseBuffer (EplEventuInstance_g.m_pShbKernelToUserInstance);
if((ShbError != kShbOk) && (ShbError != kShbMemUsedByOtherProcs))
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventuDelInstance(): ShbCirReleaseBuffer(K2U) -> 0x%X\n", ShbError);
Ret = kEplNoResource;
}
else
{
EplEventuInstance_g.m_pShbKernelToUserInstance = NULL;
}
// free buffer Kernel -> User
ShbError =
ShbCirReleaseBuffer(EplEventuInstance_g.m_pShbKernelToUserInstance);
if ((ShbError != kShbOk) && (ShbError != kShbMemUsedByOtherProcs)) {
EPL_DBGLVL_EVENTK_TRACE1
("EplEventuDelInstance(): ShbCirReleaseBuffer(K2U) -> 0x%X\n",
ShbError);
Ret = kEplNoResource;
} else {
EplEventuInstance_g.m_pShbKernelToUserInstance = NULL;
}
#endif
return Ret;
return Ret;
}
@ -347,159 +348,153 @@ return Ret;
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplEventuProcess(tEplEvent* pEvent_p)
tEplKernel PUBLIC EplEventuProcess(tEplEvent * pEvent_p)
{
tEplKernel Ret;
tEplEventSource EventSource;
tEplKernel Ret;
tEplEventSource EventSource;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// check m_EventSink
switch(pEvent_p->m_EventSink)
{
// NMT-User-Module
case kEplEventSinkNmtu:
{
// check m_EventSink
switch (pEvent_p->m_EventSink) {
// NMT-User-Module
case kEplEventSinkNmtu:
{
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTU)) != 0)
Ret = EplNmtuProcessEvent(pEvent_p);
if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
{
EventSource = kEplEventSourceNmtu;
Ret = EplNmtuProcessEvent(pEvent_p);
if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) {
EventSource = kEplEventSourceNmtu;
// Error event for API layer
EplEventuPostError(kEplEventSourceEventu,
Ret,
sizeof(EventSource),
&EventSource);
}
// Error event for API layer
EplEventuPostError(kEplEventSourceEventu,
Ret,
sizeof(EventSource),
&EventSource);
}
#endif
break;
}
break;
}
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
// NMT-MN-User-Module
case kEplEventSinkNmtMnu:
{
Ret = EplNmtMnuProcessEvent(pEvent_p);
if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
{
EventSource = kEplEventSourceNmtMnu;
// NMT-MN-User-Module
case kEplEventSinkNmtMnu:
{
Ret = EplNmtMnuProcessEvent(pEvent_p);
if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) {
EventSource = kEplEventSourceNmtMnu;
// Error event for API layer
EplEventuPostError(kEplEventSourceEventu,
Ret,
sizeof(EventSource),
&EventSource);
}
break;
}
// Error event for API layer
EplEventuPostError(kEplEventSourceEventu,
Ret,
sizeof(EventSource),
&EventSource);
}
break;
}
#endif
#if ((((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDOC)) != 0) \
|| (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDOS)) != 0))
// events for asynchronus SDO Sequence Layer
case kEplEventSinkSdoAsySeq:
{
Ret = EplSdoAsySeqProcessEvent(pEvent_p);
if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
{
EventSource = kEplEventSourceSdoAsySeq;
// events for asynchronus SDO Sequence Layer
case kEplEventSinkSdoAsySeq:
{
Ret = EplSdoAsySeqProcessEvent(pEvent_p);
if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) {
EventSource = kEplEventSourceSdoAsySeq;
// Error event for API layer
EplEventuPostError(kEplEventSourceEventu,
Ret,
sizeof(EventSource),
&EventSource);
}
break;
}
// Error event for API layer
EplEventuPostError(kEplEventSourceEventu,
Ret,
sizeof(EventSource),
&EventSource);
}
break;
}
#endif
// LED user part module
case kEplEventSinkLedu:
{
// LED user part module
case kEplEventSinkLedu:
{
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_LEDU)) != 0)
Ret = EplLeduProcessEvent(pEvent_p);
if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
{
EventSource = kEplEventSourceLedu;
Ret = EplLeduProcessEvent(pEvent_p);
if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) {
EventSource = kEplEventSourceLedu;
// Error event for API layer
EplEventuPostError(kEplEventSourceEventu,
Ret,
sizeof(EventSource),
&EventSource);
}
// Error event for API layer
EplEventuPostError(kEplEventSourceEventu,
Ret,
sizeof(EventSource),
&EventSource);
}
#endif
break;
}
break;
}
// event for EPL api
case kEplEventSinkApi:
{
if (EplEventuInstance_g.m_pfnApiProcessEventCb != NULL)
{
Ret = EplEventuInstance_g.m_pfnApiProcessEventCb(pEvent_p);
if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
{
EventSource = kEplEventSourceEplApi;
// event for EPL api
case kEplEventSinkApi:
{
if (EplEventuInstance_g.m_pfnApiProcessEventCb != NULL) {
Ret =
EplEventuInstance_g.
m_pfnApiProcessEventCb(pEvent_p);
if ((Ret != kEplSuccessful)
&& (Ret != kEplShutdown)) {
EventSource = kEplEventSourceEplApi;
// Error event for API layer
EplEventuPostError(kEplEventSourceEventu,
Ret,
sizeof(EventSource),
&EventSource);
}
}
break;
// Error event for API layer
EplEventuPostError
(kEplEventSourceEventu, Ret,
sizeof(EventSource), &EventSource);
}
}
break;
}
}
case kEplEventSinkDlluCal:
{
Ret = EplDlluCalProcess(pEvent_p);
if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
{
EventSource = kEplEventSourceDllu;
case kEplEventSinkDlluCal:
{
Ret = EplDlluCalProcess(pEvent_p);
if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) {
EventSource = kEplEventSourceDllu;
// Error event for API layer
EplEventuPostError(kEplEventSourceEventu,
Ret,
sizeof(EventSource),
&EventSource);
}
break;
// Error event for API layer
EplEventuPostError(kEplEventSourceEventu,
Ret,
sizeof(EventSource),
&EventSource);
}
break;
}
}
case kEplEventSinkErru:
{
/*
Ret = EplErruProcess(pEvent_p);
if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
{
EventSource = kEplEventSourceErru;
case kEplEventSinkErru:
{
/*
Ret = EplErruProcess(pEvent_p);
if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
{
EventSource = kEplEventSourceErru;
// Error event for API layer
EplEventuPostError(kEplEventSourceEventu,
Ret,
sizeof(EventSource),
&EventSource);
}
*/
break;
// Error event for API layer
EplEventuPostError(kEplEventSourceEventu,
Ret,
sizeof(EventSource),
&EventSource);
}
*/
break;
}
}
// unknown sink
default:
{
Ret = kEplEventUnknownSink;
}
// unknown sink
default:
{
Ret = kEplEventUnknownSink;
}
} // end of switch(pEvent_p->m_EventSink)
} // end of switch(pEvent_p->m_EventSink)
return Ret;
return Ret;
}
@ -522,143 +517,158 @@ tEplEventSource EventSource;
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplEventuPost(tEplEvent * pEvent_p)
{
tEplKernel Ret;
tEplKernel Ret;
#ifndef EPL_NO_FIFO
tShbError ShbError;
tShbCirChunk ShbCirChunk;
unsigned long ulDataSize;
unsigned int fBufferCompleted;
tShbError ShbError;
tShbCirChunk ShbCirChunk;
unsigned long ulDataSize;
unsigned int fBufferCompleted;
#endif
Ret = kEplSuccessful;
Ret = kEplSuccessful;
#ifndef EPL_NO_FIFO
// 2006/08/03 d.k.: Event and argument are posted as separate chunks to the event queue.
ulDataSize = sizeof(tEplEvent) + ((pEvent_p->m_pArg != NULL) ? pEvent_p->m_uiSize : 0);
// 2006/08/03 d.k.: Event and argument are posted as separate chunks to the event queue.
ulDataSize =
sizeof(tEplEvent) +
((pEvent_p->m_pArg != NULL) ? pEvent_p->m_uiSize : 0);
#endif
// decide in which buffer the event have to write
switch(pEvent_p->m_EventSink)
{
// kernelspace modules
case kEplEventSinkSync:
case kEplEventSinkNmtk:
case kEplEventSinkDllk:
case kEplEventSinkDllkCal:
case kEplEventSinkPdok:
case kEplEventSinkErrk:
{
// decide in which buffer the event have to write
switch (pEvent_p->m_EventSink) {
// kernelspace modules
case kEplEventSinkSync:
case kEplEventSinkNmtk:
case kEplEventSinkDllk:
case kEplEventSinkDllkCal:
case kEplEventSinkPdok:
case kEplEventSinkErrk:
{
#ifndef EPL_NO_FIFO
// post message
ShbError = ShbCirAllocDataBlock (EplEventuInstance_g.m_pShbUserToKernelInstance,
&ShbCirChunk,
ulDataSize);
if (ShbError != kShbOk)
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventuPost(): ShbCirAllocDataBlock(U2K) -> 0x%X\n", ShbError);
Ret = kEplEventPostError;
goto Exit;
}
ShbError = ShbCirWriteDataChunk (EplEventuInstance_g.m_pShbUserToKernelInstance,
&ShbCirChunk,
pEvent_p,
sizeof (tEplEvent),
&fBufferCompleted);
if (ShbError != kShbOk)
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventuPost(): ShbCirWriteDataChunk(U2K) -> 0x%X\n", ShbError);
Ret = kEplEventPostError;
goto Exit;
}
if (fBufferCompleted == FALSE)
{
ShbError = ShbCirWriteDataChunk (EplEventuInstance_g.m_pShbUserToKernelInstance,
&ShbCirChunk,
pEvent_p->m_pArg,
(unsigned long) pEvent_p->m_uiSize,
&fBufferCompleted);
if ((ShbError != kShbOk) || (fBufferCompleted == FALSE))
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventuPost(): ShbCirWriteDataChunk2(U2K) -> 0x%X\n", ShbError);
Ret = kEplEventPostError;
goto Exit;
}
}
// post message
ShbError =
ShbCirAllocDataBlock(EplEventuInstance_g.
m_pShbUserToKernelInstance,
&ShbCirChunk, ulDataSize);
if (ShbError != kShbOk) {
EPL_DBGLVL_EVENTK_TRACE1
("EplEventuPost(): ShbCirAllocDataBlock(U2K) -> 0x%X\n",
ShbError);
Ret = kEplEventPostError;
goto Exit;
}
ShbError =
ShbCirWriteDataChunk(EplEventuInstance_g.
m_pShbUserToKernelInstance,
&ShbCirChunk, pEvent_p,
sizeof(tEplEvent),
&fBufferCompleted);
if (ShbError != kShbOk) {
EPL_DBGLVL_EVENTK_TRACE1
("EplEventuPost(): ShbCirWriteDataChunk(U2K) -> 0x%X\n",
ShbError);
Ret = kEplEventPostError;
goto Exit;
}
if (fBufferCompleted == FALSE) {
ShbError =
ShbCirWriteDataChunk(EplEventuInstance_g.
m_pShbUserToKernelInstance,
&ShbCirChunk,
pEvent_p->m_pArg,
(unsigned long)
pEvent_p->m_uiSize,
&fBufferCompleted);
if ((ShbError != kShbOk)
|| (fBufferCompleted == FALSE)) {
EPL_DBGLVL_EVENTK_TRACE1
("EplEventuPost(): ShbCirWriteDataChunk2(U2K) -> 0x%X\n",
ShbError);
Ret = kEplEventPostError;
goto Exit;
}
}
#else
Ret = EplEventkProcess(pEvent_p);
Ret = EplEventkProcess(pEvent_p);
#endif
break;
}
break;
}
// userspace modules
case kEplEventSinkNmtMnu:
case kEplEventSinkNmtu:
case kEplEventSinkSdoAsySeq:
case kEplEventSinkApi:
case kEplEventSinkDlluCal:
case kEplEventSinkErru:
case kEplEventSinkLedu:
{
// userspace modules
case kEplEventSinkNmtMnu:
case kEplEventSinkNmtu:
case kEplEventSinkSdoAsySeq:
case kEplEventSinkApi:
case kEplEventSinkDlluCal:
case kEplEventSinkErru:
case kEplEventSinkLedu:
{
#ifndef EPL_NO_FIFO
// post message
ShbError = ShbCirAllocDataBlock (EplEventuInstance_g.m_pShbKernelToUserInstance,
&ShbCirChunk,
ulDataSize);
if(ShbError != kShbOk)
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventuPost(): ShbCirAllocDataBlock(K2U) -> 0x%X\n", ShbError);
Ret = kEplEventPostError;
goto Exit;
}
ShbError = ShbCirWriteDataChunk (EplEventuInstance_g.m_pShbKernelToUserInstance,
&ShbCirChunk,
pEvent_p,
sizeof (tEplEvent),
&fBufferCompleted);
if(ShbError != kShbOk)
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventuPost(): ShbCirWriteDataChunk(K2U) -> 0x%X\n", ShbError);
Ret = kEplEventPostError;
goto Exit;
}
if (fBufferCompleted == FALSE)
{
ShbError = ShbCirWriteDataChunk (EplEventuInstance_g.m_pShbKernelToUserInstance,
&ShbCirChunk,
pEvent_p->m_pArg,
(unsigned long) pEvent_p->m_uiSize,
&fBufferCompleted);
if ((ShbError != kShbOk) || (fBufferCompleted == FALSE))
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventuPost(): ShbCirWriteDataChunk2(K2U) -> 0x%X\n", ShbError);
Ret = kEplEventPostError;
goto Exit;
}
}
// post message
ShbError =
ShbCirAllocDataBlock(EplEventuInstance_g.
m_pShbKernelToUserInstance,
&ShbCirChunk, ulDataSize);
if (ShbError != kShbOk) {
EPL_DBGLVL_EVENTK_TRACE1
("EplEventuPost(): ShbCirAllocDataBlock(K2U) -> 0x%X\n",
ShbError);
Ret = kEplEventPostError;
goto Exit;
}
ShbError =
ShbCirWriteDataChunk(EplEventuInstance_g.
m_pShbKernelToUserInstance,
&ShbCirChunk, pEvent_p,
sizeof(tEplEvent),
&fBufferCompleted);
if (ShbError != kShbOk) {
EPL_DBGLVL_EVENTK_TRACE1
("EplEventuPost(): ShbCirWriteDataChunk(K2U) -> 0x%X\n",
ShbError);
Ret = kEplEventPostError;
goto Exit;
}
if (fBufferCompleted == FALSE) {
ShbError =
ShbCirWriteDataChunk(EplEventuInstance_g.
m_pShbKernelToUserInstance,
&ShbCirChunk,
pEvent_p->m_pArg,
(unsigned long)
pEvent_p->m_uiSize,
&fBufferCompleted);
if ((ShbError != kShbOk)
|| (fBufferCompleted == FALSE)) {
EPL_DBGLVL_EVENTK_TRACE1
("EplEventuPost(): ShbCirWriteDataChunk2(K2U) -> 0x%X\n",
ShbError);
Ret = kEplEventPostError;
goto Exit;
}
}
#else
Ret = EplEventuProcess(pEvent_p);
Ret = EplEventuProcess(pEvent_p);
#endif
break;
}
break;
}
default:
{
Ret = kEplEventUnknownSink;
}
default:
{
Ret = kEplEventUnknownSink;
}
}// end of switch(pEvent_p->m_EventSink)
} // end of switch(pEvent_p->m_EventSink)
#ifndef EPL_NO_FIFO
Exit:
Exit:
#endif
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplEventuPostError
@ -680,36 +690,35 @@ Exit:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplEventuPostError(tEplEventSource EventSource_p,
tEplKernel EplError_p,
unsigned int uiArgSize_p,
void* pArg_p)
tEplKernel EplError_p,
unsigned int uiArgSize_p, void *pArg_p)
{
tEplKernel Ret;
BYTE abBuffer[EPL_MAX_EVENT_ARG_SIZE];
tEplEventError* pEventError = (tEplEventError*) abBuffer;
tEplEvent EplEvent;
tEplKernel Ret;
BYTE abBuffer[EPL_MAX_EVENT_ARG_SIZE];
tEplEventError *pEventError = (tEplEventError *) abBuffer;
tEplEvent EplEvent;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// create argument
pEventError->m_EventSource = EventSource_p;
pEventError->m_EplError = EplError_p;
EPL_MEMCPY(&pEventError->m_Arg, pArg_p, uiArgSize_p);
// create argument
pEventError->m_EventSource = EventSource_p;
pEventError->m_EplError = EplError_p;
EPL_MEMCPY(&pEventError->m_Arg, pArg_p, uiArgSize_p);
// create event
EplEvent.m_EventType = kEplEventTypeError;
EplEvent.m_EventSink = kEplEventSinkApi;
EPL_MEMSET(&EplEvent.m_NetTime, 0x00, sizeof(EplEvent.m_NetTime));
EplEvent.m_uiSize = (sizeof(EventSource_p)+ sizeof(EplError_p)+ uiArgSize_p);
EplEvent.m_pArg = &abBuffer[0];
// create event
EplEvent.m_EventType = kEplEventTypeError;
EplEvent.m_EventSink = kEplEventSinkApi;
EPL_MEMSET(&EplEvent.m_NetTime, 0x00, sizeof(EplEvent.m_NetTime));
EplEvent.m_uiSize =
(sizeof(EventSource_p) + sizeof(EplError_p) + uiArgSize_p);
EplEvent.m_pArg = &abBuffer[0];
// post errorevent
Ret = EplEventuPost(&EplEvent);
// post errorevent
Ret = EplEventuPost(&EplEvent);
return Ret;
return Ret;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
@ -735,19 +744,18 @@ tEplEvent EplEvent;
//
//---------------------------------------------------------------------------
#ifndef EPL_NO_FIFO
static void EplEventuRxSignalHandlerCb (
tShbInstance pShbRxInstance_p,
unsigned long ulDataSize_p)
static void EplEventuRxSignalHandlerCb(tShbInstance pShbRxInstance_p,
unsigned long ulDataSize_p)
{
tEplEvent *pEplEvent;
tShbError ShbError;
tEplEvent *pEplEvent;
tShbError ShbError;
//unsigned long ulBlockCount;
//unsigned long ulDataSize;
BYTE abDataBuffer[sizeof(tEplEvent) + EPL_MAX_EVENT_ARG_SIZE];
// d.k.: abDataBuffer contains the complete tEplEvent structure
// and behind this the argument
BYTE abDataBuffer[sizeof(tEplEvent) + EPL_MAX_EVENT_ARG_SIZE];
// d.k.: abDataBuffer contains the complete tEplEvent structure
// and behind this the argument
TGT_DBG_SIGNAL_TRACE_POINT(21);
TGT_DBG_SIGNAL_TRACE_POINT(21);
// d.k. not needed because it is already done in SharedBuff
/* do
@ -763,38 +771,32 @@ BYTE abDataBuffer[sizeof(tEplEvent) + EPL_MAX_EVENT_ARG_SIZE];
BENCHMARK_MOD_28_RESET(1); // 14 µs until set
*/
// copy data from event queue
ShbError = ShbCirReadDataBlock (pShbRxInstance_p,
&abDataBuffer[0],
sizeof(abDataBuffer),
&ulDataSize_p);
if(ShbError != kShbOk)
{
// error goto exit
goto Exit;
}
// copy data from event queue
ShbError = ShbCirReadDataBlock(pShbRxInstance_p,
&abDataBuffer[0],
sizeof(abDataBuffer), &ulDataSize_p);
if (ShbError != kShbOk) {
// error goto exit
goto Exit;
}
// resolve the pointer to the event structure
pEplEvent = (tEplEvent *) abDataBuffer;
// set Datasize
pEplEvent->m_uiSize = (ulDataSize_p - sizeof(tEplEvent));
if (pEplEvent->m_uiSize > 0) {
// set pointer to argument
pEplEvent->m_pArg = &abDataBuffer[sizeof(tEplEvent)];
} else {
//set pointer to NULL
pEplEvent->m_pArg = NULL;
}
// resolve the pointer to the event structure
pEplEvent = (tEplEvent *) abDataBuffer;
// set Datasize
pEplEvent->m_uiSize = (ulDataSize_p - sizeof(tEplEvent));
if(pEplEvent->m_uiSize > 0)
{
// set pointer to argument
pEplEvent->m_pArg = &abDataBuffer[sizeof(tEplEvent)];
}
else
{
//set pointer to NULL
pEplEvent->m_pArg = NULL;
}
BENCHMARK_MOD_28_SET(1);
// call processfunction
EplEventuProcess(pEplEvent);
BENCHMARK_MOD_28_SET(1);
// call processfunction
EplEventuProcess(pEplEvent);
BENCHMARK_MOD_28_RESET(1);
// read number of left messages to process
BENCHMARK_MOD_28_RESET(1);
// read number of left messages to process
// d.k. not needed because it is already done in SharedBuff
/* ShbError = ShbCirGetReadBlockCount (pShbRxInstance_p, &ulBlockCount);
if (ShbError != kShbOk)
@ -804,10 +806,9 @@ BYTE abDataBuffer[sizeof(tEplEvent) + EPL_MAX_EVENT_ARG_SIZE];
}
} while (ulBlockCount > 0);
*/
Exit:
return;
Exit:
return;
}
#endif
// EOF

View File

@ -95,7 +95,6 @@
// local function prototypes
//---------------------------------------------------------------------------
/***************************************************************************/
/* */
/* */
@ -109,7 +108,6 @@
//
/***************************************************************************/
//=========================================================================//
// //
// P R I V A T E D E F I N I T I O N S //
@ -124,10 +122,9 @@
// local types
//---------------------------------------------------------------------------
typedef struct
{
tEplIdentResponse* m_apIdentResponse[254]; // the IdentResponse are managed dynamically
tEplIdentuCbResponse m_apfnCbResponse[254];
typedef struct {
tEplIdentResponse *m_apIdentResponse[254]; // the IdentResponse are managed dynamically
tEplIdentuCbResponse m_apfnCbResponse[254];
} tEplIdentuInstance;
@ -135,7 +132,7 @@ typedef struct
// local vars
//---------------------------------------------------------------------------
static tEplIdentuInstance EplIdentuInstance_g;
static tEplIdentuInstance EplIdentuInstance_g;
//---------------------------------------------------------------------------
// local function prototypes
@ -169,14 +166,13 @@ static tEplKernel PUBLIC EplIdentuCbIdentResponse(tEplFrameInfo * pFrameInfo_p);
EPLDLLEXPORT tEplKernel PUBLIC EplIdentuInit()
{
tEplKernel Ret;
tEplKernel Ret;
Ret = EplIdentuAddInstance();
Ret = EplIdentuAddInstance();
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplIdentuAddInstance
@ -197,21 +193,23 @@ tEplKernel Ret;
EPLDLLEXPORT tEplKernel PUBLIC EplIdentuAddInstance()
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// reset instance structure
EPL_MEMSET(&EplIdentuInstance_g, 0, sizeof (EplIdentuInstance_g));
// reset instance structure
EPL_MEMSET(&EplIdentuInstance_g, 0, sizeof(EplIdentuInstance_g));
// register IdentResponse callback function
Ret = EplDlluCalRegAsndService(kEplDllAsndIdentResponse, EplIdentuCbIdentResponse, kEplDllAsndFilterAny);
// register IdentResponse callback function
Ret =
EplDlluCalRegAsndService(kEplDllAsndIdentResponse,
EplIdentuCbIdentResponse,
kEplDllAsndFilterAny);
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplIdentuDelInstance
@ -232,20 +230,21 @@ tEplKernel Ret;
EPLDLLEXPORT tEplKernel PUBLIC EplIdentuDelInstance()
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// deregister IdentResponse callback function
Ret = EplDlluCalRegAsndService(kEplDllAsndIdentResponse, NULL, kEplDllAsndFilterNone);
// deregister IdentResponse callback function
Ret =
EplDlluCalRegAsndService(kEplDllAsndIdentResponse, NULL,
kEplDllAsndFilterNone);
Ret = EplIdentuReset();
Ret = EplIdentuReset();
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplIdentuReset
@ -266,26 +265,25 @@ tEplKernel Ret;
EPLDLLEXPORT tEplKernel PUBLIC EplIdentuReset()
{
tEplKernel Ret;
int iIndex;
tEplKernel Ret;
int iIndex;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
for (iIndex = 0; iIndex < tabentries (EplIdentuInstance_g.m_apIdentResponse); iIndex++)
{
if (EplIdentuInstance_g.m_apIdentResponse[iIndex] != NULL)
{ // free memory
EPL_FREE(EplIdentuInstance_g.m_apIdentResponse[iIndex]);
}
}
for (iIndex = 0;
iIndex < tabentries(EplIdentuInstance_g.m_apIdentResponse);
iIndex++) {
if (EplIdentuInstance_g.m_apIdentResponse[iIndex] != NULL) { // free memory
EPL_FREE(EplIdentuInstance_g.m_apIdentResponse[iIndex]);
}
}
EPL_MEMSET(&EplIdentuInstance_g, 0, sizeof (EplIdentuInstance_g));
EPL_MEMSET(&EplIdentuInstance_g, 0, sizeof(EplIdentuInstance_g));
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplIdentuGetIdentResponse
@ -302,31 +300,28 @@ int iIndex;
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplIdentuGetIdentResponse(
unsigned int uiNodeId_p,
tEplIdentResponse** ppIdentResponse_p)
tEplKernel PUBLIC EplIdentuGetIdentResponse(unsigned int uiNodeId_p,
tEplIdentResponse **
ppIdentResponse_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// decrement node ID, because array is zero based
uiNodeId_p--;
if (uiNodeId_p < tabentries (EplIdentuInstance_g.m_apIdentResponse))
{
*ppIdentResponse_p = EplIdentuInstance_g.m_apIdentResponse[uiNodeId_p];
}
else
{ // invalid node ID specified
*ppIdentResponse_p = NULL;
Ret = kEplInvalidNodeId;
}
// decrement node ID, because array is zero based
uiNodeId_p--;
if (uiNodeId_p < tabentries(EplIdentuInstance_g.m_apIdentResponse)) {
*ppIdentResponse_p =
EplIdentuInstance_g.m_apIdentResponse[uiNodeId_p];
} else { // invalid node ID specified
*ppIdentResponse_p = NULL;
Ret = kEplInvalidNodeId;
}
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplIdentuRequestIdentResponse
@ -343,42 +338,38 @@ tEplKernel Ret;
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplIdentuRequestIdentResponse(
unsigned int uiNodeId_p,
tEplIdentuCbResponse pfnCbResponse_p)
tEplKernel PUBLIC EplIdentuRequestIdentResponse(unsigned int uiNodeId_p,
tEplIdentuCbResponse
pfnCbResponse_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// decrement node ID, because array is zero based
uiNodeId_p--;
if (uiNodeId_p < tabentries (EplIdentuInstance_g.m_apfnCbResponse))
{
// decrement node ID, because array is zero based
uiNodeId_p--;
if (uiNodeId_p < tabentries(EplIdentuInstance_g.m_apfnCbResponse)) {
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
if (EplIdentuInstance_g.m_apfnCbResponse[uiNodeId_p] != NULL)
{ // request already issued (maybe by someone else)
Ret = kEplInvalidOperation;
}
else
{
EplIdentuInstance_g.m_apfnCbResponse[uiNodeId_p] = pfnCbResponse_p;
Ret = EplDlluCalIssueRequest(kEplDllReqServiceIdent, (uiNodeId_p + 1), 0xFF);
}
if (EplIdentuInstance_g.m_apfnCbResponse[uiNodeId_p] != NULL) { // request already issued (maybe by someone else)
Ret = kEplInvalidOperation;
} else {
EplIdentuInstance_g.m_apfnCbResponse[uiNodeId_p] =
pfnCbResponse_p;
Ret =
EplDlluCalIssueRequest(kEplDllReqServiceIdent,
(uiNodeId_p + 1), 0xFF);
}
#else
Ret = kEplInvalidOperation;
Ret = kEplInvalidOperation;
#endif
}
else
{ // invalid node ID specified
Ret = kEplInvalidNodeId;
}
} else { // invalid node ID specified
Ret = kEplInvalidNodeId;
}
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplIdentuGetRunningRequests
@ -399,21 +390,18 @@ tEplKernel Ret;
EPLDLLEXPORT DWORD PUBLIC EplIdentuGetRunningRequests(void)
{
DWORD dwReqs = 0;
unsigned int uiIndex;
DWORD dwReqs = 0;
unsigned int uiIndex;
for (uiIndex = 0; uiIndex < 32; uiIndex++)
{
if (EplIdentuInstance_g.m_apfnCbResponse[uiIndex] != NULL)
{
dwReqs |= (1 << uiIndex);
}
}
for (uiIndex = 0; uiIndex < 32; uiIndex++) {
if (EplIdentuInstance_g.m_apfnCbResponse[uiIndex] != NULL) {
dwReqs |= (1 << uiIndex);
}
}
return dwReqs;
return dwReqs;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
@ -440,58 +428,61 @@ unsigned int uiIndex;
static tEplKernel PUBLIC EplIdentuCbIdentResponse(tEplFrameInfo * pFrameInfo_p)
{
tEplKernel Ret = kEplSuccessful;
unsigned int uiNodeId;
unsigned int uiIndex;
tEplIdentuCbResponse pfnCbResponse;
tEplKernel Ret = kEplSuccessful;
unsigned int uiNodeId;
unsigned int uiIndex;
tEplIdentuCbResponse pfnCbResponse;
uiNodeId = AmiGetByteFromLe(&pFrameInfo_p->m_pFrame->m_le_bSrcNodeId);
uiNodeId = AmiGetByteFromLe(&pFrameInfo_p->m_pFrame->m_le_bSrcNodeId);
uiIndex = uiNodeId - 1;
uiIndex = uiNodeId - 1;
if (uiIndex < tabentries (EplIdentuInstance_g.m_apfnCbResponse))
{
// memorize pointer to callback function
pfnCbResponse = EplIdentuInstance_g.m_apfnCbResponse[uiIndex];
// reset callback function pointer so that caller may issue next request immediately
EplIdentuInstance_g.m_apfnCbResponse[uiIndex] = NULL;
if (uiIndex < tabentries(EplIdentuInstance_g.m_apfnCbResponse)) {
// memorize pointer to callback function
pfnCbResponse = EplIdentuInstance_g.m_apfnCbResponse[uiIndex];
// reset callback function pointer so that caller may issue next request immediately
EplIdentuInstance_g.m_apfnCbResponse[uiIndex] = NULL;
if (pFrameInfo_p->m_uiFrameSize < EPL_C_DLL_MINSIZE_IDENTRES)
{ // IdentResponse not received or it has invalid size
if (pfnCbResponse == NULL)
{ // response was not requested
goto Exit;
}
Ret = pfnCbResponse(uiNodeId, NULL);
}
else
{ // IdentResponse received
if (EplIdentuInstance_g.m_apIdentResponse[uiIndex] == NULL)
{ // memory for IdentResponse must be allocated
EplIdentuInstance_g.m_apIdentResponse[uiIndex] = EPL_MALLOC(sizeof (tEplIdentResponse));
if (EplIdentuInstance_g.m_apIdentResponse[uiIndex] == NULL)
{ // malloc failed
if (pfnCbResponse == NULL)
{ // response was not requested
goto Exit;
}
Ret = pfnCbResponse(uiNodeId, &pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_IdentResponse);
goto Exit;
}
}
// copy IdentResponse to instance structure
EPL_MEMCPY(EplIdentuInstance_g.m_apIdentResponse[uiIndex], &pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_IdentResponse, sizeof(tEplIdentResponse));
if (pfnCbResponse == NULL)
{ // response was not requested
goto Exit;
}
Ret = pfnCbResponse(uiNodeId, EplIdentuInstance_g.m_apIdentResponse[uiIndex]);
}
}
if (pFrameInfo_p->m_uiFrameSize < EPL_C_DLL_MINSIZE_IDENTRES) { // IdentResponse not received or it has invalid size
if (pfnCbResponse == NULL) { // response was not requested
goto Exit;
}
Ret = pfnCbResponse(uiNodeId, NULL);
} else { // IdentResponse received
if (EplIdentuInstance_g.m_apIdentResponse[uiIndex] == NULL) { // memory for IdentResponse must be allocated
EplIdentuInstance_g.m_apIdentResponse[uiIndex] =
EPL_MALLOC(sizeof(tEplIdentResponse));
if (EplIdentuInstance_g.m_apIdentResponse[uiIndex] == NULL) { // malloc failed
if (pfnCbResponse == NULL) { // response was not requested
goto Exit;
}
Ret =
pfnCbResponse(uiNodeId,
&pFrameInfo_p->
m_pFrame->m_Data.
m_Asnd.m_Payload.
m_IdentResponse);
goto Exit;
}
}
// copy IdentResponse to instance structure
EPL_MEMCPY(EplIdentuInstance_g.
m_apIdentResponse[uiIndex],
&pFrameInfo_p->m_pFrame->m_Data.m_Asnd.
m_Payload.m_IdentResponse,
sizeof(tEplIdentResponse));
if (pfnCbResponse == NULL) { // response was not requested
goto Exit;
}
Ret =
pfnCbResponse(uiNodeId,
EplIdentuInstance_g.
m_apIdentResponse[uiIndex]);
}
}
Exit:
return Ret;
Exit:
return Ret;
}
// EOF

View File

@ -90,10 +90,9 @@
// local types
//---------------------------------------------------------------------------
typedef struct
{
unsigned int m_uiNodeId;
tEplNmtuCheckEventCallback m_pfnCheckEventCb;
typedef struct {
unsigned int m_uiNodeId;
tEplNmtuCheckEventCallback m_pfnCheckEventCb;
} tEplNmtCnuInstance;
@ -101,7 +100,7 @@ typedef struct
// modul globale vars
//---------------------------------------------------------------------------
static tEplNmtCnuInstance EplNmtCnuInstance_g;
static tEplNmtCnuInstance EplNmtCnuInstance_g;
//---------------------------------------------------------------------------
// local function prototypes
@ -109,12 +108,10 @@ static tEplNmtCnuInstance EplNmtCnuInstance_g;
static tEplNmtCommand EplNmtCnuGetNmtCommand(tEplFrameInfo * pFrameInfo_p);
static BOOL EplNmtCnuNodeIdList(BYTE* pbNmtCommandDate_p);
static BOOL EplNmtCnuNodeIdList(BYTE * pbNmtCommandDate_p);
static tEplKernel PUBLIC EplNmtCnuCommandCb(tEplFrameInfo * pFrameInfo_p);
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
@ -140,11 +137,11 @@ static tEplKernel PUBLIC EplNmtCnuCommandCb(tEplFrameInfo * pFrameInfo_p);
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuInit(unsigned int uiNodeId_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = EplNmtCnuAddInstance(uiNodeId_p);
Ret = EplNmtCnuAddInstance(uiNodeId_p);
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -166,25 +163,24 @@ tEplKernel Ret;
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuAddInstance(unsigned int uiNodeId_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// reset instance structure
EPL_MEMSET(&EplNmtCnuInstance_g, 0, sizeof (EplNmtCnuInstance_g));
// reset instance structure
EPL_MEMSET(&EplNmtCnuInstance_g, 0, sizeof(EplNmtCnuInstance_g));
// save nodeid
EplNmtCnuInstance_g.m_uiNodeId = uiNodeId_p;
// save nodeid
EplNmtCnuInstance_g.m_uiNodeId = uiNodeId_p;
// register callback-function for NMT-commands
// register callback-function for NMT-commands
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
Ret = EplDlluCalRegAsndService(kEplDllAsndNmtCommand,
EplNmtCnuCommandCb,
kEplDllAsndFilterLocal);
Ret = EplDlluCalRegAsndService(kEplDllAsndNmtCommand,
EplNmtCnuCommandCb,
kEplDllAsndFilterLocal);
#endif
return Ret;
return Ret;
}
@ -207,18 +203,17 @@ tEplKernel Ret;
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuDelInstance()
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
// deregister callback function from DLL
Ret = EplDlluCalRegAsndService(kEplDllAsndNmtCommand,
NULL,
kEplDllAsndFilterNone);
// deregister callback function from DLL
Ret = EplDlluCalRegAsndService(kEplDllAsndNmtCommand,
NULL, kEplDllAsndFilterNone);
#endif
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -239,49 +234,50 @@ tEplKernel Ret;
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuSendNmtRequest(
unsigned int uiNodeId_p,
tEplNmtCommand NmtCommand_p)
EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuSendNmtRequest(unsigned int uiNodeId_p,
tEplNmtCommand
NmtCommand_p)
{
tEplKernel Ret;
tEplFrameInfo NmtRequestFrameInfo;
tEplFrame NmtRequestFrame;
tEplKernel Ret;
tEplFrameInfo NmtRequestFrameInfo;
tEplFrame NmtRequestFrame;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// build frame
EPL_MEMSET(&NmtRequestFrame.m_be_abDstMac[0], 0x00, sizeof(NmtRequestFrame.m_be_abDstMac)); // set by DLL
EPL_MEMSET(&NmtRequestFrame.m_be_abSrcMac[0], 0x00, sizeof(NmtRequestFrame.m_be_abSrcMac)); // set by DLL
AmiSetWordToBe(&NmtRequestFrame.m_be_wEtherType,
EPL_C_DLL_ETHERTYPE_EPL);
AmiSetByteToLe(&NmtRequestFrame.m_le_bDstNodeId, (BYTE) EPL_C_ADR_MN_DEF_NODE_ID); // node id of the MN
AmiSetByteToLe(&NmtRequestFrame.m_le_bMessageType,
(BYTE) kEplMsgTypeAsnd);
AmiSetByteToLe(&NmtRequestFrame.m_Data.m_Asnd.m_le_bServiceId,
(BYTE) kEplDllAsndNmtRequest);
AmiSetByteToLe(&NmtRequestFrame.m_Data.m_Asnd.m_Payload.
m_NmtRequestService.m_le_bNmtCommandId,
(BYTE) NmtCommand_p);
AmiSetByteToLe(&NmtRequestFrame.m_Data.m_Asnd.m_Payload.m_NmtRequestService.m_le_bTargetNodeId, (BYTE) uiNodeId_p); // target for the nmt command
EPL_MEMSET(&NmtRequestFrame.m_Data.m_Asnd.m_Payload.m_NmtRequestService.
m_le_abNmtCommandData[0], 0x00,
sizeof(NmtRequestFrame.m_Data.m_Asnd.m_Payload.
m_NmtRequestService.m_le_abNmtCommandData));
// build frame
EPL_MEMSET(&NmtRequestFrame.m_be_abDstMac[0], 0x00, sizeof(NmtRequestFrame.m_be_abDstMac)); // set by DLL
EPL_MEMSET(&NmtRequestFrame.m_be_abSrcMac[0], 0x00, sizeof(NmtRequestFrame.m_be_abSrcMac)); // set by DLL
AmiSetWordToBe(&NmtRequestFrame.m_be_wEtherType, EPL_C_DLL_ETHERTYPE_EPL);
AmiSetByteToLe(&NmtRequestFrame.m_le_bDstNodeId, (BYTE) EPL_C_ADR_MN_DEF_NODE_ID); // node id of the MN
AmiSetByteToLe(&NmtRequestFrame.m_le_bMessageType, (BYTE)kEplMsgTypeAsnd);
AmiSetByteToLe(&NmtRequestFrame.m_Data.m_Asnd.m_le_bServiceId, (BYTE) kEplDllAsndNmtRequest);
AmiSetByteToLe(&NmtRequestFrame.m_Data.m_Asnd.m_Payload.m_NmtRequestService.m_le_bNmtCommandId,
(BYTE)NmtCommand_p);
AmiSetByteToLe(&NmtRequestFrame.m_Data.m_Asnd.m_Payload.m_NmtRequestService.m_le_bTargetNodeId,
(BYTE)uiNodeId_p); // target for the nmt command
EPL_MEMSET(&NmtRequestFrame.m_Data.m_Asnd.m_Payload.m_NmtRequestService.m_le_abNmtCommandData[0], 0x00, sizeof(NmtRequestFrame.m_Data.m_Asnd.m_Payload.m_NmtRequestService.m_le_abNmtCommandData));
// build info-structure
NmtRequestFrameInfo.m_NetTime.m_dwNanoSec = 0;
NmtRequestFrameInfo.m_NetTime.m_dwSec = 0;
NmtRequestFrameInfo.m_pFrame = &NmtRequestFrame;
NmtRequestFrameInfo.m_uiFrameSize = EPL_C_DLL_MINSIZE_NMTREQ; // sizeof(NmtRequestFrame);
// build info-structure
NmtRequestFrameInfo.m_NetTime.m_dwNanoSec = 0;
NmtRequestFrameInfo.m_NetTime.m_dwSec = 0;
NmtRequestFrameInfo.m_pFrame = &NmtRequestFrame;
NmtRequestFrameInfo.m_uiFrameSize = EPL_C_DLL_MINSIZE_NMTREQ; // sizeof(NmtRequestFrame);
// send NMT-Request
// send NMT-Request
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
Ret = EplDlluCalAsyncSend(&NmtRequestFrameInfo, // pointer to frameinfo
kEplDllAsyncReqPrioNmt); // priority
Ret = EplDlluCalAsyncSend(&NmtRequestFrameInfo, // pointer to frameinfo
kEplDllAsyncReqPrioNmt); // priority
#endif
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplNmtCnuRegisterStateChangeCb
@ -301,17 +297,18 @@ tEplFrame NmtRequestFrame;
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuRegisterCheckEventCb(
tEplNmtuCheckEventCallback pfnEplNmtCheckEventCb_p)
EPLDLLEXPORT tEplKernel PUBLIC
EplNmtCnuRegisterCheckEventCb(tEplNmtuCheckEventCallback
pfnEplNmtCheckEventCb_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// save callback-function in modul global var
EplNmtCnuInstance_g.m_pfnCheckEventCb = pfnEplNmtCheckEventCb_p;
// save callback-function in modul global var
EplNmtCnuInstance_g.m_pfnCheckEventCb = pfnEplNmtCheckEventCb_p;
return Ret;
return Ret;
}
@ -321,7 +318,6 @@ tEplKernel Ret;
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplNmtCnuCommandCb
@ -341,273 +337,290 @@ tEplKernel Ret;
//---------------------------------------------------------------------------
static tEplKernel PUBLIC EplNmtCnuCommandCb(tEplFrameInfo * pFrameInfo_p)
{
tEplKernel Ret = kEplSuccessful;
tEplNmtCommand NmtCommand;
BOOL fNodeIdInList;
tEplNmtEvent NmtEvent = kEplNmtEventNoEvent;
tEplKernel Ret = kEplSuccessful;
tEplNmtCommand NmtCommand;
BOOL fNodeIdInList;
tEplNmtEvent NmtEvent = kEplNmtEventNoEvent;
if (pFrameInfo_p == NULL) {
Ret = kEplNmtInvalidFramePointer;
goto Exit;
}
if(pFrameInfo_p == NULL)
{
Ret = kEplNmtInvalidFramePointer;
goto Exit;
}
NmtCommand = EplNmtCnuGetNmtCommand(pFrameInfo_p);
NmtCommand = EplNmtCnuGetNmtCommand(pFrameInfo_p);
// check NMT-Command
switch (NmtCommand) {
// check NMT-Command
switch(NmtCommand)
{
//------------------------------------------------------------------------
// plain NMT state commands
case kEplNmtCmdStartNode:
{ // send NMT-Event to state maschine kEplNmtEventStartNode
NmtEvent = kEplNmtEventStartNode;
break;
}
//------------------------------------------------------------------------
// plain NMT state commands
case kEplNmtCmdStartNode:
{ // send NMT-Event to state maschine kEplNmtEventStartNode
NmtEvent = kEplNmtEventStartNode;
break;
}
case kEplNmtCmdStopNode:
{ // send NMT-Event to state maschine kEplNmtEventStopNode
NmtEvent = kEplNmtEventStopNode;
break;
}
case kEplNmtCmdStopNode:
{ // send NMT-Event to state maschine kEplNmtEventStopNode
NmtEvent = kEplNmtEventStopNode;
break;
}
case kEplNmtCmdEnterPreOperational2:
{ // send NMT-Event to state maschine kEplNmtEventEnterPreOperational2
NmtEvent = kEplNmtEventEnterPreOperational2;
break;
}
case kEplNmtCmdEnterPreOperational2:
{ // send NMT-Event to state maschine kEplNmtEventEnterPreOperational2
NmtEvent = kEplNmtEventEnterPreOperational2;
break;
}
case kEplNmtCmdEnableReadyToOperate:
{ // send NMT-Event to state maschine kEplNmtEventEnableReadyToOperate
NmtEvent = kEplNmtEventEnableReadyToOperate;
break;
}
case kEplNmtCmdEnableReadyToOperate:
{ // send NMT-Event to state maschine kEplNmtEventEnableReadyToOperate
NmtEvent = kEplNmtEventEnableReadyToOperate;
break;
}
case kEplNmtCmdResetNode:
{ // send NMT-Event to state maschine kEplNmtEventResetNode
NmtEvent = kEplNmtEventResetNode;
break;
}
case kEplNmtCmdResetNode:
{ // send NMT-Event to state maschine kEplNmtEventResetNode
NmtEvent = kEplNmtEventResetNode;
break;
}
case kEplNmtCmdResetCommunication:
{ // send NMT-Event to state maschine kEplNmtEventResetCom
NmtEvent = kEplNmtEventResetCom;
break;
}
case kEplNmtCmdResetCommunication:
{ // send NMT-Event to state maschine kEplNmtEventResetCom
NmtEvent = kEplNmtEventResetCom;
break;
}
case kEplNmtCmdResetConfiguration:
{ // send NMT-Event to state maschine kEplNmtEventResetConfig
NmtEvent = kEplNmtEventResetConfig;
break;
}
case kEplNmtCmdResetConfiguration:
{ // send NMT-Event to state maschine kEplNmtEventResetConfig
NmtEvent = kEplNmtEventResetConfig;
break;
}
case kEplNmtCmdSwReset:
{ // send NMT-Event to state maschine kEplNmtEventSwReset
NmtEvent = kEplNmtEventSwReset;
break;
}
case kEplNmtCmdSwReset:
{ // send NMT-Event to state maschine kEplNmtEventSwReset
NmtEvent = kEplNmtEventSwReset;
break;
}
//------------------------------------------------------------------------
// extended NMT state commands
//------------------------------------------------------------------------
// extended NMT state commands
case kEplNmtCmdStartNodeEx:
{
// check if own nodeid is in EPL node list
fNodeIdInList =
EplNmtCnuNodeIdList(&
(pFrameInfo_p->m_pFrame->m_Data.
m_Asnd.m_Payload.
m_NmtCommandService.
m_le_abNmtCommandData[0]));
if (fNodeIdInList != FALSE) { // own nodeid in list
// send event to process command
NmtEvent = kEplNmtEventStartNode;
}
break;
}
case kEplNmtCmdStartNodeEx:
{
// check if own nodeid is in EPL node list
fNodeIdInList = EplNmtCnuNodeIdList(&(pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_NmtCommandService.m_le_abNmtCommandData[0]));
if(fNodeIdInList != FALSE)
{ // own nodeid in list
// send event to process command
NmtEvent = kEplNmtEventStartNode;
}
break;
}
case kEplNmtCmdStopNodeEx:
{ // check if own nodeid is in EPL node list
fNodeIdInList =
EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.
m_Asnd.m_Payload.
m_NmtCommandService.
m_le_abNmtCommandData[0]);
if (fNodeIdInList != FALSE) { // own nodeid in list
// send event to process command
NmtEvent = kEplNmtEventStopNode;
}
break;
}
case kEplNmtCmdStopNodeEx:
{ // check if own nodeid is in EPL node list
fNodeIdInList = EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_NmtCommandService.m_le_abNmtCommandData[0]);
if(fNodeIdInList != FALSE)
{ // own nodeid in list
// send event to process command
NmtEvent = kEplNmtEventStopNode;
}
break;
}
case kEplNmtCmdEnterPreOperational2Ex:
{ // check if own nodeid is in EPL node list
fNodeIdInList =
EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.
m_Asnd.m_Payload.
m_NmtCommandService.
m_le_abNmtCommandData[0]);
if (fNodeIdInList != FALSE) { // own nodeid in list
// send event to process command
NmtEvent = kEplNmtEventEnterPreOperational2;
}
break;
}
case kEplNmtCmdEnterPreOperational2Ex:
{ // check if own nodeid is in EPL node list
fNodeIdInList = EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_NmtCommandService.m_le_abNmtCommandData[0]);
if(fNodeIdInList != FALSE)
{ // own nodeid in list
// send event to process command
NmtEvent = kEplNmtEventEnterPreOperational2;
}
break;
}
case kEplNmtCmdEnableReadyToOperateEx:
{ // check if own nodeid is in EPL node list
fNodeIdInList =
EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.
m_Asnd.m_Payload.
m_NmtCommandService.
m_le_abNmtCommandData[0]);
if (fNodeIdInList != FALSE) { // own nodeid in list
// send event to process command
NmtEvent = kEplNmtEventEnableReadyToOperate;
}
break;
}
case kEplNmtCmdEnableReadyToOperateEx:
{ // check if own nodeid is in EPL node list
fNodeIdInList = EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_NmtCommandService.m_le_abNmtCommandData[0]);
if(fNodeIdInList != FALSE)
{ // own nodeid in list
// send event to process command
NmtEvent = kEplNmtEventEnableReadyToOperate;
}
break;
}
case kEplNmtCmdResetNodeEx:
{ // check if own nodeid is in EPL node list
fNodeIdInList =
EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.
m_Asnd.m_Payload.
m_NmtCommandService.
m_le_abNmtCommandData[0]);
if (fNodeIdInList != FALSE) { // own nodeid in list
// send event to process command
NmtEvent = kEplNmtEventResetNode;
}
break;
}
case kEplNmtCmdResetNodeEx:
{// check if own nodeid is in EPL node list
fNodeIdInList = EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_NmtCommandService.m_le_abNmtCommandData[0]);
if(fNodeIdInList != FALSE)
{ // own nodeid in list
// send event to process command
NmtEvent = kEplNmtEventResetNode;
}
break;
}
case kEplNmtCmdResetCommunicationEx:
{ // check if own nodeid is in EPL node list
fNodeIdInList =
EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.
m_Asnd.m_Payload.
m_NmtCommandService.
m_le_abNmtCommandData[0]);
if (fNodeIdInList != FALSE) { // own nodeid in list
// send event to process command
NmtEvent = kEplNmtEventResetCom;
}
break;
}
case kEplNmtCmdResetCommunicationEx:
{ // check if own nodeid is in EPL node list
fNodeIdInList = EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_NmtCommandService.m_le_abNmtCommandData[0]);
if(fNodeIdInList != FALSE)
{ // own nodeid in list
// send event to process command
NmtEvent = kEplNmtEventResetCom;
}
break;
}
case kEplNmtCmdResetConfigurationEx:
{ // check if own nodeid is in EPL node list
fNodeIdInList =
EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.
m_Asnd.m_Payload.
m_NmtCommandService.
m_le_abNmtCommandData[0]);
if (fNodeIdInList != FALSE) { // own nodeid in list
// send event to process command
NmtEvent = kEplNmtEventResetConfig;
}
break;
}
case kEplNmtCmdResetConfigurationEx:
{ // check if own nodeid is in EPL node list
fNodeIdInList = EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_NmtCommandService.m_le_abNmtCommandData[0]);
if(fNodeIdInList != FALSE)
{ // own nodeid in list
// send event to process command
NmtEvent = kEplNmtEventResetConfig;
}
break;
}
case kEplNmtCmdSwResetEx:
{ // check if own nodeid is in EPL node list
fNodeIdInList =
EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.
m_Asnd.m_Payload.
m_NmtCommandService.
m_le_abNmtCommandData[0]);
if (fNodeIdInList != FALSE) { // own nodeid in list
// send event to process command
NmtEvent = kEplNmtEventSwReset;
}
break;
}
case kEplNmtCmdSwResetEx:
{ // check if own nodeid is in EPL node list
fNodeIdInList = EplNmtCnuNodeIdList(&pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_NmtCommandService.m_le_abNmtCommandData[0]);
if(fNodeIdInList != FALSE)
{ // own nodeid in list
// send event to process command
NmtEvent = kEplNmtEventSwReset;
}
break;
}
//------------------------------------------------------------------------
// NMT managing commands
//------------------------------------------------------------------------
// NMT managing commands
// TODO: add functions to process managing command (optional)
// TODO: add functions to process managing command (optional)
case kEplNmtCmdNetHostNameSet:
{
break;
}
case kEplNmtCmdNetHostNameSet:
{
break;
}
case kEplNmtCmdFlushArpEntry:
{
break;
}
case kEplNmtCmdFlushArpEntry:
{
break;
}
//------------------------------------------------------------------------
// NMT info services
//------------------------------------------------------------------------
// NMT info services
// TODO: forward event with infos to the application (optional)
// TODO: forward event with infos to the application (optional)
case kEplNmtCmdPublishConfiguredCN:
{
break;
}
case kEplNmtCmdPublishConfiguredCN:
{
break;
}
case kEplNmtCmdPublishActiveCN:
{
break;
}
case kEplNmtCmdPublishActiveCN:
{
break;
}
case kEplNmtCmdPublishPreOperational1:
{
break;
}
case kEplNmtCmdPublishPreOperational1:
{
break;
}
case kEplNmtCmdPublishPreOperational2:
{
break;
}
case kEplNmtCmdPublishPreOperational2:
{
break;
}
case kEplNmtCmdPublishReadyToOperate:
{
break;
}
case kEplNmtCmdPublishReadyToOperate:
{
break;
}
case kEplNmtCmdPublishOperational:
{
break;
}
case kEplNmtCmdPublishOperational:
{
break;
}
case kEplNmtCmdPublishStopped:
{
break;
}
case kEplNmtCmdPublishStopped:
{
break;
}
case kEplNmtCmdPublishEmergencyNew:
{
break;
}
case kEplNmtCmdPublishEmergencyNew:
{
break;
}
case kEplNmtCmdPublishTime:
{
break;
}
case kEplNmtCmdPublishTime:
{
break;
}
//-----------------------------------------------------------------------
// error from MN
// -> requested command not supported by MN
case kEplNmtCmdInvalidService:
{
//-----------------------------------------------------------------------
// error from MN
// -> requested command not supported by MN
case kEplNmtCmdInvalidService:
{
// TODO: errorevent to application
break;
}
// TODO: errorevent to application
break;
}
//------------------------------------------------------------------------
// default
default:
{
Ret = kEplNmtUnknownCommand;
goto Exit;
}
//------------------------------------------------------------------------
// default
default:
{
Ret = kEplNmtUnknownCommand;
goto Exit;
}
} // end of switch(NmtCommand)
}// end of switch(NmtCommand)
if (NmtEvent != kEplNmtEventNoEvent)
{
if (EplNmtCnuInstance_g.m_pfnCheckEventCb != NULL)
{
Ret = EplNmtCnuInstance_g.m_pfnCheckEventCb(NmtEvent);
if (Ret == kEplReject)
{
Ret = kEplSuccessful;
goto Exit;
}
else if (Ret != kEplSuccessful)
{
goto Exit;
}
}
if (NmtEvent != kEplNmtEventNoEvent) {
if (EplNmtCnuInstance_g.m_pfnCheckEventCb != NULL) {
Ret = EplNmtCnuInstance_g.m_pfnCheckEventCb(NmtEvent);
if (Ret == kEplReject) {
Ret = kEplSuccessful;
goto Exit;
} else if (Ret != kEplSuccessful) {
goto Exit;
}
}
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTU)) != 0)
Ret = EplNmtuNmtEvent(NmtEvent);
Ret = EplNmtuNmtEvent(NmtEvent);
#endif
}
}
Exit:
return Ret;
Exit:
return Ret;
}
@ -631,14 +644,18 @@ Exit:
//---------------------------------------------------------------------------
static tEplNmtCommand EplNmtCnuGetNmtCommand(tEplFrameInfo * pFrameInfo_p)
{
tEplNmtCommand NmtCommand;
tEplNmtCommandService* pNmtCommandService;
tEplNmtCommand NmtCommand;
tEplNmtCommandService *pNmtCommandService;
pNmtCommandService = &pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_NmtCommandService;
pNmtCommandService =
&pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.
m_NmtCommandService;
NmtCommand = (tEplNmtCommand)AmiGetByteFromLe(&pNmtCommandService->m_le_bNmtCommandId);
NmtCommand =
(tEplNmtCommand) AmiGetByteFromLe(&pNmtCommandService->
m_le_bNmtCommandId);
return NmtCommand;
return NmtCommand;
}
//---------------------------------------------------------------------------
@ -659,33 +676,29 @@ tEplNmtCommandService* pNmtCommandService;
// State:
//
//---------------------------------------------------------------------------
static BOOL EplNmtCnuNodeIdList(BYTE* pbNmtCommandDate_p)
static BOOL EplNmtCnuNodeIdList(BYTE * pbNmtCommandDate_p)
{
BOOL fNodeIdInList;
unsigned int uiByteOffset;
BYTE bBitOffset;
BYTE bNodeListByte;
BOOL fNodeIdInList;
unsigned int uiByteOffset;
BYTE bBitOffset;
BYTE bNodeListByte;
// get byte-offset of the own nodeid in NodeIdList
// devide though 8
uiByteOffset = (unsigned int)(EplNmtCnuInstance_g.m_uiNodeId >> 3);
// get bitoffset
bBitOffset = (BYTE) EplNmtCnuInstance_g.m_uiNodeId % 8;
// get byte-offset of the own nodeid in NodeIdList
// devide though 8
uiByteOffset = (unsigned int)(EplNmtCnuInstance_g.m_uiNodeId >> 3);
// get bitoffset
bBitOffset = (BYTE) EplNmtCnuInstance_g.m_uiNodeId % 8;
bNodeListByte = AmiGetByteFromLe(&pbNmtCommandDate_p[uiByteOffset]);
if((bNodeListByte & bBitOffset) == 0)
{
fNodeIdInList = FALSE;
}
else
{
fNodeIdInList = TRUE;
}
bNodeListByte = AmiGetByteFromLe(&pbNmtCommandDate_p[uiByteOffset]);
if ((bNodeListByte & bBitOffset) == 0) {
fNodeIdInList = FALSE;
} else {
fNodeIdInList = TRUE;
}
return fNodeIdInList;
return fNodeIdInList;
}
#endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_CN)) != 0)
// EOF

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -71,11 +71,9 @@
#include "kernel/EplNmtkCal.h"
// TODO: init function needed to prepare EplNmtkGetNmtState for
// io-controll-call from EplNmtuCal-Modul
/***************************************************************************/
/* */
/* */
@ -100,8 +98,6 @@
// local function prototypes
//---------------------------------------------------------------------------
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
@ -126,7 +122,6 @@
//
//---------------------------------------------------------------------------
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
@ -151,7 +146,4 @@
//
//---------------------------------------------------------------------------
// EOF

View File

@ -68,7 +68,6 @@
****************************************************************************/
#include "EplInc.h"
#include "user/EplNmtu.h"
#include "user/EplObdu.h"
@ -94,10 +93,9 @@
// local types
//---------------------------------------------------------------------------
typedef struct
{
tEplNmtuStateChangeCallback m_pfnNmtChangeCb;
tEplTimerHdl m_TimerHdl;
typedef struct {
tEplNmtuStateChangeCallback m_pfnNmtChangeCb;
tEplTimerHdl m_TimerHdl;
} tEplNmtuInstance;
@ -136,11 +134,11 @@ static tEplNmtuInstance EplNmtuInstance_g;
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtuInit()
{
tEplKernel Ret;
tEplKernel Ret;
Ret = EplNmtuAddInstance();
Ret = EplNmtuAddInstance();
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -162,13 +160,13 @@ tEplKernel Ret;
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtuAddInstance()
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
EplNmtuInstance_g.m_pfnNmtChangeCb = NULL;
EplNmtuInstance_g.m_pfnNmtChangeCb = NULL;
return Ret;
return Ret;
}
@ -191,16 +189,16 @@ tEplKernel Ret;
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtuDelInstance()
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
EplNmtuInstance_g.m_pfnNmtChangeCb = NULL;
EplNmtuInstance_g.m_pfnNmtChangeCb = NULL;
// delete timer
Ret = EplTimeruDeleteTimer(&EplNmtuInstance_g.m_TimerHdl);
// delete timer
Ret = EplTimeruDeleteTimer(&EplNmtuInstance_g.m_TimerHdl);
return Ret;
return Ret;
}
@ -223,20 +221,19 @@ tEplKernel Ret;
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtuNmtEvent(tEplNmtEvent NmtEvent_p)
{
tEplKernel Ret;
tEplEvent Event;
tEplKernel Ret;
tEplEvent Event;
Event.m_EventSink = kEplEventSinkNmtk;
Event.m_NetTime.m_dwNanoSec = 0;
Event.m_NetTime.m_dwSec = 0;
Event.m_EventType = kEplEventTypeNmtEvent;
Event.m_pArg = &NmtEvent_p;
Event.m_uiSize = sizeof(NmtEvent_p);
Event.m_EventSink = kEplEventSinkNmtk;
Event.m_NetTime.m_dwNanoSec = 0;
Event.m_NetTime.m_dwSec = 0;
Event.m_EventType = kEplEventTypeNmtEvent;
Event.m_pArg = &NmtEvent_p;
Event.m_uiSize = sizeof(NmtEvent_p);
Ret = EplEventuPost(&Event);
Ret = EplEventuPost(&Event);
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -258,16 +255,16 @@ tEplEvent Event;
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplNmtState PUBLIC EplNmtuGetNmtState()
{
tEplNmtState NmtState;
tEplNmtState NmtState;
// $$$ call function of communication abstraction layer
// $$$ call function of communication abstraction layer
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0)
NmtState = EplNmtkGetNmtState();
NmtState = EplNmtkGetNmtState();
#else
NmtState = 0;
NmtState = 0;
#endif
return NmtState;
return NmtState;
}
//---------------------------------------------------------------------------
@ -287,335 +284,366 @@ tEplNmtState NmtState;
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtuProcessEvent(
tEplEvent* pEplEvent_p)
EPLDLLEXPORT tEplKernel PUBLIC EplNmtuProcessEvent(tEplEvent * pEplEvent_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// process event
switch(pEplEvent_p->m_EventType)
{
// state change of NMT-Module
case kEplEventTypeNmtStateChange:
{
tEplEventNmtStateChange* pNmtStateChange;
// process event
switch (pEplEvent_p->m_EventType) {
// state change of NMT-Module
case kEplEventTypeNmtStateChange:
{
tEplEventNmtStateChange *pNmtStateChange;
// delete timer
Ret = EplTimeruDeleteTimer(&EplNmtuInstance_g.m_TimerHdl);
// delete timer
Ret =
EplTimeruDeleteTimer(&EplNmtuInstance_g.m_TimerHdl);
pNmtStateChange = (tEplEventNmtStateChange*)pEplEvent_p->m_pArg;
pNmtStateChange =
(tEplEventNmtStateChange *) pEplEvent_p->m_pArg;
// call cb-functions to inform higher layer
if(EplNmtuInstance_g.m_pfnNmtChangeCb != NULL)
{
Ret = EplNmtuInstance_g.m_pfnNmtChangeCb(*pNmtStateChange);
}
// call cb-functions to inform higher layer
if (EplNmtuInstance_g.m_pfnNmtChangeCb != NULL) {
Ret =
EplNmtuInstance_g.
m_pfnNmtChangeCb(*pNmtStateChange);
}
if (Ret == kEplSuccessful)
{ // everything is OK, so switch to next state if necessary
switch (pNmtStateChange->m_NewNmtState)
{
// EPL stack is not running
case kEplNmtGsOff:
break;
if (Ret == kEplSuccessful) { // everything is OK, so switch to next state if necessary
switch (pNmtStateChange->m_NewNmtState) {
// EPL stack is not running
case kEplNmtGsOff:
break;
// first init of the hardware
case kEplNmtGsInitialising:
{
Ret = EplNmtuNmtEvent(kEplNmtEventEnterResetApp);
break;
}
// first init of the hardware
case kEplNmtGsInitialising:
{
Ret =
EplNmtuNmtEvent
(kEplNmtEventEnterResetApp);
break;
}
// init of the manufacturer-specific profile area and the
// standardised device profile area
case kEplNmtGsResetApplication:
{
Ret = EplNmtuNmtEvent(kEplNmtEventEnterResetCom);
break;
}
// init of the manufacturer-specific profile area and the
// standardised device profile area
case kEplNmtGsResetApplication:
{
Ret =
EplNmtuNmtEvent
(kEplNmtEventEnterResetCom);
break;
}
// init of the communication profile area
case kEplNmtGsResetCommunication:
{
Ret = EplNmtuNmtEvent(kEplNmtEventEnterResetConfig);
break;
}
// init of the communication profile area
case kEplNmtGsResetCommunication:
{
Ret =
EplNmtuNmtEvent
(kEplNmtEventEnterResetConfig);
break;
}
// build the configuration with infos from OD
case kEplNmtGsResetConfiguration:
{
unsigned int uiNodeId;
// build the configuration with infos from OD
case kEplNmtGsResetConfiguration:
{
unsigned int uiNodeId;
// get node ID from OD
// get node ID from OD
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0) || (EPL_OBD_USE_KERNEL != FALSE)
uiNodeId = EplObduGetNodeId(EPL_MCO_PTR_INSTANCE_PTR);
uiNodeId =
EplObduGetNodeId
(EPL_MCO_PTR_INSTANCE_PTR);
#else
uiNodeId = 0;
uiNodeId = 0;
#endif
//check node ID if not should be master or slave
if (uiNodeId == EPL_C_ADR_MN_DEF_NODE_ID)
{ // node shall be MN
//check node ID if not should be master or slave
if (uiNodeId == EPL_C_ADR_MN_DEF_NODE_ID) { // node shall be MN
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
Ret = EplNmtuNmtEvent(kEplNmtEventEnterMsNotActive);
Ret =
EplNmtuNmtEvent
(kEplNmtEventEnterMsNotActive);
#else
TRACE0("EplNmtuProcess(): no MN functionality implemented\n");
TRACE0
("EplNmtuProcess(): no MN functionality implemented\n");
#endif
}
else
{ // node shall be CN
Ret = EplNmtuNmtEvent(kEplNmtEventEnterCsNotActive);
}
break;
}
} else { // node shall be CN
Ret =
EplNmtuNmtEvent
(kEplNmtEventEnterCsNotActive);
}
break;
}
//-----------------------------------------------------------
// CN part of the state machine
//-----------------------------------------------------------
// CN part of the state machine
// node listens for EPL-Frames and check timeout
case kEplNmtCsNotActive:
{
DWORD dwBuffer;
tEplObdSize ObdSize;
tEplTimerArg TimerArg;
// node listens for EPL-Frames and check timeout
case kEplNmtCsNotActive:
{
DWORD dwBuffer;
tEplObdSize ObdSize;
tEplTimerArg TimerArg;
// create timer to switch automatically to BasicEthernet if no MN available in network
// create timer to switch automatically to BasicEthernet if no MN available in network
// read NMT_CNBasicEthernetTimerout_U32 from OD
ObdSize = sizeof(dwBuffer);
// read NMT_CNBasicEthernetTimerout_U32 from OD
ObdSize = sizeof(dwBuffer);
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0) || (EPL_OBD_USE_KERNEL != FALSE)
Ret = EplObduReadEntry(EPL_MCO_PTR_INSTANCE_PTR_
0x1F99,
0x00,
&dwBuffer,
&ObdSize);
Ret =
EplObduReadEntry
(EPL_MCO_PTR_INSTANCE_PTR_
0x1F99, 0x00, &dwBuffer,
&ObdSize);
#else
Ret = kEplObdIndexNotExist;
Ret = kEplObdIndexNotExist;
#endif
if(Ret != kEplSuccessful)
{
break;
}
if (dwBuffer != 0)
{ // BasicEthernet is enabled
// convert us into ms
dwBuffer = dwBuffer / 1000;
if (dwBuffer == 0)
{ // timer was below one ms
// set one ms
dwBuffer = 1;
}
TimerArg.m_EventSink = kEplEventSinkNmtk;
TimerArg.m_ulArg = (unsigned long) kEplNmtEventTimerBasicEthernet;
Ret = EplTimeruModifyTimerMs(&EplNmtuInstance_g.m_TimerHdl, (unsigned long) dwBuffer, TimerArg);
// potential error is forwarded to event queue which generates error event
}
break;
}
if (Ret != kEplSuccessful) {
break;
}
if (dwBuffer != 0) { // BasicEthernet is enabled
// convert us into ms
dwBuffer =
dwBuffer / 1000;
if (dwBuffer == 0) { // timer was below one ms
// set one ms
dwBuffer = 1;
}
TimerArg.m_EventSink =
kEplEventSinkNmtk;
TimerArg.m_ulArg =
(unsigned long)
kEplNmtEventTimerBasicEthernet;
Ret =
EplTimeruModifyTimerMs
(&EplNmtuInstance_g.
m_TimerHdl,
(unsigned long)
dwBuffer,
TimerArg);
// potential error is forwarded to event queue which generates error event
}
break;
}
// node processes only async frames
case kEplNmtCsPreOperational1:
{
break;
}
// node processes only async frames
case kEplNmtCsPreOperational1:
{
break;
}
// node processes isochronous and asynchronous frames
case kEplNmtCsPreOperational2:
{
Ret = EplNmtuNmtEvent(kEplNmtEventEnterReadyToOperate);
break;
}
// node processes isochronous and asynchronous frames
case kEplNmtCsPreOperational2:
{
Ret =
EplNmtuNmtEvent
(kEplNmtEventEnterReadyToOperate);
break;
}
// node should be configured und application is ready
case kEplNmtCsReadyToOperate:
{
break;
}
// node should be configured und application is ready
case kEplNmtCsReadyToOperate:
{
break;
}
// normal work state
case kEplNmtCsOperational:
{
break;
}
// normal work state
case kEplNmtCsOperational:
{
break;
}
// node stopped by MN
// -> only process asynchronous frames
case kEplNmtCsStopped:
{
break;
}
// node stopped by MN
// -> only process asynchronous frames
case kEplNmtCsStopped:
{
break;
}
// no EPL cycle
// -> normal ethernet communication
case kEplNmtCsBasicEthernet:
{
break;
}
// no EPL cycle
// -> normal ethernet communication
case kEplNmtCsBasicEthernet:
{
break;
}
//-----------------------------------------------------------
// MN part of the state machine
//-----------------------------------------------------------
// MN part of the state machine
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
// node listens for EPL-Frames and check timeout
case kEplNmtMsNotActive:
{
DWORD dwBuffer;
tEplObdSize ObdSize;
tEplTimerArg TimerArg;
// node listens for EPL-Frames and check timeout
case kEplNmtMsNotActive:
{
DWORD dwBuffer;
tEplObdSize ObdSize;
tEplTimerArg TimerArg;
// create timer to switch automatically to BasicEthernet/PreOp1 if no other MN active in network
// create timer to switch automatically to BasicEthernet/PreOp1 if no other MN active in network
// check NMT_StartUp_U32.Bit13
// read NMT_StartUp_U32 from OD
ObdSize = sizeof(dwBuffer);
// check NMT_StartUp_U32.Bit13
// read NMT_StartUp_U32 from OD
ObdSize = sizeof(dwBuffer);
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0) || (EPL_OBD_USE_KERNEL != FALSE)
Ret = EplObduReadEntry(EPL_MCO_PTR_INSTANCE_PTR_
0x1F80,
0x00,
&dwBuffer,
&ObdSize);
Ret =
EplObduReadEntry
(EPL_MCO_PTR_INSTANCE_PTR_
0x1F80, 0x00, &dwBuffer,
&ObdSize);
#else
Ret = kEplObdIndexNotExist;
Ret = kEplObdIndexNotExist;
#endif
if(Ret != kEplSuccessful)
{
break;
}
if (Ret != kEplSuccessful) {
break;
}
if((dwBuffer & EPL_NMTST_BASICETHERNET) == 0)
{ // NMT_StartUp_U32.Bit13 == 0
// new state PreOperational1
TimerArg.m_ulArg = (unsigned long) kEplNmtEventTimerMsPreOp1;
}
else
{ // NMT_StartUp_U32.Bit13 == 1
// new state BasicEthernet
TimerArg.m_ulArg = (unsigned long) kEplNmtEventTimerBasicEthernet;
}
if ((dwBuffer & EPL_NMTST_BASICETHERNET) == 0) { // NMT_StartUp_U32.Bit13 == 0
// new state PreOperational1
TimerArg.m_ulArg =
(unsigned long)
kEplNmtEventTimerMsPreOp1;
} else { // NMT_StartUp_U32.Bit13 == 1
// new state BasicEthernet
TimerArg.m_ulArg =
(unsigned long)
kEplNmtEventTimerBasicEthernet;
}
// read NMT_BootTime_REC.MNWaitNotAct_U32 from OD
ObdSize = sizeof(dwBuffer);
// read NMT_BootTime_REC.MNWaitNotAct_U32 from OD
ObdSize = sizeof(dwBuffer);
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0) || (EPL_OBD_USE_KERNEL != FALSE)
Ret = EplObduReadEntry(EPL_MCO_PTR_INSTANCE_PTR_
0x1F89,
0x01,
&dwBuffer,
&ObdSize);
Ret =
EplObduReadEntry
(EPL_MCO_PTR_INSTANCE_PTR_
0x1F89, 0x01, &dwBuffer,
&ObdSize);
#else
Ret = kEplObdIndexNotExist;
Ret = kEplObdIndexNotExist;
#endif
if(Ret != kEplSuccessful)
{
break;
}
// convert us into ms
dwBuffer = dwBuffer / 1000;
if (dwBuffer == 0)
{ // timer was below one ms
// set one ms
dwBuffer = 1;
}
TimerArg.m_EventSink = kEplEventSinkNmtk;
Ret = EplTimeruModifyTimerMs(&EplNmtuInstance_g.m_TimerHdl, (unsigned long) dwBuffer, TimerArg);
// potential error is forwarded to event queue which generates error event
break;
}
if (Ret != kEplSuccessful) {
break;
}
// convert us into ms
dwBuffer = dwBuffer / 1000;
if (dwBuffer == 0) { // timer was below one ms
// set one ms
dwBuffer = 1;
}
TimerArg.m_EventSink =
kEplEventSinkNmtk;
Ret =
EplTimeruModifyTimerMs
(&EplNmtuInstance_g.
m_TimerHdl,
(unsigned long)dwBuffer,
TimerArg);
// potential error is forwarded to event queue which generates error event
break;
}
// node processes only async frames
case kEplNmtMsPreOperational1:
{
DWORD dwBuffer = 0;
tEplObdSize ObdSize;
tEplTimerArg TimerArg;
// node processes only async frames
case kEplNmtMsPreOperational1:
{
DWORD dwBuffer = 0;
tEplObdSize ObdSize;
tEplTimerArg TimerArg;
// create timer to switch automatically to PreOp2 if MN identified all mandatory CNs
// create timer to switch automatically to PreOp2 if MN identified all mandatory CNs
// read NMT_BootTime_REC.MNWaitPreOp1_U32 from OD
ObdSize = sizeof(dwBuffer);
// read NMT_BootTime_REC.MNWaitPreOp1_U32 from OD
ObdSize = sizeof(dwBuffer);
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0) || (EPL_OBD_USE_KERNEL != FALSE)
Ret = EplObduReadEntry(EPL_MCO_PTR_INSTANCE_PTR_
0x1F89,
0x03,
&dwBuffer,
&ObdSize);
if(Ret != kEplSuccessful)
{
// ignore error, because this timeout is optional
dwBuffer = 0;
}
Ret =
EplObduReadEntry
(EPL_MCO_PTR_INSTANCE_PTR_
0x1F89, 0x03, &dwBuffer,
&ObdSize);
if (Ret != kEplSuccessful) {
// ignore error, because this timeout is optional
dwBuffer = 0;
}
#endif
if (dwBuffer == 0)
{ // delay is deactivated
// immediately post timer event
Ret = EplNmtuNmtEvent(kEplNmtEventTimerMsPreOp2);
break;
}
// convert us into ms
dwBuffer = dwBuffer / 1000;
if (dwBuffer == 0)
{ // timer was below one ms
// set one ms
dwBuffer = 1;
}
TimerArg.m_EventSink = kEplEventSinkNmtk;
TimerArg.m_ulArg = (unsigned long) kEplNmtEventTimerMsPreOp2;
Ret = EplTimeruModifyTimerMs(&EplNmtuInstance_g.m_TimerHdl, (unsigned long) dwBuffer, TimerArg);
// potential error is forwarded to event queue which generates error event
break;
}
if (dwBuffer == 0) { // delay is deactivated
// immediately post timer event
Ret =
EplNmtuNmtEvent
(kEplNmtEventTimerMsPreOp2);
break;
}
// convert us into ms
dwBuffer = dwBuffer / 1000;
if (dwBuffer == 0) { // timer was below one ms
// set one ms
dwBuffer = 1;
}
TimerArg.m_EventSink =
kEplEventSinkNmtk;
TimerArg.m_ulArg =
(unsigned long)
kEplNmtEventTimerMsPreOp2;
Ret =
EplTimeruModifyTimerMs
(&EplNmtuInstance_g.
m_TimerHdl,
(unsigned long)dwBuffer,
TimerArg);
// potential error is forwarded to event queue which generates error event
break;
}
// node processes isochronous and asynchronous frames
case kEplNmtMsPreOperational2:
{
break;
}
// node processes isochronous and asynchronous frames
case kEplNmtMsPreOperational2:
{
break;
}
// node should be configured und application is ready
case kEplNmtMsReadyToOperate:
{
break;
}
// node should be configured und application is ready
case kEplNmtMsReadyToOperate:
{
break;
}
// normal work state
case kEplNmtMsOperational:
{
break;
}
// normal work state
case kEplNmtMsOperational:
{
break;
}
// no EPL cycle
// -> normal ethernet communication
case kEplNmtMsBasicEthernet:
{
break;
}
// no EPL cycle
// -> normal ethernet communication
case kEplNmtMsBasicEthernet:
{
break;
}
#endif // (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
default:
{
TRACE1("EplNmtuProcess(): unhandled NMT state 0x%X\n", pNmtStateChange->m_NewNmtState);
}
}
}
else if (Ret == kEplReject)
{ // application wants to change NMT state itself
// it's OK
Ret = kEplSuccessful;
}
default:
{
TRACE1
("EplNmtuProcess(): unhandled NMT state 0x%X\n",
pNmtStateChange->
m_NewNmtState);
}
}
} else if (Ret == kEplReject) { // application wants to change NMT state itself
// it's OK
Ret = kEplSuccessful;
}
EPL_DBGLVL_NMTU_TRACE0("EplNmtuProcessEvent(): NMT-State-Maschine announce change of NMT State\n");
break;
}
EPL_DBGLVL_NMTU_TRACE0
("EplNmtuProcessEvent(): NMT-State-Maschine announce change of NMT State\n");
break;
}
default:
{
Ret = kEplNmtInvalidEvent;
}
default:
{
Ret = kEplNmtInvalidEvent;
}
}
}
//Exit:
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -636,17 +664,18 @@ tEplKernel Ret;
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtuRegisterStateChangeCb(
tEplNmtuStateChangeCallback pfnEplNmtStateChangeCb_p)
EPLDLLEXPORT tEplKernel PUBLIC
EplNmtuRegisterStateChangeCb(tEplNmtuStateChangeCallback
pfnEplNmtStateChangeCb_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// save callback-function in modul global var
EplNmtuInstance_g.m_pfnNmtChangeCb = pfnEplNmtStateChangeCb_p;
// save callback-function in modul global var
EplNmtuInstance_g.m_pfnNmtChangeCb = pfnEplNmtStateChangeCb_p;
return Ret;
return Ret;
}
@ -676,6 +705,4 @@ tEplKernel Ret;
#endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTU)) != 0)
// EOF

View File

@ -95,9 +95,6 @@
// local function prototypes
//---------------------------------------------------------------------------
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
@ -124,14 +121,14 @@
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplNmtState PUBLIC EplNmtkCalGetNmtState()
{
tEplNmtState NmtState;
// for test direkt call for EplNmtkGetNmtState()
tEplNmtState NmtState;
// for test direkt call for EplNmtkGetNmtState()
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0)
NmtState = EplNmtkGetNmtState();
NmtState = EplNmtkGetNmtState();
#else
NmtState = 0;
NmtState = 0;
#endif
return NmtState;
return NmtState;
}
//=========================================================================//
@ -158,7 +155,4 @@ return NmtState;
//
//---------------------------------------------------------------------------
// EOF

File diff suppressed because it is too large Load Diff

View File

@ -96,9 +96,6 @@
// local function prototypes
//---------------------------------------------------------------------------
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
@ -123,7 +120,6 @@
//
//---------------------------------------------------------------------------
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
@ -148,7 +144,4 @@
//
//---------------------------------------------------------------------------
// EOF

View File

@ -97,8 +97,6 @@
// local function prototypes
//---------------------------------------------------------------------------
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
@ -123,19 +121,18 @@
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduWriteEntry (unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void * pSrcData_p,
tEplObdSize Size_p)
EPLDLLEXPORT tEplKernel PUBLIC EplObduWriteEntry(unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void *pSrcData_p,
tEplObdSize Size_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = EplObduCalWriteEntry(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
Ret = EplObduCalWriteEntry(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplObduReadEntry()
@ -156,19 +153,18 @@ tEplKernel Ret;
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduReadEntry (unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void * pDstData_p,
tEplObdSize* pSize_p)
EPLDLLEXPORT tEplKernel PUBLIC EplObduReadEntry(unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void *pDstData_p,
tEplObdSize * pSize_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = EplObduCalReadEntry(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
Ret = EplObduCalReadEntry(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplObdAccessOdPart()
@ -183,14 +179,14 @@ tEplKernel Ret;
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduAccessOdPart (tEplObdPart ObdPart_p,
tEplObdDir Direction_p)
EPLDLLEXPORT tEplKernel PUBLIC EplObduAccessOdPart(tEplObdPart ObdPart_p,
tEplObdDir Direction_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = EplObduCalAccessOdPart(ObdPart_p, Direction_p);
Ret = EplObduCalAccessOdPart(ObdPart_p, Direction_p);
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -206,13 +202,13 @@ tEplKernel Ret;
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduDefineVar (tEplVarParam MEM* pVarParam_p)
EPLDLLEXPORT tEplKernel PUBLIC EplObduDefineVar(tEplVarParam MEM * pVarParam_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = EplObduCalDefineVar(pVarParam_p);
Ret = EplObduCalDefineVar(pVarParam_p);
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -230,14 +226,14 @@ tEplKernel Ret;
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT void* PUBLIC EplObduGetObjectDataPtr (unsigned int uiIndex_p,
unsigned int uiSubIndex_p)
EPLDLLEXPORT void *PUBLIC EplObduGetObjectDataPtr(unsigned int uiIndex_p,
unsigned int uiSubIndex_p)
{
void* pData;
void *pData;
pData = EplObduCalGetObjectDataPtr(uiIndex_p, uiSubIndex_p);
pData = EplObduCalGetObjectDataPtr(uiIndex_p, uiSubIndex_p);
return pData;
return pData;
}
//---------------------------------------------------------------------------
@ -254,13 +250,13 @@ void* pData;
//
//---------------------------------------------------------------------------
#if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE))
EPLDLLEXPORT tEplKernel PUBLIC EplObduRegisterUserOd (tEplObdEntryPtr pUserOd_p)
EPLDLLEXPORT tEplKernel PUBLIC EplObduRegisterUserOd(tEplObdEntryPtr pUserOd_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = EplObduCalRegisterUserOd(pUserOd_p);
Ret = EplObduCalRegisterUserOd(pUserOd_p);
return Ret;
return Ret;
}
#endif
@ -279,10 +275,11 @@ tEplKernel Ret;
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT void PUBLIC EplObduInitVarEntry (tEplObdVarEntry MEM* pVarEntry_p,
BYTE bType_p, tEplObdSize ObdSize_p)
EPLDLLEXPORT void PUBLIC EplObduInitVarEntry(tEplObdVarEntry MEM * pVarEntry_p,
BYTE bType_p,
tEplObdSize ObdSize_p)
{
EplObduCalInitVarEntry(pVarEntry_p, bType_p, ObdSize_p);
EplObduCalInitVarEntry(pVarEntry_p, bType_p, ObdSize_p);
}
//---------------------------------------------------------------------------
@ -303,13 +300,13 @@ EPLDLLEXPORT void PUBLIC EplObduInitVarEntry (tEplObdVarEntry MEM* pVarEntry_p,
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplObdSize PUBLIC EplObduGetDataSize(unsigned int uiIndex_p,
unsigned int uiSubIndex_p)
unsigned int uiSubIndex_p)
{
tEplObdSize Size;
tEplObdSize Size;
Size = EplObduCalGetDataSize(uiIndex_p, uiSubIndex_p);
Size = EplObduCalGetDataSize(uiIndex_p, uiSubIndex_p);
return Size;
return Size;
}
//---------------------------------------------------------------------------
@ -328,11 +325,11 @@ tEplObdSize Size;
//---------------------------------------------------------------------------
EPLDLLEXPORT unsigned int PUBLIC EplObduGetNodeId()
{
unsigned int uiNodeId;
unsigned int uiNodeId;
uiNodeId = EplObduCalGetNodeId();
uiNodeId = EplObduCalGetNodeId();
return uiNodeId;
return uiNodeId;
}
//---------------------------------------------------------------------------
@ -351,13 +348,13 @@ unsigned int uiNodeId;
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduSetNodeId(unsigned int uiNodeId_p,
tEplObdNodeIdType NodeIdType_p)
tEplObdNodeIdType NodeIdType_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = EplObduCalSetNodeId(uiNodeId_p, NodeIdType_p);
Ret = EplObduCalSetNodeId(uiNodeId_p, NodeIdType_p);
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -377,14 +374,16 @@ tEplKernel Ret;
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduGetAccessType(unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
tEplObdAccess* pAccessTyp_p)
unsigned int uiSubIndex_p,
tEplObdAccess *
pAccessTyp_p)
{
tEplObdAccess AccessType;
tEplObdAccess AccessType;
AccessType = EplObduCalGetAccessType(uiIndex_p, uiSubIndex_p, pAccessTyp_p);
AccessType =
EplObduCalGetAccessType(uiIndex_p, uiSubIndex_p, pAccessTyp_p);
return AccessType;
return AccessType;
}
//---------------------------------------------------------------------------
@ -411,16 +410,18 @@ tEplObdAccess AccessType;
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduReadEntryToLe (unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void * pDstData_p,
tEplObdSize * pSize_p)
EPLDLLEXPORT tEplKernel PUBLIC EplObduReadEntryToLe(unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void *pDstData_p,
tEplObdSize * pSize_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = EplObduCalReadEntryToLe(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
Ret =
EplObduCalReadEntryToLe(uiIndex_p, uiSubIndex_p, pDstData_p,
pSize_p);
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -444,16 +445,19 @@ return Ret;
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduWriteEntryFromLe (unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void * pSrcData_p,
tEplObdSize Size_p)
EPLDLLEXPORT tEplKernel PUBLIC EplObduWriteEntryFromLe(unsigned int uiIndex_p,
unsigned int
uiSubIndex_p,
void *pSrcData_p,
tEplObdSize Size_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = EplObduCalWriteEntryFromLe(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
Ret =
EplObduCalWriteEntryFromLe(uiIndex_p, uiSubIndex_p, pSrcData_p,
Size_p);
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -471,17 +475,19 @@ return Ret;
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduSearchVarEntry (EPL_MCO_DECL_INSTANCE_PTR_
unsigned int uiIndex_p,
unsigned int uiSubindex_p,
tEplObdVarEntry MEM** ppVarEntry_p)
EPLDLLEXPORT tEplKernel PUBLIC EplObduSearchVarEntry(EPL_MCO_DECL_INSTANCE_PTR_
unsigned int uiIndex_p,
unsigned int uiSubindex_p,
tEplObdVarEntry MEM **
ppVarEntry_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = EplObduCalSearchVarEntry(uiIndex_p, uiSubindex_p, ppVarEntry_p);
Ret = EplObduCalSearchVarEntry(uiIndex_p, uiSubindex_p, ppVarEntry_p);
return Ret;
return Ret;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
@ -509,4 +515,3 @@ return Ret;
#endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0)
// EOF

View File

@ -74,7 +74,6 @@
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0) && (EPL_OBD_USE_KERNEL != FALSE)
/***************************************************************************/
/* */
/* */
@ -99,8 +98,6 @@
// local function prototypes
//---------------------------------------------------------------------------
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
@ -124,24 +121,22 @@
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalWriteEntry (
unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void * pSrcData_p,
tEplObdSize Size_p)
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalWriteEntry(unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void *pSrcData_p,
tEplObdSize Size_p)
{
tEplKernel Ret;
tEplKernel Ret;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
Ret = EplObdWriteEntry(uiIndex_p,uiSubIndex_p,pSrcData_p,Size_p);
Ret = EplObdWriteEntry(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
#else
Ret = kEplSuccessful;
Ret = kEplSuccessful;
#endif
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplObduCalReadEntry()
@ -160,24 +155,22 @@ tEplKernel Ret;
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalReadEntry (
unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void * pDstData_p,
tEplObdSize *pSize_p)
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalReadEntry(unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void *pDstData_p,
tEplObdSize * pSize_p)
{
tEplKernel Ret;
tEplKernel Ret;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
Ret = EplObdReadEntry(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
Ret = EplObdReadEntry(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
#else
Ret = kEplSuccessful;
Ret = kEplSuccessful;
#endif
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplObduCalAccessOdPart()
@ -192,19 +185,18 @@ tEplKernel Ret;
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalAccessOdPart (
tEplObdPart ObdPart_p,
tEplObdDir Direction_p)
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalAccessOdPart(tEplObdPart ObdPart_p,
tEplObdDir Direction_p)
{
tEplKernel Ret;
tEplKernel Ret;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
Ret = EplObdAccessOdPart(ObdPart_p, Direction_p);
Ret = EplObdAccessOdPart(ObdPart_p, Direction_p);
#else
Ret = kEplSuccessful;
Ret = kEplSuccessful;
#endif
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -220,17 +212,18 @@ tEplKernel Ret;
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalDefineVar (tEplVarParam MEM* pVarParam_p)
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalDefineVar(tEplVarParam MEM *
pVarParam_p)
{
tEplKernel Ret;
tEplKernel Ret;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
Ret = EplObdDefineVar(pVarParam_p);
Ret = EplObdDefineVar(pVarParam_p);
#else
Ret = kEplSuccessful;
Ret = kEplSuccessful;
#endif
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -247,18 +240,18 @@ tEplKernel Ret;
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT void* PUBLIC EplObduCalGetObjectDataPtr ( unsigned int uiIndex_p,
unsigned int uiSubIndex_p)
EPLDLLEXPORT void *PUBLIC EplObduCalGetObjectDataPtr(unsigned int uiIndex_p,
unsigned int uiSubIndex_p)
{
void* pData;
void *pData;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
pData = EplObdGetObjectDataPtr(uiIndex_p, uiSubIndex_p);
pData = EplObdGetObjectDataPtr(uiIndex_p, uiSubIndex_p);
#else
pData = NULL;
pData = NULL;
#endif
return pData;
return pData;
}
//---------------------------------------------------------------------------
@ -275,17 +268,18 @@ void* pData;
//
//---------------------------------------------------------------------------
#if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE))
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalRegisterUserOd (tEplObdEntryPtr pUserOd_p)
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalRegisterUserOd(tEplObdEntryPtr
pUserOd_p)
{
tEplKernel Ret;
tEplKernel Ret;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
Ret = EplObdRegisterUserOd(pUserOd_p);
Ret = EplObdRegisterUserOd(pUserOd_p);
#else
Ret = kEplSuccessful;
Ret = kEplSuccessful;
#endif
return Ret;
return Ret;
}
#endif
@ -304,15 +298,15 @@ tEplKernel Ret;
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT void PUBLIC EplObduCalInitVarEntry (tEplObdVarEntry MEM* pVarEntry_p,
BYTE bType_p, tEplObdSize ObdSize_p)
EPLDLLEXPORT void PUBLIC EplObduCalInitVarEntry(tEplObdVarEntry MEM *
pVarEntry_p, BYTE bType_p,
tEplObdSize ObdSize_p)
{
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
EplObdInitVarEntry(pVarEntry_p, bType_p, ObdSize_p);
EplObdInitVarEntry(pVarEntry_p, bType_p, ObdSize_p);
#endif
}
//---------------------------------------------------------------------------
//
// Function: EplObduCalGetDataSize()
@ -331,17 +325,17 @@ EPLDLLEXPORT void PUBLIC EplObduCalInitVarEntry (tEplObdVarEntry MEM* pVarEntry_
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplObdSize PUBLIC EplObduCalGetDataSize(unsigned int uiIndex_p,
unsigned int uiSubIndex_p)
unsigned int uiSubIndex_p)
{
tEplObdSize Size;
tEplObdSize Size;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
Size = EplObdGetDataSize(uiIndex_p, uiSubIndex_p);
Size = EplObdGetDataSize(uiIndex_p, uiSubIndex_p);
#else
Size = 0;
Size = 0;
#endif
return Size;
return Size;
}
//---------------------------------------------------------------------------
@ -360,15 +354,15 @@ tEplObdSize Size;
//---------------------------------------------------------------------------
EPLDLLEXPORT unsigned int PUBLIC EplObduCalGetNodeId()
{
unsigned int uiNodeId;
unsigned int uiNodeId;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
uiNodeId = EplObdGetNodeId();
uiNodeId = EplObdGetNodeId();
#else
uiNodeId = 0;
uiNodeId = 0;
#endif
return uiNodeId;
return uiNodeId;
}
//---------------------------------------------------------------------------
@ -387,17 +381,18 @@ unsigned int uiNodeId;
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalSetNodeId(unsigned int uiNodeId_p,
tEplObdNodeIdType NodeIdType_p)
tEplObdNodeIdType
NodeIdType_p)
{
tEplKernel Ret;
tEplKernel Ret;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
Ret = EplObdSetNodeId(uiNodeId_p, NodeIdType_p);
Ret = EplObdSetNodeId(uiNodeId_p, NodeIdType_p);
#else
Ret = kEplSuccessful;
Ret = kEplSuccessful;
#endif
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -417,19 +412,20 @@ tEplKernel Ret;
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalGetAccessType(unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
tEplObdAccess* pAccessTyp_p)
unsigned int
uiSubIndex_p,
tEplObdAccess *
pAccessTyp_p)
{
tEplObdAccess AccesType;
tEplObdAccess AccesType;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
AccesType = EplObdGetAccessType(uiIndex_p, uiSubIndex_p, pAccessTyp_p);
AccesType = EplObdGetAccessType(uiIndex_p, uiSubIndex_p, pAccessTyp_p);
#else
AccesType = 0;
AccesType = 0;
#endif
return AccesType;
return AccesType;
}
@ -451,20 +447,21 @@ return AccesType;
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalReadEntryToLe (unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void * pDstData_p,
tEplObdSize * pSize_p)
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalReadEntryToLe(unsigned int uiIndex_p,
unsigned int
uiSubIndex_p,
void *pDstData_p,
tEplObdSize * pSize_p)
{
tEplKernel Ret;
tEplKernel Ret;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
Ret = EplObdReadEntryToLe(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
Ret = EplObdReadEntryToLe(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
#else
Ret = kEplSuccessful;
Ret = kEplSuccessful;
#endif
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -484,19 +481,22 @@ tEplKernel Ret;
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalWriteEntryFromLe (unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void * pSrcData_p,
tEplObdSize Size_p)
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalWriteEntryFromLe(unsigned int
uiIndex_p,
unsigned int
uiSubIndex_p,
void *pSrcData_p,
tEplObdSize Size_p)
{
tEplKernel Ret;
tEplKernel Ret;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
Ret = EplObdWriteEntryFromLe(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
Ret =
EplObdWriteEntryFromLe(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
#else
Ret = kEplSuccessful;
Ret = kEplSuccessful;
#endif
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -514,23 +514,21 @@ tEplKernel Ret;
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalSearchVarEntry (EPL_MCO_DECL_INSTANCE_PTR_
unsigned int uiIndex_p,
unsigned int uiSubindex_p,
tEplObdVarEntry MEM** ppVarEntry_p)
EPLDLLEXPORT tEplKernel PUBLIC
EplObduCalSearchVarEntry(EPL_MCO_DECL_INSTANCE_PTR_ unsigned int uiIndex_p,
unsigned int uiSubindex_p,
tEplObdVarEntry MEM ** ppVarEntry_p)
{
tEplKernel Ret;
tEplKernel Ret;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
Ret = EplObdSearchVarEntry(uiIndex_p, uiSubindex_p, ppVarEntry_p);
Ret = EplObdSearchVarEntry(uiIndex_p, uiSubindex_p, ppVarEntry_p);
#else
Ret = kEplSuccessful;
Ret = kEplSuccessful;
#endif
return Ret;
return Ret;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
@ -557,6 +555,4 @@ tEplKernel Ret;
#endif //(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0)
// EOF

View File

@ -82,13 +82,13 @@
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) == 0)
#error 'ERROR: Missing DLLk-Modul!'
#error 'ERROR: Missing DLLk-Modul!'
#endif
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) == 0)
#error 'ERROR: Missing OBDk-Modul!'
#error 'ERROR: Missing OBDk-Modul!'
#endif
/***************************************************************************/
@ -120,7 +120,6 @@
// local function prototypes
//---------------------------------------------------------------------------
/***************************************************************************/
/* */
/* */
@ -134,7 +133,6 @@
//
/***************************************************************************/
//=========================================================================//
// //
// P R I V A T E D E F I N I T I O N S //
@ -153,12 +151,10 @@
// local vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
@ -183,7 +179,7 @@
tEplKernel EplPdokAddInstance(void)
{
return kEplSuccessful;
return kEplSuccessful;
}
//---------------------------------------------------------------------------
@ -204,10 +200,9 @@ tEplKernel EplPdokAddInstance(void)
tEplKernel EplPdokDelInstance(void)
{
return kEplSuccessful;
return kEplSuccessful;
}
//---------------------------------------------------------------------------
//
// Function: EplPdokCbPdoReceived
@ -228,27 +223,27 @@ tEplKernel EplPdokDelInstance(void)
tEplKernel EplPdokCbPdoReceived(tEplFrameInfo * pFrameInfo_p)
{
tEplKernel Ret = kEplSuccessful;
tEplEvent Event;
tEplKernel Ret = kEplSuccessful;
tEplEvent Event;
#if (DEV_SYSTEM == _DEV_GNU_CF548X_)
// reset LED
// reset LED
// MCF_GPIO_PODR_PCIBG &= ~PDO_LED; // Level
#endif
Event.m_EventSink = kEplEventSinkPdok;
Event.m_EventType = kEplEventTypePdoRx;
// limit copied data to size of PDO (because from some CNs the frame is larger than necessary)
Event.m_uiSize = AmiGetWordFromLe(&pFrameInfo_p->m_pFrame->m_Data.m_Pres.m_le_wSize) + 24; // pFrameInfo_p->m_uiFrameSize;
Event.m_pArg = pFrameInfo_p->m_pFrame;
Ret = EplEventkPost(&Event);
Event.m_EventSink = kEplEventSinkPdok;
Event.m_EventType = kEplEventTypePdoRx;
// limit copied data to size of PDO (because from some CNs the frame is larger than necessary)
Event.m_uiSize = AmiGetWordFromLe(&pFrameInfo_p->m_pFrame->m_Data.m_Pres.m_le_wSize) + 24; // pFrameInfo_p->m_uiFrameSize;
Event.m_pArg = pFrameInfo_p->m_pFrame;
Ret = EplEventkPost(&Event);
#if (DEV_SYSTEM == _DEV_GNU_CF548X_)
// set LED
// set LED
// MCF_GPIO_PODR_PCIBG |= PDO_LED; // Level
#endif
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -271,26 +266,26 @@ tEplEvent Event;
tEplKernel EplPdokCbPdoTransmitted(tEplFrameInfo * pFrameInfo_p)
{
tEplKernel Ret = kEplSuccessful;
tEplEvent Event;
tEplKernel Ret = kEplSuccessful;
tEplEvent Event;
#if (DEV_SYSTEM == _DEV_GNU_CF548X_)
// reset LED
MCF_GPIO_PODR_PCIBG &= ~PDO_LED; // Level
// reset LED
MCF_GPIO_PODR_PCIBG &= ~PDO_LED; // Level
#endif
Event.m_EventSink = kEplEventSinkPdok;
Event.m_EventType = kEplEventTypePdoTx;
Event.m_uiSize = sizeof (tEplFrameInfo);
Event.m_pArg = pFrameInfo_p;
Ret = EplEventkPost(&Event);
Event.m_EventSink = kEplEventSinkPdok;
Event.m_EventType = kEplEventTypePdoTx;
Event.m_uiSize = sizeof(tEplFrameInfo);
Event.m_pArg = pFrameInfo_p;
Ret = EplEventkPost(&Event);
#if (DEV_SYSTEM == _DEV_GNU_CF548X_)
// set LED
MCF_GPIO_PODR_PCIBG |= PDO_LED; // Level
// set LED
MCF_GPIO_PODR_PCIBG |= PDO_LED; // Level
#endif
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -311,16 +306,16 @@ tEplEvent Event;
tEplKernel EplPdokCbSoa(tEplFrameInfo * pFrameInfo_p)
{
tEplKernel Ret = kEplSuccessful;
tEplEvent Event;
tEplKernel Ret = kEplSuccessful;
tEplEvent Event;
Event.m_EventSink = kEplEventSinkPdok;
Event.m_EventType = kEplEventTypePdoSoa;
Event.m_uiSize = 0;
Event.m_pArg = NULL;
Ret = EplEventkPost(&Event);
Event.m_EventSink = kEplEventSinkPdok;
Event.m_EventType = kEplEventTypePdoSoa;
Event.m_uiSize = 0;
Event.m_pArg = NULL;
Ret = EplEventkPost(&Event);
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -343,323 +338,331 @@ tEplEvent Event;
tEplKernel EplPdokProcess(tEplEvent * pEvent_p)
{
tEplKernel Ret = kEplSuccessful;
WORD wPdoSize;
WORD wBitOffset;
WORD wBitSize;
WORD wVarSize;
QWORD qwObjectMapping;
BYTE bMappSubindex;
BYTE bObdSubindex;
WORD wObdMappIndex;
WORD wObdCommIndex;
WORD wPdoId;
BYTE bObdData;
BYTE bObjectCount;
BYTE bFrameData;
BOOL fValid;
tEplObdSize ObdSize;
tEplFrame *pFrame;
tEplFrameInfo *pFrameInfo;
unsigned int uiNodeId;
tEplMsgType MsgType;
tEplKernel Ret = kEplSuccessful;
WORD wPdoSize;
WORD wBitOffset;
WORD wBitSize;
WORD wVarSize;
QWORD qwObjectMapping;
BYTE bMappSubindex;
BYTE bObdSubindex;
WORD wObdMappIndex;
WORD wObdCommIndex;
WORD wPdoId;
BYTE bObdData;
BYTE bObjectCount;
BYTE bFrameData;
BOOL fValid;
tEplObdSize ObdSize;
tEplFrame *pFrame;
tEplFrameInfo *pFrameInfo;
unsigned int uiNodeId;
tEplMsgType MsgType;
// 0xFF=invalid, RPDO: 0x00=PReq, localNodeId=PRes, remoteNodeId=PRes
// TPDO: 0x00=PRes, MN: CnNodeId=PReq
// 0xFF=invalid, RPDO: 0x00=PReq, localNodeId=PRes, remoteNodeId=PRes
// TPDO: 0x00=PRes, MN: CnNodeId=PReq
switch (pEvent_p->m_EventType)
{
case kEplEventTypePdoRx: // RPDO received
pFrame = (tEplFrame *) pEvent_p->m_pArg;
switch (pEvent_p->m_EventType) {
case kEplEventTypePdoRx: // RPDO received
pFrame = (tEplFrame *) pEvent_p->m_pArg;
// check if received RPDO is valid
bFrameData = AmiGetByteFromLe(&pFrame->m_Data.m_Pres.m_le_bFlag1);
if ((bFrameData & EPL_FRAME_FLAG1_RD) == 0)
{ // RPDO invalid
goto Exit;
}
// check if received RPDO is valid
bFrameData =
AmiGetByteFromLe(&pFrame->m_Data.m_Pres.m_le_bFlag1);
if ((bFrameData & EPL_FRAME_FLAG1_RD) == 0) { // RPDO invalid
goto Exit;
}
// retrieve EPL message type
MsgType = AmiGetByteFromLe(&pFrame->m_le_bMessageType);
if (MsgType == kEplMsgTypePreq) { // RPDO is PReq frame
uiNodeId = EPL_PDO_PREQ_NODE_ID; // 0x00
} else { // RPDO is PRes frame
// retrieve node ID
uiNodeId = AmiGetByteFromLe(&pFrame->m_le_bSrcNodeId);
}
// retrieve EPL message type
MsgType = AmiGetByteFromLe(&pFrame->m_le_bMessageType);
if (MsgType == kEplMsgTypePreq)
{ // RPDO is PReq frame
uiNodeId = EPL_PDO_PREQ_NODE_ID; // 0x00
}
else
{ // RPDO is PRes frame
// retrieve node ID
uiNodeId = AmiGetByteFromLe(&pFrame->m_le_bSrcNodeId);
}
// search for appropriate valid RPDO in OD
wObdMappIndex = EPL_PDOK_OBD_IDX_RX_MAPP_PARAM;
for (wObdCommIndex = EPL_PDOK_OBD_IDX_RX_COMM_PARAM;
wObdCommIndex < (EPL_PDOK_OBD_IDX_RX_COMM_PARAM + 0x00FF);
wObdCommIndex++, wObdMappIndex++) {
ObdSize = 1;
// read node ID from OD
Ret =
EplObdReadEntry(wObdCommIndex, 0x01, &bObdData,
&ObdSize);
if ((Ret == kEplObdIndexNotExist)
|| (Ret == kEplObdSubindexNotExist)
|| (Ret == kEplObdIllegalPart)) { // PDO does not exist; last PDO reached
Ret = kEplSuccessful;
goto Exit;
} else if (Ret != kEplSuccessful) { // other fatal error occured
goto Exit;
}
// entry read successfully
if (bObdData != uiNodeId) { // node ID does not equal - wrong PDO, try next PDO in OD
continue;
}
ObdSize = 1;
// read number of mapped objects from OD; this indicates if the PDO is valid
Ret =
EplObdReadEntry(wObdMappIndex, 0x00, &bObjectCount,
&ObdSize);
if ((Ret == kEplObdIndexNotExist)
|| (Ret == kEplObdSubindexNotExist)
|| (Ret == kEplObdIllegalPart)) { // PDO does not exist; last PDO reached
Ret = kEplSuccessful;
goto Exit;
} else if (Ret != kEplSuccessful) { // other fatal error occured
goto Exit;
}
// entry read successfully
if (bObjectCount == 0) { // PDO in OD not valid, try next PDO in OD
continue;
}
// search for appropriate valid RPDO in OD
wObdMappIndex = EPL_PDOK_OBD_IDX_RX_MAPP_PARAM;
for (wObdCommIndex = EPL_PDOK_OBD_IDX_RX_COMM_PARAM;
wObdCommIndex < (EPL_PDOK_OBD_IDX_RX_COMM_PARAM + 0x00FF);
wObdCommIndex++, wObdMappIndex++)
{
ObdSize = 1;
// read node ID from OD
Ret = EplObdReadEntry(wObdCommIndex, 0x01, &bObdData, &ObdSize);
if ((Ret == kEplObdIndexNotExist)
|| (Ret == kEplObdSubindexNotExist)
|| (Ret == kEplObdIllegalPart))
{ // PDO does not exist; last PDO reached
Ret = kEplSuccessful;
goto Exit;
}
else if (Ret != kEplSuccessful)
{ // other fatal error occured
goto Exit;
}
// entry read successfully
if (bObdData != uiNodeId)
{ // node ID does not equal - wrong PDO, try next PDO in OD
continue;
}
ObdSize = 1;
// read number of mapped objects from OD; this indicates if the PDO is valid
Ret = EplObdReadEntry(wObdMappIndex, 0x00, &bObjectCount, &ObdSize);
if ((Ret == kEplObdIndexNotExist)
|| (Ret == kEplObdSubindexNotExist)
|| (Ret == kEplObdIllegalPart))
{ // PDO does not exist; last PDO reached
Ret = kEplSuccessful;
goto Exit;
}
else if (Ret != kEplSuccessful)
{ // other fatal error occured
goto Exit;
}
// entry read successfully
if (bObjectCount == 0)
{ // PDO in OD not valid, try next PDO in OD
continue;
}
ObdSize = 1;
// check PDO mapping version
Ret =
EplObdReadEntry(wObdCommIndex, 0x02, &bObdData,
&ObdSize);
if (Ret != kEplSuccessful) { // other fatal error occured
goto Exit;
}
// entry read successfully
// retrieve PDO version from frame
bFrameData =
AmiGetByteFromLe(&pFrame->m_Data.m_Pres.
m_le_bPdoVersion);
if ((bObdData & EPL_VERSION_MAIN) != (bFrameData & EPL_VERSION_MAIN)) { // PDO versions do not match
// $$$ raise PDO error
// termiate processing of this RPDO
goto Exit;
}
// valid RPDO found
ObdSize = 1;
// check PDO mapping version
Ret = EplObdReadEntry(wObdCommIndex, 0x02, &bObdData, &ObdSize);
if (Ret != kEplSuccessful)
{ // other fatal error occured
goto Exit;
}
// entry read successfully
// retrieve PDO version from frame
bFrameData = AmiGetByteFromLe(&pFrame->m_Data.m_Pres.m_le_bPdoVersion);
if ((bObdData & EPL_VERSION_MAIN) != (bFrameData & EPL_VERSION_MAIN))
{ // PDO versions do not match
// $$$ raise PDO error
// termiate processing of this RPDO
goto Exit;
}
// retrieve PDO size
wPdoSize =
AmiGetWordFromLe(&pFrame->m_Data.m_Pres.m_le_wSize);
// valid RPDO found
// process mapping
for (bMappSubindex = 1; bMappSubindex <= bObjectCount;
bMappSubindex++) {
ObdSize = 8; // QWORD
// read object mapping from OD
Ret =
EplObdReadEntry(wObdMappIndex,
bMappSubindex,
&qwObjectMapping, &ObdSize);
if (Ret != kEplSuccessful) { // other fatal error occured
goto Exit;
}
// check if object mapping entry is valid, i.e. unequal zero, because "empty" entries are allowed
if (qwObjectMapping == 0) { // invalid entry, continue with next entry
continue;
}
// decode object mapping
wObdCommIndex =
(WORD) (qwObjectMapping &
0x000000000000FFFFLL);
bObdSubindex =
(BYTE) ((qwObjectMapping &
0x0000000000FF0000LL) >> 16);
wBitOffset =
(WORD) ((qwObjectMapping &
0x0000FFFF00000000LL) >> 32);
wBitSize =
(WORD) ((qwObjectMapping &
0xFFFF000000000000LL) >> 48);
// retrieve PDO size
wPdoSize = AmiGetWordFromLe(&pFrame->m_Data.m_Pres.m_le_wSize);
// check if object exceeds PDO size
if (((wBitOffset + wBitSize) >> 3) > wPdoSize) { // wrong object mapping; PDO size is too low
// $$$ raise PDO error
// terminate processing of this RPDO
goto Exit;
}
// copy object from RPDO to process/OD variable
ObdSize = wBitSize >> 3;
Ret =
EplObdWriteEntryFromLe(wObdCommIndex,
bObdSubindex,
&pFrame->m_Data.
m_Pres.
m_le_abPayload[(wBitOffset >> 3)], ObdSize);
if (Ret != kEplSuccessful) { // other fatal error occured
goto Exit;
}
// process mapping
for (bMappSubindex = 1; bMappSubindex <= bObjectCount; bMappSubindex++)
{
ObdSize = 8; // QWORD
// read object mapping from OD
Ret = EplObdReadEntry(wObdMappIndex, bMappSubindex, &qwObjectMapping, &ObdSize);
if (Ret != kEplSuccessful)
{ // other fatal error occured
goto Exit;
}
}
// check if object mapping entry is valid, i.e. unequal zero, because "empty" entries are allowed
if (qwObjectMapping == 0)
{ // invalid entry, continue with next entry
continue;
}
// processing finished successfully
goto Exit;
}
break;
// decode object mapping
wObdCommIndex = (WORD) (qwObjectMapping & 0x000000000000FFFFLL);
bObdSubindex = (BYTE) ((qwObjectMapping & 0x0000000000FF0000LL) >> 16);
wBitOffset = (WORD) ((qwObjectMapping & 0x0000FFFF00000000LL) >> 32);
wBitSize = (WORD) ((qwObjectMapping & 0xFFFF000000000000LL) >> 48);
case kEplEventTypePdoTx: // TPDO transmitted
pFrameInfo = (tEplFrameInfo *) pEvent_p->m_pArg;
pFrame = pFrameInfo->m_pFrame;
// check if object exceeds PDO size
if (((wBitOffset + wBitSize) >> 3) > wPdoSize)
{ // wrong object mapping; PDO size is too low
// $$$ raise PDO error
// terminate processing of this RPDO
goto Exit;
}
// set TPDO invalid, so that only fully processed TPDOs are sent as valid
bFrameData =
AmiGetByteFromLe(&pFrame->m_Data.m_Pres.m_le_bFlag1);
AmiSetByteToLe(&pFrame->m_Data.m_Pres.m_le_bFlag1,
(bFrameData & ~EPL_FRAME_FLAG1_RD));
// copy object from RPDO to process/OD variable
ObdSize = wBitSize >> 3;
Ret = EplObdWriteEntryFromLe(wObdCommIndex, bObdSubindex, &pFrame->m_Data.m_Pres.m_le_abPayload[(wBitOffset >> 3)], ObdSize);
if (Ret != kEplSuccessful)
{ // other fatal error occured
goto Exit;
}
// retrieve EPL message type
MsgType = AmiGetByteFromLe(&pFrame->m_le_bMessageType);
if (MsgType == kEplMsgTypePres) { // TPDO is PRes frame
uiNodeId = EPL_PDO_PRES_NODE_ID; // 0x00
} else { // TPDO is PReq frame
// retrieve node ID
uiNodeId = AmiGetByteFromLe(&pFrame->m_le_bDstNodeId);
}
}
// search for appropriate valid TPDO in OD
wObdMappIndex = EPL_PDOK_OBD_IDX_TX_MAPP_PARAM;
wObdCommIndex = EPL_PDOK_OBD_IDX_TX_COMM_PARAM;
for (wPdoId = 0;; wPdoId++, wObdCommIndex++, wObdMappIndex++) {
ObdSize = 1;
// read node ID from OD
Ret =
EplObdReadEntry(wObdCommIndex, 0x01, &bObdData,
&ObdSize);
if ((Ret == kEplObdIndexNotExist)
|| (Ret == kEplObdSubindexNotExist)
|| (Ret == kEplObdIllegalPart)) { // PDO does not exist; last PDO reached
Ret = kEplSuccessful;
goto Exit;
} else if (Ret != kEplSuccessful) { // other fatal error occured
goto Exit;
}
// entry read successfully
if (bObdData != uiNodeId) { // node ID does not equal - wrong PDO, try next PDO in OD
continue;
}
ObdSize = 1;
// read number of mapped objects from OD; this indicates if the PDO is valid
Ret =
EplObdReadEntry(wObdMappIndex, 0x00, &bObjectCount,
&ObdSize);
if ((Ret == kEplObdIndexNotExist)
|| (Ret == kEplObdSubindexNotExist)
|| (Ret == kEplObdIllegalPart)) { // PDO does not exist; last PDO reached
Ret = kEplSuccessful;
goto Exit;
} else if (Ret != kEplSuccessful) { // other fatal error occured
goto Exit;
}
// entry read successfully
if (bObjectCount == 0) { // PDO in OD not valid, try next PDO in OD
continue;
}
// valid TPDO found
// processing finished successfully
goto Exit;
}
break;
ObdSize = 1;
// get PDO mapping version from OD
Ret =
EplObdReadEntry(wObdCommIndex, 0x02, &bObdData,
&ObdSize);
if (Ret != kEplSuccessful) { // other fatal error occured
goto Exit;
}
// entry read successfully
// set PDO version in frame
AmiSetByteToLe(&pFrame->m_Data.m_Pres.m_le_bPdoVersion,
bObdData);
case kEplEventTypePdoTx: // TPDO transmitted
pFrameInfo = (tEplFrameInfo *) pEvent_p->m_pArg;
pFrame = pFrameInfo->m_pFrame;
// calculate PDO size
wPdoSize = 0;
// set TPDO invalid, so that only fully processed TPDOs are sent as valid
bFrameData = AmiGetByteFromLe(&pFrame->m_Data.m_Pres.m_le_bFlag1);
AmiSetByteToLe(&pFrame->m_Data.m_Pres.m_le_bFlag1, (bFrameData & ~EPL_FRAME_FLAG1_RD));
// process mapping
for (bMappSubindex = 1; bMappSubindex <= bObjectCount;
bMappSubindex++) {
ObdSize = 8; // QWORD
// read object mapping from OD
Ret =
EplObdReadEntry(wObdMappIndex,
bMappSubindex,
&qwObjectMapping, &ObdSize);
if (Ret != kEplSuccessful) { // other fatal error occured
goto Exit;
}
// check if object mapping entry is valid, i.e. unequal zero, because "empty" entries are allowed
if (qwObjectMapping == 0) { // invalid entry, continue with next entry
continue;
}
// decode object mapping
wObdCommIndex =
(WORD) (qwObjectMapping &
0x000000000000FFFFLL);
bObdSubindex =
(BYTE) ((qwObjectMapping &
0x0000000000FF0000LL) >> 16);
wBitOffset =
(WORD) ((qwObjectMapping &
0x0000FFFF00000000LL) >> 32);
wBitSize =
(WORD) ((qwObjectMapping &
0xFFFF000000000000LL) >> 48);
// retrieve EPL message type
MsgType = AmiGetByteFromLe(&pFrame->m_le_bMessageType);
if (MsgType == kEplMsgTypePres)
{ // TPDO is PRes frame
uiNodeId = EPL_PDO_PRES_NODE_ID; // 0x00
}
else
{ // TPDO is PReq frame
// retrieve node ID
uiNodeId = AmiGetByteFromLe(&pFrame->m_le_bDstNodeId);
}
// calculate max PDO size
ObdSize = wBitSize >> 3;
wVarSize = (wBitOffset >> 3) + (WORD) ObdSize;
if ((unsigned int)(wVarSize + 24) > pFrameInfo->m_uiFrameSize) { // TPDO is too short
// $$$ raise PDO error, set Ret
goto Exit;
}
if (wVarSize > wPdoSize) { // memorize new PDO size
wPdoSize = wVarSize;
}
// copy object from process/OD variable to TPDO
Ret =
EplObdReadEntryToLe(wObdCommIndex,
bObdSubindex,
&pFrame->m_Data.m_Pres.
m_le_abPayload[(wBitOffset >> 3)], &ObdSize);
if (Ret != kEplSuccessful) { // other fatal error occured
goto Exit;
}
// search for appropriate valid TPDO in OD
wObdMappIndex = EPL_PDOK_OBD_IDX_TX_MAPP_PARAM;
wObdCommIndex = EPL_PDOK_OBD_IDX_TX_COMM_PARAM;
for (wPdoId = 0; ; wPdoId++, wObdCommIndex++, wObdMappIndex++)
{
ObdSize = 1;
// read node ID from OD
Ret = EplObdReadEntry(wObdCommIndex, 0x01, &bObdData, &ObdSize);
if ((Ret == kEplObdIndexNotExist)
|| (Ret == kEplObdSubindexNotExist)
|| (Ret == kEplObdIllegalPart))
{ // PDO does not exist; last PDO reached
Ret = kEplSuccessful;
goto Exit;
}
else if (Ret != kEplSuccessful)
{ // other fatal error occured
goto Exit;
}
// entry read successfully
if (bObdData != uiNodeId)
{ // node ID does not equal - wrong PDO, try next PDO in OD
continue;
}
ObdSize = 1;
// read number of mapped objects from OD; this indicates if the PDO is valid
Ret = EplObdReadEntry(wObdMappIndex, 0x00, &bObjectCount, &ObdSize);
if ((Ret == kEplObdIndexNotExist)
|| (Ret == kEplObdSubindexNotExist)
|| (Ret == kEplObdIllegalPart))
{ // PDO does not exist; last PDO reached
Ret = kEplSuccessful;
goto Exit;
}
else if (Ret != kEplSuccessful)
{ // other fatal error occured
goto Exit;
}
// entry read successfully
if (bObjectCount == 0)
{ // PDO in OD not valid, try next PDO in OD
continue;
}
}
// valid TPDO found
// set PDO size in frame
AmiSetWordToLe(&pFrame->m_Data.m_Pres.m_le_wSize,
wPdoSize);
ObdSize = 1;
// get PDO mapping version from OD
Ret = EplObdReadEntry(wObdCommIndex, 0x02, &bObdData, &ObdSize);
if (Ret != kEplSuccessful)
{ // other fatal error occured
goto Exit;
}
// entry read successfully
// set PDO version in frame
AmiSetByteToLe(&pFrame->m_Data.m_Pres.m_le_bPdoVersion, bObdData);
Ret = EplPdokCalAreTpdosValid(&fValid);
if (fValid != FALSE) {
// set TPDO valid
bFrameData =
AmiGetByteFromLe(&pFrame->m_Data.m_Pres.
m_le_bFlag1);
AmiSetByteToLe(&pFrame->m_Data.m_Pres.
m_le_bFlag1,
(bFrameData |
EPL_FRAME_FLAG1_RD));
}
// processing finished successfully
// calculate PDO size
wPdoSize = 0;
goto Exit;
}
break;
// process mapping
for (bMappSubindex = 1; bMappSubindex <= bObjectCount; bMappSubindex++)
{
ObdSize = 8; // QWORD
// read object mapping from OD
Ret = EplObdReadEntry(wObdMappIndex, bMappSubindex, &qwObjectMapping, &ObdSize);
if (Ret != kEplSuccessful)
{ // other fatal error occured
goto Exit;
}
case kEplEventTypePdoSoa: // SoA received
// check if object mapping entry is valid, i.e. unequal zero, because "empty" entries are allowed
if (qwObjectMapping == 0)
{ // invalid entry, continue with next entry
continue;
}
// invalidate TPDOs
Ret = EplPdokCalSetTpdosValid(FALSE);
break;
// decode object mapping
wObdCommIndex = (WORD) (qwObjectMapping & 0x000000000000FFFFLL);
bObdSubindex = (BYTE) ((qwObjectMapping & 0x0000000000FF0000LL) >> 16);
wBitOffset = (WORD) ((qwObjectMapping & 0x0000FFFF00000000LL) >> 32);
wBitSize = (WORD) ((qwObjectMapping & 0xFFFF000000000000LL) >> 48);
default:
{
ASSERTMSG(FALSE,
"EplPdokProcess(): unhandled event type!\n");
}
}
// calculate max PDO size
ObdSize = wBitSize >> 3;
wVarSize = (wBitOffset >> 3) + (WORD) ObdSize;
if ((unsigned int)(wVarSize + 24) > pFrameInfo->m_uiFrameSize)
{ // TPDO is too short
// $$$ raise PDO error, set Ret
goto Exit;
}
if (wVarSize > wPdoSize)
{ // memorize new PDO size
wPdoSize = wVarSize;
}
// copy object from process/OD variable to TPDO
Ret = EplObdReadEntryToLe(wObdCommIndex, bObdSubindex, &pFrame->m_Data.m_Pres.m_le_abPayload[(wBitOffset >> 3)], &ObdSize);
if (Ret != kEplSuccessful)
{ // other fatal error occured
goto Exit;
}
}
// set PDO size in frame
AmiSetWordToLe(&pFrame->m_Data.m_Pres.m_le_wSize, wPdoSize);
Ret = EplPdokCalAreTpdosValid(&fValid);
if (fValid != FALSE)
{
// set TPDO valid
bFrameData = AmiGetByteFromLe(&pFrame->m_Data.m_Pres.m_le_bFlag1);
AmiSetByteToLe(&pFrame->m_Data.m_Pres.m_le_bFlag1, (bFrameData | EPL_FRAME_FLAG1_RD));
}
// processing finished successfully
goto Exit;
}
break;
case kEplEventTypePdoSoa: // SoA received
// invalidate TPDOs
Ret = EplPdokCalSetTpdosValid(FALSE);
break;
default:
{
ASSERTMSG(FALSE, "EplPdokProcess(): unhandled event type!\n");
}
}
Exit:
return Ret;
Exit:
return Ret;
}
//=========================================================================//
@ -689,4 +692,3 @@ Exit:
#endif // #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0)
// EOF

View File

@ -72,7 +72,6 @@
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0)
/***************************************************************************/
/* */
/* */
@ -97,7 +96,6 @@
// local function prototypes
//---------------------------------------------------------------------------
/***************************************************************************/
/* */
/* */
@ -111,7 +109,6 @@
//
/***************************************************************************/
//=========================================================================//
// //
// P R I V A T E D E F I N I T I O N S //
@ -126,9 +123,8 @@
// local types
//---------------------------------------------------------------------------
typedef struct
{
BOOL m_fTpdosValid;
typedef struct {
BOOL m_fTpdosValid;
} tEplPdokCalInstance;
@ -136,13 +132,12 @@ typedef struct
// local vars
//---------------------------------------------------------------------------
static tEplPdokCalInstance EplPdokCalInstance_g;
static tEplPdokCalInstance EplPdokCalInstance_g;
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
@ -167,9 +162,9 @@ static tEplPdokCalInstance EplPdokCalInstance_g;
tEplKernel EplPdokCalAddInstance(void)
{
EPL_MEMSET(&EplPdokCalInstance_g, 0, sizeof(EplPdokCalInstance_g));
EPL_MEMSET(&EplPdokCalInstance_g, 0, sizeof(EplPdokCalInstance_g));
return kEplSuccessful;
return kEplSuccessful;
}
//---------------------------------------------------------------------------
@ -190,10 +185,9 @@ tEplKernel EplPdokCalAddInstance(void)
tEplKernel EplPdokCalDelInstance(void)
{
return kEplSuccessful;
return kEplSuccessful;
}
//---------------------------------------------------------------------------
//
// Function: EplPdokCalSetTpdosValid()
@ -212,11 +206,11 @@ tEplKernel EplPdokCalDelInstance(void)
tEplKernel EplPdokCalSetTpdosValid(BOOL fValid_p)
{
tEplKernel Ret = kEplSuccessful;
tEplKernel Ret = kEplSuccessful;
EplPdokCalInstance_g.m_fTpdosValid = fValid_p;
EplPdokCalInstance_g.m_fTpdosValid = fValid_p;
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -236,14 +230,13 @@ tEplKernel Ret = kEplSuccessful;
tEplKernel EplPdokCalAreTpdosValid(BOOL * pfValid_p)
{
tEplKernel Ret = kEplSuccessful;
tEplKernel Ret = kEplSuccessful;
*pfValid_p = EplPdokCalInstance_g.m_fTpdosValid;
*pfValid_p = EplPdokCalInstance_g.m_fTpdosValid;
return Ret;
return Ret;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
@ -271,4 +264,3 @@ tEplKernel Ret = kEplSuccessful;
#endif
// EOF

View File

@ -82,7 +82,6 @@
#error "EPL PDOu module needs EPL module OBDU or OBDK!"
#endif
/***************************************************************************/
/* */
/* */
@ -103,7 +102,6 @@
#define EPL_PDOU_OBD_IDX_MASK 0xFF00
#define EPL_PDOU_PDO_ID_MASK 0x00FF
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
@ -116,7 +114,6 @@
// local function prototypes
//---------------------------------------------------------------------------
/***************************************************************************/
/* */
/* */
@ -130,7 +127,6 @@
//
/***************************************************************************/
//=========================================================================//
// //
// P R I V A T E D E F I N I T I O N S //
@ -149,25 +145,23 @@
// local vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
static tEplKernel EplPdouCheckPdoValidity(tEplObdCbParam MEM* pParam_p, unsigned int uiIndex_p);
static tEplKernel EplPdouCheckPdoValidity(tEplObdCbParam MEM * pParam_p,
unsigned int uiIndex_p);
static void EplPdouDecodeObjectMapping(QWORD qwObjectMapping_p,
unsigned int* puiIndex_p,
unsigned int* puiSubIndex_p,
unsigned int* puiBitOffset_p,
unsigned int* puiBitSize_p);
unsigned int *puiIndex_p,
unsigned int *puiSubIndex_p,
unsigned int *puiBitOffset_p,
unsigned int *puiBitSize_p);
static tEplKernel EplPdouCheckObjectMapping(QWORD qwObjectMapping_p,
tEplObdAccess AccessType_p,
DWORD* pdwAbortCode_p,
unsigned int* puiPdoSize_p);
tEplObdAccess AccessType_p,
DWORD * pdwAbortCode_p,
unsigned int *puiPdoSize_p);
//=========================================================================//
// //
@ -193,10 +187,9 @@ static tEplKernel EplPdouCheckObjectMapping(QWORD qwObjectMapping_p,
tEplKernel EplPdouAddInstance(void)
{
return kEplSuccessful;
return kEplSuccessful;
}
//---------------------------------------------------------------------------
//
// Function: EplPdouDelInstance()
@ -215,10 +208,9 @@ tEplKernel EplPdouAddInstance(void)
tEplKernel EplPdouDelInstance(void)
{
return kEplSuccessful;
return kEplSuccessful;
}
//---------------------------------------------------------------------------
//
// Function: EplPdouCbObdAccess
@ -234,170 +226,153 @@ tEplKernel EplPdouDelInstance(void)
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplPdouCbObdAccess(tEplObdCbParam MEM* pParam_p)
tEplKernel PUBLIC EplPdouCbObdAccess(tEplObdCbParam MEM * pParam_p)
{
tEplKernel Ret = kEplSuccessful;
unsigned int uiPdoId;
unsigned int uiIndexType;
tEplObdSize ObdSize;
BYTE bObjectCount;
QWORD qwObjectMapping;
tEplObdAccess AccessType;
BYTE bMappSubindex;
unsigned int uiCurPdoSize;
WORD wMaxPdoSize;
unsigned int uiSubIndex;
tEplKernel Ret = kEplSuccessful;
unsigned int uiPdoId;
unsigned int uiIndexType;
tEplObdSize ObdSize;
BYTE bObjectCount;
QWORD qwObjectMapping;
tEplObdAccess AccessType;
BYTE bMappSubindex;
unsigned int uiCurPdoSize;
WORD wMaxPdoSize;
unsigned int uiSubIndex;
// fetch PDO ID
uiPdoId = pParam_p->m_uiIndex & EPL_PDOU_PDO_ID_MASK;
// fetch PDO ID
uiPdoId = pParam_p->m_uiIndex & EPL_PDOU_PDO_ID_MASK;
// fetch object index type
uiIndexType = pParam_p->m_uiIndex & EPL_PDOU_OBD_IDX_MASK;
// fetch object index type
uiIndexType = pParam_p->m_uiIndex & EPL_PDOU_OBD_IDX_MASK;
if (pParam_p->m_ObdEvent != kEplObdEvPreWrite)
{ // read accesses, post write events etc. are OK
pParam_p->m_dwAbortCode = 0;
goto Exit;
}
if (pParam_p->m_ObdEvent != kEplObdEvPreWrite) { // read accesses, post write events etc. are OK
pParam_p->m_dwAbortCode = 0;
goto Exit;
}
// check index type
switch (uiIndexType) {
case EPL_PDOU_OBD_IDX_RX_COMM_PARAM:
// RPDO communication parameter accessed
case EPL_PDOU_OBD_IDX_TX_COMM_PARAM:
{ // TPDO communication parameter accessed
Ret = EplPdouCheckPdoValidity(pParam_p,
(EPL_PDOU_OBD_IDX_MAPP_PARAM
| pParam_p->m_uiIndex));
if (Ret != kEplSuccessful) { // PDO is valid or does not exist
goto Exit;
}
// check index type
switch (uiIndexType)
{
case EPL_PDOU_OBD_IDX_RX_COMM_PARAM:
// RPDO communication parameter accessed
case EPL_PDOU_OBD_IDX_TX_COMM_PARAM:
{ // TPDO communication parameter accessed
Ret = EplPdouCheckPdoValidity(pParam_p,
(EPL_PDOU_OBD_IDX_MAPP_PARAM | pParam_p->m_uiIndex));
if (Ret != kEplSuccessful)
{ // PDO is valid or does not exist
goto Exit;
}
goto Exit;
}
goto Exit;
}
case EPL_PDOU_OBD_IDX_RX_MAPP_PARAM:
{ // RPDO mapping parameter accessed
case EPL_PDOU_OBD_IDX_RX_MAPP_PARAM:
{ // RPDO mapping parameter accessed
AccessType = kEplObdAccWrite;
break;
}
AccessType = kEplObdAccWrite;
break;
}
case EPL_PDOU_OBD_IDX_TX_MAPP_PARAM:
{ // TPDO mapping parameter accessed
case EPL_PDOU_OBD_IDX_TX_MAPP_PARAM:
{ // TPDO mapping parameter accessed
AccessType = kEplObdAccRead;
break;
}
AccessType = kEplObdAccRead;
break;
}
default:
{ // this callback function is only for
// PDO mapping and communication parameters
pParam_p->m_dwAbortCode = EPL_SDOAC_GENERAL_ERROR;
goto Exit;
}
}
default:
{ // this callback function is only for
// PDO mapping and communication parameters
pParam_p->m_dwAbortCode = EPL_SDOAC_GENERAL_ERROR;
goto Exit;
}
}
// RPDO and TPDO mapping parameter accessed
// RPDO and TPDO mapping parameter accessed
if (pParam_p->m_uiSubIndex == 0) { // object mapping count accessed
if (pParam_p->m_uiSubIndex == 0)
{ // object mapping count accessed
// PDO is enabled or disabled
bObjectCount = *((BYTE *) pParam_p->m_pArg);
// PDO is enabled or disabled
bObjectCount = *((BYTE*) pParam_p->m_pArg);
if (bObjectCount == 0) { // PDO shall be disabled
if (bObjectCount == 0)
{ // PDO shall be disabled
// that is always possible
goto Exit;
}
// PDO shall be enabled
// it should have been disabled for this operation
Ret = EplPdouCheckPdoValidity(pParam_p, pParam_p->m_uiIndex);
if (Ret != kEplSuccessful) { // PDO is valid or does not exist
goto Exit;
}
// that is always possible
goto Exit;
}
if (AccessType == kEplObdAccWrite) {
uiSubIndex = 0x04; // PReqActPayloadLimit_U16
} else {
uiSubIndex = 0x05; // PResActPayloadLimit_U16
}
// PDO shall be enabled
// it should have been disabled for this operation
Ret = EplPdouCheckPdoValidity(pParam_p, pParam_p->m_uiIndex);
if (Ret != kEplSuccessful)
{ // PDO is valid or does not exist
goto Exit;
}
// fetch maximum PDO size from Object 1F98h: NMT_CycleTiming_REC
ObdSize = sizeof(wMaxPdoSize);
Ret =
EplObduReadEntry(0x1F98, uiSubIndex, &wMaxPdoSize,
&ObdSize);
if (Ret != kEplSuccessful) { // other fatal error occured
pParam_p->m_dwAbortCode = EPL_SDOAC_GENERAL_ERROR;
goto Exit;
}
// check all objectmappings
for (bMappSubindex = 1; bMappSubindex <= bObjectCount;
bMappSubindex++) {
// read object mapping from OD
ObdSize = sizeof(qwObjectMapping); // QWORD
Ret = EplObduReadEntry(pParam_p->m_uiIndex,
bMappSubindex, &qwObjectMapping,
&ObdSize);
if (Ret != kEplSuccessful) { // other fatal error occured
pParam_p->m_dwAbortCode =
EPL_SDOAC_GENERAL_ERROR;
goto Exit;
}
// check object mapping
Ret = EplPdouCheckObjectMapping(qwObjectMapping,
AccessType,
&pParam_p->
m_dwAbortCode,
&uiCurPdoSize);
if (Ret != kEplSuccessful) { // illegal object mapping
goto Exit;
}
if (AccessType == kEplObdAccWrite)
{
uiSubIndex = 0x04; // PReqActPayloadLimit_U16
}
else
{
uiSubIndex = 0x05; // PResActPayloadLimit_U16
}
if (uiCurPdoSize > wMaxPdoSize) { // mapping exceeds object size
pParam_p->m_dwAbortCode =
EPL_SDOAC_GENERAL_ERROR;
Ret = kEplPdoVarNotFound;
}
// fetch maximum PDO size from Object 1F98h: NMT_CycleTiming_REC
ObdSize = sizeof (wMaxPdoSize);
Ret = EplObduReadEntry(0x1F98, uiSubIndex, &wMaxPdoSize, &ObdSize);
if (Ret != kEplSuccessful)
{ // other fatal error occured
pParam_p->m_dwAbortCode = EPL_SDOAC_GENERAL_ERROR;
goto Exit;
}
}
// check all objectmappings
for (bMappSubindex = 1; bMappSubindex <= bObjectCount; bMappSubindex++)
{
// read object mapping from OD
ObdSize = sizeof (qwObjectMapping); // QWORD
Ret = EplObduReadEntry(pParam_p->m_uiIndex,
bMappSubindex, &qwObjectMapping, &ObdSize);
if (Ret != kEplSuccessful)
{ // other fatal error occured
pParam_p->m_dwAbortCode = EPL_SDOAC_GENERAL_ERROR;
goto Exit;
}
} else { // ObjectMapping
Ret = EplPdouCheckPdoValidity(pParam_p, pParam_p->m_uiIndex);
if (Ret != kEplSuccessful) { // PDO is valid or does not exist
goto Exit;
}
// check existence of object and validity of object length
// check object mapping
Ret = EplPdouCheckObjectMapping(qwObjectMapping,
AccessType,
&pParam_p->m_dwAbortCode,
&uiCurPdoSize);
if (Ret != kEplSuccessful)
{ // illegal object mapping
goto Exit;
}
qwObjectMapping = *((QWORD *) pParam_p->m_pArg);
if (uiCurPdoSize > wMaxPdoSize)
{ // mapping exceeds object size
pParam_p->m_dwAbortCode = EPL_SDOAC_GENERAL_ERROR;
Ret = kEplPdoVarNotFound;
}
Ret = EplPdouCheckObjectMapping(qwObjectMapping,
AccessType,
&pParam_p->m_dwAbortCode,
&uiCurPdoSize);
}
}
}
else
{ // ObjectMapping
Ret = EplPdouCheckPdoValidity(pParam_p, pParam_p->m_uiIndex);
if (Ret != kEplSuccessful)
{ // PDO is valid or does not exist
goto Exit;
}
// check existence of object and validity of object length
qwObjectMapping = *((QWORD*) pParam_p->m_pArg);
Ret = EplPdouCheckObjectMapping(qwObjectMapping,
AccessType,
&pParam_p->m_dwAbortCode,
&uiCurPdoSize);
}
Exit:
return Ret;
Exit:
return Ret;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
@ -419,33 +394,32 @@ Exit:
//
//---------------------------------------------------------------------------
static tEplKernel EplPdouCheckPdoValidity(tEplObdCbParam MEM* pParam_p, unsigned int uiIndex_p)
static tEplKernel EplPdouCheckPdoValidity(tEplObdCbParam MEM * pParam_p,
unsigned int uiIndex_p)
{
tEplKernel Ret = kEplSuccessful;
tEplObdSize ObdSize;
BYTE bObjectCount;
tEplKernel Ret = kEplSuccessful;
tEplObdSize ObdSize;
BYTE bObjectCount;
ObdSize = 1;
// read number of mapped objects from OD; this indicates if the PDO is valid
Ret = EplObduReadEntry(uiIndex_p, 0x00, &bObjectCount, &ObdSize);
if (Ret != kEplSuccessful)
{ // other fatal error occured
pParam_p->m_dwAbortCode = EPL_SDOAC_GEN_INTERNAL_INCOMPATIBILITY;
goto Exit;
}
// entry read successfully
if (bObjectCount != 0)
{ // PDO in OD is still valid
pParam_p->m_dwAbortCode = EPL_SDOAC_GEN_PARAM_INCOMPATIBILITY;
Ret = kEplPdoNotExist;
goto Exit;
}
ObdSize = 1;
// read number of mapped objects from OD; this indicates if the PDO is valid
Ret = EplObduReadEntry(uiIndex_p, 0x00, &bObjectCount, &ObdSize);
if (Ret != kEplSuccessful) { // other fatal error occured
pParam_p->m_dwAbortCode =
EPL_SDOAC_GEN_INTERNAL_INCOMPATIBILITY;
goto Exit;
}
// entry read successfully
if (bObjectCount != 0) { // PDO in OD is still valid
pParam_p->m_dwAbortCode = EPL_SDOAC_GEN_PARAM_INCOMPATIBILITY;
Ret = kEplPdoNotExist;
goto Exit;
}
Exit:
return Ret;
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplPdouDecodeObjectMapping
@ -466,26 +440,25 @@ Exit:
//---------------------------------------------------------------------------
static void EplPdouDecodeObjectMapping(QWORD qwObjectMapping_p,
unsigned int* puiIndex_p,
unsigned int* puiSubIndex_p,
unsigned int* puiBitOffset_p,
unsigned int* puiBitSize_p)
unsigned int *puiIndex_p,
unsigned int *puiSubIndex_p,
unsigned int *puiBitOffset_p,
unsigned int *puiBitSize_p)
{
*puiIndex_p = (unsigned int)
(qwObjectMapping_p & 0x000000000000FFFFLL);
*puiIndex_p = (unsigned int)
(qwObjectMapping_p & 0x000000000000FFFFLL);
*puiSubIndex_p = (unsigned int)
((qwObjectMapping_p & 0x0000000000FF0000LL) >> 16);
*puiSubIndex_p = (unsigned int)
((qwObjectMapping_p & 0x0000000000FF0000LL) >> 16);
*puiBitOffset_p = (unsigned int)
((qwObjectMapping_p & 0x0000FFFF00000000LL) >> 32);
*puiBitOffset_p = (unsigned int)
((qwObjectMapping_p & 0x0000FFFF00000000LL) >> 32);
*puiBitSize_p = (unsigned int)
((qwObjectMapping_p & 0xFFFF000000000000LL) >> 48);
*puiBitSize_p = (unsigned int)
((qwObjectMapping_p & 0xFFFF000000000000LL) >> 48);
}
//---------------------------------------------------------------------------
//
// Function: EplPdouCheckObjectMapping
@ -508,101 +481,85 @@ static void EplPdouDecodeObjectMapping(QWORD qwObjectMapping_p,
//---------------------------------------------------------------------------
static tEplKernel EplPdouCheckObjectMapping(QWORD qwObjectMapping_p,
tEplObdAccess AccessType_p,
DWORD* pdwAbortCode_p,
unsigned int* puiPdoSize_p)
tEplObdAccess AccessType_p,
DWORD * pdwAbortCode_p,
unsigned int *puiPdoSize_p)
{
tEplKernel Ret = kEplSuccessful;
tEplObdSize ObdSize;
unsigned int uiIndex;
unsigned int uiSubIndex;
unsigned int uiBitOffset;
unsigned int uiBitSize;
tEplObdAccess AccessType;
BOOL fNumerical;
tEplKernel Ret = kEplSuccessful;
tEplObdSize ObdSize;
unsigned int uiIndex;
unsigned int uiSubIndex;
unsigned int uiBitOffset;
unsigned int uiBitSize;
tEplObdAccess AccessType;
BOOL fNumerical;
if (qwObjectMapping_p == 0)
{ // discard zero value
*puiPdoSize_p = 0;
goto Exit;
}
if (qwObjectMapping_p == 0) { // discard zero value
*puiPdoSize_p = 0;
goto Exit;
}
// decode object mapping
EplPdouDecodeObjectMapping(qwObjectMapping_p,
&uiIndex,
&uiSubIndex, &uiBitOffset, &uiBitSize);
// decode object mapping
EplPdouDecodeObjectMapping(qwObjectMapping_p,
&uiIndex,
&uiSubIndex,
&uiBitOffset,
&uiBitSize);
if ((uiBitOffset & 0x7) != 0x0) { // bit mapping is not supported
*pdwAbortCode_p = EPL_SDOAC_GENERAL_ERROR;
Ret = kEplPdoGranularityMismatch;
goto Exit;
}
if ((uiBitOffset & 0x7) != 0x0)
{ // bit mapping is not supported
*pdwAbortCode_p = EPL_SDOAC_GENERAL_ERROR;
Ret = kEplPdoGranularityMismatch;
goto Exit;
}
if ((uiBitSize & 0x7) != 0x0) { // bit mapping is not supported
*pdwAbortCode_p = EPL_SDOAC_GENERAL_ERROR;
Ret = kEplPdoGranularityMismatch;
goto Exit;
}
// check access type
Ret = EplObduGetAccessType(uiIndex, uiSubIndex, &AccessType);
if (Ret != kEplSuccessful) { // entry doesn't exist
*pdwAbortCode_p = EPL_SDOAC_OBJECT_NOT_EXIST;
goto Exit;
}
if ((uiBitSize & 0x7) != 0x0)
{ // bit mapping is not supported
*pdwAbortCode_p = EPL_SDOAC_GENERAL_ERROR;
Ret = kEplPdoGranularityMismatch;
goto Exit;
}
if ((AccessType & kEplObdAccPdo) == 0) { // object is not mappable
*pdwAbortCode_p = EPL_SDOAC_OBJECT_NOT_MAPPABLE;
Ret = kEplPdoVarNotFound;
goto Exit;
}
// check access type
Ret = EplObduGetAccessType(uiIndex, uiSubIndex, &AccessType);
if (Ret != kEplSuccessful)
{ // entry doesn't exist
*pdwAbortCode_p = EPL_SDOAC_OBJECT_NOT_EXIST;
goto Exit;
}
if ((AccessType & AccessType_p) == 0) { // object is not writeable (RPDO) or readable (TPDO) respectively
*pdwAbortCode_p = EPL_SDOAC_OBJECT_NOT_MAPPABLE;
Ret = kEplPdoVarNotFound;
goto Exit;
}
if ((AccessType & kEplObdAccPdo) == 0)
{ // object is not mappable
*pdwAbortCode_p = EPL_SDOAC_OBJECT_NOT_MAPPABLE;
Ret = kEplPdoVarNotFound;
goto Exit;
}
ObdSize = EplObduGetDataSize(uiIndex, uiSubIndex);
if (ObdSize < (uiBitSize >> 3)) { // object does not exist or has smaller size
*pdwAbortCode_p = EPL_SDOAC_GENERAL_ERROR;
Ret = kEplPdoVarNotFound;
}
if ((AccessType & AccessType_p) == 0)
{ // object is not writeable (RPDO) or readable (TPDO) respectively
*pdwAbortCode_p = EPL_SDOAC_OBJECT_NOT_MAPPABLE;
Ret = kEplPdoVarNotFound;
goto Exit;
}
Ret = EplObduIsNumerical(uiIndex, uiSubIndex, &fNumerical);
if (Ret != kEplSuccessful) { // entry doesn't exist
*pdwAbortCode_p = EPL_SDOAC_OBJECT_NOT_EXIST;
goto Exit;
}
ObdSize = EplObduGetDataSize(uiIndex, uiSubIndex);
if (ObdSize < (uiBitSize >> 3))
{ // object does not exist or has smaller size
*pdwAbortCode_p = EPL_SDOAC_GENERAL_ERROR;
Ret = kEplPdoVarNotFound;
}
if ((fNumerical != FALSE)
&& ((uiBitSize >> 3) != ObdSize)) {
// object is numerical,
// therefor size has to fit, but it does not.
*pdwAbortCode_p = EPL_SDOAC_GENERAL_ERROR;
Ret = kEplPdoVarNotFound;
goto Exit;
}
// calucaled needed PDO size
*puiPdoSize_p = (uiBitOffset >> 3) + (uiBitSize >> 3);
Ret = EplObduIsNumerical(uiIndex, uiSubIndex, &fNumerical);
if (Ret != kEplSuccessful)
{ // entry doesn't exist
*pdwAbortCode_p = EPL_SDOAC_OBJECT_NOT_EXIST;
goto Exit;
}
if ((fNumerical != FALSE)
&& ((uiBitSize >> 3) != ObdSize))
{
// object is numerical,
// therefor size has to fit, but it does not.
*pdwAbortCode_p = EPL_SDOAC_GENERAL_ERROR;
Ret = kEplPdoVarNotFound;
goto Exit;
}
// calucaled needed PDO size
*puiPdoSize_p = (uiBitOffset >> 3) + (uiBitSize >> 3);
Exit:
return Ret;
Exit:
return Ret;
}
#endif // #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOU)) != 0)
// EOF

View File

@ -94,11 +94,9 @@
//---------------------------------------------------------------------------
// instance table
typedef struct
{
unsigned int m_auiSdoAsndConnection[EPL_SDO_MAX_CONNECTION_ASND];
tEplSequLayerReceiveCb m_fpSdoAsySeqCb;
typedef struct {
unsigned int m_auiSdoAsndConnection[EPL_SDO_MAX_CONNECTION_ASND];
tEplSequLayerReceiveCb m_fpSdoAsySeqCb;
} tEplSdoAsndInstance;
@ -106,7 +104,7 @@ typedef struct
// modul globale vars
//---------------------------------------------------------------------------
static tEplSdoAsndInstance SdoAsndInstance_g;
static tEplSdoAsndInstance SdoAsndInstance_g;
//---------------------------------------------------------------------------
// local function prototypes
@ -127,8 +125,6 @@ tEplKernel PUBLIC EplSdoAsnduCb(tEplFrameInfo * pFrameInfo_p);
//
/***************************************************************************/
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
@ -155,15 +151,13 @@ tEplKernel PUBLIC EplSdoAsnduCb(tEplFrameInfo * pFrameInfo_p);
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoAsnduInit(tEplSequLayerReceiveCb fpReceiveCb_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = EplSdoAsnduAddInstance(fpReceiveCb_p);
Ret = EplSdoAsnduAddInstance(fpReceiveCb_p);
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplSdoAsnduAddInstance
@ -184,30 +178,26 @@ return Ret;
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoAsnduAddInstance(tEplSequLayerReceiveCb fpReceiveCb_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// init control structure
EPL_MEMSET(&SdoAsndInstance_g, 0x00, sizeof(SdoAsndInstance_g));
// init control structure
EPL_MEMSET(&SdoAsndInstance_g, 0x00, sizeof(SdoAsndInstance_g));
// save pointer to callback-function
if (fpReceiveCb_p != NULL)
{
SdoAsndInstance_g.m_fpSdoAsySeqCb = fpReceiveCb_p;
}
else
{
Ret = kEplSdoUdpMissCb;
}
// save pointer to callback-function
if (fpReceiveCb_p != NULL) {
SdoAsndInstance_g.m_fpSdoAsySeqCb = fpReceiveCb_p;
} else {
Ret = kEplSdoUdpMissCb;
}
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
Ret = EplDlluCalRegAsndService(kEplDllAsndSdo,
EplSdoAsnduCb,
kEplDllAsndFilterLocal);
Ret = EplDlluCalRegAsndService(kEplDllAsndSdo,
EplSdoAsnduCb, kEplDllAsndFilterLocal);
#endif
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -230,21 +220,19 @@ tEplKernel Ret;
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoAsnduDelInstance()
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
// deregister callback function from DLL
Ret = EplDlluCalRegAsndService(kEplDllAsndSdo,
NULL,
kEplDllAsndFilterNone);
// deregister callback function from DLL
Ret = EplDlluCalRegAsndService(kEplDllAsndSdo,
NULL, kEplDllAsndFilterNone);
#endif
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplSdoAsnduInitCon
@ -263,61 +251,53 @@ return Ret;
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoAsnduInitCon(tEplSdoConHdl* pSdoConHandle_p,
unsigned int uiTargetNodeId_p)
tEplKernel PUBLIC EplSdoAsnduInitCon(tEplSdoConHdl * pSdoConHandle_p,
unsigned int uiTargetNodeId_p)
{
tEplKernel Ret;
unsigned int uiCount;
unsigned int uiFreeCon;
unsigned int* puiConnection;
tEplKernel Ret;
unsigned int uiCount;
unsigned int uiFreeCon;
unsigned int *puiConnection;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
if ((uiTargetNodeId_p == EPL_C_ADR_INVALID)
|| (uiTargetNodeId_p >= EPL_C_ADR_BROADCAST))
{
Ret = kEplSdoAsndInvalidNodeId;
goto Exit;
}
if ((uiTargetNodeId_p == EPL_C_ADR_INVALID)
|| (uiTargetNodeId_p >= EPL_C_ADR_BROADCAST)) {
Ret = kEplSdoAsndInvalidNodeId;
goto Exit;
}
// get free entry in control structure
uiCount = 0;
uiFreeCon = EPL_SDO_MAX_CONNECTION_ASND;
puiConnection = &SdoAsndInstance_g.m_auiSdoAsndConnection[0];
while (uiCount < EPL_SDO_MAX_CONNECTION_ASND) {
if (*puiConnection == uiTargetNodeId_p) { // existing connection to target node found
// save handle for higher layer
*pSdoConHandle_p = (uiCount | EPL_SDO_ASND_HANDLE);
// get free entry in control structure
uiCount = 0;
uiFreeCon = EPL_SDO_MAX_CONNECTION_ASND;
puiConnection = &SdoAsndInstance_g.m_auiSdoAsndConnection[0];
while(uiCount < EPL_SDO_MAX_CONNECTION_ASND)
{
if (*puiConnection == uiTargetNodeId_p)
{ // existing connection to target node found
// save handle for higher layer
*pSdoConHandle_p = (uiCount | EPL_SDO_ASND_HANDLE );
goto Exit;
} else if (*puiConnection == 0) { // free entry-> save target nodeId
uiFreeCon = uiCount;
}
uiCount++;
puiConnection++;
}
goto Exit;
}
else if (*puiConnection == 0)
{ // free entry-> save target nodeId
uiFreeCon = uiCount;
}
uiCount++;
puiConnection++;
}
if (uiFreeCon == EPL_SDO_MAX_CONNECTION_ASND) {
// no free connection
Ret = kEplSdoAsndNoFreeHandle;
} else {
puiConnection =
&SdoAsndInstance_g.m_auiSdoAsndConnection[uiFreeCon];
*puiConnection = uiTargetNodeId_p;
// save handle for higher layer
*pSdoConHandle_p = (uiFreeCon | EPL_SDO_ASND_HANDLE);
if (uiFreeCon == EPL_SDO_MAX_CONNECTION_ASND)
{
// no free connection
Ret = kEplSdoAsndNoFreeHandle;
}
else
{
puiConnection = &SdoAsndInstance_g.m_auiSdoAsndConnection[uiFreeCon];
*puiConnection = uiTargetNodeId_p;
// save handle for higher layer
*pSdoConHandle_p = (uiFreeCon | EPL_SDO_ASND_HANDLE );
goto Exit;
}
goto Exit;
}
Exit:
return Ret;
Exit:
return Ret;
}
//---------------------------------------------------------------------------
@ -339,47 +319,47 @@ Exit:
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoAsnduSendData(tEplSdoConHdl SdoConHandle_p,
tEplFrame * pSrcData_p,
DWORD dwDataSize_p)
tEplKernel PUBLIC EplSdoAsnduSendData(tEplSdoConHdl SdoConHandle_p,
tEplFrame * pSrcData_p,
DWORD dwDataSize_p)
{
tEplKernel Ret;
unsigned int uiArray;
tEplFrameInfo FrameInfo;
tEplKernel Ret;
unsigned int uiArray;
tEplFrameInfo FrameInfo;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
uiArray = (SdoConHandle_p & ~EPL_SDO_ASY_HANDLE_MASK);
uiArray = (SdoConHandle_p & ~EPL_SDO_ASY_HANDLE_MASK);
if(uiArray > EPL_SDO_MAX_CONNECTION_ASND)
{
Ret = kEplSdoAsndInvalidHandle;
goto Exit;
}
if (uiArray > EPL_SDO_MAX_CONNECTION_ASND) {
Ret = kEplSdoAsndInvalidHandle;
goto Exit;
}
// fillout Asnd header
// own node id not needed -> filled by DLL
// fillout Asnd header
// own node id not needed -> filled by DLL
// set message type
AmiSetByteToLe(&pSrcData_p->m_le_bMessageType, (BYTE) kEplMsgTypeAsnd); // ASnd == 0x06
// target node id
AmiSetByteToLe(&pSrcData_p->m_le_bDstNodeId,
(BYTE) SdoAsndInstance_g.
m_auiSdoAsndConnection[uiArray]);
// set source-nodeid (filled by DLL 0)
AmiSetByteToLe(&pSrcData_p->m_le_bSrcNodeId, 0x00);
// set message type
AmiSetByteToLe(&pSrcData_p->m_le_bMessageType, (BYTE)kEplMsgTypeAsnd); // ASnd == 0x06
// target node id
AmiSetByteToLe(&pSrcData_p->m_le_bDstNodeId, (BYTE) SdoAsndInstance_g.m_auiSdoAsndConnection[uiArray]);
// set source-nodeid (filled by DLL 0)
AmiSetByteToLe(&pSrcData_p->m_le_bSrcNodeId, 0x00);
// calc size
dwDataSize_p += EPL_ASND_HEADER_SIZE;
// calc size
dwDataSize_p += EPL_ASND_HEADER_SIZE;
// send function of DLL
FrameInfo.m_uiFrameSize = dwDataSize_p;
FrameInfo.m_pFrame = pSrcData_p;
EPL_MEMSET(&FrameInfo.m_NetTime , 0x00, sizeof(tEplNetTime));
// send function of DLL
FrameInfo.m_uiFrameSize = dwDataSize_p;
FrameInfo.m_pFrame = pSrcData_p;
EPL_MEMSET(&FrameInfo.m_NetTime, 0x00, sizeof(tEplNetTime));
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
Ret = EplDlluCalAsyncSend(&FrameInfo,kEplDllAsyncReqPrioGeneric);
Ret = EplDlluCalAsyncSend(&FrameInfo, kEplDllAsyncReqPrioGeneric);
#endif
Exit:
return Ret;
Exit:
return Ret;
}
@ -401,25 +381,22 @@ Exit:
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoAsnduDelCon(tEplSdoConHdl SdoConHandle_p)
{
tEplKernel Ret;
unsigned int uiArray;
tEplKernel Ret;
unsigned int uiArray;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
uiArray = (SdoConHandle_p & ~EPL_SDO_ASY_HANDLE_MASK);
// check parameter
if (uiArray > EPL_SDO_MAX_CONNECTION_ASND) {
Ret = kEplSdoAsndInvalidHandle;
goto Exit;
}
// set target nodeId to 0
SdoAsndInstance_g.m_auiSdoAsndConnection[uiArray] = 0;
uiArray = (SdoConHandle_p & ~EPL_SDO_ASY_HANDLE_MASK);
// check parameter
if(uiArray > EPL_SDO_MAX_CONNECTION_ASND)
{
Ret = kEplSdoAsndInvalidHandle;
goto Exit;
}
// set target nodeId to 0
SdoAsndInstance_g.m_auiSdoAsndConnection[uiArray] = 0;
Exit:
return Ret;
Exit:
return Ret;
}
//=========================================================================//
@ -447,63 +424,60 @@ Exit:
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoAsnduCb(tEplFrameInfo * pFrameInfo_p)
{
tEplKernel Ret = kEplSuccessful;
unsigned int uiCount;
unsigned int* puiConnection;
unsigned int uiNodeId;
unsigned int uiFreeEntry = 0xFFFF;
tEplSdoConHdl SdoConHdl;
tEplFrame* pFrame;
tEplKernel Ret = kEplSuccessful;
unsigned int uiCount;
unsigned int *puiConnection;
unsigned int uiNodeId;
unsigned int uiFreeEntry = 0xFFFF;
tEplSdoConHdl SdoConHdl;
tEplFrame *pFrame;
pFrame = pFrameInfo_p->m_pFrame;
pFrame = pFrameInfo_p->m_pFrame;
uiNodeId = AmiGetByteFromLe(&pFrame->m_le_bSrcNodeId);
uiNodeId = AmiGetByteFromLe(&pFrame->m_le_bSrcNodeId);
// search corresponding entry in control structure
uiCount = 0;
puiConnection = &SdoAsndInstance_g.m_auiSdoAsndConnection[0];
while (uiCount < EPL_SDO_MAX_CONNECTION_ASND)
{
if (uiNodeId == *puiConnection)
{
break;
}
else if ((*puiConnection == 0)
&& (uiFreeEntry == 0xFFFF))
{ // free entry
uiFreeEntry = uiCount;
}
uiCount++;
puiConnection++;
}
// search corresponding entry in control structure
uiCount = 0;
puiConnection = &SdoAsndInstance_g.m_auiSdoAsndConnection[0];
while (uiCount < EPL_SDO_MAX_CONNECTION_ASND) {
if (uiNodeId == *puiConnection) {
break;
} else if ((*puiConnection == 0)
&& (uiFreeEntry == 0xFFFF)) { // free entry
uiFreeEntry = uiCount;
}
uiCount++;
puiConnection++;
}
if (uiCount == EPL_SDO_MAX_CONNECTION_ASND)
{
if (uiFreeEntry != 0xFFFF)
{
puiConnection = &SdoAsndInstance_g.m_auiSdoAsndConnection[uiFreeEntry];
*puiConnection = uiNodeId;
uiCount = uiFreeEntry;
}
else
{
EPL_DBGLVL_SDO_TRACE0("EplSdoAsnduCb(): no free handle\n");
goto Exit;
}
}
if (uiCount == EPL_SDO_MAX_CONNECTION_ASND) {
if (uiFreeEntry != 0xFFFF) {
puiConnection =
&SdoAsndInstance_g.
m_auiSdoAsndConnection[uiFreeEntry];
*puiConnection = uiNodeId;
uiCount = uiFreeEntry;
} else {
EPL_DBGLVL_SDO_TRACE0
("EplSdoAsnduCb(): no free handle\n");
goto Exit;
}
}
// if (uiNodeId == *puiConnection)
{ // entry found or created
SdoConHdl = (uiCount | EPL_SDO_ASND_HANDLE );
{ // entry found or created
SdoConHdl = (uiCount | EPL_SDO_ASND_HANDLE);
SdoAsndInstance_g.m_fpSdoAsySeqCb(SdoConHdl, &pFrame->m_Data.m_Asnd.m_Payload.m_SdoSequenceFrame, (pFrameInfo_p->m_uiFrameSize - 18));
}
SdoAsndInstance_g.m_fpSdoAsySeqCb(SdoConHdl,
&pFrame->m_Data.m_Asnd.
m_Payload.m_SdoSequenceFrame,
(pFrameInfo_p->m_uiFrameSize -
18));
}
Exit:
return Ret;
Exit:
return Ret;
}
#endif // end of #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDO_ASND)) != 0)
// EOF

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -68,7 +68,6 @@
****************************************************************************/
#include "user/EplSdoUdpu.h"
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDO_UDP)) != 0)
@ -79,7 +78,6 @@
#include <linux/sched.h>
#endif
/***************************************************************************/
/* */
/* */
@ -100,29 +98,27 @@
// local types
//---------------------------------------------------------------------------
typedef struct
{
unsigned long m_ulIpAddr; // in network byte order
unsigned int m_uiPort; // in network byte order
typedef struct {
unsigned long m_ulIpAddr; // in network byte order
unsigned int m_uiPort; // in network byte order
} tEplSdoUdpCon;
// instance table
typedef struct
{
tEplSdoUdpCon m_aSdoAbsUdpConnection[EPL_SDO_MAX_CONNECTION_UDP];
tEplSequLayerReceiveCb m_fpSdoAsySeqCb;
SOCKET m_UdpSocket;
typedef struct {
tEplSdoUdpCon m_aSdoAbsUdpConnection[EPL_SDO_MAX_CONNECTION_UDP];
tEplSequLayerReceiveCb m_fpSdoAsySeqCb;
SOCKET m_UdpSocket;
#if (TARGET_SYSTEM == _WIN32_)
HANDLE m_ThreadHandle;
LPCRITICAL_SECTION m_pCriticalSection;
CRITICAL_SECTION m_CriticalSection;
HANDLE m_ThreadHandle;
LPCRITICAL_SECTION m_pCriticalSection;
CRITICAL_SECTION m_CriticalSection;
#elif (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
struct completion m_CompletionUdpThread;
int m_ThreadHandle;
int m_iTerminateThread;
struct completion m_CompletionUdpThread;
int m_ThreadHandle;
int m_iTerminateThread;
#endif
} tEplSdoUdpInstance;
@ -131,7 +127,7 @@ typedef struct
// modul globale vars
//---------------------------------------------------------------------------
static tEplSdoUdpInstance SdoUdpInstance_g;
static tEplSdoUdpInstance SdoUdpInstance_g;
//---------------------------------------------------------------------------
// local function prototypes
@ -141,7 +137,7 @@ static tEplSdoUdpInstance SdoUdpInstance_g;
static DWORD PUBLIC EplSdoUdpThread(LPVOID lpParameter);
#elif (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
static int EplSdoUdpThread(void * pArg_p);
static int EplSdoUdpThread(void *pArg_p);
#endif
/***************************************************************************/
@ -157,8 +153,6 @@ static int EplSdoUdpThread(void * pArg_p);
//
/***************************************************************************/
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
@ -185,12 +179,11 @@ static int EplSdoUdpThread(void * pArg_p);
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoUdpuInit(tEplSequLayerReceiveCb fpReceiveCb_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = EplSdoUdpuAddInstance(fpReceiveCb_p);
Ret = EplSdoUdpuAddInstance(fpReceiveCb_p);
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -214,59 +207,54 @@ return Ret;
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoUdpuAddInstance(tEplSequLayerReceiveCb fpReceiveCb_p)
{
tEplKernel Ret;
tEplKernel Ret;
#if (TARGET_SYSTEM == _WIN32_)
int iError;
WSADATA Wsa;
int iError;
WSADATA Wsa;
#endif
// set instance variables to 0
EPL_MEMSET(&SdoUdpInstance_g, 0x00, sizeof(SdoUdpInstance_g));
// set instance variables to 0
EPL_MEMSET(&SdoUdpInstance_g, 0x00, sizeof(SdoUdpInstance_g));
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// save pointer to callback-function
if (fpReceiveCb_p != NULL)
{
SdoUdpInstance_g.m_fpSdoAsySeqCb = fpReceiveCb_p;
}
else
{
Ret = kEplSdoUdpMissCb;
goto Exit;
}
// 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 acccess of instnace variables
SdoUdpInstance_g.m_pCriticalSection = &SdoUdpInstance_g.m_CriticalSection;
InitializeCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
// 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 acccess of instnace variables
SdoUdpInstance_g.m_pCriticalSection =
&SdoUdpInstance_g.m_CriticalSection;
InitializeCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
#elif (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
init_completion(&SdoUdpInstance_g.m_CompletionUdpThread);
SdoUdpInstance_g.m_iTerminateThread = 0;
init_completion(&SdoUdpInstance_g.m_CompletionUdpThread);
SdoUdpInstance_g.m_iTerminateThread = 0;
#endif
SdoUdpInstance_g.m_ThreadHandle = 0;
SdoUdpInstance_g.m_UdpSocket = INVALID_SOCKET;
SdoUdpInstance_g.m_ThreadHandle = 0;
SdoUdpInstance_g.m_UdpSocket = INVALID_SOCKET;
Ret = EplSdoUdpuConfig(INADDR_ANY, 0);
Ret = EplSdoUdpuConfig(INADDR_ANY, 0);
Exit:
return Ret;
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplSdoUdpuDelInstance
@ -287,56 +275,52 @@ Exit:
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoUdpuDelInstance()
{
tEplKernel Ret;
tEplKernel Ret;
#if (TARGET_SYSTEM == _WIN32_)
BOOL fTermError;
BOOL fTermError;
#endif
Ret = kEplSuccessful;
Ret = kEplSuccessful;
if (SdoUdpInstance_g.m_ThreadHandle != 0)
{ // listen thread was started
// close thread
if (SdoUdpInstance_g.m_ThreadHandle != 0) { // listen thread was started
// close thread
#if (TARGET_SYSTEM == _WIN32_)
fTermError = TerminateThread(SdoUdpInstance_g.m_ThreadHandle, 0);
if(fTermError == FALSE)
{
Ret = kEplSdoUdpThreadError;
goto Exit;
}
fTermError =
TerminateThread(SdoUdpInstance_g.m_ThreadHandle, 0);
if (fTermError == FALSE) {
Ret = kEplSdoUdpThreadError;
goto Exit;
}
#elif (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
SdoUdpInstance_g.m_iTerminateThread = 1;
/* kill_proc(SdoUdpInstance_g.m_ThreadHandle, SIGTERM, 1 ); */
send_sig(SIGTERM, SdoUdpInstance_g.m_ThreadHandle, 1);
wait_for_completion(&SdoUdpInstance_g.m_CompletionUdpThread);
SdoUdpInstance_g.m_iTerminateThread = 1;
/* kill_proc(SdoUdpInstance_g.m_ThreadHandle, SIGTERM, 1 ); */
send_sig(SIGTERM, SdoUdpInstance_g.m_ThreadHandle, 1);
wait_for_completion(&SdoUdpInstance_g.m_CompletionUdpThread);
#endif
SdoUdpInstance_g.m_ThreadHandle = 0;
}
if (SdoUdpInstance_g.m_UdpSocket != INVALID_SOCKET)
{
// close socket
closesocket(SdoUdpInstance_g.m_UdpSocket);
SdoUdpInstance_g.m_UdpSocket = INVALID_SOCKET;
}
SdoUdpInstance_g.m_ThreadHandle = 0;
}
if (SdoUdpInstance_g.m_UdpSocket != INVALID_SOCKET) {
// close socket
closesocket(SdoUdpInstance_g.m_UdpSocket);
SdoUdpInstance_g.m_UdpSocket = INVALID_SOCKET;
}
#if (TARGET_SYSTEM == _WIN32_)
// delete critical section
DeleteCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
// delete critical section
DeleteCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
#endif
#if (TARGET_SYSTEM == _WIN32_)
// for win 32
WSACleanup();
// for win 32
WSACleanup();
#endif
#if (TARGET_SYSTEM == _WIN32_)
Exit:
Exit:
#endif
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -356,120 +340,107 @@ Exit:
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoUdpuConfig(unsigned long ulIpAddr_p, unsigned int uiPort_p)
tEplKernel PUBLIC EplSdoUdpuConfig(unsigned long ulIpAddr_p,
unsigned int uiPort_p)
{
tEplKernel Ret;
struct sockaddr_in Addr;
int iError;
tEplKernel Ret;
struct sockaddr_in Addr;
int iError;
#if (TARGET_SYSTEM == _WIN32_)
BOOL fTermError;
unsigned long ulThreadId;
BOOL fTermError;
unsigned long ulThreadId;
#endif
Ret = kEplSuccessful;
Ret = kEplSuccessful;
if (uiPort_p == 0)
{ // set UDP port to default port number
uiPort_p = EPL_C_SDO_EPL_PORT;
}
else if (uiPort_p > 65535)
{
Ret = kEplSdoUdpSocketError;
goto Exit;
}
if (uiPort_p == 0) { // set UDP port to default port number
uiPort_p = EPL_C_SDO_EPL_PORT;
} else if (uiPort_p > 65535) {
Ret = kEplSdoUdpSocketError;
goto Exit;
}
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 == _WIN32_)
fTermError = TerminateThread(SdoUdpInstance_g.m_ThreadHandle, 0);
if(fTermError == FALSE)
{
Ret = kEplSdoUdpThreadError;
goto Exit;
}
fTermError =
TerminateThread(SdoUdpInstance_g.m_ThreadHandle, 0);
if (fTermError == FALSE) {
Ret = kEplSdoUdpThreadError;
goto Exit;
}
#elif (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
SdoUdpInstance_g.m_iTerminateThread = 1;
/* kill_proc(SdoUdpInstance_g.m_ThreadHandle, SIGTERM, 1 ); */
send_sig(SIGTERM, SdoUdpInstance_g.m_ThreadHandle, 1);
wait_for_completion(&SdoUdpInstance_g.m_CompletionUdpThread);
SdoUdpInstance_g.m_iTerminateThread = 0;
SdoUdpInstance_g.m_iTerminateThread = 1;
/* kill_proc(SdoUdpInstance_g.m_ThreadHandle, SIGTERM, 1 ); */
send_sig(SIGTERM, SdoUdpInstance_g.m_ThreadHandle, 1);
wait_for_completion(&SdoUdpInstance_g.m_CompletionUdpThread);
SdoUdpInstance_g.m_iTerminateThread = 0;
#endif
SdoUdpInstance_g.m_ThreadHandle = 0;
}
SdoUdpInstance_g.m_ThreadHandle = 0;
}
if (SdoUdpInstance_g.m_UdpSocket != INVALID_SOCKET)
{
// close socket
iError = closesocket(SdoUdpInstance_g.m_UdpSocket);
SdoUdpInstance_g.m_UdpSocket = INVALID_SOCKET;
if(iError != 0)
{
Ret = kEplSdoUdpSocketError;
goto Exit;
}
}
// create Socket
SdoUdpInstance_g.m_UdpSocket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (SdoUdpInstance_g.m_UdpSocket == INVALID_SOCKET)
{
Ret = kEplSdoUdpNoSocket;
EPL_DBGLVL_SDO_TRACE0("EplSdoUdpuConfig: socket() failed\n");
goto Exit;
}
// bind socket
Addr.sin_family = AF_INET;
Addr.sin_port = htons((unsigned short) uiPort_p);
Addr.sin_addr.s_addr = htonl(ulIpAddr_p);
iError = bind(SdoUdpInstance_g.m_UdpSocket, (struct sockaddr*)&Addr, sizeof (Addr));
if (iError < 0)
{
//iError = WSAGetLastError();
EPL_DBGLVL_SDO_TRACE1("EplSdoUdpuConfig: bind() finished with %i\n", iError);
Ret = kEplSdoUdpNoSocket;
goto Exit;
}
// create Listen-Thread
if (SdoUdpInstance_g.m_UdpSocket != INVALID_SOCKET) {
// close socket
iError = closesocket(SdoUdpInstance_g.m_UdpSocket);
SdoUdpInstance_g.m_UdpSocket = INVALID_SOCKET;
if (iError != 0) {
Ret = kEplSdoUdpSocketError;
goto Exit;
}
}
// create Socket
SdoUdpInstance_g.m_UdpSocket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (SdoUdpInstance_g.m_UdpSocket == INVALID_SOCKET) {
Ret = kEplSdoUdpNoSocket;
EPL_DBGLVL_SDO_TRACE0("EplSdoUdpuConfig: socket() failed\n");
goto Exit;
}
// bind socket
Addr.sin_family = AF_INET;
Addr.sin_port = htons((unsigned short)uiPort_p);
Addr.sin_addr.s_addr = htonl(ulIpAddr_p);
iError =
bind(SdoUdpInstance_g.m_UdpSocket, (struct sockaddr *)&Addr,
sizeof(Addr));
if (iError < 0) {
//iError = WSAGetLastError();
EPL_DBGLVL_SDO_TRACE1
("EplSdoUdpuConfig: bind() finished with %i\n", iError);
Ret = kEplSdoUdpNoSocket;
goto Exit;
}
// create Listen-Thread
#if (TARGET_SYSTEM == _WIN32_)
// for win32
// create thread
SdoUdpInstance_g.m_ThreadHandle = CreateThread(NULL,
0,
EplSdoUdpThread,
&SdoUdpInstance_g,
0,
&ulThreadId);
if(SdoUdpInstance_g.m_ThreadHandle == NULL)
{
Ret = kEplSdoUdpThreadError;
goto Exit;
}
// for win32
// create thread
SdoUdpInstance_g.m_ThreadHandle = CreateThread(NULL,
0,
EplSdoUdpThread,
&SdoUdpInstance_g,
0, &ulThreadId);
if (SdoUdpInstance_g.m_ThreadHandle == NULL) {
Ret = kEplSdoUdpThreadError;
goto Exit;
}
#elif (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
SdoUdpInstance_g.m_ThreadHandle = kernel_thread(EplSdoUdpThread, &SdoUdpInstance_g, CLONE_KERNEL);
if(SdoUdpInstance_g.m_ThreadHandle == 0)
{
Ret = kEplSdoUdpThreadError;
goto Exit;
}
SdoUdpInstance_g.m_ThreadHandle =
kernel_thread(EplSdoUdpThread, &SdoUdpInstance_g, CLONE_KERNEL);
if (SdoUdpInstance_g.m_ThreadHandle == 0) {
Ret = kEplSdoUdpThreadError;
goto Exit;
}
#endif
Exit:
return Ret;
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplSdoUdpuInitCon
@ -488,57 +459,51 @@ Exit:
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoUdpuInitCon(tEplSdoConHdl* pSdoConHandle_p,
unsigned int uiTargetNodeId_p)
tEplKernel PUBLIC EplSdoUdpuInitCon(tEplSdoConHdl * pSdoConHandle_p,
unsigned int uiTargetNodeId_p)
{
tEplKernel Ret;
unsigned int uiCount;
unsigned int uiFreeCon;
tEplSdoUdpCon* pSdoUdpCon;
tEplKernel Ret;
unsigned int uiCount;
unsigned int uiFreeCon;
tEplSdoUdpCon *pSdoUdpCon;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// get free entry in control structure
uiCount = 0;
uiFreeCon = EPL_SDO_MAX_CONNECTION_UDP;
pSdoUdpCon = &SdoUdpInstance_g.m_aSdoAbsUdpConnection[0];
while (uiCount < EPL_SDO_MAX_CONNECTION_UDP)
{
if ((pSdoUdpCon->m_ulIpAddr & htonl(0xFF)) == htonl(uiTargetNodeId_p))
{ // existing connection to target node found
// set handle
*pSdoConHandle_p = (uiCount | EPL_SDO_UDP_HANDLE);
// get free entry in control structure
uiCount = 0;
uiFreeCon = EPL_SDO_MAX_CONNECTION_UDP;
pSdoUdpCon = &SdoUdpInstance_g.m_aSdoAbsUdpConnection[0];
while (uiCount < EPL_SDO_MAX_CONNECTION_UDP) {
if ((pSdoUdpCon->m_ulIpAddr & htonl(0xFF)) == htonl(uiTargetNodeId_p)) { // existing connection to target node found
// set handle
*pSdoConHandle_p = (uiCount | EPL_SDO_UDP_HANDLE);
goto Exit;
}
else if ((pSdoUdpCon->m_ulIpAddr == 0)
&& (pSdoUdpCon->m_uiPort == 0))
{
uiFreeCon = uiCount;
}
uiCount++;
pSdoUdpCon++;
}
goto Exit;
} else if ((pSdoUdpCon->m_ulIpAddr == 0)
&& (pSdoUdpCon->m_uiPort == 0)) {
uiFreeCon = uiCount;
}
uiCount++;
pSdoUdpCon++;
}
if (uiFreeCon == EPL_SDO_MAX_CONNECTION_UDP)
{
// error no free handle
Ret = kEplSdoUdpNoFreeHandle;
}
else
{
pSdoUdpCon = &SdoUdpInstance_g.m_aSdoAbsUdpConnection[uiFreeCon];
// save infos for connection
pSdoUdpCon->m_uiPort = htons(EPL_C_SDO_EPL_PORT);
pSdoUdpCon->m_ulIpAddr = htonl(0xC0A86400 | uiTargetNodeId_p); // 192.168.100.uiTargetNodeId_p
if (uiFreeCon == EPL_SDO_MAX_CONNECTION_UDP) {
// error no free handle
Ret = kEplSdoUdpNoFreeHandle;
} else {
pSdoUdpCon =
&SdoUdpInstance_g.m_aSdoAbsUdpConnection[uiFreeCon];
// save infos for connection
pSdoUdpCon->m_uiPort = htons(EPL_C_SDO_EPL_PORT);
pSdoUdpCon->m_ulIpAddr = htonl(0xC0A86400 | uiTargetNodeId_p); // 192.168.100.uiTargetNodeId_p
// set handle
*pSdoConHandle_p = (uiFreeCon | EPL_SDO_UDP_HANDLE);
// set handle
*pSdoConHandle_p = (uiFreeCon | EPL_SDO_UDP_HANDLE);
}
}
Exit:
return Ret;
Exit:
return Ret;
}
@ -561,67 +526,67 @@ Exit:
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoUdpuSendData(tEplSdoConHdl SdoConHandle_p,
tEplFrame * pSrcData_p,
DWORD dwDataSize_p)
tEplKernel PUBLIC EplSdoUdpuSendData(tEplSdoConHdl SdoConHandle_p,
tEplFrame * pSrcData_p, DWORD dwDataSize_p)
{
tEplKernel Ret;
int iError;
unsigned int uiArray;
struct sockaddr_in Addr;
tEplKernel Ret;
int iError;
unsigned int uiArray;
struct sockaddr_in Addr;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
uiArray = (SdoConHandle_p & ~EPL_SDO_ASY_HANDLE_MASK);
if(uiArray >= EPL_SDO_MAX_CONNECTION_UDP)
{
Ret = kEplSdoUdpInvalidHdl;
goto Exit;
}
//set message type
AmiSetByteToLe(&pSrcData_p->m_le_bMessageType, 0x06); // SDO
// target node id (for Udp = 0)
AmiSetByteToLe(&pSrcData_p->m_le_bDstNodeId, 0x00);
// set source-nodeid (for Udp = 0)
AmiSetByteToLe(&pSrcData_p->m_le_bSrcNodeId, 0x00);
uiArray = (SdoConHandle_p & ~EPL_SDO_ASY_HANDLE_MASK);
if (uiArray >= EPL_SDO_MAX_CONNECTION_UDP) {
Ret = kEplSdoUdpInvalidHdl;
goto Exit;
}
//set message type
AmiSetByteToLe(&pSrcData_p->m_le_bMessageType, 0x06); // SDO
// target node id (for Udp = 0)
AmiSetByteToLe(&pSrcData_p->m_le_bDstNodeId, 0x00);
// set source-nodeid (for Udp = 0)
AmiSetByteToLe(&pSrcData_p->m_le_bSrcNodeId, 0x00);
// calc size
dwDataSize_p += EPL_ASND_HEADER_SIZE;
// calc size
dwDataSize_p += EPL_ASND_HEADER_SIZE;
// call sendto
Addr.sin_family = AF_INET;
// call sendto
Addr.sin_family = AF_INET;
#if (TARGET_SYSTEM == _WIN32_)
// enter critical section for process function
EnterCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
// enter critical section for process function
EnterCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
#endif
Addr.sin_port = (unsigned short) SdoUdpInstance_g.m_aSdoAbsUdpConnection[uiArray].m_uiPort;
Addr.sin_addr.s_addr = SdoUdpInstance_g.m_aSdoAbsUdpConnection[uiArray].m_ulIpAddr;
Addr.sin_port =
(unsigned short)SdoUdpInstance_g.m_aSdoAbsUdpConnection[uiArray].
m_uiPort;
Addr.sin_addr.s_addr =
SdoUdpInstance_g.m_aSdoAbsUdpConnection[uiArray].m_ulIpAddr;
#if (TARGET_SYSTEM == _WIN32_)
// leave critical section for process function
LeaveCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
// leave critical section for process function
LeaveCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
#endif
iError = sendto (SdoUdpInstance_g.m_UdpSocket, // sockethandle
(const char*) &pSrcData_p->m_le_bMessageType, // data to send
dwDataSize_p, // number of bytes to send
0, // flags
(struct sockaddr*)&Addr, // target
sizeof(struct sockaddr_in)); // sizeof targetadress
if(iError < 0)
{
EPL_DBGLVL_SDO_TRACE1("EplSdoUdpuSendData: sendto() finished with %i\n", iError);
Ret = kEplSdoUdpSendError;
goto Exit;
}
iError = sendto(SdoUdpInstance_g.m_UdpSocket, // sockethandle
(const char *)&pSrcData_p->m_le_bMessageType, // data to send
dwDataSize_p, // number of bytes to send
0, // flags
(struct sockaddr *)&Addr, // target
sizeof(struct sockaddr_in)); // sizeof targetadress
if (iError < 0) {
EPL_DBGLVL_SDO_TRACE1
("EplSdoUdpuSendData: sendto() finished with %i\n", iError);
Ret = kEplSdoUdpSendError;
goto Exit;
}
Exit:
return Ret;
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplSdoUdpuDelCon
@ -640,29 +605,24 @@ Exit:
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoUdpuDelCon(tEplSdoConHdl SdoConHandle_p)
{
tEplKernel Ret;
unsigned int uiArray;
tEplKernel Ret;
unsigned int uiArray;
uiArray = (SdoConHandle_p & ~EPL_SDO_ASY_HANDLE_MASK);
uiArray = (SdoConHandle_p & ~EPL_SDO_ASY_HANDLE_MASK);
if (uiArray >= EPL_SDO_MAX_CONNECTION_UDP) {
Ret = kEplSdoUdpInvalidHdl;
goto Exit;
} else {
Ret = kEplSuccessful;
}
if(uiArray >= EPL_SDO_MAX_CONNECTION_UDP)
{
Ret = kEplSdoUdpInvalidHdl;
goto Exit;
}
else
{
Ret = kEplSuccessful;
}
// delete connection
SdoUdpInstance_g.m_aSdoAbsUdpConnection[uiArray].m_ulIpAddr = 0;
SdoUdpInstance_g.m_aSdoAbsUdpConnection[uiArray].m_uiPort = 0;
// delete connection
SdoUdpInstance_g.m_aSdoAbsUdpConnection[uiArray].m_ulIpAddr = 0;
SdoUdpInstance_g.m_aSdoAbsUdpConnection[uiArray].m_uiPort = 0;
Exit:
return Ret;
Exit:
return Ret;
}
//=========================================================================//
@ -691,131 +651,140 @@ Exit:
#if (TARGET_SYSTEM == _WIN32_)
static DWORD PUBLIC EplSdoUdpThread(LPVOID lpParameter)
#elif (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
static int EplSdoUdpThread(void * pArg_p)
static int EplSdoUdpThread(void *pArg_p)
#endif
{
tEplSdoUdpInstance* pInstance;
struct sockaddr_in RemoteAddr;
int iError;
int iCount;
int iFreeEntry;
BYTE abBuffer[EPL_MAX_SDO_REC_FRAME_SIZE];
unsigned int uiSize;
tEplSdoConHdl SdoConHdl;
tEplSdoUdpInstance *pInstance;
struct sockaddr_in RemoteAddr;
int iError;
int iCount;
int iFreeEntry;
BYTE abBuffer[EPL_MAX_SDO_REC_FRAME_SIZE];
unsigned int uiSize;
tEplSdoConHdl SdoConHdl;
#if (TARGET_SYSTEM == _WIN32_)
pInstance = (tEplSdoUdpInstance*)lpParameter;
for (;;)
pInstance = (tEplSdoUdpInstance *) lpParameter;
for (;;)
#elif (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
pInstance = (tEplSdoUdpInstance*)pArg_p;
daemonize("EplSdoUdpThread");
allow_signal( SIGTERM );
pInstance = (tEplSdoUdpInstance *) pArg_p;
daemonize("EplSdoUdpThread");
allow_signal(SIGTERM);
for (;pInstance->m_iTerminateThread == 0;)
for (; pInstance->m_iTerminateThread == 0;)
#endif
{
// wait for data
uiSize = sizeof(struct sockaddr);
iError = recvfrom(pInstance->m_UdpSocket, // Socket
(char *)&abBuffer[0], // buffer for data
sizeof(abBuffer), // size of the buffer
0, // flags
(struct sockaddr*)&RemoteAddr,
(int*)&uiSize);
{
// wait for data
uiSize = sizeof(struct sockaddr);
iError = recvfrom(pInstance->m_UdpSocket, // Socket
(char *)&abBuffer[0], // buffer for data
sizeof(abBuffer), // size of the buffer
0, // flags
(struct sockaddr *)&RemoteAddr,
(int *)&uiSize);
#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
if (iError == -ERESTARTSYS)
{
break;
}
if (iError == -ERESTARTSYS) {
break;
}
#endif
if (iError > 0)
{
// get handle for higher layer
iCount = 0;
iFreeEntry = 0xFFFF;
if (iError > 0) {
// get handle for higher layer
iCount = 0;
iFreeEntry = 0xFFFF;
#if (TARGET_SYSTEM == _WIN32_)
// enter critical section for process function
EnterCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
// enter critical section for process function
EnterCriticalSection(SdoUdpInstance_g.
m_pCriticalSection);
#endif
while (iCount < EPL_SDO_MAX_CONNECTION_UDP)
{
// check if this connection is already known
if((pInstance->m_aSdoAbsUdpConnection[iCount].m_ulIpAddr == RemoteAddr.sin_addr.s_addr)
&& (pInstance->m_aSdoAbsUdpConnection[iCount].m_uiPort == RemoteAddr.sin_port))
{
break;
}
while (iCount < EPL_SDO_MAX_CONNECTION_UDP) {
// check if this connection is already known
if ((pInstance->m_aSdoAbsUdpConnection[iCount].
m_ulIpAddr == RemoteAddr.sin_addr.s_addr)
&& (pInstance->
m_aSdoAbsUdpConnection[iCount].
m_uiPort == RemoteAddr.sin_port)) {
break;
}
if((pInstance->m_aSdoAbsUdpConnection[iCount].m_ulIpAddr == 0)
&& (pInstance->m_aSdoAbsUdpConnection[iCount].m_uiPort == 0)
&& (iFreeEntry == 0xFFFF))
if ((pInstance->m_aSdoAbsUdpConnection[iCount].
m_ulIpAddr == 0)
&& (pInstance->
m_aSdoAbsUdpConnection[iCount].
m_uiPort == 0)
&& (iFreeEntry == 0xFFFF))
{
iFreeEntry = iCount;
}
{
iFreeEntry = iCount;
}
iCount++;
}
iCount++;
}
if (iCount == EPL_SDO_MAX_CONNECTION_UDP)
{
// connection unknown
// see if there is a free handle
if (iFreeEntry != 0xFFFF)
{
// save adress infos
pInstance->m_aSdoAbsUdpConnection[iFreeEntry].m_ulIpAddr =
RemoteAddr.sin_addr.s_addr;
pInstance->m_aSdoAbsUdpConnection[iFreeEntry].m_uiPort =
RemoteAddr.sin_port;
if (iCount == EPL_SDO_MAX_CONNECTION_UDP) {
// connection unknown
// see if there is a free handle
if (iFreeEntry != 0xFFFF) {
// save adress infos
pInstance->
m_aSdoAbsUdpConnection[iFreeEntry].
m_ulIpAddr =
RemoteAddr.sin_addr.s_addr;
pInstance->
m_aSdoAbsUdpConnection[iFreeEntry].
m_uiPort = RemoteAddr.sin_port;
#if (TARGET_SYSTEM == _WIN32_)
// leave critical section for process function
LeaveCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
// leave critical section for process function
LeaveCriticalSection(SdoUdpInstance_g.
m_pCriticalSection);
#endif
// call callback
SdoConHdl = iFreeEntry;
SdoConHdl |= EPL_SDO_UDP_HANDLE;
// offset 4 -> start of SDO Sequence header
pInstance->m_fpSdoAsySeqCb(SdoConHdl, (tEplAsySdoSeq*)&abBuffer[4], (iError - 4));
}
else
{
EPL_DBGLVL_SDO_TRACE0("Error in EplSdoUdpThread() no free handle\n");
// call callback
SdoConHdl = iFreeEntry;
SdoConHdl |= EPL_SDO_UDP_HANDLE;
// offset 4 -> start of SDO Sequence header
pInstance->m_fpSdoAsySeqCb(SdoConHdl,
(tEplAsySdoSeq
*) &
abBuffer[4],
(iError -
4));
} else {
EPL_DBGLVL_SDO_TRACE0
("Error in EplSdoUdpThread() no free handle\n");
#if (TARGET_SYSTEM == _WIN32_)
// leave critical section for process function
LeaveCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
// leave critical section for process function
LeaveCriticalSection(SdoUdpInstance_g.
m_pCriticalSection);
#endif
}
}
}
else
{
// known connection
// call callback with correct handle
SdoConHdl = iCount;
SdoConHdl |= EPL_SDO_UDP_HANDLE;
} else {
// known connection
// call callback with correct handle
SdoConHdl = iCount;
SdoConHdl |= EPL_SDO_UDP_HANDLE;
#if (TARGET_SYSTEM == _WIN32_)
// leave critical section for process function
LeaveCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
// leave critical section for process function
LeaveCriticalSection(SdoUdpInstance_g.
m_pCriticalSection);
#endif
// offset 4 -> start of SDO Sequence header
pInstance->m_fpSdoAsySeqCb(SdoConHdl, (tEplAsySdoSeq*)&abBuffer[4], (iError - 4));
}
} // end of if(iError!=SOCKET_ERROR)
}// end of for(;;)
// offset 4 -> start of SDO Sequence header
pInstance->m_fpSdoAsySeqCb(SdoConHdl,
(tEplAsySdoSeq *) &
abBuffer[4],
(iError - 4));
}
} // end of if(iError!=SOCKET_ERROR)
} // 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;
}
#endif // end of #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDO_UDP)) != 0)
// EOF

View File

@ -95,7 +95,6 @@
// local function prototypes
//---------------------------------------------------------------------------
/***************************************************************************/
/* */
/* */
@ -109,7 +108,6 @@
//
/***************************************************************************/
//=========================================================================//
// //
// P R I V A T E D E F I N I T I O N S //
@ -124,9 +122,8 @@
// local types
//---------------------------------------------------------------------------
typedef struct
{
tEplStatusuCbResponse m_apfnCbResponse[254];
typedef struct {
tEplStatusuCbResponse m_apfnCbResponse[254];
} tEplStatusuInstance;
@ -134,13 +131,14 @@ typedef struct
// local vars
//---------------------------------------------------------------------------
static tEplStatusuInstance EplStatusuInstance_g;
static tEplStatusuInstance EplStatusuInstance_g;
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
static tEplKernel PUBLIC EplStatusuCbStatusResponse(tEplFrameInfo * pFrameInfo_p);
static tEplKernel PUBLIC EplStatusuCbStatusResponse(tEplFrameInfo *
pFrameInfo_p);
//=========================================================================//
// //
@ -168,14 +166,13 @@ static tEplKernel PUBLIC EplStatusuCbStatusResponse(tEplFrameInfo * pFrameInfo_p
EPLDLLEXPORT tEplKernel PUBLIC EplStatusuInit()
{
tEplKernel Ret;
tEplKernel Ret;
Ret = EplStatusuAddInstance();
Ret = EplStatusuAddInstance();
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplStatusuAddInstance
@ -196,21 +193,23 @@ tEplKernel Ret;
EPLDLLEXPORT tEplKernel PUBLIC EplStatusuAddInstance()
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// reset instance structure
EPL_MEMSET(&EplStatusuInstance_g, 0, sizeof (EplStatusuInstance_g));
// reset instance structure
EPL_MEMSET(&EplStatusuInstance_g, 0, sizeof(EplStatusuInstance_g));
// register StatusResponse callback function
Ret = EplDlluCalRegAsndService(kEplDllAsndStatusResponse, EplStatusuCbStatusResponse, kEplDllAsndFilterAny);
// register StatusResponse callback function
Ret =
EplDlluCalRegAsndService(kEplDllAsndStatusResponse,
EplStatusuCbStatusResponse,
kEplDllAsndFilterAny);
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplStatusuDelInstance
@ -231,18 +230,19 @@ tEplKernel Ret;
EPLDLLEXPORT tEplKernel PUBLIC EplStatusuDelInstance()
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// deregister StatusResponse callback function
Ret = EplDlluCalRegAsndService(kEplDllAsndStatusResponse, NULL, kEplDllAsndFilterNone);
// deregister StatusResponse callback function
Ret =
EplDlluCalRegAsndService(kEplDllAsndStatusResponse, NULL,
kEplDllAsndFilterNone);
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplStatusuReset
@ -260,18 +260,17 @@ tEplKernel Ret;
EPLDLLEXPORT tEplKernel PUBLIC EplStatusuReset()
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// reset instance structure
EPL_MEMSET(&EplStatusuInstance_g, 0, sizeof (EplStatusuInstance_g));
// reset instance structure
EPL_MEMSET(&EplStatusuInstance_g, 0, sizeof(EplStatusuInstance_g));
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplStatusuRequestStatusResponse
@ -288,42 +287,38 @@ tEplKernel Ret;
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplStatusuRequestStatusResponse(
unsigned int uiNodeId_p,
tEplStatusuCbResponse pfnCbResponse_p)
tEplKernel PUBLIC EplStatusuRequestStatusResponse(unsigned int uiNodeId_p,
tEplStatusuCbResponse
pfnCbResponse_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// decrement node ID, because array is zero based
uiNodeId_p--;
if (uiNodeId_p < tabentries (EplStatusuInstance_g.m_apfnCbResponse))
{
// decrement node ID, because array is zero based
uiNodeId_p--;
if (uiNodeId_p < tabentries(EplStatusuInstance_g.m_apfnCbResponse)) {
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
if (EplStatusuInstance_g.m_apfnCbResponse[uiNodeId_p] != NULL)
{ // request already issued (maybe by someone else)
Ret = kEplInvalidOperation;
}
else
{
EplStatusuInstance_g.m_apfnCbResponse[uiNodeId_p] = pfnCbResponse_p;
Ret = EplDlluCalIssueRequest(kEplDllReqServiceStatus, (uiNodeId_p + 1), 0xFF);
}
if (EplStatusuInstance_g.m_apfnCbResponse[uiNodeId_p] != NULL) { // request already issued (maybe by someone else)
Ret = kEplInvalidOperation;
} else {
EplStatusuInstance_g.m_apfnCbResponse[uiNodeId_p] =
pfnCbResponse_p;
Ret =
EplDlluCalIssueRequest(kEplDllReqServiceStatus,
(uiNodeId_p + 1), 0xFF);
}
#else
Ret = kEplInvalidOperation;
Ret = kEplInvalidOperation;
#endif
}
else
{ // invalid node ID specified
Ret = kEplInvalidNodeId;
}
} else { // invalid node ID specified
Ret = kEplInvalidNodeId;
}
return Ret;
return Ret;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
@ -347,41 +342,39 @@ tEplKernel Ret;
// State:
//
//---------------------------------------------------------------------------
static tEplKernel PUBLIC EplStatusuCbStatusResponse(tEplFrameInfo * pFrameInfo_p)
static tEplKernel PUBLIC EplStatusuCbStatusResponse(tEplFrameInfo *
pFrameInfo_p)
{
tEplKernel Ret = kEplSuccessful;
unsigned int uiNodeId;
unsigned int uiIndex;
tEplStatusuCbResponse pfnCbResponse;
tEplKernel Ret = kEplSuccessful;
unsigned int uiNodeId;
unsigned int uiIndex;
tEplStatusuCbResponse pfnCbResponse;
uiNodeId = AmiGetByteFromLe(&pFrameInfo_p->m_pFrame->m_le_bSrcNodeId);
uiNodeId = AmiGetByteFromLe(&pFrameInfo_p->m_pFrame->m_le_bSrcNodeId);
uiIndex = uiNodeId - 1;
uiIndex = uiNodeId - 1;
if (uiIndex < tabentries (EplStatusuInstance_g.m_apfnCbResponse))
{
// memorize pointer to callback function
pfnCbResponse = EplStatusuInstance_g.m_apfnCbResponse[uiIndex];
if (pfnCbResponse == NULL)
{ // response was not requested
goto Exit;
}
// reset callback function pointer so that caller may issue next request
EplStatusuInstance_g.m_apfnCbResponse[uiIndex] = NULL;
if (uiIndex < tabentries(EplStatusuInstance_g.m_apfnCbResponse)) {
// memorize pointer to callback function
pfnCbResponse = EplStatusuInstance_g.m_apfnCbResponse[uiIndex];
if (pfnCbResponse == NULL) { // response was not requested
goto Exit;
}
// reset callback function pointer so that caller may issue next request
EplStatusuInstance_g.m_apfnCbResponse[uiIndex] = NULL;
if (pFrameInfo_p->m_uiFrameSize < EPL_C_DLL_MINSIZE_STATUSRES)
{ // StatusResponse not received or it has invalid size
Ret = pfnCbResponse(uiNodeId, NULL);
}
else
{ // StatusResponse received
Ret = pfnCbResponse(uiNodeId, &pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_StatusResponse);
}
}
if (pFrameInfo_p->m_uiFrameSize < EPL_C_DLL_MINSIZE_STATUSRES) { // StatusResponse not received or it has invalid size
Ret = pfnCbResponse(uiNodeId, NULL);
} else { // StatusResponse received
Ret =
pfnCbResponse(uiNodeId,
&pFrameInfo_p->m_pFrame->m_Data.
m_Asnd.m_Payload.m_StatusResponse);
}
}
Exit:
return Ret;
Exit:
return Ret;
}
// EOF

View File

@ -86,10 +86,9 @@
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
typedef struct
{
struct timer_list m_Timer;
tEplTimerArg TimerArgument;
typedef struct {
struct timer_list m_Timer;
tEplTimerArg TimerArgument;
} tEplTimeruData;
@ -137,14 +136,13 @@ static void PUBLIC EplTimeruCbMs(unsigned long ulParameter_p);
tEplKernel PUBLIC EplTimeruInit()
{
tEplKernel Ret;
tEplKernel Ret;
Ret = EplTimeruAddInstance();
Ret = EplTimeruAddInstance();
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruAddInstance
@ -161,14 +159,13 @@ tEplKernel Ret;
tEplKernel PUBLIC EplTimeruAddInstance()
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruDelInstance
@ -187,14 +184,13 @@ tEplKernel Ret;
tEplKernel PUBLIC EplTimeruDelInstance()
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruSetTimerMs
@ -211,43 +207,40 @@ tEplKernel Ret;
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruSetTimerMs(tEplTimerHdl* pTimerHdl_p,
unsigned long ulTime_p,
tEplTimerArg Argument_p)
tEplKernel PUBLIC EplTimeruSetTimerMs(tEplTimerHdl * pTimerHdl_p,
unsigned long ulTime_p,
tEplTimerArg Argument_p)
{
tEplKernel Ret = kEplSuccessful;
tEplTimeruData* pData;
tEplKernel Ret = kEplSuccessful;
tEplTimeruData *pData;
// check pointer to handle
if(pTimerHdl_p == NULL)
{
Ret = kEplTimerInvalidHandle;
goto Exit;
}
// check pointer to handle
if (pTimerHdl_p == NULL) {
Ret = kEplTimerInvalidHandle;
goto Exit;
}
pData = (tEplTimeruData*) EPL_MALLOC(sizeof (tEplTimeruData));
if (pData == NULL)
{
Ret = kEplNoResource;
goto Exit;
}
pData = (tEplTimeruData *) EPL_MALLOC(sizeof(tEplTimeruData));
if (pData == NULL) {
Ret = kEplNoResource;
goto Exit;
}
init_timer(&pData->m_Timer);
pData->m_Timer.function = EplTimeruCbMs;
pData->m_Timer.data = (unsigned long) pData;
pData->m_Timer.expires = jiffies + ulTime_p * HZ / 1000;
init_timer(&pData->m_Timer);
pData->m_Timer.function = EplTimeruCbMs;
pData->m_Timer.data = (unsigned long)pData;
pData->m_Timer.expires = jiffies + ulTime_p * HZ / 1000;
EPL_MEMCPY(&pData->TimerArgument, &Argument_p, sizeof(tEplTimerArg));
EPL_MEMCPY(&pData->TimerArgument, &Argument_p, sizeof(tEplTimerArg));
add_timer(&pData->m_Timer);
add_timer(&pData->m_Timer);
*pTimerHdl_p = (tEplTimerHdl) pData;
*pTimerHdl_p = (tEplTimerHdl) pData;
Exit:
return Ret;
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruModifyTimerMs
@ -264,57 +257,50 @@ Exit:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruModifyTimerMs(tEplTimerHdl* pTimerHdl_p,
unsigned long ulTime_p,
tEplTimerArg Argument_p)
tEplKernel PUBLIC EplTimeruModifyTimerMs(tEplTimerHdl * pTimerHdl_p,
unsigned long ulTime_p,
tEplTimerArg Argument_p)
{
tEplKernel Ret = kEplSuccessful;
tEplTimeruData* pData;
tEplKernel Ret = kEplSuccessful;
tEplTimeruData *pData;
// check pointer to handle
if(pTimerHdl_p == NULL)
{
Ret = kEplTimerInvalidHandle;
goto Exit;
}
// check pointer to handle
if (pTimerHdl_p == NULL) {
Ret = kEplTimerInvalidHandle;
goto Exit;
}
// check handle itself, i.e. was the handle initialized before
if (*pTimerHdl_p == 0) {
Ret = EplTimeruSetTimerMs(pTimerHdl_p, ulTime_p, Argument_p);
goto Exit;
}
pData = (tEplTimeruData *) * pTimerHdl_p;
if ((tEplTimeruData *) pData->m_Timer.data != pData) {
Ret = kEplTimerInvalidHandle;
goto Exit;
}
// check handle itself, i.e. was the handle initialized before
if (*pTimerHdl_p == 0)
{
Ret = EplTimeruSetTimerMs(pTimerHdl_p, ulTime_p, Argument_p);
goto Exit;
}
pData = (tEplTimeruData*) *pTimerHdl_p;
if ((tEplTimeruData*)pData->m_Timer.data != pData)
{
Ret = kEplTimerInvalidHandle;
goto Exit;
}
mod_timer(&pData->m_Timer, (jiffies + ulTime_p * HZ / 1000));
mod_timer(&pData->m_Timer, (jiffies + ulTime_p * HZ / 1000));
// copy the TimerArg after the timer is restarted,
// so that a timer occured immediately before mod_timer
// won't use the new TimerArg and
// therefore the old timer cannot be distinguished from the new one.
// But if the new timer is too fast, it may get lost.
EPL_MEMCPY(&pData->TimerArgument, &Argument_p, sizeof(tEplTimerArg));
// copy the TimerArg after the timer is restarted,
// so that a timer occured immediately before mod_timer
// won't use the new TimerArg and
// therefore the old timer cannot be distinguished from the new one.
// But if the new timer is too fast, it may get lost.
EPL_MEMCPY(&pData->TimerArgument, &Argument_p, sizeof(tEplTimerArg));
// check if timer is really running
if (timer_pending(&pData->m_Timer) == 0)
{ // timer is not running
// retry starting it
add_timer(&pData->m_Timer);
}
// set handle to pointer of tEplTimeruData
// check if timer is really running
if (timer_pending(&pData->m_Timer) == 0) { // timer is not running
// retry starting it
add_timer(&pData->m_Timer);
}
// set handle to pointer of tEplTimeruData
// *pTimerHdl_p = (tEplTimerHdl) pData;
Exit:
return Ret;
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruDeleteTimer
@ -329,50 +315,45 @@ Exit:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruDeleteTimer(tEplTimerHdl* pTimerHdl_p)
tEplKernel PUBLIC EplTimeruDeleteTimer(tEplTimerHdl * pTimerHdl_p)
{
tEplKernel Ret = kEplSuccessful;
tEplTimeruData* pData;
tEplKernel Ret = kEplSuccessful;
tEplTimeruData *pData;
// check pointer to handle
if(pTimerHdl_p == NULL)
{
Ret = kEplTimerInvalidHandle;
goto Exit;
}
// check handle itself, i.e. was the handle initialized before
if (*pTimerHdl_p == 0)
{
Ret = kEplSuccessful;
goto Exit;
}
pData = (tEplTimeruData*) *pTimerHdl_p;
if ((tEplTimeruData*)pData->m_Timer.data != pData)
{
Ret = kEplTimerInvalidHandle;
goto Exit;
}
// check pointer to handle
if (pTimerHdl_p == NULL) {
Ret = kEplTimerInvalidHandle;
goto Exit;
}
// check handle itself, i.e. was the handle initialized before
if (*pTimerHdl_p == 0) {
Ret = kEplSuccessful;
goto Exit;
}
pData = (tEplTimeruData *) * pTimerHdl_p;
if ((tEplTimeruData *) pData->m_Timer.data != pData) {
Ret = kEplTimerInvalidHandle;
goto Exit;
}
/* if (del_timer(&pData->m_Timer) == 1)
{
kfree(pData);
}
*/
// try to delete the timer
del_timer(&pData->m_Timer);
// free memory in any case
kfree(pData);
// try to delete the timer
del_timer(&pData->m_Timer);
// free memory in any case
kfree(pData);
// uninitialize handle
*pTimerHdl_p = 0;
// uninitialize handle
*pTimerHdl_p = 0;
Exit:
return Ret;
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruIsTimerActive
@ -391,33 +372,28 @@ Exit:
BOOL PUBLIC EplTimeruIsTimerActive(tEplTimerHdl TimerHdl_p)
{
BOOL fActive = FALSE;
tEplTimeruData* pData;
BOOL fActive = FALSE;
tEplTimeruData *pData;
// check handle itself, i.e. was the handle initialized before
if (TimerHdl_p == 0)
{ // timer was not created yet, so it is not active
goto Exit;
}
pData = (tEplTimeruData*) TimerHdl_p;
if ((tEplTimeruData*)pData->m_Timer.data != pData)
{ // invalid timer
goto Exit;
}
// check handle itself, i.e. was the handle initialized before
if (TimerHdl_p == 0) { // timer was not created yet, so it is not active
goto Exit;
}
pData = (tEplTimeruData *) TimerHdl_p;
if ((tEplTimeruData *) pData->m_Timer.data != pData) { // invalid timer
goto Exit;
}
// check if timer is running
if (timer_pending(&pData->m_Timer) == 0) { // timer is not running
goto Exit;
}
// check if timer is running
if (timer_pending(&pData->m_Timer) == 0)
{ // timer is not running
goto Exit;
}
fActive = TRUE;
fActive = TRUE;
Exit:
return fActive;
Exit:
return fActive;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
@ -443,30 +419,28 @@ Exit:
//---------------------------------------------------------------------------
static void PUBLIC EplTimeruCbMs(unsigned long ulParameter_p)
{
tEplKernel Ret = kEplSuccessful;
tEplTimeruData* pData;
tEplEvent EplEvent;
tEplTimerEventArg TimerEventArg;
tEplKernel Ret = kEplSuccessful;
tEplTimeruData *pData;
tEplEvent EplEvent;
tEplTimerEventArg TimerEventArg;
pData = (tEplTimeruData*) ulParameter_p;
pData = (tEplTimeruData *) ulParameter_p;
// call event function
TimerEventArg.m_TimerHdl = (tEplTimerHdl)pData;
TimerEventArg.m_ulArg = pData->TimerArgument.m_ulArg;
// call event function
TimerEventArg.m_TimerHdl = (tEplTimerHdl) pData;
TimerEventArg.m_ulArg = pData->TimerArgument.m_ulArg;
EplEvent.m_EventSink = pData->TimerArgument.m_EventSink;
EplEvent.m_EventType = kEplEventTypeTimer;
EPL_MEMSET(&EplEvent.m_NetTime, 0x00, sizeof(tEplNetTime));
EplEvent.m_pArg = &TimerEventArg;
EplEvent.m_uiSize = sizeof(TimerEventArg);
EplEvent.m_EventSink = pData->TimerArgument.m_EventSink;
EplEvent.m_EventType = kEplEventTypeTimer;
EPL_MEMSET(&EplEvent.m_NetTime, 0x00, sizeof(tEplNetTime));
EplEvent.m_pArg = &TimerEventArg;
EplEvent.m_uiSize = sizeof(TimerEventArg);
Ret = EplEventuPost(&EplEvent);
Ret = EplEventuPost(&EplEvent);
// d.k. do not free memory, user has to call EplTimeruDeleteTimer()
//kfree(pData);
// d.k. do not free memory, user has to call EplTimeruDeleteTimer()
//kfree(pData);
}
// EOF

View File

@ -132,11 +132,11 @@
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruInit()
{
tEplKernel Ret;
tEplKernel Ret;
Ret = EplTimeruAddInstance();
Ret = EplTimeruAddInstance();
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -158,11 +158,11 @@ return Ret;
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruAddInstance()
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -186,11 +186,11 @@ return Ret;
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruDelInstance()
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -212,27 +212,24 @@ tEplKernel Ret;
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruSetTimerMs(tEplTimerHdl* pTimerHdl_p,
unsigned long ulTime_p,
tEplTimerArg Argument_p)
tEplKernel PUBLIC EplTimeruSetTimerMs(tEplTimerHdl * pTimerHdl_p,
unsigned long ulTime_p,
tEplTimerArg Argument_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// check handle
if (pTimerHdl_p == NULL) {
Ret = kEplTimerInvalidHandle;
goto Exit;
}
// check handle
if(pTimerHdl_p == NULL)
{
Ret = kEplTimerInvalidHandle;
goto Exit;
}
Exit:
return Ret;
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruModifyTimerMs
@ -252,24 +249,22 @@ Exit:
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruModifyTimerMs(tEplTimerHdl* pTimerHdl_p,
unsigned long ulTime_p,
tEplTimerArg Argument_p)
tEplKernel PUBLIC EplTimeruModifyTimerMs(tEplTimerHdl * pTimerHdl_p,
unsigned long ulTime_p,
tEplTimerArg Argument_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// check parameter
if(pTimerHdl_p == NULL)
{
Ret = kEplTimerInvalidHandle;
goto Exit;
}
// check parameter
if (pTimerHdl_p == NULL) {
Ret = kEplTimerInvalidHandle;
goto Exit;
}
Exit:
return Ret;
Exit:
return Ret;
}
//---------------------------------------------------------------------------
@ -289,25 +284,22 @@ Exit:
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruDeleteTimer(tEplTimerHdl* pTimerHdl_p)
tEplKernel PUBLIC EplTimeruDeleteTimer(tEplTimerHdl * pTimerHdl_p)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// check parameter
if(pTimerHdl_p == NULL)
{
Ret = kEplTimerInvalidHandle;
goto Exit;
}
// check parameter
if (pTimerHdl_p == NULL) {
Ret = kEplTimerInvalidHandle;
goto Exit;
}
// set handle invalide
*pTimerHdl_p = 0;
// set handle invalide
*pTimerHdl_p = 0;
Exit:
return Ret;
Exit:
return Ret;
}
@ -317,7 +309,4 @@ Exit:
// //
//=========================================================================//
// EOF

View File

@ -85,24 +85,22 @@
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
typedef struct
{
tEplTimerArg TimerArgument;
HANDLE DelteHandle;
unsigned long ulTimeout;
typedef struct {
tEplTimerArg TimerArgument;
HANDLE DelteHandle;
unsigned long ulTimeout;
}tEplTimeruThread;
} tEplTimeruThread;
typedef struct
{
LPCRITICAL_SECTION m_pCriticalSection;
CRITICAL_SECTION m_CriticalSection;
}tEplTimeruInstance;
typedef struct {
LPCRITICAL_SECTION m_pCriticalSection;
CRITICAL_SECTION m_CriticalSection;
} tEplTimeruInstance;
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
static tEplTimeruInstance EplTimeruInstance_g;
static tEplTimeruThread ThreadData_l;
static tEplTimeruThread ThreadData_l;
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
@ -146,11 +144,11 @@ DWORD PUBLIC EplSdoTimeruThreadms(LPVOID lpParameter);
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruInit()
{
tEplKernel Ret;
tEplKernel Ret;
Ret = EplTimeruAddInstance();
Ret = EplTimeruAddInstance();
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -172,18 +170,16 @@ return Ret;
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruAddInstance()
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// create critical section
EplTimeruInstance_g.m_pCriticalSection =
&EplTimeruInstance_g.m_CriticalSection;
InitializeCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
// create critical section
EplTimeruInstance_g.m_pCriticalSection = &EplTimeruInstance_g.m_CriticalSection;
InitializeCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -207,11 +203,11 @@ return Ret;
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruDelInstance()
{
tEplKernel Ret;
tEplKernel Ret;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
@ -233,71 +229,60 @@ tEplKernel Ret;
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruSetTimerMs(tEplTimerHdl* pTimerHdl_p,
unsigned long ulTime_p,
tEplTimerArg Argument_p)
tEplKernel PUBLIC EplTimeruSetTimerMs(tEplTimerHdl * pTimerHdl_p,
unsigned long ulTime_p,
tEplTimerArg Argument_p)
{
tEplKernel Ret;
HANDLE DeleteHandle;
HANDLE ThreadHandle;
DWORD ThreadId;
tEplKernel Ret;
HANDLE DeleteHandle;
HANDLE ThreadHandle;
DWORD ThreadId;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// check handle
if (pTimerHdl_p == NULL) {
Ret = kEplTimerInvalidHandle;
goto Exit;
}
// enter critical section
EnterCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
// check handle
if(pTimerHdl_p == NULL)
{
Ret = kEplTimerInvalidHandle;
goto Exit;
}
// first create event to delete timer
DeleteHandle = CreateEvent(NULL, FALSE, FALSE, NULL);
if (DeleteHandle == NULL) {
Ret = kEplTimerNoTimerCreated;
goto Exit;
}
// set handle for caller
*pTimerHdl_p = (tEplTimerHdl) DeleteHandle;
// enter critical section
EnterCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
// fill data for thread
ThreadData_l.DelteHandle = DeleteHandle;
EPL_MEMCPY(&ThreadData_l.TimerArgument, &Argument_p,
sizeof(tEplTimerArg));
ThreadData_l.ulTimeout = ulTime_p;
// first create event to delete timer
DeleteHandle = CreateEvent(NULL,FALSE,FALSE, NULL);
if(DeleteHandle == NULL)
{
Ret = kEplTimerNoTimerCreated;
goto Exit;
}
// create thread to create waitable timer and wait for timer
ThreadHandle = CreateThread(NULL,
0,
EplSdoTimeruThreadms,
&ThreadData_l, 0, &ThreadId);
if (ThreadHandle == NULL) {
// leave critical section
LeaveCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
// set handle for caller
*pTimerHdl_p = (tEplTimerHdl)DeleteHandle;
// delte handle
CloseHandle(DeleteHandle);
Ret = kEplTimerNoTimerCreated;
goto Exit;
}
// fill data for thread
ThreadData_l.DelteHandle = DeleteHandle;
EPL_MEMCPY(&ThreadData_l.TimerArgument, &Argument_p, sizeof(tEplTimerArg));
ThreadData_l.ulTimeout = ulTime_p;
// create thread to create waitable timer and wait for timer
ThreadHandle = CreateThread(NULL,
0,
EplSdoTimeruThreadms,
&ThreadData_l,
0,
&ThreadId);
if(ThreadHandle == NULL)
{
// leave critical section
LeaveCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
// delte handle
CloseHandle(DeleteHandle);
Ret = kEplTimerNoTimerCreated;
goto Exit;
}
Exit:
return Ret;
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruModifyTimerMs
@ -317,69 +302,64 @@ Exit:
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruModifyTimerMs(tEplTimerHdl* pTimerHdl_p,
unsigned long ulTime_p,
tEplTimerArg Argument_p)
tEplKernel PUBLIC EplTimeruModifyTimerMs(tEplTimerHdl * pTimerHdl_p,
unsigned long ulTime_p,
tEplTimerArg Argument_p)
{
tEplKernel Ret;
HANDLE DeleteHandle;
HANDLE ThreadHandle;
DWORD ThreadId;
tEplKernel Ret;
HANDLE DeleteHandle;
HANDLE ThreadHandle;
DWORD ThreadId;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// check parameter
if(pTimerHdl_p == NULL)
{
Ret = kEplTimerInvalidHandle;
goto Exit;
}
// check parameter
if (pTimerHdl_p == NULL) {
Ret = kEplTimerInvalidHandle;
goto Exit;
}
DeleteHandle = (HANDLE)(*pTimerHdl_p);
DeleteHandle = (HANDLE) (*pTimerHdl_p);
// set event to end timer task for this timer
SetEvent(DeleteHandle);
// set event to end timer task for this timer
SetEvent(DeleteHandle);
// create new timer
// first create event to delete timer
DeleteHandle = CreateEvent(NULL,FALSE,FALSE, NULL);
if(DeleteHandle == NULL)
{
Ret = kEplTimerNoTimerCreated;
goto Exit;
}
// create new timer
// first create event to delete timer
DeleteHandle = CreateEvent(NULL, FALSE, FALSE, NULL);
if (DeleteHandle == NULL) {
Ret = kEplTimerNoTimerCreated;
goto Exit;
}
// set handle for caller
*pTimerHdl_p = (tEplTimerHdl) DeleteHandle;
// set handle for caller
*pTimerHdl_p = (tEplTimerHdl)DeleteHandle;
// enter critical section
EnterCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
// enter critical section
EnterCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
// fill data for thread
ThreadData_l.DelteHandle = DeleteHandle;
EPL_MEMCPY(&ThreadData_l.TimerArgument, &Argument_p,
sizeof(tEplTimerArg));
ThreadData_l.ulTimeout = ulTime_p;
// fill data for thread
ThreadData_l.DelteHandle = DeleteHandle;
EPL_MEMCPY(&ThreadData_l.TimerArgument, &Argument_p, sizeof(tEplTimerArg));
ThreadData_l.ulTimeout = ulTime_p;
// create thread to create waitable timer and wait for timer
ThreadHandle = CreateThread(NULL,
0,
EplSdoTimeruThreadms,
&ThreadData_l, 0, &ThreadId);
if (ThreadHandle == NULL) {
// leave critical section
LeaveCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
// create thread to create waitable timer and wait for timer
ThreadHandle = CreateThread(NULL,
0,
EplSdoTimeruThreadms,
&ThreadData_l,
0,
&ThreadId);
if(ThreadHandle == NULL)
{
// leave critical section
LeaveCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
// delte handle
// delte handle
Ret = kEplTimerNoTimerCreated;
goto Exit;
}
Ret = kEplTimerNoTimerCreated;
goto Exit;
}
Exit:
return Ret;
Exit:
return Ret;
}
//---------------------------------------------------------------------------
@ -399,31 +379,29 @@ Exit:
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruDeleteTimer(tEplTimerHdl* pTimerHdl_p)
tEplKernel PUBLIC EplTimeruDeleteTimer(tEplTimerHdl * pTimerHdl_p)
{
tEplKernel Ret;
HANDLE DeleteHandle;
tEplKernel Ret;
HANDLE DeleteHandle;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// check parameter
if(pTimerHdl_p == NULL)
{
Ret = kEplTimerInvalidHandle;
goto Exit;
}
// check parameter
if (pTimerHdl_p == NULL) {
Ret = kEplTimerInvalidHandle;
goto Exit;
}
DeleteHandle = (HANDLE)(*pTimerHdl_p);
DeleteHandle = (HANDLE) (*pTimerHdl_p);
// set event to end timer task for this timer
SetEvent(DeleteHandle);
// set event to end timer task for this timer
SetEvent(DeleteHandle);
// set handle invalide
*pTimerHdl_p = 0;
// set handle invalide
*pTimerHdl_p = 0;
Exit:
return Ret;
Exit:
return Ret;
}
@ -452,100 +430,84 @@ Exit:
//---------------------------------------------------------------------------
DWORD PUBLIC EplSdoTimeruThreadms(LPVOID lpParameter)
{
tEplKernel Ret;
tEplTimeruThread* pThreadData;
HANDLE aHandles[2];
BOOL fReturn;
LARGE_INTEGER TimeoutTime;
unsigned long ulEvent;
tEplEvent EplEvent;
tEplTimeruThread ThreadData;
tEplTimerEventArg TimerEventArg;
tEplKernel Ret;
tEplTimeruThread *pThreadData;
HANDLE aHandles[2];
BOOL fReturn;
LARGE_INTEGER TimeoutTime;
unsigned long ulEvent;
tEplEvent EplEvent;
tEplTimeruThread ThreadData;
tEplTimerEventArg TimerEventArg;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// get pointer to data
pThreadData = (tEplTimeruThread*)lpParameter;
// copy thread data
EPL_MEMCPY(&ThreadData, pThreadData, sizeof(ThreadData));
pThreadData = &ThreadData;
// get pointer to data
pThreadData = (tEplTimeruThread *) lpParameter;
// copy thread data
EPL_MEMCPY(&ThreadData, pThreadData, sizeof(ThreadData));
pThreadData = &ThreadData;
// leave critical section
LeaveCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
// leave critical section
LeaveCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
// create waitable timer
aHandles[1] = CreateWaitableTimer(NULL,FALSE,NULL);
if(aHandles[1] == NULL)
{
Ret = kEplTimerNoTimerCreated;
goto Exit;
}
// create waitable timer
aHandles[1] = CreateWaitableTimer(NULL, FALSE, NULL);
if (aHandles[1] == NULL) {
Ret = kEplTimerNoTimerCreated;
goto Exit;
}
// set timer
// set timeout interval -> needed to be negativ
// -> because relative timeout
// -> multiply by 10000 for 100 ns timebase of function
TimeoutTime.QuadPart = (((long long)pThreadData->ulTimeout) * -10000);
fReturn = SetWaitableTimer(aHandles[1],
&TimeoutTime, 0, NULL, NULL, FALSE);
if (fReturn == 0) {
Ret = kEplTimerNoTimerCreated;
goto Exit;
}
// save delte event handle in handle array
aHandles[0] = pThreadData->DelteHandle;
// set timer
// set timeout interval -> needed to be negativ
// -> because relative timeout
// -> multiply by 10000 for 100 ns timebase of function
TimeoutTime.QuadPart = (((long long)pThreadData->ulTimeout) * -10000);
fReturn = SetWaitableTimer(aHandles[1],
&TimeoutTime,
0,
NULL,
NULL,
FALSE);
if(fReturn == 0)
{
Ret = kEplTimerNoTimerCreated;
goto Exit;
}
// wait for one of the events
ulEvent = WaitForMultipleObjects(2, &aHandles[0], FALSE, INFINITE);
if (ulEvent == WAIT_OBJECT_0) { // delte event
// save delte event handle in handle array
aHandles[0] = pThreadData->DelteHandle;
// close handels
CloseHandle(aHandles[1]);
// terminate thread
goto Exit;
} else if (ulEvent == (WAIT_OBJECT_0 + 1)) { // timer event
// call event function
TimerEventArg.m_TimerHdl =
(tEplTimerHdl) pThreadData->DelteHandle;
TimerEventArg.m_ulArg = pThreadData->TimerArgument.m_ulArg;
// wait for one of the events
ulEvent = WaitForMultipleObjects( 2,
&aHandles[0],
FALSE,
INFINITE);
if(ulEvent == WAIT_OBJECT_0)
{ // delte event
EplEvent.m_EventSink = pThreadData->TimerArgument.m_EventSink;
EplEvent.m_EventType = kEplEventTypeTimer;
EPL_MEMSET(&EplEvent.m_NetTime, 0x00, sizeof(tEplNetTime));
EplEvent.m_pArg = &TimerEventArg;
EplEvent.m_uiSize = sizeof(TimerEventArg);
// close handels
CloseHandle(aHandles[1]);
// terminate thread
goto Exit;
}
else if(ulEvent == (WAIT_OBJECT_0 + 1))
{ // timer event
// call event function
TimerEventArg.m_TimerHdl = (tEplTimerHdl)pThreadData->DelteHandle;
TimerEventArg.m_ulArg = pThreadData->TimerArgument.m_ulArg;
Ret = EplEventuPost(&EplEvent);
EplEvent.m_EventSink = pThreadData->TimerArgument.m_EventSink;
EplEvent.m_EventType = kEplEventTypeTimer;
EPL_MEMSET(&EplEvent.m_NetTime, 0x00, sizeof(tEplNetTime));
EplEvent.m_pArg = &TimerEventArg;
EplEvent.m_uiSize = sizeof(TimerEventArg);
// close handels
CloseHandle(aHandles[1]);
// terminate thread
goto Exit;
Ret = EplEventuPost(&EplEvent);
} else { // error
ulEvent = GetLastError();
TRACE1("Error in WaitForMultipleObjects Errorcode: 0x%x\n",
ulEvent);
// terminate thread
goto Exit;
}
// close handels
CloseHandle(aHandles[1]);
// terminate thread
goto Exit;
}
else
{ // error
ulEvent = GetLastError();
TRACE1("Error in WaitForMultipleObjects Errorcode: 0x%x\n",ulEvent);
// terminate thread
goto Exit;
}
Exit:
return Ret;
Exit:
return Ret;
}
// EOF

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -68,12 +68,10 @@
****************************************************************************/
#include <linux/net.h>
#include <linux/in.h>
#include "SocketLinuxKernel.h"
/***************************************************************************/
/* */
/* */
@ -82,34 +80,26 @@
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Kernel Module specific Data Structures
//---------------------------------------------------------------------------
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
@ -136,75 +126,72 @@
SOCKET socket(int af, int type, int protocol)
{
int rc;
SOCKET socket;
int rc;
SOCKET socket;
rc = sock_create_kern(af, type, protocol, &socket);
if (rc < 0)
{
socket = NULL;
goto Exit;
}
rc = sock_create_kern(af, type, protocol, &socket);
if (rc < 0) {
socket = NULL;
goto Exit;
}
Exit:
return socket;
Exit:
return socket;
}
int bind(SOCKET socket_p, const struct sockaddr *addr, int addrlen)
{
int rc;
int rc;
rc = socket_p->ops->bind(socket_p,
(struct sockaddr *)addr,
addrlen);
rc = socket_p->ops->bind(socket_p, (struct sockaddr *)addr, addrlen);
return rc;
return rc;
}
int closesocket(SOCKET socket_p)
{
sock_release(socket_p);
sock_release(socket_p);
return 0;
return 0;
}
int recvfrom(SOCKET socket_p, char* buf, int len, int flags, struct sockaddr *from, int * fromlen)
int recvfrom(SOCKET socket_p, char *buf, int len, int flags,
struct sockaddr *from, int *fromlen)
{
int rc;
struct msghdr msg;
struct kvec iov;
int rc;
struct msghdr msg;
struct kvec iov;
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_name = from; // will be struct sock_addr
msg.msg_namelen = *fromlen;
iov.iov_len = len;
iov.iov_base = buf;
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_name = from; // will be struct sock_addr
msg.msg_namelen = *fromlen;
iov.iov_len = len;
iov.iov_base = buf;
rc = kernel_recvmsg(socket_p, &msg, &iov, 1, iov.iov_len, 0);
rc = kernel_recvmsg(socket_p, &msg, &iov, 1, iov.iov_len, 0);
return rc;
return rc;
}
int sendto(SOCKET socket_p, const char* buf, int len, int flags, const struct sockaddr *to, int tolen)
int sendto(SOCKET socket_p, const char *buf, int len, int flags,
const struct sockaddr *to, int tolen)
{
int rc;
struct msghdr msg;
struct kvec iov;
int rc;
struct msghdr msg;
struct kvec iov;
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_name = (struct sockaddr *)to; // will be struct sock_addr
msg.msg_namelen = tolen;
msg.msg_flags = 0;
iov.iov_len = len;
iov.iov_base = (char *)buf;
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_name = (struct sockaddr *)to; // will be struct sock_addr
msg.msg_namelen = tolen;
msg.msg_flags = 0;
iov.iov_len = len;
iov.iov_base = (char *)buf;
rc = kernel_sendmsg(socket_p, &msg, &iov, 1, len);
rc = kernel_sendmsg(socket_p, &msg, &iov, 1, len);
return rc;
return rc;
}
// EOF

View File

@ -91,27 +91,25 @@
// const defines
//---------------------------------------------------------------------------
#define TIMER_COUNT 2 /* max 15 timers selectable */
#define TIMER_MIN_VAL_SINGLE 5000 /* min 5us */
#define TIMER_MIN_VAL_CYCLE 100000 /* min 100us */
#define TIMER_COUNT 2 /* max 15 timers selectable */
#define TIMER_MIN_VAL_SINGLE 5000 /* min 5us */
#define TIMER_MIN_VAL_CYCLE 100000 /* min 100us */
#define PROVE_OVERRUN
#ifndef CONFIG_HIGH_RES_TIMERS
#error "Kernel symbol CONFIG_HIGH_RES_TIMERS is required."
#error "Kernel symbol CONFIG_HIGH_RES_TIMERS is required."
#endif
// TracePoint support for realtime-debugging
#ifdef _DBG_TRACE_POINTS_
void PUBLIC TgtDbgSignalTracePoint (BYTE bTracePointNumber_p);
void PUBLIC TgtDbgPostTraceValue (DWORD dwTraceValue_p);
#define TGT_DBG_SIGNAL_TRACE_POINT(p) TgtDbgSignalTracePoint(p)
#define TGT_DBG_POST_TRACE_VALUE(v) TgtDbgPostTraceValue(v)
void PUBLIC TgtDbgSignalTracePoint(BYTE bTracePointNumber_p);
void PUBLIC TgtDbgPostTraceValue(DWORD dwTraceValue_p);
#define TGT_DBG_SIGNAL_TRACE_POINT(p) TgtDbgSignalTracePoint(p)
#define TGT_DBG_POST_TRACE_VALUE(v) TgtDbgPostTraceValue(v)
#else
#define TGT_DBG_SIGNAL_TRACE_POINT(p)
#define TGT_DBG_POST_TRACE_VALUE(v)
#define TGT_DBG_SIGNAL_TRACE_POINT(p)
#define TGT_DBG_POST_TRACE_VALUE(v)
#endif
#define HRT_DBG_POST_TRACE_VALUE(Event_p, uiNodeId_p, wErrorCode_p) \
TGT_DBG_POST_TRACE_VALUE((0xE << 28) | (Event_p << 24) \
@ -128,19 +126,17 @@
// modul global types
//---------------------------------------------------------------------------
typedef struct
{
tEplTimerEventArg m_EventArg;
tEplTimerkCallback m_pfnCallback;
struct hrtimer m_Timer;
BOOL m_fContinuously;
unsigned long long m_ullPeriod;
typedef struct {
tEplTimerEventArg m_EventArg;
tEplTimerkCallback m_pfnCallback;
struct hrtimer m_Timer;
BOOL m_fContinuously;
unsigned long long m_ullPeriod;
} tEplTimerHighReskTimerInfo;
typedef struct
{
tEplTimerHighReskTimerInfo m_aTimerInfo[TIMER_COUNT];
typedef struct {
tEplTimerHighReskTimerInfo m_aTimerInfo[TIMER_COUNT];
} tEplTimerHighReskInstance;
@ -148,13 +144,13 @@ typedef struct
// local vars
//---------------------------------------------------------------------------
static tEplTimerHighReskInstance EplTimerHighReskInstance_l;
static tEplTimerHighReskInstance EplTimerHighReskInstance_l;
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
enum hrtimer_restart EplTimerHighReskCallback (struct hrtimer* pTimer_p);
enum hrtimer_restart EplTimerHighReskCallback(struct hrtimer *pTimer_p);
//=========================================================================//
// //
@ -162,7 +158,6 @@ enum hrtimer_restart EplTimerHighReskCallback (struct hrtimer* pTimer_p);
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplTimerHighReskInit()
@ -179,15 +174,14 @@ enum hrtimer_restart EplTimerHighReskCallback (struct hrtimer* pTimer_p);
tEplKernel PUBLIC EplTimerHighReskInit(void)
{
tEplKernel Ret;
tEplKernel Ret;
Ret = EplTimerHighReskAddInstance();
Ret = EplTimerHighReskAddInstance();
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimerHighReskAddInstance()
@ -204,45 +198,45 @@ tEplKernel Ret;
tEplKernel PUBLIC EplTimerHighReskAddInstance(void)
{
tEplKernel Ret;
unsigned int uiIndex;
tEplKernel Ret;
unsigned int uiIndex;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
EPL_MEMSET(&EplTimerHighReskInstance_l, 0, sizeof (EplTimerHighReskInstance_l));
EPL_MEMSET(&EplTimerHighReskInstance_l, 0,
sizeof(EplTimerHighReskInstance_l));
#ifndef CONFIG_HIGH_RES_TIMERS
printk("EplTimerHighResk: Kernel symbol CONFIG_HIGH_RES_TIMERS is required.\n");
Ret = kEplNoResource;
return Ret;
printk
("EplTimerHighResk: Kernel symbol CONFIG_HIGH_RES_TIMERS is required.\n");
Ret = kEplNoResource;
return Ret;
#endif
/*
* Initialize hrtimer structures for all usable timers.
*/
for (uiIndex = 0; uiIndex < TIMER_COUNT; uiIndex++)
{
tEplTimerHighReskTimerInfo* pTimerInfo;
struct hrtimer* pTimer;
/*
* Initialize hrtimer structures for all usable timers.
*/
for (uiIndex = 0; uiIndex < TIMER_COUNT; uiIndex++) {
tEplTimerHighReskTimerInfo *pTimerInfo;
struct hrtimer *pTimer;
pTimerInfo = &EplTimerHighReskInstance_l.m_aTimerInfo[uiIndex];
pTimer = &pTimerInfo->m_Timer;
hrtimer_init(pTimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
pTimerInfo = &EplTimerHighReskInstance_l.m_aTimerInfo[uiIndex];
pTimer = &pTimerInfo->m_Timer;
hrtimer_init(pTimer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
pTimer->function = EplTimerHighReskCallback;
pTimer->function = EplTimerHighReskCallback;
/*
* We use HRTIMER_CB_SOFTIRQ here.
* HRTIMER_CB_IRQSAFE is critical as the callback function
* would be called with IRQs disabled.
*/
pTimer->cb_mode = HRTIMER_CB_SOFTIRQ;
}
/*
* We use HRTIMER_CB_SOFTIRQ here.
* HRTIMER_CB_IRQSAFE is critical as the callback function
* would be called with IRQs disabled.
*/
pTimer->cb_mode = HRTIMER_CB_SOFTIRQ;
}
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimerHighReskDelInstance()
@ -259,30 +253,28 @@ unsigned int uiIndex;
tEplKernel PUBLIC EplTimerHighReskDelInstance(void)
{
tEplTimerHighReskTimerInfo* pTimerInfo;
tEplKernel Ret;
unsigned int uiIndex;
tEplTimerHighReskTimerInfo *pTimerInfo;
tEplKernel Ret;
unsigned int uiIndex;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
for (uiIndex = 0; uiIndex < TIMER_COUNT; uiIndex++)
{
pTimerInfo = &EplTimerHighReskInstance_l.m_aTimerInfo[0];
pTimerInfo->m_pfnCallback = NULL;
pTimerInfo->m_EventArg.m_TimerHdl = 0;
/*
* In this case we can not just try to cancel the timer.
* We actually have to wait until its callback function
* has returned.
*/
hrtimer_cancel(&pTimerInfo->m_Timer);
}
for (uiIndex = 0; uiIndex < TIMER_COUNT; uiIndex++) {
pTimerInfo = &EplTimerHighReskInstance_l.m_aTimerInfo[0];
pTimerInfo->m_pfnCallback = NULL;
pTimerInfo->m_EventArg.m_TimerHdl = 0;
/*
* In this case we can not just try to cancel the timer.
* We actually have to wait until its callback function
* has returned.
*/
hrtimer_cancel(&pTimerInfo->m_Timer);
}
return Ret;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimerHighReskModifyTimerNs()
@ -313,96 +305,89 @@ unsigned int uiIndex;
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimerHighReskModifyTimerNs(tEplTimerHdl* pTimerHdl_p,
unsigned long long ullTimeNs_p,
tEplTimerkCallback pfnCallback_p,
unsigned long ulArgument_p,
BOOL fContinuously_p)
tEplKernel PUBLIC EplTimerHighReskModifyTimerNs(tEplTimerHdl * pTimerHdl_p,
unsigned long long ullTimeNs_p,
tEplTimerkCallback
pfnCallback_p,
unsigned long ulArgument_p,
BOOL fContinuously_p)
{
tEplKernel Ret;
unsigned int uiIndex;
tEplTimerHighReskTimerInfo* pTimerInfo;
ktime_t RelTime;
tEplKernel Ret;
unsigned int uiIndex;
tEplTimerHighReskTimerInfo *pTimerInfo;
ktime_t RelTime;
Ret = kEplSuccessful;
Ret = kEplSuccessful;
// check pointer to handle
if(pTimerHdl_p == NULL)
{
Ret = kEplTimerInvalidHandle;
goto Exit;
}
// check pointer to handle
if (pTimerHdl_p == NULL) {
Ret = kEplTimerInvalidHandle;
goto Exit;
}
if (*pTimerHdl_p == 0)
{ // no timer created yet
if (*pTimerHdl_p == 0) { // no timer created yet
// search free timer info structure
pTimerInfo = &EplTimerHighReskInstance_l.m_aTimerInfo[0];
for (uiIndex = 0; uiIndex < TIMER_COUNT; uiIndex++, pTimerInfo++)
{
if (pTimerInfo->m_EventArg.m_TimerHdl == 0)
{ // free structure found
break;
}
}
if (uiIndex >= TIMER_COUNT)
{ // no free structure found
Ret = kEplTimerNoTimerCreated;
goto Exit;
}
// search free timer info structure
pTimerInfo = &EplTimerHighReskInstance_l.m_aTimerInfo[0];
for (uiIndex = 0; uiIndex < TIMER_COUNT;
uiIndex++, pTimerInfo++) {
if (pTimerInfo->m_EventArg.m_TimerHdl == 0) { // free structure found
break;
}
}
if (uiIndex >= TIMER_COUNT) { // no free structure found
Ret = kEplTimerNoTimerCreated;
goto Exit;
}
pTimerInfo->m_EventArg.m_TimerHdl = HDL_INIT(uiIndex);
}
else
{
uiIndex = HDL_TO_IDX(*pTimerHdl_p);
if (uiIndex >= TIMER_COUNT)
{ // invalid handle
Ret = kEplTimerInvalidHandle;
goto Exit;
}
pTimerInfo->m_EventArg.m_TimerHdl = HDL_INIT(uiIndex);
} else {
uiIndex = HDL_TO_IDX(*pTimerHdl_p);
if (uiIndex >= TIMER_COUNT) { // invalid handle
Ret = kEplTimerInvalidHandle;
goto Exit;
}
pTimerInfo = &EplTimerHighReskInstance_l.m_aTimerInfo[uiIndex];
}
pTimerInfo = &EplTimerHighReskInstance_l.m_aTimerInfo[uiIndex];
}
/*
* increment timer handle
* (if timer expires right after this statement, the user
* would detect an unknown timer handle and discard it)
*/
pTimerInfo->m_EventArg.m_TimerHdl = HDL_INC(pTimerInfo->m_EventArg.m_TimerHdl);
*pTimerHdl_p = pTimerInfo->m_EventArg.m_TimerHdl;
/*
* increment timer handle
* (if timer expires right after this statement, the user
* would detect an unknown timer handle and discard it)
*/
pTimerInfo->m_EventArg.m_TimerHdl =
HDL_INC(pTimerInfo->m_EventArg.m_TimerHdl);
*pTimerHdl_p = pTimerInfo->m_EventArg.m_TimerHdl;
// reject too small time values
if ( (fContinuously_p && (ullTimeNs_p < TIMER_MIN_VAL_CYCLE))
|| (!fContinuously_p && (ullTimeNs_p < TIMER_MIN_VAL_SINGLE)) )
{
Ret = kEplTimerNoTimerCreated;
goto Exit;
}
// reject too small time values
if ((fContinuously_p && (ullTimeNs_p < TIMER_MIN_VAL_CYCLE))
|| (!fContinuously_p && (ullTimeNs_p < TIMER_MIN_VAL_SINGLE))) {
Ret = kEplTimerNoTimerCreated;
goto Exit;
}
pTimerInfo->m_EventArg.m_ulArg = ulArgument_p;
pTimerInfo->m_pfnCallback = pfnCallback_p;
pTimerInfo->m_fContinuously = fContinuously_p;
pTimerInfo->m_ullPeriod = ullTimeNs_p;
pTimerInfo->m_EventArg.m_ulArg = ulArgument_p;
pTimerInfo->m_pfnCallback = pfnCallback_p;
pTimerInfo->m_fContinuously = fContinuously_p;
pTimerInfo->m_ullPeriod = ullTimeNs_p;
/*
* HRTIMER_MODE_REL does not influence general handling of this timer.
* It only sets relative mode for this start operation.
* -> Expire time is calculated by: Now + RelTime
* hrtimer_start also skips pending timer events.
* The state HRTIMER_STATE_CALLBACK is ignored.
* We have to cope with that in our callback function.
*/
RelTime = ktime_add_ns(ktime_set(0,0), ullTimeNs_p);
hrtimer_start(&pTimerInfo->m_Timer, RelTime, HRTIMER_MODE_REL);
/*
* HRTIMER_MODE_REL does not influence general handling of this timer.
* It only sets relative mode for this start operation.
* -> Expire time is calculated by: Now + RelTime
* hrtimer_start also skips pending timer events.
* The state HRTIMER_STATE_CALLBACK is ignored.
* We have to cope with that in our callback function.
*/
RelTime = ktime_add_ns(ktime_set(0, 0), ullTimeNs_p);
hrtimer_start(&pTimerInfo->m_Timer, RelTime, HRTIMER_MODE_REL);
Exit:
return Ret;
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimerHighReskDeleteTimer()
@ -418,64 +403,56 @@ Exit:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimerHighReskDeleteTimer(tEplTimerHdl* pTimerHdl_p)
tEplKernel PUBLIC EplTimerHighReskDeleteTimer(tEplTimerHdl * pTimerHdl_p)
{
tEplKernel Ret = kEplSuccessful;
unsigned int uiIndex;
tEplTimerHighReskTimerInfo* pTimerInfo;
tEplKernel Ret = kEplSuccessful;
unsigned int uiIndex;
tEplTimerHighReskTimerInfo *pTimerInfo;
// check pointer to handle
if(pTimerHdl_p == NULL)
{
Ret = kEplTimerInvalidHandle;
goto Exit;
}
// check pointer to handle
if (pTimerHdl_p == NULL) {
Ret = kEplTimerInvalidHandle;
goto Exit;
}
if (*pTimerHdl_p == 0)
{ // no timer created yet
goto Exit;
}
else
{
uiIndex = HDL_TO_IDX(*pTimerHdl_p);
if (uiIndex >= TIMER_COUNT)
{ // invalid handle
Ret = kEplTimerInvalidHandle;
goto Exit;
}
pTimerInfo = &EplTimerHighReskInstance_l.m_aTimerInfo[uiIndex];
if (pTimerInfo->m_EventArg.m_TimerHdl != *pTimerHdl_p)
{ // invalid handle
goto Exit;
}
}
if (*pTimerHdl_p == 0) { // no timer created yet
goto Exit;
} else {
uiIndex = HDL_TO_IDX(*pTimerHdl_p);
if (uiIndex >= TIMER_COUNT) { // invalid handle
Ret = kEplTimerInvalidHandle;
goto Exit;
}
pTimerInfo = &EplTimerHighReskInstance_l.m_aTimerInfo[uiIndex];
if (pTimerInfo->m_EventArg.m_TimerHdl != *pTimerHdl_p) { // invalid handle
goto Exit;
}
}
*pTimerHdl_p = 0;
pTimerInfo->m_EventArg.m_TimerHdl = 0;
pTimerInfo->m_pfnCallback = NULL;
*pTimerHdl_p = 0;
pTimerInfo->m_EventArg.m_TimerHdl = 0;
pTimerInfo->m_pfnCallback = NULL;
/*
* Three return cases of hrtimer_try_to_cancel have to be tracked:
* 1 - timer has been removed
* 0 - timer was not active
* We need not do anything. hrtimer timers just consist of
* a hrtimer struct, which we might enqueue in the hrtimers
* event list by calling hrtimer_start().
* If a timer is not enqueued, it is not present in hrtimers.
* -1 - callback function is running
* In this case we have to ensure that the timer is not
* continuously restarted. This has been done by clearing
* its handle.
*/
hrtimer_try_to_cancel(&pTimerInfo->m_Timer);
/*
* Three return cases of hrtimer_try_to_cancel have to be tracked:
* 1 - timer has been removed
* 0 - timer was not active
* We need not do anything. hrtimer timers just consist of
* a hrtimer struct, which we might enqueue in the hrtimers
* event list by calling hrtimer_start().
* If a timer is not enqueued, it is not present in hrtimers.
* -1 - callback function is running
* In this case we have to ensure that the timer is not
* continuously restarted. This has been done by clearing
* its handle.
*/
hrtimer_try_to_cancel(&pTimerInfo->m_Timer);
Exit:
return Ret;
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimerHighReskCallback()
@ -490,66 +467,63 @@ Exit:
//
//---------------------------------------------------------------------------
enum hrtimer_restart EplTimerHighReskCallback (struct hrtimer* pTimer_p)
enum hrtimer_restart EplTimerHighReskCallback(struct hrtimer *pTimer_p)
{
unsigned int uiIndex;
tEplTimerHighReskTimerInfo* pTimerInfo;
tEplTimerHdl OrgTimerHdl;
enum hrtimer_restart Ret;
unsigned int uiIndex;
tEplTimerHighReskTimerInfo *pTimerInfo;
tEplTimerHdl OrgTimerHdl;
enum hrtimer_restart Ret;
BENCHMARK_MOD_24_SET(4);
BENCHMARK_MOD_24_SET(4);
Ret = HRTIMER_NORESTART;
pTimerInfo = container_of(pTimer_p, tEplTimerHighReskTimerInfo, m_Timer);
uiIndex = HDL_TO_IDX(pTimerInfo->m_EventArg.m_TimerHdl);
if (uiIndex >= TIMER_COUNT)
{ // invalid handle
goto Exit;
}
Ret = HRTIMER_NORESTART;
pTimerInfo =
container_of(pTimer_p, tEplTimerHighReskTimerInfo, m_Timer);
uiIndex = HDL_TO_IDX(pTimerInfo->m_EventArg.m_TimerHdl);
if (uiIndex >= TIMER_COUNT) { // invalid handle
goto Exit;
}
/*
* We store the timer handle before calling the callback function
* as the timer can be modified inside it.
*/
OrgTimerHdl = pTimerInfo->m_EventArg.m_TimerHdl;
/*
* We store the timer handle before calling the callback function
* as the timer can be modified inside it.
*/
OrgTimerHdl = pTimerInfo->m_EventArg.m_TimerHdl;
if (pTimerInfo->m_pfnCallback != NULL)
{
pTimerInfo->m_pfnCallback(&pTimerInfo->m_EventArg);
}
if (pTimerInfo->m_pfnCallback != NULL) {
pTimerInfo->m_pfnCallback(&pTimerInfo->m_EventArg);
}
if (pTimerInfo->m_fContinuously)
{
ktime_t Interval;
if (pTimerInfo->m_fContinuously) {
ktime_t Interval;
#ifdef PROVE_OVERRUN
ktime_t Now;
unsigned long Overruns;
ktime_t Now;
unsigned long Overruns;
#endif
if (OrgTimerHdl != pTimerInfo->m_EventArg.m_TimerHdl)
{
/* modified timer has already been restarted */
goto Exit;
}
if (OrgTimerHdl != pTimerInfo->m_EventArg.m_TimerHdl) {
/* modified timer has already been restarted */
goto Exit;
}
#ifdef PROVE_OVERRUN
Now = ktime_get();
Interval = ktime_add_ns(ktime_set(0,0), pTimerInfo->m_ullPeriod);
Overruns = hrtimer_forward(pTimer_p, Now, Interval);
if (Overruns > 1)
{
printk("EplTimerHighResk: Continuous timer (handle 0x%lX) had to skip %lu interval(s)!\n", pTimerInfo->m_EventArg.m_TimerHdl, Overruns-1);
}
Now = ktime_get();
Interval =
ktime_add_ns(ktime_set(0, 0), pTimerInfo->m_ullPeriod);
Overruns = hrtimer_forward(pTimer_p, Now, Interval);
if (Overruns > 1) {
printk
("EplTimerHighResk: Continuous timer (handle 0x%lX) had to skip %lu interval(s)!\n",
pTimerInfo->m_EventArg.m_TimerHdl, Overruns - 1);
}
#else
pTimer_p->expires = ktime_add_ns(pTimer_p->expires,
pTimerInfo->m_ullPeriod);
pTimer_p->expires = ktime_add_ns(pTimer_p->expires,
pTimerInfo->m_ullPeriod);
#endif
Ret = HRTIMER_RESTART;
}
Ret = HRTIMER_RESTART;
}
Exit:
BENCHMARK_MOD_24_RESET(4);
return Ret;
Exit:
BENCHMARK_MOD_24_RESET(4);
return Ret;
}

View File

@ -59,7 +59,6 @@
Build Environment:
-------------------------------------------------------------------------
Revision History:
@ -75,7 +74,6 @@
****************************************************************************/
#include <linux/version.h>
#include <linux/module.h>
#include <linux/netdevice.h>
@ -93,13 +91,12 @@
#include <linux/udp.h>
#include <linux/mm.h>
#include <linux/types.h>
#include <linux/skbuff.h> /* for struct sk_buff */
#include <linux/skbuff.h> /* for struct sk_buff */
#include "kernel/VirtualEthernet.h"
#include "kernel/EplDllkCal.h"
#include "kernel/EplDllk.h"
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_VETH)) != 0)
/***************************************************************************/
@ -110,28 +107,24 @@
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
#ifndef EPL_VETH_TX_TIMEOUT
//#define EPL_VETH_TX_TIMEOUT (2*HZ)
#define EPL_VETH_TX_TIMEOUT 0 // d.k.: we use no timeout
#define EPL_VETH_TX_TIMEOUT 0 // d.k.: we use no timeout
#endif
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
static struct net_device * pVEthNetDevice_g = NULL;
static struct net_device *pVEthNetDevice_g = NULL;
//---------------------------------------------------------------------------
// local function prototypes
@ -140,11 +133,10 @@ static struct net_device * pVEthNetDevice_g = NULL;
static int VEthOpen(struct net_device *pNetDevice_p);
static int VEthClose(struct net_device *pNetDevice_p);
static int VEthXmit(struct sk_buff *pSkb_p, struct net_device *pNetDevice_p);
static struct net_device_stats* VEthGetStats(struct net_device *pNetDevice_p);
static struct net_device_stats *VEthGetStats(struct net_device *pNetDevice_p);
static void VEthTimeout(struct net_device *pNetDevice_p);
static tEplKernel VEthRecvFrame(tEplFrameInfo * pFrameInfo_p);
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
@ -171,188 +163,182 @@ static tEplKernel VEthRecvFrame(tEplFrameInfo * pFrameInfo_p);
static int VEthOpen(struct net_device *pNetDevice_p)
{
tEplKernel Ret = kEplSuccessful;
tEplKernel Ret = kEplSuccessful;
//open the device
//open the device
// struct net_device_stats* pStats = (struct net_device_stats*)pNetDevice_p->priv;
//start the interface queue for the network subsystem
netif_start_queue(pNetDevice_p);
//start the interface queue for the network subsystem
netif_start_queue(pNetDevice_p);
// register callback function in DLL
Ret = EplDllkRegAsyncHandler(VEthRecvFrame);
// register callback function in DLL
Ret = EplDllkRegAsyncHandler(VEthRecvFrame);
EPL_DBGLVL_VETH_TRACE1("VEthOpen: EplDllkRegAsyncHandler returned 0x%02X\n", Ret);
EPL_DBGLVL_VETH_TRACE1
("VEthOpen: EplDllkRegAsyncHandler returned 0x%02X\n", Ret);
return 0;
return 0;
}
static int VEthClose(struct net_device *pNetDevice_p)
{
tEplKernel Ret = kEplSuccessful;
tEplKernel Ret = kEplSuccessful;
EPL_DBGLVL_VETH_TRACE0("VEthClose\n");
EPL_DBGLVL_VETH_TRACE0("VEthClose\n");
Ret = EplDllkDeregAsyncHandler(VEthRecvFrame);
Ret = EplDllkDeregAsyncHandler(VEthRecvFrame);
//stop the interface queue for the network subsystem
netif_stop_queue(pNetDevice_p);
return 0;
//stop the interface queue for the network subsystem
netif_stop_queue(pNetDevice_p);
return 0;
}
static int VEthXmit(struct sk_buff *pSkb_p, struct net_device *pNetDevice_p)
{
tEplKernel Ret = kEplSuccessful;
tEplFrameInfo FrameInfo;
tEplKernel Ret = kEplSuccessful;
tEplFrameInfo FrameInfo;
//transmit function
struct net_device_stats* pStats = (struct net_device_stats*)pNetDevice_p->priv;
//transmit function
struct net_device_stats *pStats =
(struct net_device_stats *)pNetDevice_p->priv;
//save timestemp
pNetDevice_p->trans_start = jiffies;
//save timestemp
pNetDevice_p->trans_start = jiffies;
FrameInfo.m_pFrame = (tEplFrame *)pSkb_p->data;
FrameInfo.m_uiFrameSize = pSkb_p->len;
FrameInfo.m_pFrame = (tEplFrame *) pSkb_p->data;
FrameInfo.m_uiFrameSize = pSkb_p->len;
//call send fkt on DLL
Ret = EplDllkCalAsyncSend(&FrameInfo, kEplDllAsyncReqPrioGeneric);
if (Ret != kEplSuccessful)
{
EPL_DBGLVL_VETH_TRACE1("VEthXmit: EplDllkCalAsyncSend returned 0x%02X\n", Ret);
netif_stop_queue(pNetDevice_p);
goto Exit;
}
else
{
EPL_DBGLVL_VETH_TRACE0("VEthXmit: frame passed to DLL\n");
dev_kfree_skb(pSkb_p);
//call send fkt on DLL
Ret = EplDllkCalAsyncSend(&FrameInfo, kEplDllAsyncReqPrioGeneric);
if (Ret != kEplSuccessful) {
EPL_DBGLVL_VETH_TRACE1
("VEthXmit: EplDllkCalAsyncSend returned 0x%02X\n", Ret);
netif_stop_queue(pNetDevice_p);
goto Exit;
} else {
EPL_DBGLVL_VETH_TRACE0("VEthXmit: frame passed to DLL\n");
dev_kfree_skb(pSkb_p);
//set stats for the device
pStats->tx_packets++;
pStats->tx_bytes += FrameInfo.m_uiFrameSize;
}
//set stats for the device
pStats->tx_packets++;
pStats->tx_bytes += FrameInfo.m_uiFrameSize;
}
Exit:
return 0;
Exit:
return 0;
}
static struct net_device_stats* VEthGetStats(struct net_device *pNetDevice_p)
static struct net_device_stats *VEthGetStats(struct net_device *pNetDevice_p)
{
EPL_DBGLVL_VETH_TRACE0("VEthGetStats\n");
EPL_DBGLVL_VETH_TRACE0("VEthGetStats\n");
return (struct net_device_stats *)pNetDevice_p->priv;
return (struct net_device_stats *)pNetDevice_p->priv;
}
static void VEthTimeout(struct net_device *pNetDevice_p)
{
EPL_DBGLVL_VETH_TRACE0("VEthTimeout(\n");
EPL_DBGLVL_VETH_TRACE0("VEthTimeout(\n");
// $$$ d.k.: move to extra function, which is called by DLL when new space is available in TxFifo
if (netif_queue_stopped (pNetDevice_p))
{
netif_wake_queue (pNetDevice_p);
}
// $$$ d.k.: move to extra function, which is called by DLL when new space is available in TxFifo
if (netif_queue_stopped(pNetDevice_p)) {
netif_wake_queue(pNetDevice_p);
}
}
static tEplKernel VEthRecvFrame(tEplFrameInfo * pFrameInfo_p)
{
tEplKernel Ret = kEplSuccessful;
struct net_device* pNetDevice = pVEthNetDevice_g;
struct net_device_stats* pStats = (struct net_device_stats*)pNetDevice->priv;
struct sk_buff *pSkb;
tEplKernel Ret = kEplSuccessful;
struct net_device *pNetDevice = pVEthNetDevice_g;
struct net_device_stats *pStats =
(struct net_device_stats *)pNetDevice->priv;
struct sk_buff *pSkb;
EPL_DBGLVL_VETH_TRACE1("VEthRecvFrame: FrameSize=%u\n", pFrameInfo_p->m_uiFrameSize);
EPL_DBGLVL_VETH_TRACE1("VEthRecvFrame: FrameSize=%u\n",
pFrameInfo_p->m_uiFrameSize);
pSkb = dev_alloc_skb(pFrameInfo_p->m_uiFrameSize + 2);
if (pSkb == NULL)
{
pStats->rx_dropped++;
goto Exit;
}
pSkb->dev = pNetDevice;
pSkb = dev_alloc_skb(pFrameInfo_p->m_uiFrameSize + 2);
if (pSkb == NULL) {
pStats->rx_dropped++;
goto Exit;
}
pSkb->dev = pNetDevice;
skb_reserve(pSkb, 2);
skb_reserve(pSkb, 2);
memcpy((void *)skb_put(pSkb, pFrameInfo_p->m_uiFrameSize), pFrameInfo_p->m_pFrame, pFrameInfo_p->m_uiFrameSize);
memcpy((void *)skb_put(pSkb, pFrameInfo_p->m_uiFrameSize),
pFrameInfo_p->m_pFrame, pFrameInfo_p->m_uiFrameSize);
pSkb->protocol = eth_type_trans(pSkb, pNetDevice);
pSkb->ip_summed = CHECKSUM_UNNECESSARY;
pSkb->protocol = eth_type_trans(pSkb, pNetDevice);
pSkb->ip_summed = CHECKSUM_UNNECESSARY;
// call netif_rx with skb
netif_rx(pSkb);
// call netif_rx with skb
netif_rx(pSkb);
EPL_DBGLVL_VETH_TRACE1("VEthRecvFrame: SrcMAC=0x%llx\n", AmiGetQword48FromBe(pFrameInfo_p->m_pFrame->m_be_abSrcMac));
EPL_DBGLVL_VETH_TRACE1("VEthRecvFrame: SrcMAC=0x%llx\n",
AmiGetQword48FromBe(pFrameInfo_p->m_pFrame->
m_be_abSrcMac));
// update receive statistics
pStats->rx_packets++;
pStats->rx_bytes += pFrameInfo_p->m_uiFrameSize;
// update receive statistics
pStats->rx_packets++;
pStats->rx_bytes += pFrameInfo_p->m_uiFrameSize;
Exit:
return Ret;
Exit:
return Ret;
}
tEplKernel PUBLIC VEthAddInstance(tEplDllkInitParam * pInitParam_p)
{
tEplKernel Ret = kEplSuccessful;
tEplKernel Ret = kEplSuccessful;
// allocate net device structure with priv pointing to stats structure
pVEthNetDevice_g = alloc_netdev(sizeof (struct net_device_stats), EPL_VETH_NAME, ether_setup);
// allocate net device structure with priv pointing to stats structure
pVEthNetDevice_g =
alloc_netdev(sizeof(struct net_device_stats), EPL_VETH_NAME,
ether_setup);
// pVEthNetDevice_g = alloc_etherdev(sizeof (struct net_device_stats));
if (pVEthNetDevice_g == NULL)
{
Ret = kEplNoResource;
goto Exit;
}
if (pVEthNetDevice_g == NULL) {
Ret = kEplNoResource;
goto Exit;
}
pVEthNetDevice_g->open = VEthOpen;
pVEthNetDevice_g->stop = VEthClose;
pVEthNetDevice_g->get_stats = VEthGetStats;
pVEthNetDevice_g->hard_start_xmit = VEthXmit;
pVEthNetDevice_g->tx_timeout = VEthTimeout;
pVEthNetDevice_g->watchdog_timeo = EPL_VETH_TX_TIMEOUT;
pVEthNetDevice_g->destructor = free_netdev;
pVEthNetDevice_g->open = VEthOpen;
pVEthNetDevice_g->stop = VEthClose;
pVEthNetDevice_g->get_stats = VEthGetStats;
pVEthNetDevice_g->hard_start_xmit = VEthXmit;
pVEthNetDevice_g->tx_timeout = VEthTimeout;
pVEthNetDevice_g->watchdog_timeo = EPL_VETH_TX_TIMEOUT;
pVEthNetDevice_g->destructor = free_netdev;
// copy own MAC address to net device structure
memcpy(pVEthNetDevice_g->dev_addr, pInitParam_p->m_be_abSrcMac, 6);
// copy own MAC address to net device structure
memcpy(pVEthNetDevice_g->dev_addr, pInitParam_p->m_be_abSrcMac, 6);
//register VEth to the network subsystem
if (register_netdev(pVEthNetDevice_g))
{
EPL_DBGLVL_VETH_TRACE0("VEthAddInstance: Could not register VEth...\n");
}
else
{
EPL_DBGLVL_VETH_TRACE0("VEthAddInstance: Register VEth successfull...\n");
}
//register VEth to the network subsystem
if (register_netdev(pVEthNetDevice_g)) {
EPL_DBGLVL_VETH_TRACE0
("VEthAddInstance: Could not register VEth...\n");
} else {
EPL_DBGLVL_VETH_TRACE0
("VEthAddInstance: Register VEth successfull...\n");
}
Exit:
return Ret;
Exit:
return Ret;
}
tEplKernel PUBLIC VEthDelInstance(void)
{
tEplKernel Ret = kEplSuccessful;
tEplKernel Ret = kEplSuccessful;
if (pVEthNetDevice_g != NULL)
{
//unregister VEth from the network subsystem
unregister_netdev(pVEthNetDevice_g);
// destructor was set to free_netdev,
// so we do not need to call free_netdev here
pVEthNetDevice_g = NULL;
}
if (pVEthNetDevice_g != NULL) {
//unregister VEth from the network subsystem
unregister_netdev(pVEthNetDevice_g);
// destructor was set to free_netdev,
// so we do not need to call free_netdev here
pVEthNetDevice_g = NULL;
}
return Ret;
return Ret;
}
#endif // (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_VETH)) != 0)

View File

@ -80,25 +80,21 @@
// typedef
//---------------------------------------------------------------------------
typedef struct
{
WORD m_wWord;
typedef struct {
WORD m_wWord;
} twStruct;
typedef struct
{
DWORD m_dwDword;
typedef struct {
DWORD m_dwDword;
} tdwStruct;
typedef struct
{
QWORD m_qwQword;
typedef struct {
QWORD m_qwQword;
} tqwStruct;
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
@ -131,46 +127,39 @@ void PUBLIC AmiSetByteToBe (void FAR* pAddr_p, BYTE bByteVal_p)
}
*/
//------------< write WORD in big endian >--------------------------
INLINE_FUNCTION void PUBLIC AmiSetWordToBe (void FAR* pAddr_p, WORD wWordVal_p)
INLINE_FUNCTION void PUBLIC AmiSetWordToBe(void FAR * pAddr_p, WORD wWordVal_p)
{
twStruct FAR* pwStruct;
twStruct wValue;
twStruct FAR *pwStruct;
twStruct wValue;
wValue.m_wWord = (WORD)((wWordVal_p & 0x00FF) << 8); //LSB to MSB
wValue.m_wWord |= (WORD)((wWordVal_p & 0xFF00) >> 8); //MSB to LSB
wValue.m_wWord = (WORD) ((wWordVal_p & 0x00FF) << 8); //LSB to MSB
wValue.m_wWord |= (WORD) ((wWordVal_p & 0xFF00) >> 8); //MSB to LSB
pwStruct = (twStruct FAR*)pAddr_p;
pwStruct->m_wWord = wValue.m_wWord;
pwStruct = (twStruct FAR *) pAddr_p;
pwStruct->m_wWord = wValue.m_wWord;
}
//------------< write DWORD in big endian >-------------------------
INLINE_FUNCTION void PUBLIC AmiSetDwordToBe (void FAR* pAddr_p, DWORD dwDwordVal_p)
INLINE_FUNCTION void PUBLIC AmiSetDwordToBe(void FAR * pAddr_p,
DWORD dwDwordVal_p)
{
tdwStruct FAR* pdwStruct;
tdwStruct dwValue;
tdwStruct FAR *pdwStruct;
tdwStruct dwValue;
dwValue.m_dwDword = ((dwDwordVal_p & 0x000000FF) << 24); //LSB to MSB
dwValue.m_dwDword |= ((dwDwordVal_p & 0x0000FF00) << 8);
dwValue.m_dwDword |= ((dwDwordVal_p & 0x00FF0000) >> 8);
dwValue.m_dwDword |= ((dwDwordVal_p & 0xFF000000) >> 24); //MSB to LSB
dwValue.m_dwDword = ((dwDwordVal_p & 0x000000FF)<<24); //LSB to MSB
dwValue.m_dwDword|= ((dwDwordVal_p & 0x0000FF00)<<8);
dwValue.m_dwDword|= ((dwDwordVal_p & 0x00FF0000)>>8 );
dwValue.m_dwDword|= ((dwDwordVal_p & 0xFF000000)>>24); //MSB to LSB
pdwStruct = (tdwStruct FAR*)pAddr_p;
pdwStruct->m_dwDword = dwValue.m_dwDword;
pdwStruct = (tdwStruct FAR *) pAddr_p;
pdwStruct->m_dwDword = dwValue.m_dwDword;
}
//---------------------------------------------------------------------------
//
// Function: AmiSetXXXToLe()
@ -197,35 +186,29 @@ void PUBLIC AmiSetByteToLe (void FAR* pAddr_p, BYTE bByteVal_p)
}
*/
//------------< write WORD in little endian >--------------------------
INLINE_FUNCTION void PUBLIC AmiSetWordToLe (void FAR* pAddr_p, WORD wWordVal_p)
INLINE_FUNCTION void PUBLIC AmiSetWordToLe(void FAR * pAddr_p, WORD wWordVal_p)
{
twStruct FAR* pwStruct;
twStruct FAR *pwStruct;
pwStruct = (twStruct FAR*)pAddr_p;
pwStruct->m_wWord = wWordVal_p;
pwStruct = (twStruct FAR *) pAddr_p;
pwStruct->m_wWord = wWordVal_p;
}
//------------< write DWORD in little endian >-------------------------
INLINE_FUNCTION void PUBLIC AmiSetDwordToLe (void FAR* pAddr_p, DWORD dwDwordVal_p)
INLINE_FUNCTION void PUBLIC AmiSetDwordToLe(void FAR * pAddr_p,
DWORD dwDwordVal_p)
{
tdwStruct FAR* pdwStruct;
tdwStruct FAR *pdwStruct;
pdwStruct = (tdwStruct FAR*)pAddr_p;
pdwStruct->m_dwDword = dwDwordVal_p;
pdwStruct = (tdwStruct FAR *) pAddr_p;
pdwStruct->m_dwDword = dwDwordVal_p;
}
//---------------------------------------------------------------------------
//
// Function: AmiGetXXXFromBe()
@ -251,46 +234,40 @@ BYTE PUBLIC AmiGetByteFromBe (void FAR* pAddr_p)
}
*/
//------------< read WORD in big endian >---------------------------
INLINE_FUNCTION WORD PUBLIC AmiGetWordFromBe (void FAR* pAddr_p)
INLINE_FUNCTION WORD PUBLIC AmiGetWordFromBe(void FAR * pAddr_p)
{
twStruct FAR* pwStruct;
twStruct wValue;
twStruct FAR *pwStruct;
twStruct wValue;
pwStruct = (twStruct FAR*)pAddr_p;
pwStruct = (twStruct FAR *) pAddr_p;
wValue.m_wWord = (WORD)((pwStruct->m_wWord & 0x00FF) << 8); //LSB to MSB
wValue.m_wWord |= (WORD)((pwStruct->m_wWord & 0xFF00) >> 8); //MSB to LSB
wValue.m_wWord = (WORD) ((pwStruct->m_wWord & 0x00FF) << 8); //LSB to MSB
wValue.m_wWord |= (WORD) ((pwStruct->m_wWord & 0xFF00) >> 8); //MSB to LSB
return ( wValue.m_wWord );
return (wValue.m_wWord);
}
//------------< read DWORD in big endian >--------------------------
INLINE_FUNCTION DWORD PUBLIC AmiGetDwordFromBe (void FAR* pAddr_p)
INLINE_FUNCTION DWORD PUBLIC AmiGetDwordFromBe(void FAR * pAddr_p)
{
tdwStruct FAR* pdwStruct;
tdwStruct dwValue;
tdwStruct FAR *pdwStruct;
tdwStruct dwValue;
pdwStruct = (tdwStruct FAR*)pAddr_p;
pdwStruct = (tdwStruct FAR *) pAddr_p;
dwValue.m_dwDword = ((pdwStruct->m_dwDword & 0x000000FF)<<24); //LSB to MSB
dwValue.m_dwDword|= ((pdwStruct->m_dwDword & 0x0000FF00)<<8);
dwValue.m_dwDword|= ((pdwStruct->m_dwDword & 0x00FF0000)>>8 );
dwValue.m_dwDword|= ((pdwStruct->m_dwDword & 0xFF000000)>>24); //MSB to LSB
dwValue.m_dwDword = ((pdwStruct->m_dwDword & 0x000000FF) << 24); //LSB to MSB
dwValue.m_dwDword |= ((pdwStruct->m_dwDword & 0x0000FF00) << 8);
dwValue.m_dwDword |= ((pdwStruct->m_dwDword & 0x00FF0000) >> 8);
dwValue.m_dwDword |= ((pdwStruct->m_dwDword & 0xFF000000) >> 24); //MSB to LSB
return ( dwValue.m_dwDword );
return (dwValue.m_dwDword);
}
//---------------------------------------------------------------------------
//
// Function: AmiGetXXXFromLe()
@ -316,34 +293,28 @@ BYTE PUBLIC AmiGetByteFromLe (void FAR* pAddr_p)
}
*/
//------------< read WORD in little endian >---------------------------
INLINE_FUNCTION WORD PUBLIC AmiGetWordFromLe (void FAR* pAddr_p)
INLINE_FUNCTION WORD PUBLIC AmiGetWordFromLe(void FAR * pAddr_p)
{
twStruct FAR* pwStruct;
twStruct FAR *pwStruct;
pwStruct = (twStruct FAR*)pAddr_p;
return ( pwStruct->m_wWord );
pwStruct = (twStruct FAR *) pAddr_p;
return (pwStruct->m_wWord);
}
//------------< read DWORD in little endian >--------------------------
INLINE_FUNCTION DWORD PUBLIC AmiGetDwordFromLe (void FAR* pAddr_p)
INLINE_FUNCTION DWORD PUBLIC AmiGetDwordFromLe(void FAR * pAddr_p)
{
tdwStruct FAR* pdwStruct;
tdwStruct FAR *pdwStruct;
pdwStruct = (tdwStruct FAR*)pAddr_p;
return ( pdwStruct->m_dwDword );
pdwStruct = (tdwStruct FAR *) pAddr_p;
return (pdwStruct->m_dwDword);
}
//---------------------------------------------------------------------------
//
// Function: AmiSetDword24ToBe()
@ -359,16 +330,16 @@ tdwStruct FAR* pdwStruct;
//
//---------------------------------------------------------------------------
INLINE_FUNCTION void PUBLIC AmiSetDword24ToBe (void FAR* pAddr_p, DWORD dwDwordVal_p)
INLINE_FUNCTION void PUBLIC AmiSetDword24ToBe(void FAR * pAddr_p,
DWORD dwDwordVal_p)
{
((BYTE FAR*) pAddr_p)[0] = ((BYTE FAR*) &dwDwordVal_p)[2];
((BYTE FAR*) pAddr_p)[1] = ((BYTE FAR*) &dwDwordVal_p)[1];
((BYTE FAR*) pAddr_p)[2] = ((BYTE FAR*) &dwDwordVal_p)[0];
((BYTE FAR *) pAddr_p)[0] = ((BYTE FAR *) & dwDwordVal_p)[2];
((BYTE FAR *) pAddr_p)[1] = ((BYTE FAR *) & dwDwordVal_p)[1];
((BYTE FAR *) pAddr_p)[2] = ((BYTE FAR *) & dwDwordVal_p)[0];
}
//---------------------------------------------------------------------------
//
// Function: AmiSetDword24ToLe()
@ -384,16 +355,16 @@ INLINE_FUNCTION void PUBLIC AmiSetDword24ToBe (void FAR* pAddr_p, DWORD dwDwordV
//
//---------------------------------------------------------------------------
INLINE_FUNCTION void PUBLIC AmiSetDword24ToLe (void FAR* pAddr_p, DWORD dwDwordVal_p)
INLINE_FUNCTION void PUBLIC AmiSetDword24ToLe(void FAR * pAddr_p,
DWORD dwDwordVal_p)
{
((BYTE FAR*) pAddr_p)[0] = ((BYTE FAR*) &dwDwordVal_p)[0];
((BYTE FAR*) pAddr_p)[1] = ((BYTE FAR*) &dwDwordVal_p)[1];
((BYTE FAR*) pAddr_p)[2] = ((BYTE FAR*) &dwDwordVal_p)[2];
((BYTE FAR *) pAddr_p)[0] = ((BYTE FAR *) & dwDwordVal_p)[0];
((BYTE FAR *) pAddr_p)[1] = ((BYTE FAR *) & dwDwordVal_p)[1];
((BYTE FAR *) pAddr_p)[2] = ((BYTE FAR *) & dwDwordVal_p)[2];
}
//---------------------------------------------------------------------------
//
// Function: AmiGetDword24FromBe()
@ -408,19 +379,18 @@ INLINE_FUNCTION void PUBLIC AmiSetDword24ToLe (void FAR* pAddr_p, DWORD dwDwordV
//
//---------------------------------------------------------------------------
INLINE_FUNCTION DWORD PUBLIC AmiGetDword24FromBe (void FAR* pAddr_p)
INLINE_FUNCTION DWORD PUBLIC AmiGetDword24FromBe(void FAR * pAddr_p)
{
tdwStruct dwStruct;
tdwStruct dwStruct;
dwStruct.m_dwDword = AmiGetDwordFromBe (pAddr_p);
dwStruct.m_dwDword >>= 8;
dwStruct.m_dwDword = AmiGetDwordFromBe(pAddr_p);
dwStruct.m_dwDword >>= 8;
return ( dwStruct.m_dwDword );
return (dwStruct.m_dwDword);
}
//---------------------------------------------------------------------------
//
// Function: AmiGetDword24FromLe()
@ -435,19 +405,18 @@ tdwStruct dwStruct;
//
//---------------------------------------------------------------------------
INLINE_FUNCTION DWORD PUBLIC AmiGetDword24FromLe (void FAR* pAddr_p)
INLINE_FUNCTION DWORD PUBLIC AmiGetDword24FromLe(void FAR * pAddr_p)
{
tdwStruct dwStruct;
tdwStruct dwStruct;
dwStruct.m_dwDword = AmiGetDwordFromLe (pAddr_p);
dwStruct.m_dwDword &= 0x00FFFFFF;
dwStruct.m_dwDword = AmiGetDwordFromLe(pAddr_p);
dwStruct.m_dwDword &= 0x00FFFFFF;
return ( dwStruct.m_dwDword );
return (dwStruct.m_dwDword);
}
//#ifdef USE_VAR64
//---------------------------------------------------------------------------
@ -465,21 +434,21 @@ tdwStruct dwStruct;
//
//---------------------------------------------------------------------------
INLINE_FUNCTION void PUBLIC AmiSetQword64ToBe (void FAR* pAddr_p, QWORD qwQwordVal_p)
INLINE_FUNCTION void PUBLIC AmiSetQword64ToBe(void FAR * pAddr_p,
QWORD qwQwordVal_p)
{
((BYTE FAR*) pAddr_p)[0] = ((BYTE FAR*) &qwQwordVal_p)[7];
((BYTE FAR*) pAddr_p)[1] = ((BYTE FAR*) &qwQwordVal_p)[6];
((BYTE FAR*) pAddr_p)[2] = ((BYTE FAR*) &qwQwordVal_p)[5];
((BYTE FAR*) pAddr_p)[3] = ((BYTE FAR*) &qwQwordVal_p)[4];
((BYTE FAR*) pAddr_p)[4] = ((BYTE FAR*) &qwQwordVal_p)[3];
((BYTE FAR*) pAddr_p)[5] = ((BYTE FAR*) &qwQwordVal_p)[2];
((BYTE FAR*) pAddr_p)[6] = ((BYTE FAR*) &qwQwordVal_p)[1];
((BYTE FAR*) pAddr_p)[7] = ((BYTE FAR*) &qwQwordVal_p)[0];
((BYTE FAR *) pAddr_p)[0] = ((BYTE FAR *) & qwQwordVal_p)[7];
((BYTE FAR *) pAddr_p)[1] = ((BYTE FAR *) & qwQwordVal_p)[6];
((BYTE FAR *) pAddr_p)[2] = ((BYTE FAR *) & qwQwordVal_p)[5];
((BYTE FAR *) pAddr_p)[3] = ((BYTE FAR *) & qwQwordVal_p)[4];
((BYTE FAR *) pAddr_p)[4] = ((BYTE FAR *) & qwQwordVal_p)[3];
((BYTE FAR *) pAddr_p)[5] = ((BYTE FAR *) & qwQwordVal_p)[2];
((BYTE FAR *) pAddr_p)[6] = ((BYTE FAR *) & qwQwordVal_p)[1];
((BYTE FAR *) pAddr_p)[7] = ((BYTE FAR *) & qwQwordVal_p)[0];
}
//---------------------------------------------------------------------------
//
// Function: AmiSetQword64ToLe()
@ -495,17 +464,17 @@ INLINE_FUNCTION void PUBLIC AmiSetQword64ToBe (void FAR* pAddr_p, QWORD qwQwordV
//
//---------------------------------------------------------------------------
INLINE_FUNCTION void PUBLIC AmiSetQword64ToLe (void FAR* pAddr_p, QWORD qwQwordVal_p)
INLINE_FUNCTION void PUBLIC AmiSetQword64ToLe(void FAR * pAddr_p,
QWORD qwQwordVal_p)
{
QWORD FAR* pqwDst;
QWORD FAR *pqwDst;
pqwDst = (QWORD FAR*) pAddr_p;
*pqwDst = qwQwordVal_p;
pqwDst = (QWORD FAR *) pAddr_p;
*pqwDst = qwQwordVal_p;
}
//---------------------------------------------------------------------------
//
// Function: AmiGetQword64FromBe()
@ -520,25 +489,24 @@ QWORD FAR* pqwDst;
//
//---------------------------------------------------------------------------
INLINE_FUNCTION QWORD PUBLIC AmiGetQword64FromBe (void FAR* pAddr_p)
INLINE_FUNCTION QWORD PUBLIC AmiGetQword64FromBe(void FAR * pAddr_p)
{
tqwStruct qwStruct;
tqwStruct qwStruct;
((BYTE FAR*) &qwStruct.m_qwQword)[0] = ((BYTE FAR*) pAddr_p)[7];
((BYTE FAR*) &qwStruct.m_qwQword)[1] = ((BYTE FAR*) pAddr_p)[6];
((BYTE FAR*) &qwStruct.m_qwQword)[2] = ((BYTE FAR*) pAddr_p)[5];
((BYTE FAR*) &qwStruct.m_qwQword)[3] = ((BYTE FAR*) pAddr_p)[4];
((BYTE FAR*) &qwStruct.m_qwQword)[4] = ((BYTE FAR*) pAddr_p)[3];
((BYTE FAR*) &qwStruct.m_qwQword)[5] = ((BYTE FAR*) pAddr_p)[2];
((BYTE FAR*) &qwStruct.m_qwQword)[6] = ((BYTE FAR*) pAddr_p)[1];
((BYTE FAR*) &qwStruct.m_qwQword)[7] = ((BYTE FAR*) pAddr_p)[0];
((BYTE FAR *) & qwStruct.m_qwQword)[0] = ((BYTE FAR *) pAddr_p)[7];
((BYTE FAR *) & qwStruct.m_qwQword)[1] = ((BYTE FAR *) pAddr_p)[6];
((BYTE FAR *) & qwStruct.m_qwQword)[2] = ((BYTE FAR *) pAddr_p)[5];
((BYTE FAR *) & qwStruct.m_qwQword)[3] = ((BYTE FAR *) pAddr_p)[4];
((BYTE FAR *) & qwStruct.m_qwQword)[4] = ((BYTE FAR *) pAddr_p)[3];
((BYTE FAR *) & qwStruct.m_qwQword)[5] = ((BYTE FAR *) pAddr_p)[2];
((BYTE FAR *) & qwStruct.m_qwQword)[6] = ((BYTE FAR *) pAddr_p)[1];
((BYTE FAR *) & qwStruct.m_qwQword)[7] = ((BYTE FAR *) pAddr_p)[0];
return ( qwStruct.m_qwQword );
return (qwStruct.m_qwQword);
}
//---------------------------------------------------------------------------
//
// Function: AmiGetQword64FromLe()
@ -553,20 +521,19 @@ tqwStruct qwStruct;
//
//---------------------------------------------------------------------------
INLINE_FUNCTION QWORD PUBLIC AmiGetQword64FromLe (void FAR* pAddr_p)
INLINE_FUNCTION QWORD PUBLIC AmiGetQword64FromLe(void FAR * pAddr_p)
{
tqwStruct FAR* pqwStruct;
tqwStruct qwStruct;
tqwStruct FAR *pqwStruct;
tqwStruct qwStruct;
pqwStruct = (tqwStruct FAR*) pAddr_p;
qwStruct.m_qwQword = pqwStruct->m_qwQword;
pqwStruct = (tqwStruct FAR *) pAddr_p;
qwStruct.m_qwQword = pqwStruct->m_qwQword;
return ( qwStruct.m_qwQword );
return (qwStruct.m_qwQword);
}
//---------------------------------------------------------------------------
//
// Function: AmiSetQword40ToBe()
@ -582,18 +549,18 @@ tqwStruct qwStruct;
//
//---------------------------------------------------------------------------
INLINE_FUNCTION void PUBLIC AmiSetQword40ToBe (void FAR* pAddr_p, QWORD qwQwordVal_p)
INLINE_FUNCTION void PUBLIC AmiSetQword40ToBe(void FAR * pAddr_p,
QWORD qwQwordVal_p)
{
((BYTE FAR*) pAddr_p)[0] = ((BYTE FAR*) &qwQwordVal_p)[4];
((BYTE FAR*) pAddr_p)[1] = ((BYTE FAR*) &qwQwordVal_p)[3];
((BYTE FAR*) pAddr_p)[2] = ((BYTE FAR*) &qwQwordVal_p)[2];
((BYTE FAR*) pAddr_p)[3] = ((BYTE FAR*) &qwQwordVal_p)[1];
((BYTE FAR*) pAddr_p)[4] = ((BYTE FAR*) &qwQwordVal_p)[0];
((BYTE FAR *) pAddr_p)[0] = ((BYTE FAR *) & qwQwordVal_p)[4];
((BYTE FAR *) pAddr_p)[1] = ((BYTE FAR *) & qwQwordVal_p)[3];
((BYTE FAR *) pAddr_p)[2] = ((BYTE FAR *) & qwQwordVal_p)[2];
((BYTE FAR *) pAddr_p)[3] = ((BYTE FAR *) & qwQwordVal_p)[1];
((BYTE FAR *) pAddr_p)[4] = ((BYTE FAR *) & qwQwordVal_p)[0];
}
//---------------------------------------------------------------------------
//
// Function: AmiSetQword40ToLe()
@ -609,15 +576,15 @@ INLINE_FUNCTION void PUBLIC AmiSetQword40ToBe (void FAR* pAddr_p, QWORD qwQwordV
//
//---------------------------------------------------------------------------
INLINE_FUNCTION void PUBLIC AmiSetQword40ToLe (void FAR* pAddr_p, QWORD qwQwordVal_p)
INLINE_FUNCTION void PUBLIC AmiSetQword40ToLe(void FAR * pAddr_p,
QWORD qwQwordVal_p)
{
((DWORD FAR*) pAddr_p)[0] = ((DWORD FAR*) &qwQwordVal_p)[0];
((BYTE FAR*) pAddr_p)[4] = ((BYTE FAR*) &qwQwordVal_p)[4];
((DWORD FAR *) pAddr_p)[0] = ((DWORD FAR *) & qwQwordVal_p)[0];
((BYTE FAR *) pAddr_p)[4] = ((BYTE FAR *) & qwQwordVal_p)[4];
}
//---------------------------------------------------------------------------
//
// Function: AmiGetQword40FromBe()
@ -632,19 +599,18 @@ INLINE_FUNCTION void PUBLIC AmiSetQword40ToLe (void FAR* pAddr_p, QWORD qwQwordV
//
//---------------------------------------------------------------------------
INLINE_FUNCTION QWORD PUBLIC AmiGetQword40FromBe (void FAR* pAddr_p)
INLINE_FUNCTION QWORD PUBLIC AmiGetQword40FromBe(void FAR * pAddr_p)
{
tqwStruct qwStruct;
tqwStruct qwStruct;
qwStruct.m_qwQword = AmiGetQword64FromBe (pAddr_p);
qwStruct.m_qwQword >>= 24;
qwStruct.m_qwQword = AmiGetQword64FromBe(pAddr_p);
qwStruct.m_qwQword >>= 24;
return ( qwStruct.m_qwQword );
return (qwStruct.m_qwQword);
}
//---------------------------------------------------------------------------
//
// Function: AmiGetQword40FromLe()
@ -659,19 +625,18 @@ tqwStruct qwStruct;
//
//---------------------------------------------------------------------------
INLINE_FUNCTION QWORD PUBLIC AmiGetQword40FromLe (void FAR* pAddr_p)
INLINE_FUNCTION QWORD PUBLIC AmiGetQword40FromLe(void FAR * pAddr_p)
{
tqwStruct qwStruct;
tqwStruct qwStruct;
qwStruct.m_qwQword = AmiGetQword64FromLe (pAddr_p);
qwStruct.m_qwQword &= 0x000000FFFFFFFFFFLL;
qwStruct.m_qwQword = AmiGetQword64FromLe(pAddr_p);
qwStruct.m_qwQword &= 0x000000FFFFFFFFFFLL;
return ( qwStruct.m_qwQword );
return (qwStruct.m_qwQword);
}
//---------------------------------------------------------------------------
//
// Function: AmiSetQword48ToBe()
@ -687,19 +652,19 @@ tqwStruct qwStruct;
//
//---------------------------------------------------------------------------
INLINE_FUNCTION void PUBLIC AmiSetQword48ToBe (void FAR* pAddr_p, QWORD qwQwordVal_p)
INLINE_FUNCTION void PUBLIC AmiSetQword48ToBe(void FAR * pAddr_p,
QWORD qwQwordVal_p)
{
((BYTE FAR*) pAddr_p)[0] = ((BYTE FAR*) &qwQwordVal_p)[5];
((BYTE FAR*) pAddr_p)[1] = ((BYTE FAR*) &qwQwordVal_p)[4];
((BYTE FAR*) pAddr_p)[2] = ((BYTE FAR*) &qwQwordVal_p)[3];
((BYTE FAR*) pAddr_p)[3] = ((BYTE FAR*) &qwQwordVal_p)[2];
((BYTE FAR*) pAddr_p)[4] = ((BYTE FAR*) &qwQwordVal_p)[1];
((BYTE FAR*) pAddr_p)[5] = ((BYTE FAR*) &qwQwordVal_p)[0];
((BYTE FAR *) pAddr_p)[0] = ((BYTE FAR *) & qwQwordVal_p)[5];
((BYTE FAR *) pAddr_p)[1] = ((BYTE FAR *) & qwQwordVal_p)[4];
((BYTE FAR *) pAddr_p)[2] = ((BYTE FAR *) & qwQwordVal_p)[3];
((BYTE FAR *) pAddr_p)[3] = ((BYTE FAR *) & qwQwordVal_p)[2];
((BYTE FAR *) pAddr_p)[4] = ((BYTE FAR *) & qwQwordVal_p)[1];
((BYTE FAR *) pAddr_p)[5] = ((BYTE FAR *) & qwQwordVal_p)[0];
}
//---------------------------------------------------------------------------
//
// Function: AmiSetQword48ToLe()
@ -715,15 +680,15 @@ INLINE_FUNCTION void PUBLIC AmiSetQword48ToBe (void FAR* pAddr_p, QWORD qwQwordV
//
//---------------------------------------------------------------------------
INLINE_FUNCTION void PUBLIC AmiSetQword48ToLe (void FAR* pAddr_p, QWORD qwQwordVal_p)
INLINE_FUNCTION void PUBLIC AmiSetQword48ToLe(void FAR * pAddr_p,
QWORD qwQwordVal_p)
{
((DWORD FAR*) pAddr_p)[0] = ((DWORD FAR*) &qwQwordVal_p)[0];
((WORD FAR*) pAddr_p)[2] = ((WORD FAR*) &qwQwordVal_p)[2];
((DWORD FAR *) pAddr_p)[0] = ((DWORD FAR *) & qwQwordVal_p)[0];
((WORD FAR *) pAddr_p)[2] = ((WORD FAR *) & qwQwordVal_p)[2];
}
//---------------------------------------------------------------------------
//
// Function: AmiGetQword48FromBe()
@ -738,19 +703,18 @@ INLINE_FUNCTION void PUBLIC AmiSetQword48ToLe (void FAR* pAddr_p, QWORD qwQwordV
//
//---------------------------------------------------------------------------
INLINE_FUNCTION QWORD PUBLIC AmiGetQword48FromBe (void FAR* pAddr_p)
INLINE_FUNCTION QWORD PUBLIC AmiGetQword48FromBe(void FAR * pAddr_p)
{
tqwStruct qwStruct;
tqwStruct qwStruct;
qwStruct.m_qwQword = AmiGetQword64FromBe (pAddr_p);
qwStruct.m_qwQword >>= 16;
qwStruct.m_qwQword = AmiGetQword64FromBe(pAddr_p);
qwStruct.m_qwQword >>= 16;
return ( qwStruct.m_qwQword );
return (qwStruct.m_qwQword);
}
//---------------------------------------------------------------------------
//
// Function: AmiGetQword48FromLe()
@ -765,19 +729,18 @@ tqwStruct qwStruct;
//
//---------------------------------------------------------------------------
INLINE_FUNCTION QWORD PUBLIC AmiGetQword48FromLe (void FAR* pAddr_p)
INLINE_FUNCTION QWORD PUBLIC AmiGetQword48FromLe(void FAR * pAddr_p)
{
tqwStruct qwStruct;
tqwStruct qwStruct;
qwStruct.m_qwQword = AmiGetQword64FromLe (pAddr_p);
qwStruct.m_qwQword &= 0x0000FFFFFFFFFFFFLL;
qwStruct.m_qwQword = AmiGetQword64FromLe(pAddr_p);
qwStruct.m_qwQword &= 0x0000FFFFFFFFFFFFLL;
return ( qwStruct.m_qwQword );
return (qwStruct.m_qwQword);
}
//---------------------------------------------------------------------------
//
// Function: AmiSetQword56ToBe()
@ -793,20 +756,20 @@ tqwStruct qwStruct;
//
//---------------------------------------------------------------------------
INLINE_FUNCTION void PUBLIC AmiSetQword56ToBe (void FAR* pAddr_p, QWORD qwQwordVal_p)
INLINE_FUNCTION void PUBLIC AmiSetQword56ToBe(void FAR * pAddr_p,
QWORD qwQwordVal_p)
{
((BYTE FAR*) pAddr_p)[0] = ((BYTE FAR*) &qwQwordVal_p)[6];
((BYTE FAR*) pAddr_p)[1] = ((BYTE FAR*) &qwQwordVal_p)[5];
((BYTE FAR*) pAddr_p)[2] = ((BYTE FAR*) &qwQwordVal_p)[4];
((BYTE FAR*) pAddr_p)[3] = ((BYTE FAR*) &qwQwordVal_p)[3];
((BYTE FAR*) pAddr_p)[4] = ((BYTE FAR*) &qwQwordVal_p)[2];
((BYTE FAR*) pAddr_p)[5] = ((BYTE FAR*) &qwQwordVal_p)[1];
((BYTE FAR*) pAddr_p)[6] = ((BYTE FAR*) &qwQwordVal_p)[0];
((BYTE FAR *) pAddr_p)[0] = ((BYTE FAR *) & qwQwordVal_p)[6];
((BYTE FAR *) pAddr_p)[1] = ((BYTE FAR *) & qwQwordVal_p)[5];
((BYTE FAR *) pAddr_p)[2] = ((BYTE FAR *) & qwQwordVal_p)[4];
((BYTE FAR *) pAddr_p)[3] = ((BYTE FAR *) & qwQwordVal_p)[3];
((BYTE FAR *) pAddr_p)[4] = ((BYTE FAR *) & qwQwordVal_p)[2];
((BYTE FAR *) pAddr_p)[5] = ((BYTE FAR *) & qwQwordVal_p)[1];
((BYTE FAR *) pAddr_p)[6] = ((BYTE FAR *) & qwQwordVal_p)[0];
}
//---------------------------------------------------------------------------
//
// Function: AmiSetQword56ToLe()
@ -822,16 +785,16 @@ INLINE_FUNCTION void PUBLIC AmiSetQword56ToBe (void FAR* pAddr_p, QWORD qwQwordV
//
//---------------------------------------------------------------------------
INLINE_FUNCTION void PUBLIC AmiSetQword56ToLe (void FAR* pAddr_p, QWORD qwQwordVal_p)
INLINE_FUNCTION void PUBLIC AmiSetQword56ToLe(void FAR * pAddr_p,
QWORD qwQwordVal_p)
{
((DWORD FAR*) pAddr_p)[0] = ((DWORD FAR*) &qwQwordVal_p)[0];
((WORD FAR*) pAddr_p)[2] = ((WORD FAR*) &qwQwordVal_p)[2];
((BYTE FAR*) pAddr_p)[6] = ((BYTE FAR*) &qwQwordVal_p)[6];
((DWORD FAR *) pAddr_p)[0] = ((DWORD FAR *) & qwQwordVal_p)[0];
((WORD FAR *) pAddr_p)[2] = ((WORD FAR *) & qwQwordVal_p)[2];
((BYTE FAR *) pAddr_p)[6] = ((BYTE FAR *) & qwQwordVal_p)[6];
}
//---------------------------------------------------------------------------
//
// Function: AmiGetQword56FromBe()
@ -846,19 +809,18 @@ INLINE_FUNCTION void PUBLIC AmiSetQword56ToLe (void FAR* pAddr_p, QWORD qwQwordV
//
//---------------------------------------------------------------------------
INLINE_FUNCTION QWORD PUBLIC AmiGetQword56FromBe (void FAR* pAddr_p)
INLINE_FUNCTION QWORD PUBLIC AmiGetQword56FromBe(void FAR * pAddr_p)
{
tqwStruct qwStruct;
tqwStruct qwStruct;
qwStruct.m_qwQword = AmiGetQword64FromBe (pAddr_p);
qwStruct.m_qwQword >>= 8;
qwStruct.m_qwQword = AmiGetQword64FromBe(pAddr_p);
qwStruct.m_qwQword >>= 8;
return ( qwStruct.m_qwQword );
return (qwStruct.m_qwQword);
}
//---------------------------------------------------------------------------
//
// Function: AmiGetQword56FromLe()
@ -873,19 +835,18 @@ tqwStruct qwStruct;
//
//---------------------------------------------------------------------------
INLINE_FUNCTION QWORD PUBLIC AmiGetQword56FromLe (void FAR* pAddr_p)
INLINE_FUNCTION QWORD PUBLIC AmiGetQword56FromLe(void FAR * pAddr_p)
{
tqwStruct qwStruct;
tqwStruct qwStruct;
qwStruct.m_qwQword = AmiGetQword64FromLe (pAddr_p);
qwStruct.m_qwQword &= 0x00FFFFFFFFFFFFFFLL;
qwStruct.m_qwQword = AmiGetQword64FromLe(pAddr_p);
qwStruct.m_qwQword &= 0x00FFFFFFFFFFFFFFLL;
return ( qwStruct.m_qwQword );
return (qwStruct.m_qwQword);
}
//---------------------------------------------------------------------------
//
// Function: AmiSetTimeOfDay()
@ -901,15 +862,16 @@ tqwStruct qwStruct;
//
//---------------------------------------------------------------------------
INLINE_FUNCTION void PUBLIC AmiSetTimeOfDay (void FAR* pAddr_p, tTimeOfDay FAR* pTimeOfDay_p)
INLINE_FUNCTION void PUBLIC AmiSetTimeOfDay(void FAR * pAddr_p,
tTimeOfDay FAR * pTimeOfDay_p)
{
AmiSetDwordToLe (((BYTE FAR*) pAddr_p), pTimeOfDay_p->m_dwMs & 0x0FFFFFFF);
AmiSetWordToLe (((BYTE FAR*) pAddr_p) + 4, pTimeOfDay_p->m_wDays);
AmiSetDwordToLe(((BYTE FAR *) pAddr_p),
pTimeOfDay_p->m_dwMs & 0x0FFFFFFF);
AmiSetWordToLe(((BYTE FAR *) pAddr_p) + 4, pTimeOfDay_p->m_wDays);
}
//---------------------------------------------------------------------------
//
// Function: AmiGetTimeOfDay()
@ -925,21 +887,19 @@ INLINE_FUNCTION void PUBLIC AmiSetTimeOfDay (void FAR* pAddr_p, tTimeOfDay FAR*
//
//---------------------------------------------------------------------------
INLINE_FUNCTION void PUBLIC AmiGetTimeOfDay (void FAR* pAddr_p, tTimeOfDay FAR* pTimeOfDay_p)
INLINE_FUNCTION void PUBLIC AmiGetTimeOfDay(void FAR * pAddr_p,
tTimeOfDay FAR * pTimeOfDay_p)
{
pTimeOfDay_p->m_dwMs = AmiGetDwordFromLe (((BYTE FAR*) pAddr_p)) & 0x0FFFFFFF;
pTimeOfDay_p->m_wDays = AmiGetWordFromLe (((BYTE FAR*) pAddr_p) + 4);
pTimeOfDay_p->m_dwMs =
AmiGetDwordFromLe(((BYTE FAR *) pAddr_p)) & 0x0FFFFFFF;
pTimeOfDay_p->m_wDays = AmiGetWordFromLe(((BYTE FAR *) pAddr_p) + 4);
}
#endif
// EOF
// Die letzte Zeile muß unbedingt eine leere Zeile sein, weil manche Compiler
// damit ein Problem haben, wenn das nicht so ist (z.B. GNU oder Borland C++ Builder).

File diff suppressed because it is too large Load Diff

View File

@ -91,11 +91,10 @@
#include <linux/spinlock.h>
#ifdef CONFIG_COLDFIRE
#include <asm/coldfire.h>
#include "fec.h"
#include <asm/coldfire.h>
#include "fec.h"
#endif
/***************************************************************************/
/* */
/* */
@ -113,45 +112,44 @@
#endif
#ifndef DBG_TRACE_POINTS
#define DBG_TRACE_POINTS 23 // # of supported debug trace points
#define DBG_TRACE_POINTS 23 // # of supported debug trace points
#endif
#ifndef DBG_TRACE_VALUES
#define DBG_TRACE_VALUES 24 // # of supported debug trace values (size of circular buffer)
#define DBG_TRACE_VALUES 24 // # of supported debug trace values (size of circular buffer)
#endif
//---------------------------------------------------------------------------
// modul global types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local vars
//---------------------------------------------------------------------------
#ifdef _DBG_TRACE_POINTS_
atomic_t aatmDbgTracePoint_l[DBG_TRACE_POINTS];
DWORD adwDbgTraceValue_l[DBG_TRACE_VALUES];
DWORD dwDbgTraceValueOld_l;
unsigned int uiDbgTraceValuePos_l;
spinlock_t spinlockDbgTraceValue_l;
unsigned long ulDbTraceValueFlags_l;
atomic_t aatmDbgTracePoint_l[DBG_TRACE_POINTS];
DWORD adwDbgTraceValue_l[DBG_TRACE_VALUES];
DWORD dwDbgTraceValueOld_l;
unsigned int uiDbgTraceValuePos_l;
spinlock_t spinlockDbgTraceValue_l;
unsigned long ulDbTraceValueFlags_l;
#endif
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
static int EplLinProcRead (char* pcBuffer_p, char** ppcStart_p, off_t Offset_p, int nBufferSize_p, int* pEof_p, void* pData_p);
static int EplLinProcWrite(struct file *file, const char __user *buffer, unsigned long count, void *data);
void PUBLIC TgtDbgSignalTracePoint (BYTE bTracePointNumber_p);
void PUBLIC TgtDbgPostTraceValue (DWORD dwTraceValue_p);
static int EplLinProcRead(char *pcBuffer_p, char **ppcStart_p, off_t Offset_p,
int nBufferSize_p, int *pEof_p, void *pData_p);
static int EplLinProcWrite(struct file *file, const char __user * buffer,
unsigned long count, void *data);
void PUBLIC TgtDbgSignalTracePoint(BYTE bTracePointNumber_p);
void PUBLIC TgtDbgPostTraceValue(DWORD dwTraceValue_p);
EPLDLLEXPORT DWORD PUBLIC EplIdentuGetRunningRequests(void);
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
@ -160,35 +158,32 @@ EPLDLLEXPORT DWORD PUBLIC EplIdentuGetRunningRequests(void);
tEplKernel EplLinProcInit(void)
{
struct proc_dir_entry* pProcDirEntry;
pProcDirEntry = create_proc_entry (EPL_PROC_DEV_NAME, S_IRUGO, NULL);
if (pProcDirEntry != NULL)
{
pProcDirEntry->read_proc = EplLinProcRead;
pProcDirEntry->write_proc = EplLinProcWrite;
pProcDirEntry->data = NULL; // device number or something else
struct proc_dir_entry *pProcDirEntry;
pProcDirEntry = create_proc_entry(EPL_PROC_DEV_NAME, S_IRUGO, NULL);
if (pProcDirEntry != NULL) {
pProcDirEntry->read_proc = EplLinProcRead;
pProcDirEntry->write_proc = EplLinProcWrite;
pProcDirEntry->data = NULL; // device number or something else
}
else
{
return kEplNoResource;
}
} else {
return kEplNoResource;
}
#ifdef _DBG_TRACE_POINTS_
// initialize spinlock and circular buffer position
spin_lock_init(&spinlockDbgTraceValue_l);
uiDbgTraceValuePos_l = 0;
dwDbgTraceValueOld_l = 0;
// initialize spinlock and circular buffer position
spin_lock_init(&spinlockDbgTraceValue_l);
uiDbgTraceValuePos_l = 0;
dwDbgTraceValueOld_l = 0;
#endif
return kEplSuccessful;
return kEplSuccessful;
}
tEplKernel EplLinProcFree(void)
{
remove_proc_entry (EPL_PROC_DEV_NAME, NULL);
remove_proc_entry(EPL_PROC_DEV_NAME, NULL);
return kEplSuccessful;
return kEplSuccessful;
}
//---------------------------------------------------------------------------
@ -196,225 +191,219 @@ tEplKernel EplLinProcFree(void)
//---------------------------------------------------------------------------
#ifdef _DBG_TRACE_POINTS_
void PUBLIC TgtDbgSignalTracePoint (
BYTE bTracePointNumber_p)
void PUBLIC TgtDbgSignalTracePoint(BYTE bTracePointNumber_p)
{
if (bTracePointNumber_p >= (sizeof(aatmDbgTracePoint_l) / sizeof(aatmDbgTracePoint_l[0])))
{
goto Exit;
}
if (bTracePointNumber_p >=
(sizeof(aatmDbgTracePoint_l) / sizeof(aatmDbgTracePoint_l[0]))) {
goto Exit;
}
atomic_inc(&aatmDbgTracePoint_l[bTracePointNumber_p]);
atomic_inc (&aatmDbgTracePoint_l[bTracePointNumber_p]);
Exit:
Exit:
return;
return;
}
void PUBLIC TgtDbgPostTraceValue (DWORD dwTraceValue_p)
void PUBLIC TgtDbgPostTraceValue(DWORD dwTraceValue_p)
{
spin_lock_irqsave(&spinlockDbgTraceValue_l, ulDbTraceValueFlags_l);
if (dwDbgTraceValueOld_l != dwTraceValue_p)
{
adwDbgTraceValue_l[uiDbgTraceValuePos_l] = dwTraceValue_p;
uiDbgTraceValuePos_l = (uiDbgTraceValuePos_l + 1) % DBG_TRACE_VALUES;
dwDbgTraceValueOld_l = dwTraceValue_p;
}
spin_unlock_irqrestore(&spinlockDbgTraceValue_l, ulDbTraceValueFlags_l);
spin_lock_irqsave(&spinlockDbgTraceValue_l, ulDbTraceValueFlags_l);
if (dwDbgTraceValueOld_l != dwTraceValue_p) {
adwDbgTraceValue_l[uiDbgTraceValuePos_l] = dwTraceValue_p;
uiDbgTraceValuePos_l =
(uiDbgTraceValuePos_l + 1) % DBG_TRACE_VALUES;
dwDbgTraceValueOld_l = dwTraceValue_p;
}
spin_unlock_irqrestore(&spinlockDbgTraceValue_l, ulDbTraceValueFlags_l);
return;
return;
}
#endif
//---------------------------------------------------------------------------
// Read function for PROC-FS read access
//---------------------------------------------------------------------------
static int EplLinProcRead (
char* pcBuffer_p,
char** ppcStart_p,
off_t Offset_p,
int nBufferSize_p,
int* pEof_p,
void* pData_p)
static int EplLinProcRead(char *pcBuffer_p,
char **ppcStart_p,
off_t Offset_p,
int nBufferSize_p, int *pEof_p, void *pData_p)
{
int nSize;
int Eof;
tEplDllkCalStatistics* pDllkCalStats;
int nSize;
int Eof;
tEplDllkCalStatistics *pDllkCalStats;
nSize = 0;
Eof = 0;
nSize = 0;
Eof = 0;
// count calls of this function
// count calls of this function
#ifdef _DBG_TRACE_POINTS_
TgtDbgSignalTracePoint(0);
TgtDbgSignalTracePoint(0);
#endif
//---------------------------------------------------------------
// generate static information
//---------------------------------------------------------------
//---------------------------------------------------------------
// generate static information
//---------------------------------------------------------------
// ---- Driver information ----
nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
"%s %s (c) 2006 %s\n",
EPL_PRODUCT_NAME, EPL_PRODUCT_VERSION, EPL_PRODUCT_MANUFACTURER);
// ---- Driver information ----
nSize += snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize,
"%s %s (c) 2006 %s\n",
EPL_PRODUCT_NAME, EPL_PRODUCT_VERSION,
EPL_PRODUCT_MANUFACTURER);
//---------------------------------------------------------------
// generate process information
//---------------------------------------------------------------
//---------------------------------------------------------------
// generate process information
//---------------------------------------------------------------
// ---- EPL state ----
nSize += snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize,
"NMT state: 0x%04X\n",
(WORD) EplNmtkGetNmtState());
// ---- EPL state ----
nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
"NMT state: 0x%04X\n",
(WORD) EplNmtkGetNmtState());
EplDllkCalGetStatistics(&pDllkCalStats);
EplDllkCalGetStatistics(&pDllkCalStats);
nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
"CurAsyncTxGen=%lu CurAsyncTxNmt=%lu CurAsyncRx=%lu\nMaxAsyncTxGen=%lu MaxAsyncTxNmt=%lu MaxAsyncRx=%lu\n", pDllkCalStats->m_ulCurTxFrameCountGen, pDllkCalStats->m_ulCurTxFrameCountNmt, pDllkCalStats->m_ulCurRxFrameCount, pDllkCalStats->m_ulMaxTxFrameCountGen, pDllkCalStats->m_ulMaxTxFrameCountNmt, pDllkCalStats->m_ulMaxRxFrameCount);
nSize += snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize,
"CurAsyncTxGen=%lu CurAsyncTxNmt=%lu CurAsyncRx=%lu\nMaxAsyncTxGen=%lu MaxAsyncTxNmt=%lu MaxAsyncRx=%lu\n",
pDllkCalStats->m_ulCurTxFrameCountGen,
pDllkCalStats->m_ulCurTxFrameCountNmt,
pDllkCalStats->m_ulCurRxFrameCount,
pDllkCalStats->m_ulMaxTxFrameCountGen,
pDllkCalStats->m_ulMaxTxFrameCountNmt,
pDllkCalStats->m_ulMaxRxFrameCount);
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
// fetch running IdentRequests
nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
"running IdentRequests: 0x%08lX\n",
EplIdentuGetRunningRequests());
// fetch running IdentRequests
nSize += snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize,
"running IdentRequests: 0x%08lX\n",
EplIdentuGetRunningRequests());
// fetch state of NmtMnu module
{
unsigned int uiMandatorySlaveCount;
unsigned int uiSignalSlaveCount;
WORD wFlags;
// fetch state of NmtMnu module
{
unsigned int uiMandatorySlaveCount;
unsigned int uiSignalSlaveCount;
WORD wFlags;
EplNmtMnuGetDiagnosticInfo(&uiMandatorySlaveCount,
&uiSignalSlaveCount,
&wFlags);
EplNmtMnuGetDiagnosticInfo(&uiMandatorySlaveCount,
&uiSignalSlaveCount, &wFlags);
nSize += snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize,
"MN MandSlaveCount: %u SigSlaveCount: %u Flags: 0x%X\n",
uiMandatorySlaveCount, uiSignalSlaveCount,
wFlags);
nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
"MN MandSlaveCount: %u SigSlaveCount: %u Flags: 0x%X\n",
uiMandatorySlaveCount, uiSignalSlaveCount, wFlags);
}
}
#endif
// ---- FEC state ----
#ifdef CONFIG_COLDFIRE
{
// Receive the base address
unsigned long base_addr;
#if (EDRV_USED_ETH_CTRL == 0)
// Set the base address of FEC0
base_addr = FEC_BASE_ADDR_FEC0;
#else
// Set the base address of FEC1
base_addr = FEC_BASE_ADDR_FEC1;
#endif
// ---- FEC state ----
#ifdef CONFIG_COLDFIRE
{
// Receive the base address
unsigned long base_addr;
#if (EDRV_USED_ETH_CTRL == 0)
// Set the base address of FEC0
base_addr = FEC_BASE_ADDR_FEC0;
#else
// Set the base address of FEC1
base_addr = FEC_BASE_ADDR_FEC1;
#endif
nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
"FEC_ECR = 0x%08X FEC_EIR = 0x%08X FEC_EIMR = 0x%08X\nFEC_TCR = 0x%08X FECTFSR = 0x%08X FECRFSR = 0x%08X\n",
FEC_ECR(base_addr), FEC_EIR(base_addr), FEC_EIMR(base_addr), FEC_TCR(base_addr), FEC_FECTFSR(base_addr), FEC_FECRFSR(base_addr));
}
#endif
nSize += snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize,
"FEC_ECR = 0x%08X FEC_EIR = 0x%08X FEC_EIMR = 0x%08X\nFEC_TCR = 0x%08X FECTFSR = 0x%08X FECRFSR = 0x%08X\n",
FEC_ECR(base_addr), FEC_EIR(base_addr),
FEC_EIMR(base_addr), FEC_TCR(base_addr),
FEC_FECTFSR(base_addr),
FEC_FECRFSR(base_addr));
}
#endif
// ---- DBG: TracePoints ----
#ifdef _DBG_TRACE_POINTS_
{
int nNum;
// ---- DBG: TracePoints ----
#ifdef _DBG_TRACE_POINTS_
{
int nNum;
nSize += snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize,
"DbgTracePoints:\n");
for (nNum = 0;
nNum < (sizeof(aatmDbgTracePoint_l) / sizeof(atomic_t));
nNum++) {
nSize +=
snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize,
" TracePoint[%2d]: %d\n", (int)nNum,
atomic_read(&aatmDbgTracePoint_l[nNum]));
}
nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
"DbgTracePoints:\n");
for (nNum=0; nNum<(sizeof(aatmDbgTracePoint_l)/sizeof(atomic_t)); nNum++)
{
nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
" TracePoint[%2d]: %d\n", (int)nNum,
atomic_read(&aatmDbgTracePoint_l[nNum]));
}
nSize += snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize,
"DbgTraceValues:\n");
for (nNum = 0; nNum < DBG_TRACE_VALUES; nNum++) {
if (nNum == uiDbgTraceValuePos_l) { // next value will be stored at that position
nSize +=
snprintf(pcBuffer_p + nSize,
nBufferSize_p - nSize, "*%08lX",
adwDbgTraceValue_l[nNum]);
} else {
nSize +=
snprintf(pcBuffer_p + nSize,
nBufferSize_p - nSize, " %08lX",
adwDbgTraceValue_l[nNum]);
}
if ((nNum & 0x00000007) == 0x00000007) { // 8 values printed -> end of line reached
nSize +=
snprintf(pcBuffer_p + nSize,
nBufferSize_p - nSize, "\n");
}
}
if ((nNum & 0x00000007) != 0x00000007) { // number of values printed is not a multiple of 8 -> print new line
nSize +=
snprintf(pcBuffer_p + nSize, nBufferSize_p - nSize,
"\n");
}
}
#endif
nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
"DbgTraceValues:\n");
for (nNum=0; nNum<DBG_TRACE_VALUES; nNum++)
{
if (nNum == uiDbgTraceValuePos_l)
{ // next value will be stored at that position
nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
"*%08lX", adwDbgTraceValue_l[nNum]);
}
else
{
nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
" %08lX", adwDbgTraceValue_l[nNum]);
}
if ((nNum & 0x00000007) == 0x00000007)
{ // 8 values printed -> end of line reached
nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
"\n");
}
}
if ((nNum & 0x00000007) != 0x00000007)
{ // number of values printed is not a multiple of 8 -> print new line
nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
"\n");
}
}
#endif
Eof = 1;
goto Exit;
Exit:
Eof = 1;
goto Exit;
*pEof_p = Eof;
Exit:
*pEof_p = Eof;
return (nSize);
return (nSize);
}
//---------------------------------------------------------------------------
// Write function for PROC-FS write access
//---------------------------------------------------------------------------
static int EplLinProcWrite(struct file *file, const char __user *buffer, unsigned long count, void *data)
static int EplLinProcWrite(struct file *file, const char __user * buffer,
unsigned long count, void *data)
{
char abBuffer[count + 1];
int iErr;
int iVal = 0;
tEplNmtEvent NmtEvent;
char abBuffer[count + 1];
int iErr;
int iVal = 0;
tEplNmtEvent NmtEvent;
if (count > 0)
{
iErr = copy_from_user(abBuffer, buffer, count);
if (iErr != 0)
{
return count;
}
abBuffer[count] = '\0';
if (count > 0) {
iErr = copy_from_user(abBuffer, buffer, count);
if (iErr != 0) {
return count;
}
abBuffer[count] = '\0';
iErr = sscanf(abBuffer, "%i", &iVal);
}
if ((iVal <= 0) || (iVal > 0x2F))
{
NmtEvent = kEplNmtEventSwReset;
}
else
{
NmtEvent = (tEplNmtEvent) iVal;
}
// execute specified NMT command on write access of /proc/epl
EplNmtuNmtEvent(NmtEvent);
iErr = sscanf(abBuffer, "%i", &iVal);
}
if ((iVal <= 0) || (iVal > 0x2F)) {
NmtEvent = kEplNmtEventSwReset;
} else {
NmtEvent = (tEplNmtEvent) iVal;
}
// execute specified NMT command on write access of /proc/epl
EplNmtuNmtEvent(NmtEvent);
return count;
return count;
}