Staging: add epl stack

This is the openPOWERLINK network stack from systec electronic.

It's a bit messed up as there is a driver mixed into the
middle of it, lots of work needs to be done to unwind the
different portions to make it sane.

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:
Daniel Krueger 2008-12-19 11:41:57 -08:00 committed by Greg Kroah-Hartman
parent 37bcd24b84
commit 9d7164cfdb
112 changed files with 56534 additions and 0 deletions

View file

@ -91,5 +91,7 @@ source "drivers/staging/mimio/Kconfig"
source "drivers/staging/frontier/Kconfig"
source "drivers/staging/epl/Kconfig"
endif # !STAGING_EXCLUDE_BUILD
endif # STAGING

View file

@ -28,3 +28,4 @@ obj-$(CONFIG_RTL8187SE) += rtl8187se/
obj-$(CONFIG_USB_RSPI) += rspiusb/
obj-$(CONFIG_INPUT_MIMIO) += mimio/
obj-$(CONFIG_TRANZPORT) += frontier/
obj-$(CONFIG_EPL) += epl/

View file

@ -0,0 +1,443 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: header file for benchmarking
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: Benchmark.h,v $
$Author: D.Krueger $
$Revision: 1.5 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
...
-------------------------------------------------------------------------
Revision History:
2006/08/16 d.k.: start of implementation
****************************************************************************/
#ifndef _BENCHMARK_H_
#define _BENCHMARK_H_
#include "global.h"
#if (TARGET_SYSTEM == _NO_OS_) && (DEV_SYSTEM == _DEV_GNU_CF548X_)
#include "common.h"
#elif (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
// #include <linux/config.h>
#include <linux/kernel.h>
#ifdef CONFIG_COLDFIRE
#include <asm/coldfire.h>
#include <asm/m5485gpio.h>
#define BENCHMARK_SET(x) MCF_GPIO_PODR_PCIBG |= (1 << (x)) // (x+1)
#define BENCHMARK_RESET(x) MCF_GPIO_PODR_PCIBG &= ~(1 << (x)) // (x+1)
#define BENCHMARK_TOGGLE(x) MCF_GPIO_PODR_PCIBR ^= (1 << (x - 5))
#else
#undef BENCHMARK_MODULES
#define BENCHMARK_MODULES 0x00000000
#endif
#else
// disable Benchmarking
#undef BENCHMARK_MODULES
#define BENCHMARK_MODULES 0x00000000
#endif
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
#ifndef BENCHMARK_MODULES
#define BENCHMARK_MODULES 0x00000000
#endif
#define BENCHMARK_MOD_01 0x00000001
#define BENCHMARK_MOD_02 0x00000002
#define BENCHMARK_MOD_03 0x00000004
#define BENCHMARK_MOD_04 0x00000008
#define BENCHMARK_MOD_05 0x00000010
#define BENCHMARK_MOD_06 0x00000020
#define BENCHMARK_MOD_07 0x00000040
#define BENCHMARK_MOD_08 0x00000080
#define BENCHMARK_MOD_09 0x00000100
#define BENCHMARK_MOD_10 0x00000200
#define BENCHMARK_MOD_11 0x00000400
#define BENCHMARK_MOD_12 0x00000800
#define BENCHMARK_MOD_13 0x00001000
#define BENCHMARK_MOD_14 0x00002000
#define BENCHMARK_MOD_15 0x00004000
#define BENCHMARK_MOD_16 0x00008000
#define BENCHMARK_MOD_17 0x00010000
#define BENCHMARK_MOD_18 0x00020000
#define BENCHMARK_MOD_19 0x00040000
#define BENCHMARK_MOD_20 0x00080000
#define BENCHMARK_MOD_21 0x00100000
#define BENCHMARK_MOD_22 0x00200000
#define BENCHMARK_MOD_23 0x00400000
#define BENCHMARK_MOD_24 0x00800000
#define BENCHMARK_MOD_25 0x01000000
#define BENCHMARK_MOD_26 0x02000000
#define BENCHMARK_MOD_27 0x04000000
#define BENCHMARK_MOD_28 0x08000000
#define BENCHMARK_MOD_29 0x10000000
#define BENCHMARK_MOD_30 0x20000000
#define BENCHMARK_MOD_31 0x40000000
#define BENCHMARK_MOD_32 0x80000000
#if (BENCHMARK_MODULES & BENCHMARK_MOD_01)
#define BENCHMARK_MOD_01_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_01_RESET(x) BENCHMARK_RESET(x)
#define BENCHMARK_MOD_01_TOGGLE(x) BENCHMARK_TOGGLE(x)
#else
#define BENCHMARK_MOD_01_SET(x)
#define BENCHMARK_MOD_01_RESET(x)
#define BENCHMARK_MOD_01_TOGGLE(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_02)
#define BENCHMARK_MOD_02_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_02_RESET(x) BENCHMARK_RESET(x)
#define BENCHMARK_MOD_02_TOGGLE(x) BENCHMARK_TOGGLE(x)
#else
#define BENCHMARK_MOD_02_SET(x)
#define BENCHMARK_MOD_02_RESET(x)
#define BENCHMARK_MOD_02_TOGGLE(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_03)
#define BENCHMARK_MOD_03_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_03_RESET(x) BENCHMARK_RESET(x)
#define BENCHMARK_MOD_03_TOGGLE(x) BENCHMARK_TOGGLE(x)
#else
#define BENCHMARK_MOD_03_SET(x)
#define BENCHMARK_MOD_03_RESET(x)
#define BENCHMARK_MOD_03_TOGGLE(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_04)
#define BENCHMARK_MOD_04_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_04_RESET(x) BENCHMARK_RESET(x)
#define BENCHMARK_MOD_04_TOGGLE(x) BENCHMARK_TOGGLE(x)
#else
#define BENCHMARK_MOD_04_SET(x)
#define BENCHMARK_MOD_04_RESET(x)
#define BENCHMARK_MOD_04_TOGGLE(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_05)
#define BENCHMARK_MOD_05_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_05_RESET(x) BENCHMARK_RESET(x)
#define BENCHMARK_MOD_05_TOGGLE(x) BENCHMARK_TOGGLE(x)
#else
#define BENCHMARK_MOD_05_SET(x)
#define BENCHMARK_MOD_05_RESET(x)
#define BENCHMARK_MOD_05_TOGGLE(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_06)
#define BENCHMARK_MOD_06_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_06_RESET(x) BENCHMARK_RESET(x)
#define BENCHMARK_MOD_06_TOGGLE(x) BENCHMARK_TOGGLE(x)
#else
#define BENCHMARK_MOD_06_SET(x)
#define BENCHMARK_MOD_06_RESET(x)
#define BENCHMARK_MOD_06_TOGGLE(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_07)
#define BENCHMARK_MOD_07_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_07_RESET(x) BENCHMARK_RESET(x)
#define BENCHMARK_MOD_07_TOGGLE(x) BENCHMARK_TOGGLE(x)
#else
#define BENCHMARK_MOD_07_SET(x)
#define BENCHMARK_MOD_07_RESET(x)
#define BENCHMARK_MOD_07_TOGGLE(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_08)
#define BENCHMARK_MOD_08_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_08_RESET(x) BENCHMARK_RESET(x)
#define BENCHMARK_MOD_08_TOGGLE(x) BENCHMARK_TOGGLE(x)
#else
#define BENCHMARK_MOD_08_SET(x)
#define BENCHMARK_MOD_08_RESET(x)
#define BENCHMARK_MOD_08_TOGGLE(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_09)
#define BENCHMARK_MOD_09_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_09_RESET(x) BENCHMARK_RESET(x)
#define BENCHMARK_MOD_09_TOGGLE(x) BENCHMARK_TOGGLE(x)
#else
#define BENCHMARK_MOD_09_SET(x)
#define BENCHMARK_MOD_09_RESET(x)
#define BENCHMARK_MOD_09_TOGGLE(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_10)
#define BENCHMARK_MOD_10_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_10_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_10_SET(x)
#define BENCHMARK_MOD_10_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_11)
#define BENCHMARK_MOD_11_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_11_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_11_SET(x)
#define BENCHMARK_MOD_11_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_12)
#define BENCHMARK_MOD_12_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_12_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_12_SET(x)
#define BENCHMARK_MOD_12_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_13)
#define BENCHMARK_MOD_13_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_13_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_13_SET(x)
#define BENCHMARK_MOD_13_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_14)
#define BENCHMARK_MOD_14_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_14_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_14_SET(x)
#define BENCHMARK_MOD_14_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_15)
#define BENCHMARK_MOD_15_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_15_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_15_SET(x)
#define BENCHMARK_MOD_15_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_16)
#define BENCHMARK_MOD_16_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_16_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_16_SET(x)
#define BENCHMARK_MOD_16_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_17)
#define BENCHMARK_MOD_17_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_17_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_17_SET(x)
#define BENCHMARK_MOD_17_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_18)
#define BENCHMARK_MOD_18_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_18_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_18_SET(x)
#define BENCHMARK_MOD_18_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_19)
#define BENCHMARK_MOD_19_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_19_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_19_SET(x)
#define BENCHMARK_MOD_19_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_20)
#define BENCHMARK_MOD_20_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_20_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_20_SET(x)
#define BENCHMARK_MOD_20_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_21)
#define BENCHMARK_MOD_21_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_21_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_21_SET(x)
#define BENCHMARK_MOD_21_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_22)
#define BENCHMARK_MOD_22_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_22_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_22_SET(x)
#define BENCHMARK_MOD_22_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_23)
#define BENCHMARK_MOD_23_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_23_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_23_SET(x)
#define BENCHMARK_MOD_23_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_24)
#define BENCHMARK_MOD_24_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_24_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_24_SET(x)
#define BENCHMARK_MOD_24_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_25)
#define BENCHMARK_MOD_25_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_25_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_25_SET(x)
#define BENCHMARK_MOD_25_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_26)
#define BENCHMARK_MOD_26_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_26_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_26_SET(x)
#define BENCHMARK_MOD_26_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_27)
#define BENCHMARK_MOD_27_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_27_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_27_SET(x)
#define BENCHMARK_MOD_27_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_28)
#define BENCHMARK_MOD_28_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_28_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_28_SET(x)
#define BENCHMARK_MOD_28_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_29)
#define BENCHMARK_MOD_29_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_29_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_29_SET(x)
#define BENCHMARK_MOD_29_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_30)
#define BENCHMARK_MOD_30_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_30_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_30_SET(x)
#define BENCHMARK_MOD_30_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_31)
#define BENCHMARK_MOD_31_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_31_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_31_SET(x)
#define BENCHMARK_MOD_31_RESET(x)
#endif
#if (BENCHMARK_MODULES & BENCHMARK_MOD_32)
#define BENCHMARK_MOD_32_SET(x) BENCHMARK_SET(x)
#define BENCHMARK_MOD_32_RESET(x) BENCHMARK_RESET(x)
#else
#define BENCHMARK_MOD_32_SET(x)
#define BENCHMARK_MOD_32_RESET(x)
#endif
//---------------------------------------------------------------------------
// modul global types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
#endif // _BENCHMARK_H_

750
drivers/staging/epl/Debug.h Normal file
View file

@ -0,0 +1,750 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: Debug interface
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: Debug.h,v $
$Author: D.Krueger $
$Revision: 1.4 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
...
-------------------------------------------------------------------------
Revision History:
****************************************************************************/
#ifndef _DEBUG_H_
#define _DEBUG_H_
#include "global.h"
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// global const defines
//---------------------------------------------------------------------------
// These definitions are important for level-debug traces.
// A macro DEBUG_GLB_LVL() defines the current debug-level using following bis.
// If the corresponding bit is set then trace message will be printed out
// (only if NDEBUG is not defined). The upper debug-levels are reserved for
// the debug-levels ALWAYS, ERROR and ASSERT.
#define DEBUG_LVL_01 0x00000001
#define DEBUG_LVL_02 0x00000002
#define DEBUG_LVL_03 0x00000004
#define DEBUG_LVL_04 0x00000008
#define DEBUG_LVL_05 0x00000010
#define DEBUG_LVL_06 0x00000020
#define DEBUG_LVL_07 0x00000040
#define DEBUG_LVL_08 0x00000080
#define DEBUG_LVL_09 0x00000100
#define DEBUG_LVL_10 0x00000200
#define DEBUG_LVL_11 0x00000400
#define DEBUG_LVL_12 0x00000800
#define DEBUG_LVL_13 0x00001000
#define DEBUG_LVL_14 0x00002000
#define DEBUG_LVL_15 0x00004000
#define DEBUG_LVL_16 0x00008000
#define DEBUG_LVL_17 0x00010000
#define DEBUG_LVL_18 0x00020000
#define DEBUG_LVL_19 0x00040000
#define DEBUG_LVL_20 0x00080000
#define DEBUG_LVL_21 0x00100000
#define DEBUG_LVL_22 0x00200000
#define DEBUG_LVL_23 0x00400000
#define DEBUG_LVL_24 0x00800000
#define DEBUG_LVL_25 0x01000000
#define DEBUG_LVL_26 0x02000000
#define DEBUG_LVL_27 0x04000000
#define DEBUG_LVL_28 0x08000000
#define DEBUG_LVL_29 0x10000000
#define DEBUG_LVL_ASSERT 0x20000000
#define DEBUG_LVL_ERROR 0x40000000
#define DEBUG_LVL_ALWAYS 0x80000000
//---------------------------------------------------------------------------
// global types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// global vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// global function prototypes
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// global macros
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// this macro defines a version string
#define MAKE_VERSION_STRING(product,appname,verstr,author) \
"§prd§:" product ",§app§:" appname ",§ver§:" verstr ",§dat§:" __DATE__ ",§aut§:" author
//---------------------------------------------------------------------------
// this macro defines a build info string (e.g. for using in printf())
#define DEBUG_MAKE_BUILD_INFO(prefix,product,prodid,descr,verstr,author) "\n" \
prefix "***************************************************\n" \
prefix "Project: " product ", " prodid "\n" \
prefix "Descript.: " descr "\n" \
prefix "Author: " author "\n" \
prefix "Date: " __DATE__ "\n" \
prefix "Version: " verstr "\n" \
prefix "***************************************************\n\n"
//---------------------------------------------------------------------------
// The default debug-level is: ERROR and ALWAYS.
// You can define an other debug-level in project settings.
#ifndef DEF_DEBUG_LVL
#define DEF_DEBUG_LVL (DEBUG_LVL_ALWAYS | DEBUG_LVL_ERROR)
#endif
#ifndef DEBUG_GLB_LVL
#define DEBUG_GLB_LVL() (DEF_DEBUG_LVL)
#endif
//---------------------------------------------------------------------------
#if (DEV_SYSTEM == _DEV_WIN32_) && defined (TRACE_MSG)
// For WIN32 the macro DEBUG_TRACE0 can be defined as function call TraceLvl()
// or as macro TRACE().
//
// Here the parameter 'lvl' can be used with more than one
// debug-level (using OR).
//
// Example: DEBUG_TRACE1(DEBUG_LVL_30 | DEBUG_LVL_02, "Hello %d", bCount);
#define DEBUG_TRACE0(lvl,str) TraceLvl((lvl),str)
#define DEBUG_TRACE1(lvl,str,p1) TraceLvl((lvl),str,p1)
#define DEBUG_TRACE2(lvl,str,p1,p2) TraceLvl((lvl),str,p1,p2)
#define DEBUG_TRACE3(lvl,str,p1,p2,p3) TraceLvl((lvl),str,p1,p2,p3)
#define DEBUG_TRACE4(lvl,str,p1,p2,p3,p4) TraceLvl((lvl),str,p1,p2,p3,p4)
#define DEBUG_GLB_LVL() dwDebugLevel_g
#else
// At microcontrollers we do reduce the memory usage by deleting DEBUG_TRACE-lines
// (compiler does delete the lines).
//
// Here the parameter 'lvl' can only be used with one debug-level.
//
// Example: DEBUG_TRACE1(DEBUG_LVL_ERROR, "error code %d", dwRet);
#if (DEBUG_GLB_LVL() & DEBUG_LVL_ALWAYS)
#define DEBUG_LVL_ALWAYS_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_ALWAYS_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_ALWAYS_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_ALWAYS_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_ALWAYS_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_ALWAYS_TRACE0(str)
#define DEBUG_LVL_ALWAYS_TRACE1(str,p1)
#define DEBUG_LVL_ALWAYS_TRACE2(str,p1,p2)
#define DEBUG_LVL_ALWAYS_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_ALWAYS_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_ERROR)
#define DEBUG_LVL_ERROR_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_ERROR_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_ERROR_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_ERROR_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_ERROR_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_ERROR_TRACE0(str)
#define DEBUG_LVL_ERROR_TRACE1(str,p1)
#define DEBUG_LVL_ERROR_TRACE2(str,p1,p2)
#define DEBUG_LVL_ERROR_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_ERROR_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_ASSERT)
#define DEBUG_LVL_ASSERT_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_ASSERT_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_ASSERT_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_ASSERT_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_ASSERT_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_ASSERT_TRACE0(str)
#define DEBUG_LVL_ASSERT_TRACE1(str,p1)
#define DEBUG_LVL_ASSERT_TRACE2(str,p1,p2)
#define DEBUG_LVL_ASSERT_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_ASSERT_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_29)
#define DEBUG_LVL_29_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_29_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_29_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_29_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_29_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_29_TRACE0(str)
#define DEBUG_LVL_29_TRACE1(str,p1)
#define DEBUG_LVL_29_TRACE2(str,p1,p2)
#define DEBUG_LVL_29_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_29_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_28)
#define DEBUG_LVL_28_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_28_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_28_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_28_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_28_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_28_TRACE0(str)
#define DEBUG_LVL_28_TRACE1(str,p1)
#define DEBUG_LVL_28_TRACE2(str,p1,p2)
#define DEBUG_LVL_28_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_28_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_27)
#define DEBUG_LVL_27_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_27_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_27_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_27_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_27_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_27_TRACE0(str)
#define DEBUG_LVL_27_TRACE1(str,p1)
#define DEBUG_LVL_27_TRACE2(str,p1,p2)
#define DEBUG_LVL_27_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_27_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_26)
#define DEBUG_LVL_26_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_26_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_26_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_26_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_26_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_26_TRACE0(str)
#define DEBUG_LVL_26_TRACE1(str,p1)
#define DEBUG_LVL_26_TRACE2(str,p1,p2)
#define DEBUG_LVL_26_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_26_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_25)
#define DEBUG_LVL_25_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_25_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_25_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_25_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_25_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_25_TRACE0(str)
#define DEBUG_LVL_25_TRACE1(str,p1)
#define DEBUG_LVL_25_TRACE2(str,p1,p2)
#define DEBUG_LVL_25_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_25_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_24)
#define DEBUG_LVL_24_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_24_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_24_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_24_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_24_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_24_TRACE0(str)
#define DEBUG_LVL_24_TRACE1(str,p1)
#define DEBUG_LVL_24_TRACE2(str,p1,p2)
#define DEBUG_LVL_24_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_24_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_23)
#define DEBUG_LVL_23_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_23_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_23_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_23_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_23_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_23_TRACE0(str)
#define DEBUG_LVL_23_TRACE1(str,p1)
#define DEBUG_LVL_23_TRACE2(str,p1,p2)
#define DEBUG_LVL_23_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_23_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_22)
#define DEBUG_LVL_22_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_22_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_22_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_22_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_22_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_22_TRACE0(str)
#define DEBUG_LVL_22_TRACE1(str,p1)
#define DEBUG_LVL_22_TRACE2(str,p1,p2)
#define DEBUG_LVL_22_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_22_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_21)
#define DEBUG_LVL_21_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_21_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_21_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_21_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_21_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_21_TRACE0(str)
#define DEBUG_LVL_21_TRACE1(str,p1)
#define DEBUG_LVL_21_TRACE2(str,p1,p2)
#define DEBUG_LVL_21_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_21_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_20)
#define DEBUG_LVL_20_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_20_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_20_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_20_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_20_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_20_TRACE0(str)
#define DEBUG_LVL_20_TRACE1(str,p1)
#define DEBUG_LVL_20_TRACE2(str,p1,p2)
#define DEBUG_LVL_20_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_20_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_19)
#define DEBUG_LVL_19_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_19_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_19_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_19_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_19_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_19_TRACE0(str)
#define DEBUG_LVL_19_TRACE1(str,p1)
#define DEBUG_LVL_19_TRACE2(str,p1,p2)
#define DEBUG_LVL_19_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_19_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_18)
#define DEBUG_LVL_18_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_18_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_18_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_18_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_18_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_18_TRACE0(str)
#define DEBUG_LVL_18_TRACE1(str,p1)
#define DEBUG_LVL_18_TRACE2(str,p1,p2)
#define DEBUG_LVL_18_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_18_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_17)
#define DEBUG_LVL_17_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_17_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_17_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_17_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_17_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_17_TRACE0(str)
#define DEBUG_LVL_17_TRACE1(str,p1)
#define DEBUG_LVL_17_TRACE2(str,p1,p2)
#define DEBUG_LVL_17_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_17_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_16)
#define DEBUG_LVL_16_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_16_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_16_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_16_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_16_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_16_TRACE0(str)
#define DEBUG_LVL_16_TRACE1(str,p1)
#define DEBUG_LVL_16_TRACE2(str,p1,p2)
#define DEBUG_LVL_16_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_16_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_15)
#define DEBUG_LVL_15_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_15_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_15_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_15_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_15_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_15_TRACE0(str)
#define DEBUG_LVL_15_TRACE1(str,p1)
#define DEBUG_LVL_15_TRACE2(str,p1,p2)
#define DEBUG_LVL_15_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_15_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_14)
#define DEBUG_LVL_14_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_14_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_14_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_14_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_14_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_14_TRACE0(str)
#define DEBUG_LVL_14_TRACE1(str,p1)
#define DEBUG_LVL_14_TRACE2(str,p1,p2)
#define DEBUG_LVL_14_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_14_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_13)
#define DEBUG_LVL_13_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_13_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_13_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_13_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_13_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_13_TRACE0(str)
#define DEBUG_LVL_13_TRACE1(str,p1)
#define DEBUG_LVL_13_TRACE2(str,p1,p2)
#define DEBUG_LVL_13_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_13_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_12)
#define DEBUG_LVL_12_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_12_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_12_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_12_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_12_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_12_TRACE0(str)
#define DEBUG_LVL_12_TRACE1(str,p1)
#define DEBUG_LVL_12_TRACE2(str,p1,p2)
#define DEBUG_LVL_12_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_12_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_11)
#define DEBUG_LVL_11_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_11_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_11_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_11_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_11_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_11_TRACE0(str)
#define DEBUG_LVL_11_TRACE1(str,p1)
#define DEBUG_LVL_11_TRACE2(str,p1,p2)
#define DEBUG_LVL_11_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_11_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_10)
#define DEBUG_LVL_10_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_10_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_10_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_10_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_10_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_10_TRACE0(str)
#define DEBUG_LVL_10_TRACE1(str,p1)
#define DEBUG_LVL_10_TRACE2(str,p1,p2)
#define DEBUG_LVL_10_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_10_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_09)
#define DEBUG_LVL_09_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_09_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_09_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_09_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_09_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_09_TRACE0(str)
#define DEBUG_LVL_09_TRACE1(str,p1)
#define DEBUG_LVL_09_TRACE2(str,p1,p2)
#define DEBUG_LVL_09_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_09_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_08)
#define DEBUG_LVL_08_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_08_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_08_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_08_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_08_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_08_TRACE0(str)
#define DEBUG_LVL_08_TRACE1(str,p1)
#define DEBUG_LVL_08_TRACE2(str,p1,p2)
#define DEBUG_LVL_08_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_08_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_07)
#define DEBUG_LVL_07_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_07_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_07_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_07_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_07_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_07_TRACE0(str)
#define DEBUG_LVL_07_TRACE1(str,p1)
#define DEBUG_LVL_07_TRACE2(str,p1,p2)
#define DEBUG_LVL_07_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_07_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_06)
#define DEBUG_LVL_06_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_06_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_06_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_06_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_06_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_06_TRACE0(str)
#define DEBUG_LVL_06_TRACE1(str,p1)
#define DEBUG_LVL_06_TRACE2(str,p1,p2)
#define DEBUG_LVL_06_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_06_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_05)
#define DEBUG_LVL_05_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_05_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_05_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_05_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_05_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_05_TRACE0(str)
#define DEBUG_LVL_05_TRACE1(str,p1)
#define DEBUG_LVL_05_TRACE2(str,p1,p2)
#define DEBUG_LVL_05_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_05_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_04)
#define DEBUG_LVL_04_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_04_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_04_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_04_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_04_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_04_TRACE0(str)
#define DEBUG_LVL_04_TRACE1(str,p1)
#define DEBUG_LVL_04_TRACE2(str,p1,p2)
#define DEBUG_LVL_04_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_04_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_03)
#define DEBUG_LVL_03_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_03_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_03_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_03_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_03_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_03_TRACE0(str)
#define DEBUG_LVL_03_TRACE1(str,p1)
#define DEBUG_LVL_03_TRACE2(str,p1,p2)
#define DEBUG_LVL_03_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_03_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_02)
#define DEBUG_LVL_02_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_02_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_02_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_02_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_02_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_02_TRACE0(str)
#define DEBUG_LVL_02_TRACE1(str,p1)
#define DEBUG_LVL_02_TRACE2(str,p1,p2)
#define DEBUG_LVL_02_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_02_TRACE4(str,p1,p2,p3,p4)
#endif
#if (DEBUG_GLB_LVL() & DEBUG_LVL_01)
#define DEBUG_LVL_01_TRACE0(str) TRACE0(str)
#define DEBUG_LVL_01_TRACE1(str,p1) TRACE1(str,p1)
#define DEBUG_LVL_01_TRACE2(str,p1,p2) TRACE2(str,p1,p2)
#define DEBUG_LVL_01_TRACE3(str,p1,p2,p3) TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_01_TRACE4(str,p1,p2,p3,p4) TRACE4(str,p1,p2,p3,p4)
#else
#define DEBUG_LVL_01_TRACE0(str)
#define DEBUG_LVL_01_TRACE1(str,p1)
#define DEBUG_LVL_01_TRACE2(str,p1,p2)
#define DEBUG_LVL_01_TRACE3(str,p1,p2,p3)
#define DEBUG_LVL_01_TRACE4(str,p1,p2,p3,p4)
#endif
#define DEBUG_TRACE0(lvl,str) lvl##_TRACE0(str)
#define DEBUG_TRACE1(lvl,str,p1) lvl##_TRACE1(str,p1)
#define DEBUG_TRACE2(lvl,str,p1,p2) lvl##_TRACE2(str,p1,p2)
#define DEBUG_TRACE3(lvl,str,p1,p2,p3) lvl##_TRACE3(str,p1,p2,p3)
#define DEBUG_TRACE4(lvl,str,p1,p2,p3,p4) lvl##_TRACE4(str,p1,p2,p3,p4)
#endif
//---------------------------------------------------------------------------
// The macro DEBUG_DUMP_DATA() can be used with the same debug-levels to dump
// out data bytes. Function DumpData() has to be included.
// NOTE: DUMP_DATA has to be defined in project settings.
#if (!defined (NDEBUG) && defined (DUMP_DATA)) || (DEV_SYSTEM == _DEV_WIN32_)
#ifdef __cplusplus
extern "C"
{
#endif
void DumpData (char* szStr_p, BYTE MEM* pbData_p, WORD wSize_p);
#ifdef __cplusplus
} // von extern "C"
#endif
#define DEBUG_DUMP_DATA(lvl,str,ptr,siz) if ((DEBUG_GLB_LVL() & (lvl))==(lvl)) \
DumpData (str, (BYTE MEM*) (ptr), (WORD) (siz));
#else
#define DEBUG_DUMP_DATA(lvl,str,ptr,siz)
#endif
//---------------------------------------------------------------------------
// The macro DEBUG_ASSERT() can be used to print out an error string if the
// parametered expresion does not result TRUE.
// NOTE: If DEBUG_KEEP_ASSERT is defined, then DEBUG_ASSERT-line will not be
// deleted from compiler (in release version too).
#if !defined (NDEBUG) || defined (DEBUG_KEEP_ASSERT)
#if (DEV_SYSTEM == _DEV_WIN32_)
// For WIN32 process will be killed after closing message box.
#define DEBUG_ASSERT0(expr,str) if (!(expr ) && ((DEBUG_GLB_LVL() & DEBUG_LVL_ASSERT)!=0)) { \
MessageBox (NULL, \
"Assertion failed: line " __LINE__ " file " __FILE__ \
"\n -> " str "\n"); \
ExitProcess (-1); }
#define DEBUG_ASSERT1(expr,str,p1) if (!(expr ) && ((DEBUG_GLB_LVL() & DEBUG_LVL_ASSERT)!=0)) { \
MessageBox (NULL, \
"Assertion failed: line " __LINE__ " file " __FILE__ \
"\n -> " str "\n"); \
ExitProcess (-1); }
#else
// For microcontrollers process will be stopped using endless loop.
#define DEBUG_ASSERT0(expr,str) if (!(expr )) { \
DEBUG_LVL_ASSERT_TRACE3 ( \
"Assertion failed: line %d file '%s'\n" \
" -> '%s'\n", __LINE__, __FILE__, str); \
while (1); }
#define DEBUG_ASSERT1(expr,str,p1) if (!(expr )) { \
DEBUG_LVL_ASSERT_TRACE4 ( \
"Assertion failed: line %d file '%s'\n" \
" -> '%s'\n" \
" -> 0x%08lX\n", __LINE__, __FILE__, str, (DWORD) p1); \
while (1); }
#endif
#else
#define DEBUG_ASSERT0(expr,str)
#define DEBUG_ASSERT1(expr,str,p1)
#endif
//---------------------------------------------------------------------------
// The macro DEBUG_ONLY() implements code, if NDEBUG is not defined.
#if !defined (DEBUG_ONLY)
#if !defined (NDEBUG)
#define DEBUG_ONLY(expr) expr
#else
#define DEBUG_ONLY(expr)
#endif
#endif
#endif // _DEBUG_H_

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,126 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: interface for ethernetdriver
"fast ethernet controller" (FEC)
freescale coldfire MCF528x and compatible FEC
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EdrvFec.h,v $
$Author: D.Krueger $
$Revision: 1.3 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
Dev C++ and GNU-Compiler for m68k
-------------------------------------------------------------------------
Revision History:
2005/08/01 m.b.: start of implementation
****************************************************************************/
#ifndef _EDRVFEC_H_
#define _EDRVFEC_H_
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
// do this in config header
#define TARGET_HARDWARE TGTHW_SPLC_CF54
// base addresses
#if ((TARGET_HARDWARE & TGT_CPU_MASK_) == TGT_CPU_5282)
#elif ((TARGET_HARDWARE & TGT_CPU_MASK_) == TGT_CPU_5485)
#else
#error 'ERROR: Target was never implemented!'
#endif
//---------------------------------------------------------------------------
// types
//---------------------------------------------------------------------------
// Rx and Tx buffer descriptor format
typedef struct
{
WORD m_wStatus; // control / status --- used by edrv, do not change in application
WORD m_wLength; // transfer length
BYTE * m_pbData; // buffer address
} tBufferDescr;
#if ((TARGET_HARDWARE & TGT_CPU_MASK_) == TGT_CPU_5282)
#elif ((TARGET_HARDWARE & TGT_CPU_MASK_) == TGT_CPU_5485)
#endif
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#endif // #ifndef _EDRV_FEC_H_

View file

@ -0,0 +1,347 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: interface for ethernetdriver
"fast ethernet controller" (FEC)
freescale coldfire MCF528x and compatible FEC
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EdrvFec5282.h,v $
$Author: D.Krueger $
$Revision: 1.3 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
Dev C++ and GNU-Compiler for m68k
-------------------------------------------------------------------------
Revision History:
2005/08/01 m.b.: start of implementation
****************************************************************************/
#ifndef _EDRVFEC_H_
#define _EDRVFEC_H_
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
// base addresses
#define FEC0_ADDR 0x0000
#define FEC1_ADDR 0x0000 //tbd
// control / status registers
#define FEC_EIR 0x1004 // interrupt event register
#define FEC_EIMR 0x1008 // interrupt mask register
#define FEC_RDAR 0x1010 // receive descriptor active register
#define FEC_TDAR 0x1014 // transmit descriptor active register
#define FEC_ECR 0x1024 // ethernet control register
#define FEC_MMFR 0x1040 // MII data register
#define FEC_MSCR 0x1044 // MII speed register
#define FEC_MIBC 0x1064 // MIB control/status register
#define FEC_RCR 0x1084 // receive control register
#define FEC_TCR 0x10C4 // transmit control register
#define FEC_PALR 0x10E4 // physical address low register
#define FEC_PAUR 0x10E8 // physical address high + type register
#define FEC_OPD 0x10EC // opcode + pause register
#define FEC_IAUR 0x1118 // upper 32 bit of individual hash table
#define FEC_IALR 0x111C // lower 32 bit of individual hash table
#define FEC_GAUR 0x1120 // upper 32 bit of group hash table
#define FEC_GALR 0x1124 // lower 32 bit of group hash table
#define FEC_TFWR 0x1144 // transmit FIFO watermark
#define FEC_FRBR 0x114C // FIFO receive bound register
#define FEC_FRSR 0x1150 // FIFO receive FIFO start register
#define FEC_ERDSR 0x1180 // pointer to receive descriptor ring
#define FEC_ETDSR 0x1184 // pointer to transmit descriptor ring
#define FEC_EMRBR 0x1188 // maximum receive buffer size
// mib block counters memory map
#define FEC_RMON_T_DROP 0x1200 // count of frames not counted correctly
#define FEC_RMON_T_PACKETS 0x1204 // RMON tx packet count
#define FEC_RMON_T_BC_PKT 0x1208 // RMON tx broadcast packets
#define FEC_RMON_T_MC_PKT 0x120C // RMON tx multicast packets
#define FEC_RMON_T_CRC_ALIGN 0x1210 // RMON tx packets w CRC/align error
#define FEC_RMON_T_UNDERSIZE 0x1214 // RMON tx packets < 64 bytes, good CRC
#define FEC_RMON_T_OVERSIZE 0x1218 // RMON tx packets > MAX_FL bytes, good CRC
#define FEC_RMON_T_FRAG 0x121C // RMON tx packets < 64 bytes, bad CRC
#define FEC_RMON_T_JAB 0x1220 // RMON tx packets > MAX_FL bytes, bad CRC
#define FEC_RMON_T_COL 0x1224 // RMON tx collision count
#define FEC_RMON_T_P64 0x1228 // RMON tx 64 byte packets
#define FEC_RMON_T_P65TO127 0x122C // RMON tx 65 to 127 byte packets
#define FEC_RMON_T_P128TO255 0x1230 // RMON tx 128 to 255 byte packets
#define FEC_RMON_T_P256TO511 0x1234 // RMON tx 256 to 511 byte packets
#define FEC_RMON_T_P512TO1023 0x1238 // RMON tx 512 to 1023 byte packets
#define FEC_RMON_T_P1024TO2047 0x123C // RMON tx 1024 to 2047 byte packets
#define FEC_RMON_T_P_GTE2048 0x1240 // RMON tx w > 2048 bytes
#define FEC_RMON_T_OCTETS 0x1244 // RMON tx octets
#define FEC_IEEE_T_DROP 0x1248 // count of frames not counted correctly
#define FEC_IEEE_T_FRAME_OK 0x124C // frames transmitted OK
#define FEC_IEEE_T_1COL 0x1250 // frames transmitted with single collision
#define FEC_IEEE_T_MCOL 0x1254 // frames transmitted with multiple collisions
#define FEC_IEEE_T_DEF 0x1258 // frames transmitted after deferral delay
#define FEC_IEEE_T_LCOL 0x125C // frames transmitted with late collisions
#define FEC_IEEE_T_EXCOL 0x1260 // frames transmitted with excessive collisions
#define FEC_IEEE_T_MACERR 0x1264 // frames transmitted with tx-FIFO underrun
#define FEC_IEEE_T_CSERR 0x1268 // frames transmitted with carrier sense error
#define FEC_IEEE_T_SQE 0x126C // frames transmitted with SQE error
#define FEC_IEEE_T_FDXFC 0x1270 // flow control pause frames transmitted
#define FEC_IEEE_T_OCTETS_OK 0x1274 // octet count for frames transmitted w/o error
#define FEC_RMON_R_PACKETS 0x1284 // RMON rx packet count
#define FEC_RMON_R_BC_PKT 0x1288 // RMON rx broadcast packets
#define FEC_RMON_R_MC_PKT 0x128C // RMON rx multicast packets
#define FEC_RMON_R_CRC_ALIGN 0x1290 // RMON rx packets w CRC/align error
#define FEC_RMON_R_UNDERSIZE 0x1294 // RMON rx packets < 64 bytes, good CRC
#define FEC_RMON_R_OVERSIZE 0x1298 // RMON rx packets > MAX_FL bytes, good CRC
#define FEC_RMON_R_FRAG 0x129C // RMON rx packets < 64 bytes, bad CRC
#define FEC_RMON_R_JAB 0x12A0 // RMON rx packets > MAX_FL bytes, bad CRC
#define FEC_RMON_R_RESVD_0 0x12A4 //
#define FEC_RMON_R_P64 0x12A8 // RMON rx 64 byte packets
#define FEC_RMON_R_P65T0127 0x12AC // RMON rx 65 to 127 byte packets
#define FEC_RMON_R_P128TO255 0x12B0 // RMON rx 128 to 255 byte packets
#define FEC_RMON_R_P256TO511 0x12B4 // RMON rx 256 to 511 byte packets
#define FEC_RMON_R_P512TO1023 0x12B8 // RMON rx 512 to 1023 byte packets
#define FEC_RMON_R_P1024TO2047 0x12BC // RMON rx 1024 to 2047 byte packets
#define FEC_RMON_R_GTE2048 0x12C0 // RMON rx w > 2048 bytes
#define FEC_RMON_R_OCTETS 0x12C4 // RMON rx octets
#define FEC_IEEE_R_DROP 0x12C8 // count of frames not counted correctly
#define FEC_IEEE_R_FRAME_OK 0x12CC // frames received OK
#define FEC_IEEE_R_CRC 0x12D0 // frames received with CRC error
#define FEC_IEEE_R_ALIGN 0x12D4 // frames received with alignment error
#define FEC_IEEE_R_MACERR 0x12D8 // receive FIFO overflow count
#define FEC_IEEE_R_FDXFC 0x12DC // flow control pause frames received
#define FEC_IEEE_R_OCTETS_OK 0x12E0 // octet count for frames rcvd w/o error
// register bit definitions and macros
#define FEC_EIR_UN (0x00080000)
#define FEC_EIR_RL (0x00100000)
#define FEC_EIR_LC (0x00200000)
#define FEC_EIR_EBERR (0x00400000)
#define FEC_EIR_MII (0x00800000)
#define FEC_EIR_RXB (0x01000000)
#define FEC_EIR_RXF (0x02000000)
#define FEC_EIR_TXB (0x04000000)
#define FEC_EIR_TXF (0x08000000)
#define FEC_EIR_GRA (0x10000000)
#define FEC_EIR_BABT (0x20000000)
#define FEC_EIR_BABR (0x40000000)
#define FEC_EIR_HBERR (0x80000000)
#define FEC_EIMR_UN (0x00080000)
#define FEC_EIMR_RL (0x00100000)
#define FEC_EIMR_LC (0x00200000)
#define FEC_EIMR_EBERR (0x00400000)
#define FEC_EIMR_MII (0x00800000)
#define FEC_EIMR_RXB (0x01000000)
#define FEC_EIMR_RXF (0x02000000)
#define FEC_EIMR_TXB (0x04000000)
#define FEC_EIMR_TXF (0x08000000)
#define FEC_EIMR_GRA (0x10000000)
#define FEC_EIMR_BABT (0x20000000)
#define FEC_EIMR_BABR (0x40000000)
#define FEC_EIMR_HBERR (0x80000000)
#define FEC_RDAR_R_DES_ACTIVE (0x01000000)
#define FEC_TDAR_X_DES_ACTIVE (0x01000000)
#define FEC_ECR_RESET (0x00000001)
#define FEC_ECR_ETHER_EN (0x00000002)
#define FEC_MMFR_DATA(x) (((x) & 0xFFFF))
#define FEC_MMFR_TA (0x00020000)
#define FEC_MMFR_RA(x) (((x) & 0x1F) << 18)
#define FEC_MMFR_PA(x) (((x) & 0x1F) << 23)
#define FEC_MMFR_OP_WR (0x10000000)
#define FEC_MMFR_OP_RD (0x20000000)
#define FEC_MMFR_ST (0x40000000)
#define FEC_MSCR_MII_SPEED(x) (((x) & 0x1F) << 1)
#define FEC_MSCR_DIS_PREAMBLE (0x00000008)
#define FEC_MIBC_MIB_IDLE (0x40000000)
#define FEC_MIBC_MIB_DISABLE (0x80000000)
#define FEC_RCR_LOOP (0x00000001)
#define FEC_RCR_DRT (0x00000002)
#define FEC_RCR_MII_MODE (0x00000004)
#define FEC_RCR_PROM (0x00000008)
#define FEC_RCR_BC_REJ (0x00000010)
#define FEC_RCR_FCE (0x00000020)
#define FEC_RCR_MAX_FL(x) (((x) & 0x07FF) << 16)
#define FEC_TCR_GTS (0x00000001)
#define FEC_TCR_HBC (0x00000002)
#define FEC_TCR_FDEN (0x00000004)
#define FEC_TCR_TFC_PAUSE (0x00000008)
#define FEC_TCR_RFC_PAUSE (0x00000010)
#define FEC_PALR_BYTE3(x) (((x) & 0xFF) << 0)
#define FEC_PALR_BYTE2(x) (((x) & 0xFF) << 8)
#define FEC_PALR_BYTE1(x) (((x) & 0xFF) << 16)
#define FEC_PALR_BYTE0(x) (((x) & 0xFF) << 24)
//#define FEC_PAUR_TYPE(x) (((x) & 0xFFFF) << 0)
#define FEC_PAUR_BYTE5(x) (((x) & 0xFF) << 16)
#define FEC_PAUR_BYTE4(x) (((x) & 0xFF) << 24)
#define FEC_OPD_PAUSE_DUR(x) (((x) & 0xFFFF))
//#define FEC_OPD_OPCODE(x) (((x) & 0xFFFF) << 16)
//m.b.
#define FEC_IAUR_BYTE7(x) (((x) & 0xFF) << 0)
#define FEC_IAUR_BYTE6(x) (((x) & 0xFF) << 8)
#define FEC_IAUR_BYTE5(x) (((x) & 0xFF) << 16)
#define FEC_IAUR_BYTE4(x) (((x) & 0xFF) << 24)
#define FEC_IALR_BYTE3(x) (((x) & 0xFF) << 0)
#define FEC_IALR_BYTE2(x) (((x) & 0xFF) << 8)
#define FEC_IALR_BYTE1(x) (((x) & 0xFF) << 16)
#define FEC_IALR_BYTE0(x) (((x) & 0xFF) << 24)
#define FEC_GAUR_BYTE7(x) (((x) & 0xFF) << 0)
#define FEC_GAUR_BYTE6(x) (((x) & 0xFF) << 8)
#define FEC_GAUR_BYTE5(x) (((x) & 0xFF) << 16)
#define FEC_GAUR_BYTE4(x) (((x) & 0xFF) << 24)
#define FEC_GALR_BYTE3(x) (((x) & 0xFF) << 0)
#define FEC_GALR_BYTE2(x) (((x) & 0xFF) << 8)
#define FEC_GALR_BYTE1(x) (((x) & 0xFF) << 16)
#define FEC_GALR_BYTE0(x) (((x) & 0xFF) << 24)
// ^^^^
#define FEC_TFWR_X_WMRK_64 (0x00000001)
#define FEC_TFWR_X_WMRK_128 (0x00000002)
#define FEC_TFWR_X_WMRK_192 (0x00000003)
//m.b.
#define FEC_FRBR_R_BOUND(x) (((x) & 0xFF) << 2)
//m.b.
#define FEC_FRSR_R_FSTART(x) (((x) & 0xFF) << 2)
//m.b.
#define FEC_ERDSR_R_DES_START(x) (((x) & 0x3FFFFFFF) << 2)
//m.b.
#define FEC_ETSDR_X_DES_START(x) (((x) & 0x3FFFFFFF) << 2)
#define FEC_EMRBR_R_BUF_SIZE(x) (((x) & 0x7F) << 4)
#define FEC_RxBD_TR 0x0001
#define FEC_RxBD_OV 0x0002
#define FEC_RxBD_CR 0x0004
#define FEC_RxBD_NO 0x0010
#define FEC_RxBD_LG 0x0020
#define FEC_RxBD_MC 0x0040
#define FEC_RxBD_BC 0x0080
#define FEC_RxBD_M 0x0100
#define FEC_RxBD_L 0x0800
#define FEC_RxBD_R02 0x1000
#define FEC_RxBD_W 0x2000
#define FEC_RxBD_R01 0x4000
#define FEC_RxBD_INUSE 0x4000
#define FEC_RxBD_E 0x8000
//m.b.
//#define FEC_TxBD_CSL 0x0001
//#define FEC_TxBD_UN 0x0002
//#define FEC_TxBD_RL 0x0040
//#define FEC_TxBD_LC 0x0080
//#define FEC_TxBD_HB 0x0100
//#define FEC_TxBD_DEF 0x0200
#define FEC_TxBD_ABC 0x0200
// ^^^^
#define FEC_TxBD_TC 0x0400
#define FEC_TxBD_L 0x0800
#define FEC_TxBD_TO2 0x1000
#define FEC_TxBD_W 0x2000
#define FEC_TxBD_TO1 0x4000
#define FEC_TxBD_INUSE 0x4000
#define FEC_TxBD_R 0x8000
//---------------------------------------------------------------------------
// types
//---------------------------------------------------------------------------
// Rx and Tx buffer descriptor format
typedef struct
{
WORD m_wStatus; // control / status --- used by edrv, do not change in application
WORD m_wLength; // transfer length
BYTE * m_pbData; // buffer address
} tBufferDescr;
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#if (NO_OF_INSTANCES > 1)
#define ECI_WRITE_DW_REG(off,val) (*(DWORD *)(void *)(&__IPSBAR[off]) = val)
#define ECI_READ_DW_REG(off) (*(DWORD *)(void *)(&__IPSBAR[off]))
#else
#if (EDRV_USED_ETH_CTRL == 0)
#define ECI_WRITE_DW_REG(off,val) (*(DWORD *)(void *)(&__IPSBAR[FEC0_ADDR+off]) = val)
#define ECI_READ_DW_REG(off) (*(DWORD *)(void *)(&__IPSBAR[FEC0_ADDR+off]))
#else
#define ECI_WRITE_DW_REG(off,val) (*(DWORD *)(void *)(&__IPSBAR[FEC1_ADDR+off]) = val)
#define ECI_READ_DW_REG(off) (*(DWORD *)(void *)(&__IPSBAR[FEC1_ADDR+off]))
#endif
#endif
#endif // #ifndef _EDRV_FEC_H_

View file

@ -0,0 +1,94 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: interface for ethernet driver simulation
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EdrvSim.h,v $
$Author: D.Krueger $
$Revision: 1.3 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
Dev C++ and GNU-Compiler for m68k
-------------------------------------------------------------------------
Revision History:
2006/06/15 d.k.: start of implementation
****************************************************************************/
#ifndef _EDRVSIM_H_
#define _EDRVSIM_H_
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
void EdrvRxInterruptHandler (BYTE bBufferInFrame_p, BYTE * pbEthernetData_p, WORD wDataLen_p);
#endif // #ifndef _EDRVSIM_H_

304
drivers/staging/epl/Epl.h Normal file
View file

@ -0,0 +1,304 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for EPL API layer
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: Epl.h,v $
$Author: D.Krueger $
$Revision: 1.8 $ $Date: 2008/11/17 16:40:39 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/05/22 d.k.: start of the implementation, version 1.00
****************************************************************************/
#ifndef _EPL_API_H_
#define _EPL_API_H_
#include "EplInc.h"
#include "EplSdo.h"
#include "EplObd.h"
#include "EplLed.h"
#include "EplEvent.h"
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
typedef struct
{
unsigned int m_uiNodeId;
tEplNmtState m_NmtState;
tEplNmtNodeEvent m_NodeEvent;
WORD m_wErrorCode; // EPL error code if m_NodeEvent == kEplNmtNodeEventError
BOOL m_fMandatory;
} tEplApiEventNode;
typedef struct
{
tEplNmtState m_NmtState; // local NMT state
tEplNmtBootEvent m_BootEvent;
WORD m_wErrorCode; // EPL error code if m_BootEvent == kEplNmtBootEventError
} tEplApiEventBoot;
typedef struct
{
tEplLedType m_LedType; // type of the LED (e.g. Status or Error)
BOOL m_fOn; // state of the LED (e.g. on or off)
} tEplApiEventLed;
typedef enum
{
kEplApiEventNmtStateChange = 0x10, // m_NmtStateChange
// kEplApiEventRequestNmt = 0x11, // m_bNmtCmd
kEplApiEventCriticalError = 0x12, // m_InternalError, Stack halted
kEplApiEventWarning = 0x13, // m_InternalError, Stack running
kEplApiEventNode = 0x20, // m_Node
kEplApiEventBoot = 0x21, // m_Boot
kEplApiEventSdo = 0x62, // m_Sdo
kEplApiEventObdAccess = 0x69, // m_ObdCbParam
kEplApiEventLed = 0x70, // m_Led
} tEplApiEventType;
typedef union
{
tEplEventNmtStateChange m_NmtStateChange;
tEplEventError m_InternalError;
tEplSdoComFinished m_Sdo;
tEplObdCbParam m_ObdCbParam;
tEplApiEventNode m_Node;
tEplApiEventBoot m_Boot;
tEplApiEventLed m_Led;
} tEplApiEventArg;
typedef tEplKernel (PUBLIC ROM* tEplApiCbEvent) (
tEplApiEventType EventType_p, // IN: event type (enum)
tEplApiEventArg* pEventArg_p, // IN: event argument (union)
void GENERIC* pUserArg_p);
typedef struct
{
unsigned int m_uiSizeOfStruct;
BOOL m_fAsyncOnly; // do not need to register PRes
unsigned int m_uiNodeId; // local node ID
BYTE m_abMacAddress[6]; // local MAC address
// 0x1F82: NMT_FeatureFlags_U32
DWORD m_dwFeatureFlags;
// Cycle Length (0x1006: NMT_CycleLen_U32) in [us]
DWORD m_dwCycleLen; // required for error detection
// 0x1F98: NMT_CycleTiming_REC
// 0x1F98.1: IsochrTxMaxPayload_U16
unsigned int m_uiIsochrTxMaxPayload; // const
// 0x1F98.2: IsochrRxMaxPayload_U16
unsigned int m_uiIsochrRxMaxPayload; // const
// 0x1F98.3: PResMaxLatency_U32
DWORD m_dwPresMaxLatency; // const in [ns], only required for IdentRes
// 0x1F98.4: PReqActPayloadLimit_U16
unsigned int m_uiPreqActPayloadLimit; // required for initialisation (+28 bytes)
// 0x1F98.5: PResActPayloadLimit_U16
unsigned int m_uiPresActPayloadLimit; // required for initialisation of Pres frame (+28 bytes)
// 0x1F98.6: ASndMaxLatency_U32
DWORD m_dwAsndMaxLatency; // const in [ns], only required for IdentRes
// 0x1F98.7: MultiplCycleCnt_U8
unsigned int m_uiMultiplCycleCnt; // required for error detection
// 0x1F98.8: AsyncMTU_U16
unsigned int m_uiAsyncMtu; // required to set up max frame size
// 0x1F98.9: Prescaler_U16
unsigned int m_uiPrescaler; // required for sync
// $$$ Multiplexed Slot
// 0x1C14: DLL_LossOfFrameTolerance_U32 in [ns]
DWORD m_dwLossOfFrameTolerance;
// 0x1F8A: NMT_MNCycleTiming_REC
// 0x1F8A.1: WaitSoCPReq_U32 in [ns]
DWORD m_dwWaitSocPreq;
// 0x1F8A.2: AsyncSlotTimeout_U32 in [ns]
DWORD m_dwAsyncSlotTimeout;
DWORD m_dwDeviceType; // NMT_DeviceType_U32
DWORD m_dwVendorId; // NMT_IdentityObject_REC.VendorId_U32
DWORD m_dwProductCode; // NMT_IdentityObject_REC.ProductCode_U32
DWORD m_dwRevisionNumber; // NMT_IdentityObject_REC.RevisionNo_U32
DWORD m_dwSerialNumber; // NMT_IdentityObject_REC.SerialNo_U32
QWORD m_qwVendorSpecificExt1;
DWORD m_dwVerifyConfigurationDate; // CFM_VerifyConfiguration_REC.ConfDate_U32
DWORD m_dwVerifyConfigurationTime; // CFM_VerifyConfiguration_REC.ConfTime_U32
DWORD m_dwApplicationSwDate; // PDL_LocVerApplSw_REC.ApplSwDate_U32 on programmable device or date portion of NMT_ManufactSwVers_VS on non-programmable device
DWORD m_dwApplicationSwTime; // PDL_LocVerApplSw_REC.ApplSwTime_U32 on programmable device or time portion of NMT_ManufactSwVers_VS on non-programmable device
DWORD m_dwIpAddress;
DWORD m_dwSubnetMask;
DWORD m_dwDefaultGateway;
BYTE m_sHostname[32];
BYTE m_abVendorSpecificExt2[48];
char* m_pszDevName; // NMT_ManufactDevName_VS (0x1008/0 local OD)
char* m_pszHwVersion; // NMT_ManufactHwVers_VS (0x1009/0 local OD)
char* m_pszSwVersion; // NMT_ManufactSwVers_VS (0x100A/0 local OD)
tEplApiCbEvent m_pfnCbEvent;
void* m_pEventUserArg;
tEplSyncCb m_pfnCbSync;
} tEplApiInitParam;
typedef struct
{
void* m_pImage;
unsigned int m_uiSize;
} tEplApiProcessImage;
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplApiInitialize(tEplApiInitParam* pInitParam_p);
tEplKernel PUBLIC EplApiShutdown(void);
tEplKernel PUBLIC EplApiReadObject(
tEplSdoComConHdl* pSdoComConHdl_p,
unsigned int uiNodeId_p,
unsigned int uiIndex_p,
unsigned int uiSubindex_p,
void* pDstData_le_p,
unsigned int* puiSize_p,
tEplSdoType SdoType_p,
void* pUserArg_p);
tEplKernel PUBLIC EplApiWriteObject(
tEplSdoComConHdl* pSdoComConHdl_p,
unsigned int uiNodeId_p,
unsigned int uiIndex_p,
unsigned int uiSubindex_p,
void* pSrcData_le_p,
unsigned int uiSize_p,
tEplSdoType SdoType_p,
void* pUserArg_p);
tEplKernel PUBLIC EplApiFreeSdoChannel(
tEplSdoComConHdl SdoComConHdl_p);
tEplKernel PUBLIC EplApiReadLocalObject(
unsigned int uiIndex_p,
unsigned int uiSubindex_p,
void* pDstData_p,
unsigned int* puiSize_p);
tEplKernel PUBLIC EplApiWriteLocalObject(
unsigned int uiIndex_p,
unsigned int uiSubindex_p,
void* pSrcData_p,
unsigned int uiSize_p);
tEplKernel PUBLIC EplApiCbObdAccess(tEplObdCbParam MEM* pParam_p);
tEplKernel PUBLIC EplApiLinkObject( unsigned int uiObjIndex_p,
void* pVar_p,
unsigned int* puiVarEntries_p,
tEplObdSize* pEntrySize_p,
unsigned int uiFirstSubindex_p);
tEplKernel PUBLIC EplApiExecNmtCommand(tEplNmtEvent NmtEvent_p);
tEplKernel PUBLIC EplApiProcess(void);
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
tEplKernel PUBLIC EplApiMnTriggerStateChange(unsigned int uiNodeId_p,
tEplNmtNodeCommand NodeCommand_p);
#endif
tEplKernel PUBLIC EplApiGetIdentResponse(
unsigned int uiNodeId_p,
tEplIdentResponse** ppIdentResponse_p);
// functions for process image will be implemented in separate file
tEplKernel PUBLIC EplApiProcessImageSetup(void);
tEplKernel PUBLIC EplApiProcessImageExchangeIn(tEplApiProcessImage* pPI_p);
tEplKernel PUBLIC EplApiProcessImageExchangeOut(tEplApiProcessImage* pPI_p);
#endif // #ifndef _EPL_API_H_

View file

@ -0,0 +1,380 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: Definitions for Abstract Memory Interface
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplAmi.h,v $
$Author: D.Krueger $
$Revision: 1.2 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
GCC
-------------------------------------------------------------------------
Revision History:
06.03.2000 -rs
Implementation
16.09.2002 -as
To save code space the functions AmiSetByte and AmiGetByte
are replaced by macros. For targets which assign BYTE by
an 16Bit type, the definition of macros must changed to
functions.
23.02.2005 r.d.:
Functions included for extended data types such as UNSIGNED24,
UNSIGNED40, ...
13.06.2006 d.k.:
Extended the interface for EPL with the different functions
for little endian and big endian
****************************************************************************/
#ifndef _EPLAMI_H_
#define _EPLAMI_H_
#if ((DEV_SYSTEM & _DEV_64BIT_SUPPORT_) == 0)
// #ifdef USE_VAR64
#error 'ERROR: development system does not support 64 bit operations!'
// #endif
#endif
//---------------------------------------------------------------------------
// types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Prototypen
//---------------------------------------------------------------------------
#ifdef __cplusplus
extern "C" {
#endif
#if (TARGET_SYSTEM == _WIN32_)
#if defined(INLINE_FUNCTION_DEF)
#undef INLINE_FUNCTION
#define INLINE_FUNCTION INLINE_FUNCTION_DEF
#define INLINE_ENABLED TRUE
#define EPL_AMI_INLINED
#include "../EplStack/amix86.c"
#endif
#elif (TARGET_SYSTEM == _LINUX_)
#if defined(__m68k__) // it is an big endian machine
#if defined(INLINE_FUNCTION_DEF)
#undef INLINE_FUNCTION
#define INLINE_FUNCTION INLINE_FUNCTION_DEF
#define INLINE_ENABLED TRUE
#define EPL_AMI_INLINED
#include "../EplStack/amibe.c"
#endif
#endif
#endif
//---------------------------------------------------------------------------
//
// write functions
//
// To save code space the function AmiSetByte is replaced by
// an macro.
// void PUBLIC AmiSetByte (void FAR* pAddr_p, BYTE bByteVal_p);
#define AmiSetByteToBe(pAddr_p, bByteVal_p) {*(BYTE FAR*)(pAddr_p) = (bByteVal_p);}
#define AmiSetByteToLe(pAddr_p, bByteVal_p) {*(BYTE FAR*)(pAddr_p) = (bByteVal_p);}
#if !defined(INLINE_ENABLED)
void PUBLIC AmiSetWordToBe (void FAR* pAddr_p, WORD wWordVal_p);
void PUBLIC AmiSetDwordToBe (void FAR* pAddr_p, DWORD dwDwordVal_p);
void PUBLIC AmiSetWordToLe (void FAR* pAddr_p, WORD wWordVal_p);
void PUBLIC AmiSetDwordToLe (void FAR* pAddr_p, DWORD dwDwordVal_p);
#endif
//---------------------------------------------------------------------------
//
// read functions
//
// To save code space the function AmiGetByte is replaced by
// an macro.
// BYTE PUBLIC AmiGetByte (void FAR* pAddr_p);
#define AmiGetByteFromBe(pAddr_p) (*(BYTE FAR*)(pAddr_p))
#define AmiGetByteFromLe(pAddr_p) (*(BYTE FAR*)(pAddr_p))
#if !defined(INLINE_ENABLED)
WORD PUBLIC AmiGetWordFromBe (void FAR* pAddr_p);
DWORD PUBLIC AmiGetDwordFromBe (void FAR* pAddr_p);
WORD PUBLIC AmiGetWordFromLe (void FAR* pAddr_p);
DWORD PUBLIC AmiGetDwordFromLe (void FAR* pAddr_p);
//---------------------------------------------------------------------------
//
// Function: AmiSetDword24()
//
// Description: sets a 24 bit value to a buffer
//
// Parameters: pAddr_p = pointer to destination buffer
// dwDwordVal_p = value to set
//
// Return: void
//
//---------------------------------------------------------------------------
void PUBLIC AmiSetDword24ToBe (void FAR* pAddr_p, DWORD dwDwordVal_p);
void PUBLIC AmiSetDword24ToLe (void FAR* pAddr_p, DWORD dwDwordVal_p);
//---------------------------------------------------------------------------
//
// Function: AmiGetDword24()
//
// Description: reads a 24 bit value from a buffer
//
// Parameters: pAddr_p = pointer to source buffer
//
// Return: DWORD = read value
//
//---------------------------------------------------------------------------
DWORD PUBLIC AmiGetDword24FromBe (void FAR* pAddr_p);
DWORD PUBLIC AmiGetDword24FromLe (void FAR* pAddr_p);
//#ifdef USE_VAR64
//---------------------------------------------------------------------------
//
// Function: AmiSetQword40()
//
// Description: sets a 40 bit value to a buffer
//
// Parameters: pAddr_p = pointer to destination buffer
// qwQwordVal_p = quadruple word value
//
// Return: void
//
//---------------------------------------------------------------------------
void PUBLIC AmiSetQword40ToBe (void FAR* pAddr_p, QWORD qwQwordVal_p);
void PUBLIC AmiSetQword40ToLe (void FAR* pAddr_p, QWORD qwQwordVal_p);
//---------------------------------------------------------------------------
//
// Function: AmiGetQword40()
//
// Description: reads a 40 bit value from a buffer
//
// Parameters: pAddr_p = pointer to source buffer
//
// Return: QWORD
//
//---------------------------------------------------------------------------
QWORD PUBLIC AmiGetQword40FromBe (void FAR* pAddr_p);
QWORD PUBLIC AmiGetQword40FromLe (void FAR* pAddr_p);
//---------------------------------------------------------------------------
//
// Function: AmiSetQword48()
//
// Description: sets a 48 bit value to a buffer
//
// Parameters: pAddr_p = pointer to destination buffer
// qwQwordVal_p = quadruple word value
//
// Return: void
//
//---------------------------------------------------------------------------
void PUBLIC AmiSetQword48ToBe (void FAR* pAddr_p, QWORD qwQwordVal_p);
void PUBLIC AmiSetQword48ToLe (void FAR* pAddr_p, QWORD qwQwordVal_p);
//---------------------------------------------------------------------------
//
// Function: AmiGetQword48()
//
// Description: reads a 48 bit value from a buffer
//
// Parameters: pAddr_p = pointer to source buffer
//
// Return: QWORD
//
//---------------------------------------------------------------------------
QWORD PUBLIC AmiGetQword48FromBe (void FAR* pAddr_p);
QWORD PUBLIC AmiGetQword48FromLe (void FAR* pAddr_p);
//---------------------------------------------------------------------------
//
// Function: AmiSetQword56()
//
// Description: sets a 56 bit value to a buffer
//
// Parameters: pAddr_p = pointer to destination buffer
// qwQwordVal_p = quadruple word value
//
// Return: void
//
//---------------------------------------------------------------------------
void PUBLIC AmiSetQword56ToBe (void FAR* pAddr_p, QWORD qwQwordVal_p);
void PUBLIC AmiSetQword56ToLe (void FAR* pAddr_p, QWORD qwQwordVal_p);
//---------------------------------------------------------------------------
//
// Function: AmiGetQword56()
//
// Description: reads a 56 bit value from a buffer
//
// Parameters: pAddr_p = pointer to source buffer
//
// Return: QWORD
//
//---------------------------------------------------------------------------
QWORD PUBLIC AmiGetQword56FromBe (void FAR* pAddr_p);
QWORD PUBLIC AmiGetQword56FromLe (void FAR* pAddr_p);
//---------------------------------------------------------------------------
//
// Function: AmiSetQword64()
//
// Description: sets a 64 bit value to a buffer
//
// Parameters: pAddr_p = pointer to destination buffer
// qwQwordVal_p = quadruple word value
//
// Return: void
//
//---------------------------------------------------------------------------
void PUBLIC AmiSetQword64ToBe (void FAR* pAddr_p, QWORD qwQwordVal_p);
void PUBLIC AmiSetQword64ToLe (void FAR* pAddr_p, QWORD qwQwordVal_p);
//---------------------------------------------------------------------------
//
// Function: AmiGetQword64()
//
// Description: reads a 64 bit value from a buffer
//
// Parameters: pAddr_p = pointer to source buffer
//
// Return: void
//
//---------------------------------------------------------------------------
QWORD PUBLIC AmiGetQword64FromBe (void FAR* pAddr_p);
QWORD PUBLIC AmiGetQword64FromLe (void FAR* pAddr_p);
//---------------------------------------------------------------------------
//
// Function: AmiSetTimeOfDay()
//
// Description: sets a TIME_OF_DAY (CANopen) value to a buffer
//
// Parameters: pAddr_p = pointer to destination buffer
// pTimeOfDay_p = pointer to struct TIME_OF_DAY
//
// Return: void
//
//---------------------------------------------------------------------------
void PUBLIC AmiSetTimeOfDay (void FAR* pAddr_p, tTimeOfDay FAR* pTimeOfDay_p);
//---------------------------------------------------------------------------
//
// Function: AmiGetTimeOfDay()
//
// Description: reads a TIME_OF_DAY (CANopen) value from a buffer
//
// Parameters: pAddr_p = pointer to source buffer
// pTimeOfDay_p = pointer to struct TIME_OF_DAY
//
// Return: void
//
//---------------------------------------------------------------------------
void PUBLIC AmiGetTimeOfDay (void FAR* pAddr_p, tTimeOfDay FAR* pTimeOfDay_p);
#endif
#undef INLINE_ENABLED // disable actual inlining of functions
#define EPL_AMI_INCLUDED
#ifdef __cplusplus
}
#endif
#endif // ifndef _EPLAMI_H_
// 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

@ -0,0 +1,153 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for EPL API layer for Linux (kernel and user space)
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplApiLinux.h,v $
$Author: D.Krueger $
$Revision: 1.5 $ $Date: 2008/08/25 12:17:41 $
$State: Exp $
Build Environment:
KEIL uVision 2
-------------------------------------------------------------------------
Revision History:
2006/10/11 d.k.: start of the implementation, version 1.00
****************************************************************************/
#ifndef _EPL_API_LINUX_H_
#define _EPL_API_LINUX_H_
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
#define EPLLIN_DEV_NAME "epl" // used for "/dev" and "/proc" entry
//---------------------------------------------------------------------------
// Commands for <ioctl>
//---------------------------------------------------------------------------
#define EPLLIN_CMD_INITIALIZE 0 // ulArg_p ~ tEplApiInitParam*
#define EPLLIN_CMD_PI_IN 1 // ulArg_p ~ tEplApiProcessImage*
#define EPLLIN_CMD_PI_OUT 2 // ulArg_p ~ tEplApiProcessImage*
#define EPLLIN_CMD_WRITE_OBJECT 3 // ulArg_p ~ tEplLinSdoObject*
#define EPLLIN_CMD_READ_OBJECT 4 // ulArg_p ~ tEplLinSdoObject*
#define EPLLIN_CMD_WRITE_LOCAL_OBJECT 5 // ulArg_p ~ tEplLinLocalObject*
#define EPLLIN_CMD_READ_LOCAL_OBJECT 6 // ulArg_p ~ tEplLinLocalObject*
#define EPLLIN_CMD_FREE_SDO_CHANNEL 7 // ulArg_p ~ tEplSdoComConHdl
#define EPLLIN_CMD_NMT_COMMAND 8 // ulArg_p ~ tEplNmtEvent
#define EPLLIN_CMD_GET_EVENT 9 // ulArg_p ~ tEplLinEvent*
#define EPLLIN_CMD_MN_TRIGGER_STATE_CHANGE 10 // ulArg_p ~ tEplLinNodeCmdObject*
#define EPLLIN_CMD_PI_SETUP 11 // ulArg_p ~ 0
#define EPLLIN_CMD_SHUTDOWN 12 // ulArg_p ~ 0
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
typedef struct
{
unsigned int m_uiEventArgSize;
tEplApiEventArg* m_pEventArg;
tEplApiEventType* m_pEventType;
tEplKernel m_RetCbEvent;
} tEplLinEvent;
typedef struct
{
tEplSdoComConHdl m_SdoComConHdl;
BOOL m_fValidSdoComConHdl;
unsigned int m_uiNodeId;
unsigned int m_uiIndex;
unsigned int m_uiSubindex;
void* m_le_pData;
unsigned int m_uiSize;
tEplSdoType m_SdoType;
void* m_pUserArg;
} tEplLinSdoObject;
typedef struct
{
unsigned int m_uiIndex;
unsigned int m_uiSubindex;
void* m_pData;
unsigned int m_uiSize;
} tEplLinLocalObject;
typedef struct
{
unsigned int m_uiNodeId;
tEplNmtNodeCommand m_NodeCommand;
} tEplLinNodeCmdObject;
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#endif // #ifndef _EPL_API_LINUX_H_

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,374 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for EPL API module (process image)
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplApiProcessImage.c,v $
$Author: D.Krueger $
$Revision: 1.7 $ $Date: 2008/11/13 17:13:09 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/10/10 d.k.: start of the implementation, version 1.00
****************************************************************************/
#include "Epl.h"
//#include "kernel/EplPdokCal.h"
#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
#include <asm/uaccess.h>
#endif
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
/***************************************************************************/
/* */
/* */
/* C L A S S EplApi */
/* */
/* */
/***************************************************************************/
//
// Description:
//
//
/***************************************************************************/
//=========================================================================//
// //
// P R I V A T E D E F I N I T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
#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
} tEplApiProcessImageInstance;
//---------------------------------------------------------------------------
// local vars
//---------------------------------------------------------------------------
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()
//
// Description: sets up static process image
//
// Parameters: (none)
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplApiProcessImageSetup(void)
{
tEplKernel Ret = kEplSuccessful;
#if ((EPL_API_PROCESS_IMAGE_SIZE_IN > 0) || (EPL_API_PROCESS_IMAGE_SIZE_OUT > 0))
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(
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(
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(
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(
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(
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(
0x2051,
EplApiProcessImageInstance_g.m_abProcessImageOutput,
&uiVarEntries,
&ObdSize,
1);
#endif
return Ret;
}
//----------------------------------------------------------------------------
// Function: EplApiProcessImageExchangeIn()
//
// Description: replaces passed input process image with the one of EPL stack
//
// Parameters: pPI_p = input process image
//
// Returns: tEplKernel = error code
//
// State:
//----------------------------------------------------------------------------
tEplKernel PUBLIC EplApiProcessImageExchangeIn(tEplApiProcessImage* pPI_p)
{
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
#endif
return Ret;
}
//----------------------------------------------------------------------------
// Function: EplApiProcessImageExchangeOut()
//
// Description: copies passed output process image to EPL stack.
//
// Parameters: pPI_p = output process image
//
// Returns: tEplKernel = error code
//
// State:
//----------------------------------------------------------------------------
tEplKernel PUBLIC EplApiProcessImageExchangeOut(tEplApiProcessImage* pPI_p)
{
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
#endif
return Ret;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
// EOF

View file

@ -0,0 +1,207 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: configuration file
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplCfg.h,v $
$Author: D.Krueger $
$Revision: 1.4 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
...
-------------------------------------------------------------------------
Revision History:
2006/06/06 k.t.: Start of Implementation
****************************************************************************/
#ifndef _EPLCFG_H_
#define _EPLCFG_H_
// =========================================================================
// generic defines which for whole EPL Stack
// =========================================================================
#define EPL_USE_DELETEINST_FUNC TRUE
// needed to support datatypes over 32 bit by global.h
#define USE_VAR64
// EPL_MAX_INSTANCES specifies count of instances of all EPL modules.
// If it is greater than 1 the first parameter of all
// functions is the instance number.
#define EPL_MAX_INSTANCES 1
// This defines the target hardware. Here is encoded wich CPU and wich external
// peripherals are connected. For possible values refere to target.h. If
// necessary value is not available EPL stack has to
// be adapted and tested.
#define TARGET_HARDWARE TGTHW_PC_WRAPP
// use no FIFOs, make direct calls
//#define EPL_NO_FIFO
// use no IPC between user- and kernelspace modules, make direct calls
#define EPL_NO_USER_KERNEL
#ifndef BENCHMARK_MODULES
#define BENCHMARK_MODULES 0 //0xEE800042L
#endif
// Default defug level:
// Only debug traces of these modules will be compiled which flags are set in define DEF_DEBUG_LVL.
#ifndef DEF_DEBUG_LVL
#define DEF_DEBUG_LVL 0xEC000000L
#endif
// EPL_DBGLVL_OBD = 0x00000004L
// * EPL_DBGLVL_ASSERT = 0x20000000L
// * EPL_DBGLVL_ERROR = 0x40000000L
// * EPL_DBGLVL_ALWAYS = 0x80000000L
// EPL_MODULE_INTEGRATION defines all modules which are included in
// EPL application. Please add or delete modules for your application.
#define EPL_MODULE_INTEGRATION EPL_MODULE_OBDK \
| EPL_MODULE_PDOK \
| EPL_MODULE_NMT_MN \
| EPL_MODULE_SDOS \
| EPL_MODULE_SDOC \
| EPL_MODULE_SDO_ASND \
| EPL_MODULE_SDO_UDP \
| EPL_MODULE_NMT_CN \
| EPL_MODULE_NMTU \
| EPL_MODULE_NMTK \
| EPL_MODULE_DLLK \
| EPL_MODULE_DLLU \
| EPL_MODULE_VETH
// | EPL_MODULE_OBDU
// =========================================================================
// EPL ethernet driver (Edrv) specific defines
// =========================================================================
// switch this define to TRUE if Edrv supports fast tx frames
#define EDRV_FAST_TXFRAMES FALSE
//#define EDRV_FAST_TXFRAMES TRUE
// switch this define to TRUE if Edrv supports early receive interrupts
#define EDRV_EARLY_RX_INT FALSE
//#define EDRV_EARLY_RX_INT TRUE
// enables setting of several port pins for benchmarking purposes
#define EDRV_BENCHMARK FALSE
//#define EDRV_BENCHMARK TRUE // MCF_GPIO_PODR_PCIBR
// Call Tx handler (i.e. EplDllCbFrameTransmitted()) already if DMA has finished,
// otherwise call the Tx handler if frame was actually transmitted over ethernet.
#define EDRV_DMA_TX_HANDLER FALSE
//#define EDRV_DMA_TX_HANDLER TRUE
// number of used ethernet controller
//#define EDRV_USED_ETH_CTRL 1
// =========================================================================
// Data Link Layer (DLL) specific defines
// =========================================================================
// switch this define to TRUE if Edrv supports fast tx frames
// and DLL shall pass PRes as ready to Edrv after SoC
#define EPL_DLL_PRES_READY_AFTER_SOC FALSE
//#define EPL_DLL_PRES_READY_AFTER_SOC TRUE
// switch this define to TRUE if Edrv supports fast tx frames
// and DLL shall pass PRes as ready to Edrv after SoA
#define EPL_DLL_PRES_READY_AFTER_SOA FALSE
//#define EPL_DLL_PRES_READY_AFTER_SOA TRUE
// =========================================================================
// OBD specific defines
// =========================================================================
// switch this define to TRUE if Epl should compare object range
// automaticly
#define EPL_OBD_CHECK_OBJECT_RANGE FALSE
//#define EPL_OBD_CHECK_OBJECT_RANGE TRUE
// set this define to TRUE if there are strings or domains in OD, which
// may be changed in object size and/or object data pointer by its object
// callback function (called event kObdEvWrStringDomain)
//#define EPL_OBD_USE_STRING_DOMAIN_IN_RAM FALSE
#define EPL_OBD_USE_STRING_DOMAIN_IN_RAM TRUE
#define EPL_OBD_USE_VARIABLE_SUBINDEX_TAB TRUE
// =========================================================================
// Timer module specific defines
// =========================================================================
// if TRUE it uses the Timer module implementation of EPL user also in EPL kernel
#define EPL_TIMER_USE_USER TRUE
// if TRUE the high resolution timer module will be used
#define EPL_TIMER_USE_HIGHRES TRUE
//#define EPL_TIMER_USE_HIGHRES FALSE
#endif //_EPLCFG_H_

View file

@ -0,0 +1,362 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for EPL default constants
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplDef.h,v $
$Author: D.Krueger $
$Revision: 1.15 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/05/22 d.k.: start of the implementation, version 1.00
****************************************************************************/
#ifndef _EPL_DEF_H_
#define _EPL_DEF_H_
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
#define EPL_C_ADR_BROADCAST 0xFF // EPL broadcast address
#define EPL_C_ADR_DIAG_DEF_NODE_ID 0xFD // EPL default address of dignostic device
#define EPL_C_ADR_DUMMY_NODE_ID 0xFC // EPL dummy node address
#define EPL_C_ADR_INVALID 0x00 // invalid EPL address
#define EPL_C_ADR_MN_DEF_NODE_ID 0xF0 // EPL default address of MN
#define EPL_C_ADR_RT1_DEF_NODE_ID 0xFE // EPL default address of router type 1
#define EPL_C_DLL_ASND_PRIO_NMTRQST 7 // increased ASnd request priority to be used by NMT Requests
#define EPL_C_DLL_ASND_PRIO_STD 0 // standard ASnd request priority
#define EPL_C_DLL_ETHERTYPE_EPL 0x88AB
#define EPL_C_DLL_ISOCHR_MAX_PAYL 1490 // Byte: maximum size of PReq and PRes payload data, requires C_IP_MAX_MTU
#define EPL_C_DLL_MAX_ASYNC_MTU 1500 // Byte: maximum asynchronous payload in bytes
#define EPL_C_DLL_MAX_PAYL_OFFSET 1499 // Byte: maximum offset of Ethernet frame payload, requires C_IP_MAX_MTU
#define EPL_C_DLL_MAX_RS 7
#define EPL_C_DLL_MIN_ASYNC_MTU 282 // Byte: minimum asynchronous payload in bytes.
#define EPL_C_DLL_MIN_PAYL_OFFSET 45 // Byte: minimum offset of Ethernet frame payload
#define EPL_C_DLL_MULTICAST_ASND 0x01111E000004LL // EPL ASnd multicast MAC address, canonical form
#define EPL_C_DLL_MULTICAST_PRES 0x01111E000002LL // EPL PRes multicast MAC address, canonical form
#define EPL_C_DLL_MULTICAST_SOA 0x01111E000003LL // EPL SoA multicast MAC address, canonical form
#define EPL_C_DLL_MULTICAST_SOC 0x01111E000001LL // EPL Soc multicast MAC address, canonical form
#define EPL_C_DLL_PREOP1_START_CYCLES 10 // number of unassigning SoA frames at start of NMT_MS_PRE_OPERATIONAL_1
#define EPL_C_DLL_T_BITTIME 10 // ns: Transmission time per bit on 100 Mbit/s network
#define EPL_C_DLL_T_EPL_PDO_HEADER 10 // Byte: size of PReq and PRes EPL PDO message header
#define EPL_C_DLL_T_ETH2_WRAPPER 18 // Byte: size of Ethernet type II wrapper consisting of header and checksum
#define EPL_C_DLL_T_IFG 640 // ns: Ethernet Interframe Gap
#define EPL_C_DLL_T_MIN_FRAME 5120 // ns: Size of minimum Ethernet frame (without preamble)
#define EPL_C_DLL_T_PREAMBLE 960 // ns: Size of Ethernet frame preamble
#define EPL_C_DLL_MINSIZE_SOC 36 // minimum size of SoC without padding and CRC
#define EPL_C_DLL_MINSIZE_PREQ 60 // minimum size of PRec without CRC
#define EPL_C_DLL_MINSIZE_PRES 60 // minimum size of PRes without CRC
#define EPL_C_DLL_MINSIZE_SOA 24 // minimum size of SoA without padding and CRC
#define EPL_C_DLL_MINSIZE_IDENTRES 176 // minimum size of IdentResponse without CRC
#define EPL_C_DLL_MINSIZE_STATUSRES 72 // minimum size of StatusResponse without CRC
#define EPL_C_DLL_MINSIZE_NMTCMD 20 // minimum size of NmtCommand without CommandData, padding and CRC
#define EPL_C_DLL_MINSIZE_NMTCMDEXT 52 // minimum size of NmtCommand without padding and CRC
#define EPL_C_DLL_MINSIZE_NMTREQ 20 // minimum size of NmtRequest without CommandData, padding and CRC
#define EPL_C_DLL_MINSIZE_NMTREQEXT 52 // minimum size of NmtRequest without padding and CRC
#define EPL_C_ERR_MONITOR_DELAY 10 // Error monitoring start delay (not used in DS 1.0.0)
#define EPL_C_IP_ADR_INVALID 0x00000000L // invalid IP address (0.0.0.0) used to indicate no change
#define EPL_C_IP_INVALID_MTU 0 // Byte: invalid MTU size used to indicate no change
#define EPL_C_IP_MAX_MTU 1518 // Byte: maximum size in bytes of the IP stack which must be processed.
#define EPL_C_IP_MIN_MTU 300 // Byte: minimum size in bytes of the IP stack which must be processed.
#define EPL_C_NMT_STATE_TOLERANCE 5 // Cycles: maximum reaction time to NMT state commands
#define EPL_C_NMT_STATREQ_CYCLE 5 // sec: StatusRequest cycle time to be applied to AsyncOnly CNs
#define EPL_C_SDO_EPL_PORT 3819
#define EPL_C_DLL_MAX_ASND_SERVICE_IDS 5 // see tEplDllAsndServiceId in EplDll.h
// Default configuration
// ======================
#ifndef EPL_D_PDO_Granularity_U8
#define EPL_D_PDO_Granularity_U8 8 // minimum size of objects to be mapped in bits UNSIGNED8 O O 1 1
#endif
#ifndef EPL_NMT_MAX_NODE_ID
#define EPL_NMT_MAX_NODE_ID 254 // maximum node-ID
#endif
#ifndef EPL_D_NMT_MaxCNNumber_U8
#define EPL_D_NMT_MaxCNNumber_U8 239 // maximum number of supported regular CNs in the Node ID range 1 .. 239 UNSIGNED8 O O 239 239
#endif
// defines for EPL API layer static process image
#ifndef EPL_API_PROCESS_IMAGE_SIZE_IN
#define EPL_API_PROCESS_IMAGE_SIZE_IN 0
#endif
#ifndef EPL_API_PROCESS_IMAGE_SIZE_OUT
#define EPL_API_PROCESS_IMAGE_SIZE_OUT 0
#endif
// configure whether OD access events shall be forwarded
// to user callback function.
// Because of reentrancy for local OD accesses, this has to be disabled
// when application resides in other address space as the stack (e.g. if
// EplApiLinuxUser.c and EplApiLinuxKernel.c are used)
#ifndef EPL_API_OBD_FORWARD_EVENT
#define EPL_API_OBD_FORWARD_EVENT TRUE
#endif
#ifndef EPL_OBD_MAX_STRING_SIZE
#define EPL_OBD_MAX_STRING_SIZE 32 // is used for objects 0x1008/0x1009/0x100A
#endif
#ifndef EPL_OBD_USE_STORE_RESTORE
#define EPL_OBD_USE_STORE_RESTORE FALSE
#endif
#ifndef EPL_OBD_CHECK_OBJECT_RANGE
#define EPL_OBD_CHECK_OBJECT_RANGE TRUE
#endif
#ifndef EPL_OBD_USE_STRING_DOMAIN_IN_RAM
#define EPL_OBD_USE_STRING_DOMAIN_IN_RAM TRUE
#endif
#ifndef EPL_OBD_USE_VARIABLE_SUBINDEX_TAB
#define EPL_OBD_USE_VARIABLE_SUBINDEX_TAB TRUE
#endif
#ifndef EPL_OBD_USE_KERNEL
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) == 0)
#define EPL_OBD_USE_KERNEL TRUE
#else
#define EPL_OBD_USE_KERNEL FALSE
#endif
#endif
#ifndef EPL_OBD_INCLUDE_A000_TO_DEVICE_PART
#define EPL_OBD_INCLUDE_A000_TO_DEVICE_PART FALSE
#endif
#ifndef EPL_VETH_NAME
#define EPL_VETH_NAME "epl" // name of net device in Linux
#endif
/*
#define EPL_D_CFG_ConfigManager_BOOL // Ability of a MN node to perform Configuration Manager functions BOOLEAN O - N -
#define EPL_D_CFM_VerifyConf_BOOL // Support of objects CFM_VerifyConfiguration_REC, CFM_ExpConfDateList_AU32, CFM_ExpConfTimeList_AU32 BOOLEAN O O N N
#define EPL_D_CFM_VerifyConfId_BOOL // Support of objects CFM_VerifyConfiguration_REC.ConfId_U32 and CFM_ExpConfIdList_AU32 BOOLEAN O O N N
#define EPL_D_DLL_CNFeatureIsochr_BOOL // CNs ability to perform isochronous functions BOOLEAN - O - Y
#define EPL_D_DLL_CNFeatureMultiplex_BOOL // nodes ability to perform control of multiplexed isochronous communication BOOLEAN - O - N
#define EPL_D_DLL_FeatureCN_BOOL // nodes ability to perform CN functions BOOLEAN O O Y Y
#define EPL_D_DLL_FeatureMN_BOOL // nodes ability to perform MN functions BOOLEAN M O - N
#define EPL_D_DLL_MNFeatureMultiplex_BOOL // MNs ability to perform control of multiplexed isochronous communication BOOLEAN O - Y -
#define EPL_D_DLL_MNFeaturePResTx_BOOL // MNs ability to transmit PRes BOOLEAN O - Y -
#define EPL_D_NMT_ASndRxMaxPayload_U16 // size of ASnd frame receive buffer UNSIGNED16 M M - -
#define EPL_D_NMT_ASndTxMaxPayload_U16 // size of ASnd frame transmit buffer UNSIGNED16 M M - -
#define EPL_D_NMT_CNASnd2SoC_U32 // minimum delay between end of reception of ASnd and start of reception of SoC UNSIGNED32 - M - -
#define EPL_D_NMT_CNASndMaxLatency_U32 // delay between end of SoA reception and start of ASnd transmission UNSIGNED32 - M - -
#define EPL_D_NMT_CNPResMaxLatency_U32 // delay between end of PReq reception and start of PRes transmission UNSIGNED32 - M - -
#define EPL_D_NMT_CNSoC2PReq_U32 // CN SoC handling maximum time, a subsequent PReq wont be handled before SoC handling was finished UNSIGNED32 - M - -
#define EPL_D_NMT_DeviceType_U32 // Device Type ID UNSIGNED32 M M - -
#define EPL_D_NMT_EPLVers_U8 EPL // Version implemented by the device UNSIGNED8 M M - -
#define EPL_D_NMT_ExtStateCmd_BOOL // abitilty to support Extended NMT State Commands BOOLEAN O O Y Y
#define EPL_D_NMT_InfoSvc_BOOL // ability to support NMT Info Services BOOLEAN O - Y -
#define EPL_D_NMT_InterfaceAddr_Xh_OSTR // Physical Address of Interface No. Xh OCTET_STRING M M - -
#define EPL_D_NMT_InterfaceDescr_Xh_VSTR // Description text of Interface No. Xh VISIBLE_STRINGM M - -
#define EPL_D_NMT_InterfaceMtu_Xh_U32 // MTU of Interface No. Xh UNSIGNED32 M M - -
#define EPL_D_NMT_InterfaceType_Xh_U8 // Type of Interface No. Xh UNSIGNED8 M M - -
#define EPL_D_NMT_IsochrRxMaxPayload_U16 // size of isochronous frame receive buffer UNSIGNED16 M M - -
#define EPL_D_NMT_IsochrTxMaxPayload_U16 // size of isochronous frame transmit buffer UNSIGNED16 M M - -
#define EPL_D_NMT_ManufactDevName_VS // Manufacturer Device Name VISIBLE_STRING O O - -
#define EPL_D_NMT_ManufactHwVers_VS // Manufacturer HW version VISIBLE_STRING O O - -
#define EPL_D_NMT_ManufactSwVers_VS // Manufacturer SW version VISIBLE_STRING O O - -
#define EPL_D_NMT_MaxCNNodeID_U8 // maximum Node ID available for regular CNs the entry provides an upper limit to the NodeID available for cross traffic PDO reception from a regular CN UNSIGNED8 O O 239 239
#define EPL_D_NMT_MaxCNNumber_U8 // maximum number of supported regular CNs in the Node ID range 1 .. 239 UNSIGNED8 O O 239 239
#define EPL_D_NMT_MaxHeartbeats_U8 // number of guard channels UNSIGNED8 O O 254 254
#define EPL_D_NMT_MNASnd2SoC_U32 // minimum delay between end of reception of ASnd and start of transmission of SoC UNSIGNED32 M - - -
#define EPL_D_NMT_MNMultiplCycMax_U8 // maximum number of EPL cycles per multiplexed cycle UNSIGNED8 O - 0 -
#define EPL_D_NMT_MNPRes2PReq_U32 // delay between end of PRes reception and start of PReq transmission UNSIGNED32 M - - -
#define EPL_D_NMT_MNPRes2PRes_U32 // delay between end of reception of PRes from CNn and start of transmission of PRes by MN UNSIGNED32 M - - -
#define EPL_D_NMT_MNPResRx2SoA_U32 // delay between end of reception of PRes from CNn and start of transmission of SoA by MN UNSIGNED32 M - - -
#define EPL_D_NMT_MNPResTx2SoA_U32 // delay between end of PRes transmission by MN and start of transmission of SoA by MN UNSIGNED32 M - - -
#define EPL_D_NMT_MNSoA2ASndTx_U32 // delay between end of transmission of SoA and start of transmission of ASnd by MN UNSIGNED32 M - - -
#define EPL_D_NMT_MNSoC2PReq_U32 // MN minimum delay between end of SoC transmission and start of PReq transmission UNSIGNED32 M - - -
#define EPL_D_NMT_NMTSvcViaUDPIP_BOOL // Ability of a node to perform NMT services via UDP/IP BOOLEAN O - Y -
#define EPL_D_NMT_NodeIDByHW_BOOL // Ability of a node to support NodeID setup by HW BOOLEAN O O Y Y
#define EPL_D_NMT_NodeIDBySW_BOOL // Ability of a node to support NodeID setup by SW BOOLEAN O O N N
#define EPL_D_NMT_ProductCode_U32 // Identity Object Product Code UNSIGNED32 M M - -
#define EPL_D_NMT_RevisionNo_U32 // Identity Object Revision Number UNSIGNED32 M M - -
#define EPL_D_NMT_SerialNo_U32 // Identity Object Serial Number UNSIGNED32 M M - -
#define EPL_D_NMT_SimpleBoot_BOOL // Ability of a MN node to perform Simple Boot Process, if not set Indivual Boot Process shall be proviced BOOLEAN M - - -
#define EPL_D_NMT_VendorID_U32 // Identity Object Vendor ID UNSIGNED32 M M - -
#define EPL_D_NWL_Forward_BOOL // Ability of node to forward datagrams BOOLEAN O O N N
#define EPL_D_NWL_IPSupport_BOOL // Ability of the node cummunicate via IP BOOLEAN - - Y Y
#define EPL_D_PDO_DynamicMapping_BOOL // Ability of a node to perform dynamic PDO mapping BOOLEAN O O Y Y
#define EPL_D_PDO_MaxDescrMem_U32 // maximum cumulative memory consumption of TPDO and RPDO describing objects in byte UNSIGNED32 O O MAX_U32 MAX_U32
#define EPL_D_PDO_RPDOChannels_U8 // number of supported RPDO channels UNSIGNED8 O O 256 256
#define EPL_D_PDO_RPDOMaxMem_U32 // Maximum memory available for RPDO data per EPL cycle in byte UNSIGNED32 O O MAX_U32 MAX_U32
#define EPL_D_PDO_RPDOObjects_U8 // Number of supported mapped objects per RPDO channel UNSIGNED8 O O 254 254
#define EPL_D_PDO_TPDOChannels_U8 // number of supported TPDO channels UNSIGNED8 O - 256 -
#define EPL_D_PDO_TPDOMaxMem_U32 // Maximum memory available for TPDO data per EPL cycle in byte UNSIGNED32 O O MAX_U32 MAX_U32
#define EPL_D_PDO_TPDOObjects_U8 // Number of supported mapped objects per TPDO channel UNSIGNED8 O O 254 254
#define EPL_D_SDO_ViaASnd_BOOL // Ability of a CN to perform SDO transfer by EPL ASnd BOOLEAN - M - -
#define EPL_D_SDO_ViaPDO_BOOL // Ability of a node to perform SDO transfer by PDO BOOLEAN O O N N
#define EPL_D_SDO_ViaUDPIP_BOOL // Ability of a CN to perform SDO transfer by UDP/IP BOOLEAN - M - -
#define EPL_D_SYN_OptimizedSync_BOOL // Ability of node to perform optimized synchronisation BOOLEAN O O N N
*/
// Emergency error codes
// ======================
#define EPL_E_NO_ERROR 0x0000
// 0xFxxx manufacturer specific error codes
#define EPL_E_NMT_NO_IDENT_RES 0xF001
#define EPL_E_NMT_NO_STATUS_RES 0xF002
// 0x816x HW errors
#define EPL_E_DLL_BAD_PHYS_MODE 0x8161
#define EPL_E_DLL_COLLISION 0x8162
#define EPL_E_DLL_COLLISION_TH 0x8163
#define EPL_E_DLL_CRC_TH 0x8164
#define EPL_E_DLL_LOSS_OF_LINK 0x8165
#define EPL_E_DLL_MAC_BUFFER 0x8166
// 0x82xx Protocol errors
#define EPL_E_DLL_ADDRESS_CONFLICT 0x8201
#define EPL_E_DLL_MULTIPLE_MN 0x8202
// 0x821x Frame size errors
#define EPL_E_PDO_SHORT_RX 0x8210
#define EPL_E_PDO_MAP_VERS 0x8211
#define EPL_E_NMT_ASND_MTU_DIF 0x8212
#define EPL_E_NMT_ASND_MTU_LIM 0x8213
#define EPL_E_NMT_ASND_TX_LIM 0x8214
// 0x823x Timing errors
#define EPL_E_NMT_CYCLE_LEN 0x8231
#define EPL_E_DLL_CYCLE_EXCEED 0x8232
#define EPL_E_DLL_CYCLE_EXCEED_TH 0x8233
#define EPL_E_NMT_IDLE_LIM 0x8234
#define EPL_E_DLL_JITTER_TH 0x8235
#define EPL_E_DLL_LATE_PRES_TH 0x8236
#define EPL_E_NMT_PREQ_CN 0x8237
#define EPL_E_NMT_PREQ_LIM 0x8238
#define EPL_E_NMT_PRES_CN 0x8239
#define EPL_E_NMT_PRES_RX_LIM 0x823A
#define EPL_E_NMT_PRES_TX_LIM 0x823B
// 0x824x Frame errors
#define EPL_E_DLL_INVALID_FORMAT 0x8241
#define EPL_E_DLL_LOSS_PREQ_TH 0x8242
#define EPL_E_DLL_LOSS_PRES_TH 0x8243
#define EPL_E_DLL_LOSS_SOA_TH 0x8244
#define EPL_E_DLL_LOSS_SOC_TH 0x8245
// 0x84xx BootUp Errors
#define EPL_E_NMT_BA1 0x8410 // other MN in MsNotActive active
#define EPL_E_NMT_BA1_NO_MN_SUPPORT 0x8411 // MN is not supported
#define EPL_E_NMT_BPO1 0x8420 // mandatory CN was not found or failed in BootStep1
#define EPL_E_NMT_BPO1_GET_IDENT 0x8421 // IdentRes was not received
#define EPL_E_NMT_BPO1_DEVICE_TYPE 0x8422 // wrong device type
#define EPL_E_NMT_BPO1_VENDOR_ID 0x8423 // wrong vendor ID
#define EPL_E_NMT_BPO1_PRODUCT_CODE 0x8424 // wrong product code
#define EPL_E_NMT_BPO1_REVISION_NO 0x8425 // wrong revision number
#define EPL_E_NMT_BPO1_SERIAL_NO 0x8426 // wrong serial number
#define EPL_E_NMT_BPO1_CF_VERIFY 0x8428 // verification of configuration failed
#define EPL_E_NMT_BPO2 0x8430 // mandatory CN failed in BootStep2
#define EPL_E_NMT_BRO 0x8440 // CheckCommunication failed for mandatory CN
#define EPL_E_NMT_WRONG_STATE 0x8480 // mandatory CN has wrong NMT state
// Defines for object 0x1F80 NMT_StartUp_U32
// ==========================================
#define EPL_NMTST_STARTALLNODES 0x00000002L // Bit 1
#define EPL_NMTST_NO_AUTOSTART 0x00000004L // Bit 2
#define EPL_NMTST_NO_STARTNODE 0x00000008L // Bit 3
#define EPL_NMTST_RESETALL_MAND_CN 0x00000010L // Bit 4
#define EPL_NMTST_STOPALL_MAND_CN 0x00000040L // Bit 6
#define EPL_NMTST_NO_AUTOPREOP2 0x00000080L // Bit 7
#define EPL_NMTST_NO_AUTOREADYTOOP 0x00000100L // Bit 8
#define EPL_NMTST_EXT_CNIDENTCHECK 0x00000200L // Bit 9
#define EPL_NMTST_SWVERSIONCHECK 0x00000400L // Bit 10
#define EPL_NMTST_CONFCHECK 0x00000800L // Bit 11
#define EPL_NMTST_NO_RETURN_PREOP1 0x00001000L // Bit 12
#define EPL_NMTST_BASICETHERNET 0x00002000L // Bit 13
// Defines for object 0x1F81 NMT_NodeAssignment_AU32
// ==================================================
#define EPL_NODEASSIGN_NODE_EXISTS 0x00000001L // Bit 0
#define EPL_NODEASSIGN_NODE_IS_CN 0x00000002L // Bit 1
#define EPL_NODEASSIGN_START_CN 0x00000004L // Bit 2
#define EPL_NODEASSIGN_MANDATORY_CN 0x00000008L // Bit 3
#define EPL_NODEASSIGN_KEEPALIVE 0x00000010L //currently not used in EPL V2 standard
#define EPL_NODEASSIGN_SWVERSIONCHECK 0x00000020L // Bit 5
#define EPL_NODEASSIGN_SWUPDATE 0x00000040L // Bit 6
#define EPL_NODEASSIGN_ASYNCONLY_NODE 0x00000100L // Bit 8
#define EPL_NODEASSIGN_MULTIPLEXED_CN 0x00000200L // Bit 9
#define EPL_NODEASSIGN_RT1 0x00000400L // Bit 10
#define EPL_NODEASSIGN_RT2 0x00000800L // Bit 11
#define EPL_NODEASSIGN_MN_PRES 0x00001000L // Bit 12
#define EPL_NODEASSIGN_VALID 0x80000000L // Bit 31
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#endif // #ifndef _EPL_DEF_H_

View file

@ -0,0 +1,220 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for DLL module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplDll.h,v $
$Author: D.Krueger $
$Revision: 1.4 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/08 d.k.: start of the implementation, version 1.00
****************************************************************************/
#ifndef _EPL_DLL_H_
#define _EPL_DLL_H_
#include "EplInc.h"
#include "EplFrame.h"
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
#ifndef EPL_DLL_MAX_ASND_SERVICE_ID
#define EPL_DLL_MAX_ASND_SERVICE_ID (EPL_C_DLL_MAX_ASND_SERVICE_IDS + 1) // last is kEplDllAsndSdo == 5
#endif
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
typedef enum
{
kEplDllAsndNotDefined = 0x00,
kEplDllAsndIdentResponse = 0x01,
kEplDllAsndStatusResponse = 0x02,
kEplDllAsndNmtRequest = 0x03,
kEplDllAsndNmtCommand = 0x04,
kEplDllAsndSdo = 0x05
} tEplDllAsndServiceId;
typedef enum
{
kEplDllAsndFilterNone = 0x00,
kEplDllAsndFilterLocal = 0x01, // receive only ASnd frames with local or broadcast node ID
kEplDllAsndFilterAny = 0x02, // receive any ASnd frame
} tEplDllAsndFilter;
typedef enum
{
kEplDllReqServiceNo = 0x00,
kEplDllReqServiceIdent = 0x01,
kEplDllReqServiceStatus = 0x02,
kEplDllReqServiceNmtRequest = 0x03,
kEplDllReqServiceUnspecified= 0xFF,
} tEplDllReqServiceId;
typedef enum
{
kEplDllAsyncReqPrioNmt = 0x07, // PRIO_NMT_REQUEST
kEplDllAsyncReqPrio6 = 0x06,
kEplDllAsyncReqPrio5 = 0x05,
kEplDllAsyncReqPrio4 = 0x04,
kEplDllAsyncReqPrioGeneric = 0x03, // PRIO_GENERIC_REQUEST
kEplDllAsyncReqPrio2 = 0x02, // till WSP 0.1.3: PRIO_ABOVE_GENERIC
kEplDllAsyncReqPrio1 = 0x01, // till WSP 0.1.3: PRIO_BELOW_GENERIC
kEplDllAsyncReqPrio0 = 0x00, // till WSP 0.1.3: PRIO_GENERIC_REQUEST
} tEplDllAsyncReqPriority;
typedef struct
{
unsigned int m_uiFrameSize;
tEplFrame * m_pFrame;
tEplNetTime m_NetTime;
} tEplFrameInfo;
typedef struct
{
unsigned int m_uiSizeOfStruct;
BOOL m_fAsyncOnly; // do not need to register PRes-Frame
unsigned int m_uiNodeId; // local node ID
// 0x1F82: NMT_FeatureFlags_U32
DWORD m_dwFeatureFlags;
// Cycle Length (0x1006: NMT_CycleLen_U32) in [us]
DWORD m_dwCycleLen; // required for error detection
// 0x1F98: NMT_CycleTiming_REC
// 0x1F98.1: IsochrTxMaxPayload_U16
unsigned int m_uiIsochrTxMaxPayload; // const
// 0x1F98.2: IsochrRxMaxPayload_U16
unsigned int m_uiIsochrRxMaxPayload; // const
// 0x1F98.3: PResMaxLatency_U32
DWORD m_dwPresMaxLatency; // const in [ns], only required for IdentRes
// 0x1F98.4: PReqActPayloadLimit_U16
unsigned int m_uiPreqActPayloadLimit; // required for initialisation (+24 bytes)
// 0x1F98.5: PResActPayloadLimit_U16
unsigned int m_uiPresActPayloadLimit; // required for initialisation of Pres frame (+24 bytes)
// 0x1F98.6: ASndMaxLatency_U32
DWORD m_dwAsndMaxLatency; // const in [ns], only required for IdentRes
// 0x1F98.7: MultiplCycleCnt_U8
unsigned int m_uiMultiplCycleCnt; // required for error detection
// 0x1F98.8: AsyncMTU_U16
unsigned int m_uiAsyncMtu; // required to set up max frame size
// $$$ 0x1F98.9: Prescaler_U16
// $$$ Multiplexed Slot
// 0x1C14: DLL_LossOfFrameTolerance_U32 in [ns]
DWORD m_dwLossOfFrameTolerance;
// 0x1F8A: NMT_MNCycleTiming_REC
// 0x1F8A.1: WaitSoCPReq_U32 in [ns]
DWORD m_dwWaitSocPreq;
// 0x1F8A.2: AsyncSlotTimeout_U32 in [ns]
DWORD m_dwAsyncSlotTimeout;
} tEplDllConfigParam;
typedef struct
{
unsigned int m_uiSizeOfStruct;
DWORD m_dwDeviceType; // NMT_DeviceType_U32
DWORD m_dwVendorId; // NMT_IdentityObject_REC.VendorId_U32
DWORD m_dwProductCode; // NMT_IdentityObject_REC.ProductCode_U32
DWORD m_dwRevisionNumber; // NMT_IdentityObject_REC.RevisionNo_U32
DWORD m_dwSerialNumber; // NMT_IdentityObject_REC.SerialNo_U32
QWORD m_qwVendorSpecificExt1;
DWORD m_dwVerifyConfigurationDate; // CFM_VerifyConfiguration_REC.ConfDate_U32
DWORD m_dwVerifyConfigurationTime; // CFM_VerifyConfiguration_REC.ConfTime_U32
DWORD m_dwApplicationSwDate; // PDL_LocVerApplSw_REC.ApplSwDate_U32 on programmable device or date portion of NMT_ManufactSwVers_VS on non-programmable device
DWORD m_dwApplicationSwTime; // PDL_LocVerApplSw_REC.ApplSwTime_U32 on programmable device or time portion of NMT_ManufactSwVers_VS on non-programmable device
DWORD m_dwIpAddress;
DWORD m_dwSubnetMask;
DWORD m_dwDefaultGateway;
BYTE m_sHostname[32];
BYTE m_abVendorSpecificExt2[48];
} tEplDllIdentParam;
typedef struct
{
unsigned int m_uiNodeId;
WORD m_wPreqPayloadLimit; // object 0x1F8B: NMT_MNPReqPayloadLimitList_AU16
WORD m_wPresPayloadLimit; // object 0x1F8D: NMT_PResPayloadLimitList_AU16
DWORD m_dwPresTimeout; // object 0x1F92: NMT_MNCNPResTimeout_AU32
} tEplDllNodeInfo;
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#endif // #ifndef _EPL_DLL_H_

View file

@ -0,0 +1,131 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for DLL Communication Abstraction Layer module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplDllCal.h,v $
$Author: D.Krueger $
$Revision: 1.4 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/20 d.k.: start of the implementation, version 1.00
****************************************************************************/
#ifndef _EPL_DLLCAL_H_
#define _EPL_DLLCAL_H_
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
/*#ifndef EPL_DLLCAL_BUFFER_ID_RX
#define EPL_DLLCAL_BUFFER_ID_RX "EplSblDllCalRx"
#endif
#ifndef EPL_DLLCAL_BUFFER_SIZE_RX
#define EPL_DLLCAL_BUFFER_SIZE_RX 32767
#endif
*/
#ifndef EPL_DLLCAL_BUFFER_ID_TX_NMT
#define EPL_DLLCAL_BUFFER_ID_TX_NMT "EplSblDllCalTxNmt"
#endif
#ifndef EPL_DLLCAL_BUFFER_SIZE_TX_NMT
#define EPL_DLLCAL_BUFFER_SIZE_TX_NMT 32767
#endif
#ifndef EPL_DLLCAL_BUFFER_ID_TX_GEN
#define EPL_DLLCAL_BUFFER_ID_TX_GEN "EplSblDllCalTxGen"
#endif
#ifndef EPL_DLLCAL_BUFFER_SIZE_TX_GEN
#define EPL_DLLCAL_BUFFER_SIZE_TX_GEN 32767
#endif
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
typedef struct
{
tEplDllAsndServiceId m_ServiceId;
tEplDllAsndFilter m_Filter;
} tEplDllCalAsndServiceIdFilter;
typedef struct
{
tEplDllReqServiceId m_Service;
unsigned int m_uiNodeId;
BYTE m_bSoaFlag1;
} tEplDllCalIssueRequest;
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#endif // #ifndef _EPL_DLLKCAL_H_

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,534 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for DLL Communication Abstraction Layer module in EPL user part
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplDlluCal.c,v $
$Author: D.Krueger $
$Revision: 1.7 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/20 d.k.: start of the implementation, version 1.00
****************************************************************************/
#include "user/EplDlluCal.h"
#include "user/EplEventu.h"
#include "EplDllCal.h"
// include only if direct call between user- and kernelspace is enabled
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
#include "kernel/EplDllkCal.h"
#endif
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
/***************************************************************************/
/* */
/* */
/* C L A S S EplDlluCal */
/* */
/* */
/***************************************************************************/
//
// Description:
//
//
/***************************************************************************/
//=========================================================================//
// //
// P R I V A T E D E F I N I T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
typedef struct
{
tEplDlluCbAsnd m_apfnDlluCbAsnd[EPL_DLL_MAX_ASND_SERVICE_ID];
} tEplDlluCalInstance;
//---------------------------------------------------------------------------
// local vars
//---------------------------------------------------------------------------
// if no dynamic memory allocation shall be used
// define structures statically
static tEplDlluCalInstance EplDlluCalInstance_g;
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
static tEplKernel EplDlluCalSetAsndServiceIdFilter(tEplDllAsndServiceId ServiceId_p, tEplDllAsndFilter Filter_p);
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplDlluCalAddInstance()
//
// Description: add and initialize new instance of DLL CAL module
//
// Parameters: none
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel EplDlluCalAddInstance()
{
tEplKernel Ret = kEplSuccessful;
// reset instance structure
EPL_MEMSET(&EplDlluCalInstance_g, 0, sizeof (EplDlluCalInstance_g));
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplDlluCalDelInstance()
//
// Description: deletes an instance of DLL CAL module
//
// Parameters: none
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel EplDlluCalDelInstance()
{
tEplKernel Ret = kEplSuccessful;
// reset instance structure
EPL_MEMSET(&EplDlluCalInstance_g, 0, sizeof (EplDlluCalInstance_g));
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplDlluCalProcess
//
// Description: process the passed asynch frame
//
// Parameters: pEvent_p = event containing frame to be processed
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel EplDlluCalProcess(tEplEvent * pEvent_p)
{
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;
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);
}
}
}
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplDlluCalRegAsndService()
//
// Description: registers the specified handler for the specified
// AsndServiceId with the specified node ID filter.
//
// Parameters: ServiceId_p = ASnd Service ID
// pfnDlluCbAsnd_p = callback function
// Filter_p = node ID filter
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel EplDlluCalRegAsndService(tEplDllAsndServiceId ServiceId_p, tEplDlluCbAsnd pfnDlluCbAsnd_p, tEplDllAsndFilter Filter_p)
{
tEplKernel Ret = kEplSuccessful;
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;
}
// set filter in DLL module in kernel part
Ret = EplDlluCalSetAsndServiceIdFilter(ServiceId_p, Filter_p);
}
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplDlluCalAsyncSend()
//
// Description: sends the frame with the specified priority.
//
// Parameters: pFrameInfo_p = frame
// m_uiFrameSize does not include the
// ethernet header (14 bytes)
// Priority_p = priority
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel EplDlluCalAsyncSend(tEplFrameInfo * pFrameInfo_p, tEplDllAsyncReqPriority Priority_p)
{
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);
#else
Ret = kEplSuccessful;
#endif
return Ret;
}
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
//---------------------------------------------------------------------------
//
// Function: EplDlluCalIssueRequest()
//
// Description: issues a StatusRequest or a IdentRequest to the specified node.
//
// Parameters: Service_p = request service ID
// uiNodeId_p = node ID
// bSoaFlag1_p = flag1 for this node (transmit in SoA and PReq)
// If 0xFF this flag is ignored.
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel EplDlluCalIssueRequest(tEplDllReqServiceId Service_p, unsigned int uiNodeId_p, BYTE bSoaFlag1_p)
{
tEplKernel Ret = kEplSuccessful;
// 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);
Ret = EplEventuPost(&Event);
break;
}
default:
{
Ret = kEplDllInvalidParam;
goto Exit;
}
}
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplDlluCalAddNode()
//
// Description: adds the specified node to the isochronous phase.
//
// Parameters: pNodeInfo_p = pointer of node info structure
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel EplDlluCalAddNode(tEplDllNodeInfo * pNodeInfo_p)
{
tEplKernel Ret = kEplSuccessful;
tEplEvent Event;
Event.m_EventSink = kEplEventSinkDllkCal;
Event.m_EventType = kEplEventTypeDllkAddNode;
Event.m_pArg = pNodeInfo_p;
Event.m_uiSize = sizeof (tEplDllNodeInfo);
Ret = EplEventuPost(&Event);
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplDlluCalDeleteNode()
//
// Description: removes the specified node from the isochronous phase.
//
// Parameters: uiNodeId_p = node ID
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel EplDlluCalDeleteNode(unsigned int uiNodeId_p)
{
tEplKernel Ret = kEplSuccessful;
tEplEvent Event;
Event.m_EventSink = kEplEventSinkDllkCal;
Event.m_EventType = kEplEventTypeDllkDelNode;
Event.m_pArg = &uiNodeId_p;
Event.m_uiSize = sizeof (uiNodeId_p);
Ret = EplEventuPost(&Event);
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplDlluCalSoftDeleteNode()
//
// Description: removes the specified node softly from the isochronous phase.
//
// Parameters: uiNodeId_p = node ID
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel EplDlluCalSoftDeleteNode(unsigned int uiNodeId_p)
{
tEplKernel Ret = kEplSuccessful;
tEplEvent Event;
Event.m_EventSink = kEplEventSinkDllkCal;
Event.m_EventType = kEplEventTypeDllkSoftDelNode;
Event.m_pArg = &uiNodeId_p;
Event.m_uiSize = sizeof (uiNodeId_p);
Ret = EplEventuPost(&Event);
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 //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplDlluCalSetAsndServiceIdFilter()
//
// Description: forwards call to EplDllkSetAsndServiceIdFilter() in kernel part
//
// Parameters: ServiceId_p = ASnd Service ID
// Filter_p = node ID filter
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
static tEplKernel EplDlluCalSetAsndServiceIdFilter(tEplDllAsndServiceId ServiceId_p, tEplDllAsndFilter Filter_p)
{
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);
Ret = EplEventuPost(&Event);
return Ret;
}
#endif // (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
// EOF

View file

@ -0,0 +1,302 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: definitions for all EPL-function return codes
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplErrDef.h,v $
$Author: D.Krueger $
$Revision: 1.9 $ $Date: 2008/06/23 14:56:33 $
$State: Exp $
Build Environment:
all
-------------------------------------------------------------------------
Revision History:
2005/12/05 -as: start of the implementation, version 1.00
****************************************************************************/
#ifndef _EPL_ERRORDEF_H_
#define _EPL_ERRORDEF_H_
//---------------------------------------------------------------------------
// return codes
//---------------------------------------------------------------------------
typedef enum
{
// area for generic errors 0x0000 - 0x000F
kEplSuccessful = 0x0000, // no error/successful run
kEplIllegalInstance = 0x0001, // the called Instanz does not exist
kEplInvalidInstanceParam = 0x0002, //
kEplNoFreeInstance = 0x0003, // XxxAddInstance was called but no free instance is available
kEplWrongSignature = 0x0004, // wrong signature while writing to object 0x1010 or 0x1011
kEplInvalidOperation = 0x0005, // operation not allowed in this situation
kEplInvalidNodeId = 0x0007, // invalid NodeId was specified
kEplNoResource = 0x0008, // resource could not be created (Windows, PxROS, ...)
kEplShutdown = 0x0009, // stack is shutting down
kEplReject = 0x000A, // reject the subsequent command
// area for EDRV module 0x0010 - 0x001F
// kEplEdrvNoFrame = 0x0010, // no CAN message was received
// kEplEdrvMsgHigh = 0x0011, // CAN message with high priority was received
// kEplEdrvMsgLow = 0x0012, // CAN message with low priority was received
kEplEdrvInitError = 0x0013, // initialisation error
kEplEdrvNoFreeBufEntry = 0x0014, // no free entry in internal buffer table for Tx frames
kEplEdrvBufNotExisting = 0x0015, // specified Tx buffer does not exist
// kEplEdrvNoFreeChannel = 0x0014, // CAN controller has not a free channel
// kEplEdrvTxBuffHighOverrun = 0x0015, // buffer for high priority CAN transmit messages has overrun
// kEplEdrvTxBuffLowOverrun = 0x0016, // buffer for low priority CAN transmit messages has overrun
// kEplEdrvIllegalBdi = 0x0017, // unsupported baudrate within baudrate table
// kEplEdrvBusy = 0x0018, // remote frame can not be updated because no bus contact or CAN
// transmission is activ
// kEplEdrvInvalidDriverType = 0x0019, // (PC: Windows or Linux) invalid driver type
// kEplEdrvDriverNotFound = 0x001A, // (PC: Windows or Linux) driver (DLL) could not be found
// kEplEdrvInvalidBaseAddress = 0x001B, // (PC: Windows or Linux) driver could not found the CAN controller
// kEplEdrvInvalidParam = 0x001C, // invalid param in function call
// area for COB module 0x0020 - 0x002F
/* kEplCobNoFreeEntry = 0x0020, // no free entry in RX- or TX-COB table
kEplCobAlreadyExist = 0x0021, // COB-ID already exists in RX- resp. TX-COB table
*/
kEplDllIllegalHdl = 0x0022, // illegal handle for a TxFrame was passed
kEplDllCbAsyncRegistered = 0x0023, // handler for non-EPL frames was already registered before
// kEplDllAsyncRxBufferFull = 0x0024, // receive buffer for asynchronous frames is full
kEplDllAsyncTxBufferEmpty = 0x0025, // transmit buffer for asynchronous frames is empty
kEplDllAsyncTxBufferFull = 0x0026, // transmit buffer for asynchronous frames is full
kEplDllNoNodeInfo = 0x0027, // MN: too less space in the internal node info structure
kEplDllInvalidParam = 0x0028, // invalid parameters passed to function
kEplDllTxBufNotReady = 0x002E, // TxBuffer (e.g. for PReq) is not ready yet
kEplDllTxFrameInvalid = 0x002F, // TxFrame (e.g. for PReq) is invalid or does not exist
/* kEplCobIllegalCanId = 0x0023, // COB-ID is not allowed (like 0x000 is reserved for NMT, ...)
kEplCobInvalidCanId = 0x0024, // COB-ID is switched off
kEplCobCdrvStateSet = 0x0025, // at least one bit of CAN driver state is set
kEplCobNoFreeEntryHighBuf = 0x0026, // no free entry in high priotity RX- or TX-COB table
kEplCobOwnId = 0x0027, // COB-ID already exists in own module which calls CobDefine() or CobCheck()
*/
// area for OBD module 0x0030 - 0x003F
kEplObdIllegalPart = 0x0030, // unknown OD part
kEplObdIndexNotExist = 0x0031, // object index does not exist in OD
kEplObdSubindexNotExist = 0x0032, // subindex does not exist in object index
kEplObdReadViolation = 0x0033, // read access to a write-only object
kEplObdWriteViolation = 0x0034, // write access to a read-only object
kEplObdAccessViolation = 0x0035, // access not allowed
kEplObdUnknownObjectType = 0x0036, // object type not defined/known
kEplObdVarEntryNotExist = 0x0037, // object does not contain VarEntry structure
kEplObdValueTooLow = 0x0038, // value to write to an object is too low
kEplObdValueTooHigh = 0x0039, // value to write to an object is too high
kEplObdValueLengthError = 0x003A, // value to write is to long or to short
// kEplObdIllegalFloat = 0x003B, // illegal float variable
// kEplObdWrongOdBuilderKey = 0x003F, // OD was generated with demo version of tool ODBuilder
// area for NMT module 0x0040 - 0x004F
kEplNmtUnknownCommand = 0x0040, // unknown NMT command
kEplNmtInvalidFramePointer = 0x0041, // pointer to the frame is not valid
kEplNmtInvalidEvent = 0x0042, // invalid event send to NMT-modul
kEplNmtInvalidState = 0x0043, // unknown state in NMT-State-Maschine
kEplNmtInvalidParam = 0x0044, // invalid parameters specified
// area for SDO/UDP module 0x0050 - 0x005F
kEplSdoUdpMissCb = 0x0050, // missing callback-function pointer during inti of
// module
kEplSdoUdpNoSocket = 0x0051, // error during init of socket
kEplSdoUdpSocketError = 0x0052, // error during usage of socket
kEplSdoUdpThreadError = 0x0053, // error during start of listen thread
kEplSdoUdpNoFreeHandle = 0x0054, // no free connection handle for Udp
kEplSdoUdpSendError = 0x0055, // Error during send of frame
kEplSdoUdpInvalidHdl = 0x0056, // the connection handle is invalid
// area for SDO Sequence layer module 0x0060 - 0x006F
kEplSdoSeqMissCb = 0x0060, // no callback-function assign
kEplSdoSeqNoFreeHandle = 0x0061, // no free handle for connection
kEplSdoSeqInvalidHdl = 0x0062, // invalid handle in SDO sequence layer
kEplSdoSeqUnsupportedProt = 0x0063, // unsupported Protocol selected
kEplSdoSeqNoFreeHistory = 0x0064, // no free entry in history
kEplSdoSeqFrameSizeError = 0x0065, // the size of the frames is not correct
kEplSdoSeqRequestAckNeeded = 0x0066, // indeicates that the history buffer is full
// and a ack request is needed
kEplSdoSeqInvalidFrame = 0x0067, // frame not valid
kEplSdoSeqConnectionBusy = 0x0068, // connection is busy -> retry later
kEplSdoSeqInvalidEvent = 0x0069, // invalid event received
// area for SDO Command Layer Module 0x0070 - 0x007F
kEplSdoComUnsupportedProt = 0x0070, // unsupported Protocol selected
kEplSdoComNoFreeHandle = 0x0071, // no free handle for connection
kEplSdoComInvalidServiceType= 0x0072, // invalid SDO service type specified
kEplSdoComInvalidHandle = 0x0073, // handle invalid
kEplSdoComInvalidSendType = 0x0074, // the stated to of frame to send is
// not possible
kEplSdoComNotResponsible = 0x0075, // internal error: command layer handle is
// not responsible for this event from sequence layer
kEplSdoComHandleExists = 0x0076, // handle to same node already exists
kEplSdoComHandleBusy = 0x0077, // transfer via this handle is already running
kEplSdoComInvalidParam = 0x0078, // invalid parameters passed to function
// area for EPL Event-Modul 0x0080 - 0x008F
kEplEventUnknownSink = 0x0080, // unknown sink for event
kEplEventPostError = 0x0081, // error during post of event
// area for EPL Timer Modul 0x0090 - 0x009F
kEplTimerInvalidHandle = 0x0090, // invalid handle for timer
kEplTimerNoTimerCreated = 0x0091, // no timer was created caused by
// an error
// area for EPL SDO/Asnd Module 0x00A0 - 0x0AF
kEplSdoAsndInvalidNodeId = 0x00A0, //0 node id is invalid
kEplSdoAsndNoFreeHandle = 0x00A1, // no free handle for connection
kEplSdoAsndInvalidHandle = 0x00A2, // handle for connection is invalid
// area for PDO module 0x00B0 - 0x00BF
kEplPdoNotExist = 0x00B0, // selected PDO does not exist
kEplPdoLengthExceeded = 0x00B1, // length of PDO mapping exceedes 64 bis
kEplPdoGranularityMismatch = 0x00B2, // configured PDO granularity is not equal to supported granularity
kEplPdoInitError = 0x00B3, // error during initialisation of PDO module
kEplPdoErrorPdoEncode = 0x00B4, // error during encoding a PDO
kEplPdoErrorPdoDecode = 0x00B5, // error during decoding a PDO
kEplPdoErrorSend = 0x00B6, // error during sending a PDO
kEplPdoErrorSyncWin = 0x00B7, // the SYNC window runs out during sending SYNC-PDOs
kEplPdoErrorMapp = 0x00B8, // invalid PDO mapping
kEplPdoVarNotFound = 0x00B9, // variable was not found in function PdoSignalVar()
kEplPdoErrorEmcyPdoLen = 0x00BA, // the length of a received PDO is unequal to the expected value
kEplPdoWriteConstObject = 0x00BB, // constant object can not be written
// (only TxType, Inhibit-, Event Time for CANopen Kit)
// area for LSS slave module
/* kEplLsssResetNode = 0x0080, // NMT command "reset node" has to be processed after LSS configuration
// new of NodeId
kEplLsssInvalidNodeId = 0x0081, // no valid NodeId is configured -> wait until it is configured with
// LSS service before calling CcmConnectToNet()
*/
// area for emergency consumer module 0x0090 - 0x009F
/* kEplEmccNoFreeProducerEntry = 0x0090, // no free entry to add a Emergency Producer
kEplEmccNodeIdNotExist = 0x0091, // selected NodeId was never added
kEplEmccNodeIdInvalid = 0x0092, // selected NodeId is outside of range (0x01 until 0x7F)
kEplEmccNodeIdExist = 0x0093, // selected NodeId already exist
*/
// area for dynamic OD 0x00A0 - 0x00AF
/* kEplDynNoMemory = 0x00A0, // no memory available
kEplDynInvalidConfig = 0x00A1, // invalid configuration in segment container
*/
// area for hertbeat consumer module 0x00B0 - 0x00BF
/* kEplHbcEntryNotExist = 0x00B0, // Heartbeat Producer node not configured
kEplHbcEntryAlreadyExist = 0x00B1, // NodeId was already defined in heartbeat consumer table (object 0x1016)
*/
// Configuration manager module 0x00C0 - 0x00CF
kEplCfgMaConfigError = 0x00C0, // error in configuration manager
kEplCfgMaSdocTimeOutError = 0x00C1, // error in configuration manager, Sdo timeout
kEplCfgMaInvalidDcf = 0x00C2, // configration file not valid
kEplCfgMaUnsupportedDcf = 0x00C3, // unsupported Dcf format
kEplCfgMaConfigWithErrors = 0x00C4, // configuration finished with errors
kEplCfgMaNoFreeConfig = 0x00C5, // no free configuration entry
kEplCfgMaNoConfigData = 0x00C6, // no configuration data present
kEplCfgMaUnsuppDatatypeDcf = 0x00C7, // unsupported datatype found in dcf
// -> this entry was not configured
// area for LSS master module 0x00D0 - 0x00DF
/* kEplLssmIllegalMode = 0x00D0, // illegal LSS mode (operation / configuration)
kEplLssmIllegalState = 0x00D1, // function was called in illegal state of LSS master
kEplLssmBusy = 0x00D2, // LSS process is busy with an previous service
kEplLssmIllegalCmd = 0x00D3, // illegal command code was set for function LssmInquireIdentity()
kEplLssmTimeout = 0x00D4, // LSS slave did not answer a LSS service
kEplLssmErrorInConfirm = 0x00D5, // LSS slave replied an error code for a LSS service
*/
// area for CCM modules 0x00E0 - 0xEF
/* kEplCcmStoreUnvalidState = 0x00E0, // memory device not available due device state
kEplCcmStoreHwError = 0x00E1, // hw error due device access
*/
// area for SRDO module 0x0100 - 0x011F
/* kEplSrdoNotExist = 0x0100, // selected SRDO does not exist
kEplSrdoGranularityMismatch = 0x0101, // configured SRDO granularity is not equal to supported granularity
kEplSrdoCfgTimingError = 0x0102, // configuration is not ok (Timing)
kEplSrdoCfgIdError = 0x0103, // configuration is not ok (CobIds)
kEplSrdoCfgCrcError = 0x0104, // configuration is not ok (CRC)
kEplSrdoNmtError = 0x0105, // an action was tried in a wrong NMT state
kEplSrdoInvalidCfg = 0x0106, // an action was tried with an invald SRDO configuration
kEplSrdoInvalid = 0x0107, // an action was tried with an invald SRDO
kEplSrdoRxTxConflict = 0x0108, // an transmission was tried with an receive SRDO (or the other way)
kEplSrdoIllegalCanId = 0x0109, // the CanId is invalid
kEplSrdoCanIdAlreadyInUse = 0x010A, // the CanId is already in use
kEplSrdoNotInOrder = 0x010B, // the two messages of a SRDO are not in order
kEplSrdoSctTimeout = 0x010C, // timeout of SCT
kEplSrdoSrvtTimeout = 0x010D, // timeout of SRVT
kEplSrdoCanIdNotValid = 0x010E, // one of received CAN-IDs are not equal to configured one
kEplSrdoDlcNotValid = 0x010F, // one of received CAN-DLC are not equal to configured one
kEplSrdoErrorMapp = 0x0110, // wrong values in mapping found
kEplSrdoDataError = 0x0111, // data of CAN messages are not invers
kEplSrdoLengthExceeded = 0x0112, // length of SRDO mapping exceedes 64 bit per CAN-message
kEplSrdoNotHandledInApp = 0x0113, // the SRDO error was not handled in AppSrdoError()
kEplSrdoOverrun = 0x0114 // a RxSRDO was received but the pevious one was not else processed
*/
kEplApiTaskDeferred = 0x0140, // EPL performs task in background and informs the application (or vice-versa), when it is finished
kEplApiInvalidParam = 0x0142, // passed invalid parameters to a function (e.g. invalid node id)
// area untill 0x07FF is reserved
// area for user application from 0x0800 to 0x7FFF
} tEplKernel;
#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).

View file

@ -0,0 +1,800 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for error handler module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplErrorHandlerk.c,v $
$Author: D.Krueger $
$Revision: 1.9 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/10/02 d.k.: start of the implementation
****************************************************************************/
#include "kernel/EplErrorHandlerk.h"
#include "EplNmt.h"
#include "kernel/EplEventk.h"
#include "kernel/EplObdk.h" // function prototyps of the EplOBD-Modul
#include "kernel/EplDllk.h"
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) == 0)
#error "EPL ErrorHandler module needs EPL module OBDK!"
#endif
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
typedef struct
{
DWORD m_dwCumulativeCnt; // subindex 1
DWORD m_dwThresholdCnt; // subindex 2
DWORD m_dwThreshold; // subindex 3
} tEplErrorHandlerkErrorCounter;
typedef struct
{
tEplErrorHandlerkErrorCounter m_CnLossSoc; // object 0x1C0B
tEplErrorHandlerkErrorCounter m_CnLossPreq; // object 0x1C0D
tEplErrorHandlerkErrorCounter m_CnCrcErr; // object 0x1C0F
unsigned long m_ulDllErrorEvents;
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
tEplErrorHandlerkErrorCounter m_MnCrcErr; // object 0x1C00
tEplErrorHandlerkErrorCounter m_MnCycTimeExceed; // object 0x1C02
DWORD m_adwMnCnLossPresCumCnt[254]; // object 0x1C07
DWORD m_adwMnCnLossPresThrCnt[254]; // object 0x1C08
DWORD m_adwMnCnLossPresThreshold[254];// object 0x1C09
BOOL m_afMnCnLossPresEvent[254];
#endif
} tEplErrorHandlerkInstance;
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
static tEplErrorHandlerkInstance EplErrorHandlerkInstance_g;
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
static tEplKernel EplErrorHandlerkLinkErrorCounter(
tEplErrorHandlerkErrorCounter* pErrorCounter_p,
unsigned int uiIndex_p);
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
static tEplKernel EplErrorHandlerkLinkArray(
DWORD* pdwValue_p,
unsigned int uiValueCount_p,
unsigned int uiIndex_p);
#endif
/***************************************************************************/
/* */
/* */
/* C L A S S <Epl-Kernelspace-Error-Handler> */
/* */
/* */
/***************************************************************************/
//
// Description:
//
//
/***************************************************************************/
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplErrorHandlerkInit
//
// Description: function initialize the first instance
//
//
//
// Parameters:
//
//
// Returns: tEpKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplErrorHandlerkInit(void)
{
tEplKernel Ret;
Ret = EplErrorHandlerkAddInstance();
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplErrorHandlerkAddInstance
//
// Description: function add one more instance
//
//
//
// Parameters:
//
//
// Returns: tEpKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplErrorHandlerkAddInstance(void)
{
tEplKernel Ret;
Ret = kEplSuccessful;
// reset only event variable,
// all other instance members are reset by OD or may keep their current value
// d.k.: this is necessary for the cumulative counters, which shall not be reset
EplErrorHandlerkInstance_g.m_ulDllErrorEvents = 0;
// link counters to OD
// $$$ d.k. if OD resides in userspace, fetch pointer to shared memory,
// which shall have the same structure as the instance (needs to be declared globally).
// Other idea: error counter shall belong to the process image
// (reset of counters by SDO write are a little bit tricky).
Ret = EplErrorHandlerkLinkErrorCounter(
&EplErrorHandlerkInstance_g.m_CnLossSoc,
0x1C0B);
if (Ret != kEplSuccessful)
{
goto Exit;
}
Ret = EplErrorHandlerkLinkErrorCounter(
&EplErrorHandlerkInstance_g.m_CnLossPreq,
0x1C0D);
// ignore return code, because object 0x1C0D is conditional
Ret = EplErrorHandlerkLinkErrorCounter(
&EplErrorHandlerkInstance_g.m_CnCrcErr,
0x1C0F);
if (Ret != kEplSuccessful)
{
goto Exit;
}
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
Ret = EplErrorHandlerkLinkErrorCounter(
&EplErrorHandlerkInstance_g.m_MnCrcErr,
0x1C00);
if (Ret != kEplSuccessful)
{
goto Exit;
}
Ret = EplErrorHandlerkLinkErrorCounter(
&EplErrorHandlerkInstance_g.m_MnCycTimeExceed,
0x1C02);
if (Ret != kEplSuccessful)
{
goto Exit;
}
Ret = EplErrorHandlerkLinkArray(
EplErrorHandlerkInstance_g.m_adwMnCnLossPresCumCnt,
tabentries(EplErrorHandlerkInstance_g.m_adwMnCnLossPresCumCnt),
0x1C07);
if (Ret != kEplSuccessful)
{
goto Exit;
}
Ret = EplErrorHandlerkLinkArray(
EplErrorHandlerkInstance_g.m_adwMnCnLossPresThrCnt,
tabentries(EplErrorHandlerkInstance_g.m_adwMnCnLossPresThrCnt),
0x1C08);
if (Ret != kEplSuccessful)
{
goto Exit;
}
Ret = EplErrorHandlerkLinkArray(
EplErrorHandlerkInstance_g.m_adwMnCnLossPresThreshold,
tabentries(EplErrorHandlerkInstance_g.m_adwMnCnLossPresThreshold),
0x1C09);
if (Ret != kEplSuccessful)
{
goto Exit;
}
#endif
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplErrorHandlerkDelInstance
//
// Description: function delete instance an free the bufferstructure
//
//
//
// Parameters:
//
//
// Returns: tEpKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplErrorHandlerkDelInstance()
{
tEplKernel Ret;
Ret = kEplSuccessful;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplErrorHandlerkProcess
//
// Description: processes error events from DLL
//
//
//
// Parameters: pEvent_p = pointer to event-structur from buffer
//
//
// Returns: tEpKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplErrorHandlerkProcess(tEplEvent* pEvent_p)
{
tEplKernel Ret;
unsigned long ulDllErrorEvents;
tEplEvent Event;
tEplNmtEvent NmtEvent;
Ret = kEplSuccessful;
// check m_EventType
switch(pEvent_p->m_EventType)
{
case kEplEventTypeDllError:
{
tEplErrorHandlerkEvent* pErrHandlerEvent = (tEplErrorHandlerkEvent*)pEvent_p->m_pArg;
ulDllErrorEvents = pErrHandlerEvent->m_ulDllErrorEvents;
// check the several error events
if ((EplErrorHandlerkInstance_g.m_CnLossSoc.m_dwThreshold > 0)
&& ((ulDllErrorEvents & EPL_DLL_ERR_CN_LOSS_SOC) != 0))
{ // loss of SoC event occured
// increment cumulative counter by 1
EplErrorHandlerkInstance_g.m_CnLossSoc.m_dwCumulativeCnt++;
// increment threshold counter by 8
EplErrorHandlerkInstance_g.m_CnLossSoc.m_dwThresholdCnt += 8;
if (EplErrorHandlerkInstance_g.m_CnLossSoc.m_dwThresholdCnt
>= EplErrorHandlerkInstance_g.m_CnLossSoc.m_dwThreshold)
{ // threshold is reached
// $$$ d.k.: generate error history entry E_DLL_LOSS_SOC_TH
// post event to NMT state machine
NmtEvent = kEplNmtEventNmtCycleError;
Event.m_EventSink = kEplEventSinkNmtk;
Event.m_EventType = kEplEventTypeNmtEvent;
Event.m_pArg = &NmtEvent;
Event.m_uiSize = sizeof (NmtEvent);
Ret = EplEventkPost(&Event);
}
EplErrorHandlerkInstance_g.m_ulDllErrorEvents |=
EPL_DLL_ERR_CN_LOSS_SOC;
}
if ((EplErrorHandlerkInstance_g.m_CnLossPreq.m_dwThreshold > 0)
&& ((ulDllErrorEvents & EPL_DLL_ERR_CN_LOSS_PREQ) != 0))
{ // loss of PReq event occured
// increment cumulative counter by 1
EplErrorHandlerkInstance_g.m_CnLossPreq.m_dwCumulativeCnt++;
// increment threshold counter by 8
EplErrorHandlerkInstance_g.m_CnLossPreq.m_dwThresholdCnt += 8;
if (EplErrorHandlerkInstance_g.m_CnLossPreq.m_dwThresholdCnt
>= EplErrorHandlerkInstance_g.m_CnLossPreq.m_dwThreshold)
{ // threshold is reached
// $$$ d.k.: generate error history entry E_DLL_LOSS_PREQ_TH
// post event to NMT state machine
NmtEvent = kEplNmtEventNmtCycleError;
Event.m_EventSink = kEplEventSinkNmtk;
Event.m_EventType = kEplEventTypeNmtEvent;
Event.m_pArg = &NmtEvent;
Event.m_uiSize = sizeof (NmtEvent);
Ret = EplEventkPost(&Event);
}
}
if ((EplErrorHandlerkInstance_g.m_CnLossPreq.m_dwThresholdCnt > 0)
&& ((ulDllErrorEvents & EPL_DLL_ERR_CN_RECVD_PREQ) != 0))
{ // PReq correctly received
// decrement threshold counter by 1
EplErrorHandlerkInstance_g.m_CnLossPreq.m_dwThresholdCnt--;
}
if ((EplErrorHandlerkInstance_g.m_CnCrcErr.m_dwThreshold > 0)
&& ((ulDllErrorEvents & EPL_DLL_ERR_CN_CRC) != 0))
{ // CRC error event occured
// increment cumulative counter by 1
EplErrorHandlerkInstance_g.m_CnCrcErr.m_dwCumulativeCnt++;
// increment threshold counter by 8
EplErrorHandlerkInstance_g.m_CnCrcErr.m_dwThresholdCnt += 8;
if (EplErrorHandlerkInstance_g.m_CnCrcErr.m_dwThresholdCnt
>= EplErrorHandlerkInstance_g.m_CnCrcErr.m_dwThreshold)
{ // threshold is reached
// $$$ d.k.: generate error history entry E_DLL_CRC_TH
// post event to NMT state machine
NmtEvent = kEplNmtEventNmtCycleError;
Event.m_EventSink = kEplEventSinkNmtk;
Event.m_EventType = kEplEventTypeNmtEvent;
Event.m_pArg = &NmtEvent;
Event.m_uiSize = sizeof (NmtEvent);
Ret = EplEventkPost(&Event);
}
EplErrorHandlerkInstance_g.m_ulDllErrorEvents |=
EPL_DLL_ERR_CN_CRC;
}
if ((ulDllErrorEvents & EPL_DLL_ERR_INVALID_FORMAT) != 0)
{ // invalid format error occured (only direct reaction)
// $$$ d.k.: generate error history entry E_DLL_INVALID_FORMAT
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
if (pErrHandlerEvent->m_NmtState >= kEplNmtMsNotActive)
{ // MN is active
if (pErrHandlerEvent->m_uiNodeId != 0)
{
tEplHeartbeatEvent HeartbeatEvent;
// remove node from isochronous phase
Ret = EplDllkDeleteNode(pErrHandlerEvent->m_uiNodeId);
// inform NmtMnu module about state change, which shall send NMT command ResetNode to this CN
HeartbeatEvent.m_uiNodeId = pErrHandlerEvent->m_uiNodeId;
HeartbeatEvent.m_NmtState = kEplNmtCsNotActive;
HeartbeatEvent.m_wErrorCode = EPL_E_DLL_INVALID_FORMAT;
Event.m_EventSink = kEplEventSinkNmtMnu;
Event.m_EventType = kEplEventTypeHeartbeat;
Event.m_uiSize = sizeof (HeartbeatEvent);
Event.m_pArg = &HeartbeatEvent;
Ret = EplEventkPost(&Event);
}
// $$$ and else should lead to InternComError
}
else
#endif
{ // CN is active
// post event to NMT state machine
NmtEvent = kEplNmtEventInternComError;
Event.m_EventSink = kEplEventSinkNmtk;
Event.m_EventType = kEplEventTypeNmtEvent;
Event.m_pArg = &NmtEvent;
Event.m_uiSize = sizeof (NmtEvent);
Ret = EplEventkPost(&Event);
}
}
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
if ((EplErrorHandlerkInstance_g.m_MnCrcErr.m_dwThreshold > 0)
&& ((ulDllErrorEvents & EPL_DLL_ERR_MN_CRC) != 0))
{ // CRC error event occured
// increment cumulative counter by 1
EplErrorHandlerkInstance_g.m_MnCrcErr.m_dwCumulativeCnt++;
// increment threshold counter by 8
EplErrorHandlerkInstance_g.m_MnCrcErr.m_dwThresholdCnt += 8;
if (EplErrorHandlerkInstance_g.m_MnCrcErr.m_dwThresholdCnt
>= EplErrorHandlerkInstance_g.m_MnCrcErr.m_dwThreshold)
{ // threshold is reached
// $$$ d.k.: generate error history entry E_DLL_CRC_TH
// post event to NMT state machine
NmtEvent = kEplNmtEventNmtCycleError;
Event.m_EventSink = kEplEventSinkNmtk;
Event.m_EventType = kEplEventTypeNmtEvent;
Event.m_pArg = &NmtEvent;
Event.m_uiSize = sizeof (NmtEvent);
Ret = EplEventkPost(&Event);
}
EplErrorHandlerkInstance_g.m_ulDllErrorEvents |=
EPL_DLL_ERR_MN_CRC;
}
if ((EplErrorHandlerkInstance_g.m_MnCycTimeExceed.m_dwThreshold > 0)
&& ((ulDllErrorEvents & EPL_DLL_ERR_MN_CYCTIMEEXCEED) != 0))
{ // cycle time exceeded event occured
// increment cumulative counter by 1
EplErrorHandlerkInstance_g.m_MnCycTimeExceed.m_dwCumulativeCnt++;
// increment threshold counter by 8
EplErrorHandlerkInstance_g.m_MnCycTimeExceed.m_dwThresholdCnt += 8;
if (EplErrorHandlerkInstance_g.m_MnCycTimeExceed.m_dwThresholdCnt
>= EplErrorHandlerkInstance_g.m_MnCycTimeExceed.m_dwThreshold)
{ // threshold is reached
// $$$ d.k.: generate error history entry E_DLL_CYCLE_EXCEED_TH
// post event to NMT state machine
NmtEvent = kEplNmtEventNmtCycleError;
Event.m_EventSink = kEplEventSinkNmtk;
Event.m_EventType = kEplEventTypeNmtEvent;
Event.m_pArg = &NmtEvent;
Event.m_uiSize = sizeof (NmtEvent);
Ret = EplEventkPost(&Event);
}
// $$$ d.k.: else generate error history entry E_DLL_CYCLE_EXCEED
EplErrorHandlerkInstance_g.m_ulDllErrorEvents |=
EPL_DLL_ERR_MN_CYCTIMEEXCEED;
}
if ((ulDllErrorEvents & EPL_DLL_ERR_MN_CN_LOSS_PRES) != 0)
{ // CN loss PRes event occured
unsigned int uiNodeId;
uiNodeId = pErrHandlerEvent->m_uiNodeId - 1;
if ((uiNodeId < tabentries(EplErrorHandlerkInstance_g.m_adwMnCnLossPresCumCnt))
&& (EplErrorHandlerkInstance_g.m_adwMnCnLossPresThreshold[uiNodeId] > 0))
{
// increment cumulative counter by 1
EplErrorHandlerkInstance_g.m_adwMnCnLossPresCumCnt[uiNodeId]++;
// increment threshold counter by 8
EplErrorHandlerkInstance_g.m_adwMnCnLossPresThrCnt[uiNodeId] += 8;
if (EplErrorHandlerkInstance_g.m_adwMnCnLossPresThrCnt[uiNodeId]
>= EplErrorHandlerkInstance_g.m_adwMnCnLossPresThreshold[uiNodeId])
{ // threshold is reached
tEplHeartbeatEvent HeartbeatEvent;
// $$$ d.k.: generate error history entry E_DLL_LOSS_PRES_TH
// remove node from isochronous phase
Ret = EplDllkDeleteNode(pErrHandlerEvent->m_uiNodeId);
// inform NmtMnu module about state change, which shall send NMT command ResetNode to this CN
HeartbeatEvent.m_uiNodeId = pErrHandlerEvent->m_uiNodeId;
HeartbeatEvent.m_NmtState = kEplNmtCsNotActive;
HeartbeatEvent.m_wErrorCode = EPL_E_DLL_LOSS_PRES_TH;
Event.m_EventSink = kEplEventSinkNmtMnu;
Event.m_EventType = kEplEventTypeHeartbeat;
Event.m_uiSize = sizeof (HeartbeatEvent);
Event.m_pArg = &HeartbeatEvent;
Ret = EplEventkPost(&Event);
}
EplErrorHandlerkInstance_g.m_afMnCnLossPresEvent[uiNodeId] = TRUE;
}
}
#endif
break;
}
// NMT event
case kEplEventTypeNmtEvent:
{
if ((*(tEplNmtEvent*)pEvent_p->m_pArg) == kEplNmtEventDllCeSoa)
{ // SoA event of CN -> decrement threshold counters
if ((EplErrorHandlerkInstance_g.m_ulDllErrorEvents & EPL_DLL_ERR_CN_LOSS_SOC) == 0)
{ // decrement loss of SoC threshold counter, because it didn't occur last cycle
if (EplErrorHandlerkInstance_g.m_CnLossSoc.m_dwThresholdCnt > 0)
{
EplErrorHandlerkInstance_g.m_CnLossSoc.m_dwThresholdCnt--;
}
}
if ((EplErrorHandlerkInstance_g.m_ulDllErrorEvents & EPL_DLL_ERR_CN_CRC) == 0)
{ // decrement CRC threshold counter, because it didn't occur last cycle
if (EplErrorHandlerkInstance_g.m_CnCrcErr.m_dwThresholdCnt > 0)
{
EplErrorHandlerkInstance_g.m_CnCrcErr.m_dwThresholdCnt--;
}
}
}
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
else if ((*(tEplNmtEvent*)pEvent_p->m_pArg) == kEplNmtEventDllMeSoaSent)
{ // SoA event of MN -> decrement threshold counters
tEplDllkNodeInfo* pIntNodeInfo;
unsigned int uiNodeId;
Ret = EplDllkGetFirstNodeInfo(&pIntNodeInfo);
if (Ret != kEplSuccessful)
{
break;
}
// iterate through node info structure list
while (pIntNodeInfo != NULL)
{
uiNodeId = pIntNodeInfo->m_uiNodeId - 1;
if (uiNodeId < tabentries(EplErrorHandlerkInstance_g.m_adwMnCnLossPresCumCnt))
{
if (EplErrorHandlerkInstance_g.m_afMnCnLossPresEvent[uiNodeId] == FALSE)
{
if (EplErrorHandlerkInstance_g.m_adwMnCnLossPresThrCnt[uiNodeId] > 0)
{
EplErrorHandlerkInstance_g.m_adwMnCnLossPresThrCnt[uiNodeId]--;
}
}
else
{
EplErrorHandlerkInstance_g.m_afMnCnLossPresEvent[uiNodeId] = FALSE;
}
}
pIntNodeInfo = pIntNodeInfo->m_pNextNodeInfo;
}
if ((EplErrorHandlerkInstance_g.m_ulDllErrorEvents & EPL_DLL_ERR_MN_CRC) == 0)
{ // decrement CRC threshold counter, because it didn't occur last cycle
if (EplErrorHandlerkInstance_g.m_MnCrcErr.m_dwThresholdCnt > 0)
{
EplErrorHandlerkInstance_g.m_MnCrcErr.m_dwThresholdCnt--;
}
}
if ((EplErrorHandlerkInstance_g.m_ulDllErrorEvents & EPL_DLL_ERR_MN_CYCTIMEEXCEED) == 0)
{ // decrement cycle exceed threshold counter, because it didn't occur last cycle
if (EplErrorHandlerkInstance_g.m_MnCycTimeExceed.m_dwThresholdCnt > 0)
{
EplErrorHandlerkInstance_g.m_MnCycTimeExceed.m_dwThresholdCnt--;
}
}
}
#endif
// reset error events
EplErrorHandlerkInstance_g.m_ulDllErrorEvents = 0L;
break;
}
// unknown type
default:
{
}
} // end of switch(pEvent_p->m_EventType)
return Ret;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplErrorHandlerkLinkErrorCounter
//
// Description: link specified error counter structure to OD entry
//
// Parameters: pErrorCounter_p = pointer to error counter structure
// uiIndex_p = OD index
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
static tEplKernel EplErrorHandlerkLinkErrorCounter(
tEplErrorHandlerkErrorCounter* pErrorCounter_p,
unsigned int uiIndex_p)
{
tEplKernel Ret = kEplSuccessful;
tEplVarParam VarParam;
VarParam.m_pData = &pErrorCounter_p->m_dwCumulativeCnt;
VarParam.m_Size = sizeof(DWORD);
VarParam.m_uiIndex = uiIndex_p;
VarParam.m_uiSubindex = 0x01;
VarParam.m_ValidFlag = kVarValidAll;
Ret = EplObdDefineVar(&VarParam);
if (Ret != kEplSuccessful)
{
goto Exit;
}
VarParam.m_pData = &pErrorCounter_p->m_dwThresholdCnt;
VarParam.m_Size = sizeof(DWORD);
VarParam.m_uiIndex = uiIndex_p;
VarParam.m_uiSubindex = 0x02;
VarParam.m_ValidFlag = kVarValidAll;
Ret = EplObdDefineVar(&VarParam);
if (Ret != kEplSuccessful)
{
goto Exit;
}
VarParam.m_pData = &pErrorCounter_p->m_dwThreshold;
VarParam.m_Size = sizeof(DWORD);
VarParam.m_uiIndex = uiIndex_p;
VarParam.m_uiSubindex = 0x03;
VarParam.m_ValidFlag = kVarValidAll;
Ret = EplObdDefineVar(&VarParam);
if (Ret != kEplSuccessful)
{
goto Exit;
}
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplErrorHandlerkLinkErrorCounter
//
// Description: link specified error counter structure to OD entry
//
// Parameters: pErrorCounter_p = pointer to error counter structure
// uiIndex_p = OD index
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
static tEplKernel EplErrorHandlerkLinkArray(
DWORD* pdwValue_p,
unsigned int uiValueCount_p,
unsigned int uiIndex_p)
{
tEplKernel Ret = kEplSuccessful;
tEplVarParam VarParam;
tEplObdSize EntrySize;
BYTE bIndexEntries;
EntrySize = (tEplObdSize) sizeof(bIndexEntries);
Ret = EplObdReadEntry (
uiIndex_p,
0x00,
(void GENERIC*) &bIndexEntries,
&EntrySize );
if ((Ret != kEplSuccessful) || (bIndexEntries == 0x00))
{
// Object doesn't exist or invalid entry number
Ret = kEplObdIndexNotExist;
goto Exit;
}
if (bIndexEntries < uiValueCount_p)
{
uiValueCount_p = bIndexEntries;
}
VarParam.m_Size = sizeof(DWORD);
VarParam.m_uiIndex = uiIndex_p;
VarParam.m_ValidFlag = kVarValidAll;
for (VarParam.m_uiSubindex = 0x01; VarParam.m_uiSubindex <= uiValueCount_p; VarParam.m_uiSubindex++)
{
VarParam.m_pData = pdwValue_p;
Ret = EplObdDefineVar(&VarParam);
if (Ret != kEplSuccessful)
{
goto Exit;
}
pdwValue_p++;
}
Exit:
return Ret;
}
#endif //(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
#endif //(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
// EOF

View file

@ -0,0 +1,303 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for event module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplEvent.h,v $
$Author: D.Krueger $
$Revision: 1.8 $ $Date: 2008/11/17 16:40:39 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/12 d.k.: start of the implementation, version 1.00
****************************************************************************/
#ifndef _EPL_EVENT_H_
#define _EPL_EVENT_H_
#include "EplInc.h"
#include "EplNmt.h"
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
// name and size of event queues
#define EPL_EVENT_NAME_SHB_KERNEL_TO_USER "ShbKernelToUser"
#ifndef EPL_EVENT_SIZE_SHB_KERNEL_TO_USER
#define EPL_EVENT_SIZE_SHB_KERNEL_TO_USER 32768 // 32 kByte
#endif
#define EPL_EVENT_NAME_SHB_USER_TO_KERNEL "ShbUserToKernel"
#ifndef EPL_EVENT_SIZE_SHB_USER_TO_KERNEL
#define EPL_EVENT_SIZE_SHB_USER_TO_KERNEL 32768 // 32 kByte
#endif
// max size of event argument
#ifndef EPL_MAX_EVENT_ARG_SIZE
#define EPL_MAX_EVENT_ARG_SIZE 256 // because of PDO
#endif
#define EPL_DLL_ERR_MN_CRC 0x00000001L // object 0x1C00
#define EPL_DLL_ERR_MN_COLLISION 0x00000002L // object 0x1C01
#define EPL_DLL_ERR_MN_CYCTIMEEXCEED 0x00000004L // object 0x1C02
#define EPL_DLL_ERR_MN_LOSS_LINK 0x00000008L // object 0x1C03
#define EPL_DLL_ERR_MN_CN_LATE_PRES 0x00000010L // objects 0x1C04-0x1C06
#define EPL_DLL_ERR_MN_CN_LOSS_PRES 0x00000080L // objects 0x1C07-0x1C09
#define EPL_DLL_ERR_CN_COLLISION 0x00000400L // object 0x1C0A
#define EPL_DLL_ERR_CN_LOSS_SOC 0x00000800L // object 0x1C0B
#define EPL_DLL_ERR_CN_LOSS_SOA 0x00001000L // object 0x1C0C
#define EPL_DLL_ERR_CN_LOSS_PREQ 0x00002000L // object 0x1C0D
#define EPL_DLL_ERR_CN_RECVD_PREQ 0x00004000L // decrement object 0x1C0D/2
#define EPL_DLL_ERR_CN_SOC_JITTER 0x00008000L // object 0x1C0E
#define EPL_DLL_ERR_CN_CRC 0x00010000L // object 0x1C0F
#define EPL_DLL_ERR_CN_LOSS_LINK 0x00020000L // object 0x1C10
#define EPL_DLL_ERR_MN_LOSS_STATRES 0x00040000L // objects 0x1C15-0x1C17 (should be operated by NmtMnu module)
#define EPL_DLL_ERR_BAD_PHYS_MODE 0x00080000L // no object
#define EPL_DLL_ERR_MAC_BUFFER 0x00100000L // no object (NMT_GT6)
#define EPL_DLL_ERR_INVALID_FORMAT 0x00200000L // no object (NMT_GT6)
#define EPL_DLL_ERR_ADDRESS_CONFLICT 0x00400000L // no object (remove CN from configuration)
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
// EventType determines the argument of the event
typedef enum
{
kEplEventTypeNmtEvent = 0x01, // NMT event
// arg is pointer to tEplNmtEvent
kEplEventTypePdoRx = 0x02, // PDO frame received event (PRes/PReq)
// arg is pointer to tEplFrame
kEplEventTypePdoTx = 0x03, // PDO frame transmitted event (PRes/PReq)
// arg is pointer to tEplFrameInfo
kEplEventTypePdoSoa = 0x04, // SoA frame received event (isochronous phase completed)
// arg is pointer to nothing
kEplEventTypeSync = 0x05, // Sync event (e.g. SoC or anticipated SoC)
// arg is pointer to nothing
kEplEventTypeTimer = 0x06, // Timer event
// arg is pointer to tEplTimerEventArg
kEplEventTypeHeartbeat = 0x07, // Heartbeat event
// arg is pointer to tEplHeartbeatEvent
kEplEventTypeDllkCreate = 0x08, // DLL kernel create event
// arg is pointer to the new tEplNmtState
kEplEventTypeDllkDestroy = 0x09, // DLL kernel destroy event
// arg is pointer to the old tEplNmtState
kEplEventTypeDllkFillTx = 0x0A, // DLL kernel fill TxBuffer event
// arg is pointer to tEplDllAsyncReqPriority
kEplEventTypeDllkPresReady = 0x0B, // DLL kernel PRes ready event
// arg is pointer to nothing
kEplEventTypeError = 0x0C, // Error event for API layer
// arg is pointer to tEplEventError
kEplEventTypeNmtStateChange = 0x0D, // indicate change of NMT-State
// arg is pointer to tEplEventNmtStateChange
kEplEventTypeDllError = 0x0E, // DLL error event for Error handler
// arg is pointer to tEplErrorHandlerkEvent
kEplEventTypeAsndRx = 0x0F, // received ASnd frame for DLL user module
// arg is pointer to tEplFrame
kEplEventTypeDllkServFilter = 0x10, // configure ServiceIdFilter
// arg is pointer to tEplDllCalServiceIdFilter
kEplEventTypeDllkIdentity = 0x11, // configure Identity
// arg is pointer to tEplDllIdentParam
kEplEventTypeDllkConfig = 0x12, // configure ConfigParam
// arg is pointer to tEplDllConfigParam
kEplEventTypeDllkIssueReq = 0x13, // issue Ident/Status request
// arg is pointer to tEplDllCalIssueRequest
kEplEventTypeDllkAddNode = 0x14, // add node to isochronous phase
// arg is pointer to tEplDllNodeInfo
kEplEventTypeDllkDelNode = 0x15, // remove node from isochronous phase
// arg is pointer to unsigned int
kEplEventTypeDllkSoftDelNode= 0x16, // remove node softly from isochronous phase
// arg is pointer to unsigned int
kEplEventTypeDllkStartReducedCycle = 0x17, // start reduced EPL cycle on MN
// arg is pointer to nothing
kEplEventTypeNmtMnuNmtCmdSent = 0x18, // NMT command was actually sent
// arg is pointer to tEplFrame
} tEplEventType;
// EventSink determines the consumer of the event
typedef enum
{
kEplEventSinkSync = 0x00, // Sync event for application or kernel EPL module
kEplEventSinkNmtk = 0x01, // events for Nmtk module
kEplEventSinkDllk = 0x02, // events for Dllk module
kEplEventSinkDlluCal = 0x03, // events for DlluCal module
kEplEventSinkDllkCal = 0x04, // events for DllkCal module
kEplEventSinkPdok = 0x05, // events for Pdok module
kEplEventSinkNmtu = 0x06, // events for Nmtu module
kEplEventSinkErrk = 0x07, // events for Error handler module
kEplEventSinkErru = 0x08, // events for Error signaling module
kEplEventSinkSdoAsySeq = 0x09, // events for asyncronous SDO Sequence Layer module
kEplEventSinkNmtMnu = 0x0A, // events for NmtMnu module
kEplEventSinkLedu = 0x0B, // events for Ledu module
kEplEventSinkApi = 0x0F, // events for API module
} tEplEventSink;
// EventSource determines the source of an errorevent
typedef enum
{
// kernelspace modules
kEplEventSourceDllk = 0x01, // Dllk module
kEplEventSourceNmtk = 0x02, // Nmtk module
kEplEventSourceObdk = 0x03, // Obdk module
kEplEventSourcePdok = 0x04, // Pdok module
kEplEventSourceTimerk = 0x05, // Timerk module
kEplEventSourceEventk = 0x06, // Eventk module
kEplEventSourceSyncCb = 0x07, // sync-Cb
kEplEventSourceErrk = 0x08, // Error handler module
// userspace modules
kEplEventSourceDllu = 0x10, // Dllu module
kEplEventSourceNmtu = 0x11, // Nmtu module
kEplEventSourceNmtCnu = 0x12, // NmtCnu module
kEplEventSourceNmtMnu = 0x13, // NmtMnu module
kEplEventSourceObdu = 0x14, // Obdu module
kEplEventSourceSdoUdp = 0x15, // Sdo/Udp module
kEplEventSourceSdoAsnd = 0x16, // Sdo/Asnd module
kEplEventSourceSdoAsySeq = 0x17, // Sdo asynchronus Sequence Layer module
kEplEventSourceSdoCom = 0x18, // Sdo command layer module
kEplEventSourceTimeru = 0x19, // Timeru module
kEplEventSourceCfgMau = 0x1A, // CfgMau module
kEplEventSourceEventu = 0x1B, // Eventu module
kEplEventSourceEplApi = 0x1C, // Api module
kEplEventSourceLedu = 0x1D, // Ledu module
} tEplEventSource;
// structure of EPL event (element order must not be changed!)
typedef struct
{
tEplEventType m_EventType /*:28*/; // event type
tEplEventSink m_EventSink /*:4*/; // event sink
tEplNetTime m_NetTime; // timestamp
unsigned int m_uiSize; // size of argument
void * m_pArg; // argument of event
} tEplEvent;
// short structure of EPL event without argument and its size (element order must not be changed!)
typedef struct
{
tEplEventType m_EventType /*:28*/; // event type
tEplEventSink m_EventSink /*:4*/; // event sink
tEplNetTime m_NetTime; // timestamp
} tEplEventShort;
typedef struct
{
unsigned int m_uiIndex;
unsigned int m_uiSubIndex;
} tEplEventObdError;
// structure for kEplEventTypeError
typedef struct
{
tEplEventSource m_EventSource; // module which posted this error event
tEplKernel m_EplError; // EPL error which occured
union
{
BYTE m_bArg;
DWORD m_dwArg;
tEplEventSource m_EventSource; // from Eventk/u module (originating error source)
tEplEventObdError m_ObdError; // from Obd module
// tEplErrHistoryEntry m_HistoryEntry; // from Nmtk/u module
} m_Arg;
} tEplEventError;
// structure for kEplEventTypeDllError
typedef struct
{
unsigned long m_ulDllErrorEvents; // EPL_DLL_ERR_*
unsigned int m_uiNodeId;
tEplNmtState m_NmtState;
} tEplErrorHandlerkEvent;
// callback function to get informed about sync event
typedef tEplKernel (PUBLIC* tEplSyncCb) (void);
// callback function for generic events
typedef tEplKernel (PUBLIC* tEplProcessEventCb) (tEplEvent* pEplEvent_p);
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#endif // #ifndef _EPL_EVENT_H_

View file

@ -0,0 +1,858 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for Epl-Kernelspace-Event-Modul
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplEventk.c,v $
$Author: D.Krueger $
$Revision: 1.9 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/20 k.t.: start of the implementation
****************************************************************************/
#include "kernel/EplEventk.h"
#include "kernel/EplNmtk.h"
#include "kernel/EplDllk.h"
#include "kernel/EplDllkCal.h"
#include "kernel/EplErrorHandlerk.h"
#include "Benchmark.h"
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0)
#include "kernel/EplPdok.h"
#include "kernel/EplPdokCal.h"
#endif
#ifdef EPL_NO_FIFO
#include "user/EplEventu.h"
#else
#include "SharedBuff.h"
#endif
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
// 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)
#else
#define TGT_DBG_SIGNAL_TRACE_POINT(p)
#define TGT_DBG_POST_TRACE_VALUE(v)
#endif
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
typedef struct
{
#ifndef EPL_NO_FIFO
tShbInstance m_pShbKernelToUserInstance;
tShbInstance m_pShbUserToKernelInstance;
#else
#endif
tEplSyncCb m_pfnCbSync;
unsigned int m_uiUserToKernelFullCount;
} tEplEventkInstance;
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
static tEplEventkInstance EplEventkInstance_g;
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
// callback function for incoming events
#ifndef EPL_NO_FIFO
static void EplEventkRxSignalHandlerCb (
tShbInstance pShbRxInstance_p,
unsigned long ulDataSize_p);
#endif
/***************************************************************************/
/* */
/* */
/* C L A S S <Epl-Kernelspace-Event> */
/* */
/* */
/***************************************************************************/
//
// Description:
//
//
/***************************************************************************/
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplEventkInit
//
// Description: function initializes the first instance
//
// Parameters: pfnCbSync_p = callback-function for sync event
//
// Returns: tEpKernel = errorcode
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplEventkInit(tEplSyncCb pfnCbSync_p)
{
tEplKernel Ret;
Ret = EplEventkAddInstance(pfnCbSync_p);
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplEventkAddInstance
//
// Description: function adds one more instance
//
// Parameters: pfnCbSync_p = callback-function for sync event
//
// Returns: tEpKernel = errorcode
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplEventkAddInstance(tEplSyncCb pfnCbSync_p)
{
tEplKernel Ret;
#ifndef EPL_NO_FIFO
tShbError ShbError;
unsigned int fShbNewCreated;
#endif
Ret = kEplSuccessful;
// init instance structure
EplEventkInstance_g.m_uiUserToKernelFullCount = 0;
// save cb-function
EplEventkInstance_g.m_pfnCbSync = pfnCbSync_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,
&EplEventkInstance_g.m_pShbKernelToUserInstance,
&fShbNewCreated);
if(ShbError != kShbOk)
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventkAddInstance(): 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,
&EplEventkInstance_g.m_pShbUserToKernelInstance,
&fShbNewCreated);
if(ShbError != kShbOk)
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventkAddInstance(): ShbCirAllocBuffer(U2K) -> 0x%X\n", ShbError);
Ret = kEplNoResource;
goto Exit;
}
// register eventhandler
ShbError = ShbCirSetSignalHandlerNewData (EplEventkInstance_g.m_pShbUserToKernelInstance,
EplEventkRxSignalHandlerCb,
kshbPriorityHigh);
if(ShbError != kShbOk)
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventkAddInstance(): ShbCirSetSignalHandlerNewData(U2K) -> 0x%X\n", ShbError);
Ret = kEplNoResource;
goto Exit;
}
Exit:
#endif
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplEventkDelInstance
//
// Description: function deletes instance and frees the buffers
//
// Parameters: void
//
// Returns: tEpKernel = errorcode
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplEventkDelInstance()
{
tEplKernel Ret;
#ifndef EPL_NO_FIFO
tShbError ShbError;
#endif
Ret = kEplSuccessful;
#ifndef EPL_NO_FIFO
// set eventhandler to NULL
ShbError = ShbCirSetSignalHandlerNewData (EplEventkInstance_g.m_pShbUserToKernelInstance,
NULL,
kShbPriorityNormal);
if(ShbError != kShbOk)
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventkDelInstance(): ShbCirSetSignalHandlerNewData(U2K) -> 0x%X\n", ShbError);
Ret = kEplNoResource;
}
// free buffer User -> Kernel
ShbError = ShbCirReleaseBuffer (EplEventkInstance_g.m_pShbUserToKernelInstance);
if(ShbError != kShbOk)
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventkDelInstance(): ShbCirReleaseBuffer(U2K) -> 0x%X\n", ShbError);
Ret = kEplNoResource;
}
else
{
EplEventkInstance_g.m_pShbUserToKernelInstance = NULL;
}
// free buffer Kernel -> User
ShbError = ShbCirReleaseBuffer (EplEventkInstance_g.m_pShbKernelToUserInstance);
if(ShbError != kShbOk)
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventkDelInstance(): ShbCirReleaseBuffer(K2U) -> 0x%X\n", ShbError);
Ret = kEplNoResource;
}
else
{
EplEventkInstance_g.m_pShbKernelToUserInstance = NULL;
}
#endif
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplEventkProcess
//
// Description: Kernelthread that dispatches events in kernel part
//
// Parameters: pEvent_p = pointer to event-structure from buffer
//
// Returns: tEpKernel = errorcode
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplEventkProcess(tEplEvent* pEvent_p)
{
tEplKernel Ret;
tEplEventSource EventSource;
Ret = kEplSuccessful;
// error handling if event queue is full
if (EplEventkInstance_g.m_uiUserToKernelFullCount > 0)
{ // UserToKernel event queue has run out of space -> kEplNmtEventInternComError
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0)
tEplEvent Event;
tEplNmtEvent NmtEvent;
#endif
#ifndef EPL_NO_FIFO
tShbError ShbError;
#endif
// directly call NMTk process function, because event queue is full
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0)
NmtEvent = kEplNmtEventInternComError;
Event.m_EventSink = kEplEventSinkNmtk;
Event.m_NetTime.m_dwNanoSec = 0;
Event.m_NetTime.m_dwSec = 0;
Event.m_EventType = kEplEventTypeNmtEvent;
Event.m_pArg = &NmtEvent;
Event.m_uiSize = sizeof(NmtEvent);
Ret = EplNmtkProcess(&Event);
#endif
// NMT state machine changed to reset (i.e. NMT_GS_RESET_COMMUNICATION)
// now, it is safe to reset the counter and empty the event queue
#ifndef EPL_NO_FIFO
ShbError = ShbCirResetBuffer (EplEventkInstance_g.m_pShbUserToKernelInstance, 1000, NULL);
#endif
EplEventkInstance_g.m_uiUserToKernelFullCount = 0;
TGT_DBG_SIGNAL_TRACE_POINT(22);
// also discard the current event (it doesn't matter if we lose another event)
goto Exit;
}
// check m_EventSink
switch(pEvent_p->m_EventSink)
{
case kEplEventSinkSync:
{
if (EplEventkInstance_g.m_pfnCbSync != NULL)
{
Ret = EplEventkInstance_g.m_pfnCbSync();
if (Ret == kEplSuccessful)
{
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0)
// mark TPDOs as valid
Ret = EplPdokCalSetTpdosValid(TRUE);
#endif
}
else if ((Ret != kEplReject) && (Ret != kEplShutdown))
{
EventSource = kEplEventSourceSyncCb;
// Error event for API layer
EplEventkPostError(kEplEventSourceEventk,
Ret,
sizeof(EventSource),
&EventSource);
}
}
break;
}
// NMT-Kernel-Modul
case kEplEventSinkNmtk:
{
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0)
Ret = EplNmtkProcess(pEvent_p);
if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
{
EventSource = kEplEventSourceNmtk;
// Error event for API layer
EplEventkPostError(kEplEventSourceEventk,
Ret,
sizeof(EventSource),
&EventSource);
}
#endif
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
if ((pEvent_p->m_EventType == kEplEventTypeNmtEvent)
&& ((*((tEplNmtEvent*)pEvent_p->m_pArg) == kEplNmtEventDllCeSoa)
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
|| (*((tEplNmtEvent*)pEvent_p->m_pArg) == kEplNmtEventDllMeSoaSent)
#endif
))
{ // forward SoA event to error handler
Ret = EplErrorHandlerkProcess(pEvent_p);
if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
{
EventSource = kEplEventSourceErrk;
// Error event for API layer
EplEventkPostError(kEplEventSourceEventk,
Ret,
sizeof(EventSource),
&EventSource);
}
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0)
// forward SoA event to PDO module
pEvent_p->m_EventType = kEplEventTypePdoSoa;
Ret = EplPdokProcess(pEvent_p);
if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
{
EventSource = kEplEventSourcePdok;
// Error event for API layer
EplEventkPostError(kEplEventSourceEventk,
Ret,
sizeof(EventSource),
&EventSource);
}
#endif
}
break;
#endif
}
// events for Dllk module
case kEplEventSinkDllk:
{
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
Ret = EplDllkProcess(pEvent_p);
if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
{
EventSource = kEplEventSourceDllk;
// Error event for API layer
EplEventkPostError(kEplEventSourceEventk,
Ret,
sizeof(EventSource),
&EventSource);
}
#endif
break;
}
// events for DllkCal module
case kEplEventSinkDllkCal:
{
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
Ret = EplDllkCalProcess(pEvent_p);
if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
{
EventSource = kEplEventSourceDllk;
// Error event for API layer
EplEventkPostError(kEplEventSourceEventk,
Ret,
sizeof(EventSource),
&EventSource);
}
#endif
break;
}
//
case kEplEventSinkPdok:
{
// PDO-Module
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0)
Ret = EplPdokProcess(pEvent_p);
if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
{
EventSource = kEplEventSourcePdok;
// Error event for API layer
EplEventkPostError(kEplEventSourceEventk,
Ret,
sizeof(EventSource),
&EventSource);
}
#endif
break;
}
// events for Error handler module
case kEplEventSinkErrk:
{
// only call error handler if DLL is present
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
Ret = EplErrorHandlerkProcess(pEvent_p);
if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
{
EventSource = kEplEventSourceErrk;
// Error event for API layer
EplEventkPostError(kEplEventSourceEventk,
Ret,
sizeof(EventSource),
&EventSource);
}
break;
#endif
}
// unknown sink
default:
{
Ret = kEplEventUnknownSink;
}
} // end of switch(pEvent_p->m_EventSink)
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplEventkPost
//
// Description: post events from kernel part
//
// Parameters: pEvent_p = pointer to event-structure from buffer
//
// Returns: tEpKernel = errorcode
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplEventkPost(tEplEvent * pEvent_p)
{
tEplKernel Ret;
#ifndef EPL_NO_FIFO
tShbError ShbError;
tShbCirChunk ShbCirChunk;
unsigned long ulDataSize;
unsigned int fBufferCompleted;
#endif
Ret = kEplSuccessful;
// the event must be posted by using the abBuffer
// it is neede because the Argument must by copied
// to the buffer too and not only the pointer
#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);
#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:
{
#ifndef EPL_NO_FIFO
// post message
BENCHMARK_MOD_27_SET(2);
ShbError = ShbCirAllocDataBlock (EplEventkInstance_g.m_pShbUserToKernelInstance,
&ShbCirChunk,
ulDataSize);
switch (ShbError)
{
case kShbOk:
break;
case kShbBufferFull:
{
EplEventkInstance_g.m_uiUserToKernelFullCount++;
Ret = kEplEventPostError;
goto Exit;
}
default:
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventkPost(): ShbCirAllocDataBlock(U2K) -> 0x%X\n", ShbError);
Ret = kEplEventPostError;
goto Exit;
}
}
ShbError = ShbCirWriteDataChunk (EplEventkInstance_g.m_pShbUserToKernelInstance,
&ShbCirChunk,
pEvent_p,
sizeof (tEplEvent),
&fBufferCompleted);
if (ShbError != kShbOk)
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventkPost(): ShbCirWriteDataChunk(U2K) -> 0x%X\n", ShbError);
Ret = kEplEventPostError;
goto Exit;
}
if (fBufferCompleted == FALSE)
{
ShbError = ShbCirWriteDataChunk (EplEventkInstance_g.m_pShbUserToKernelInstance,
&ShbCirChunk,
pEvent_p->m_pArg,
(unsigned long) pEvent_p->m_uiSize,
&fBufferCompleted);
if ((ShbError != kShbOk) || (fBufferCompleted == FALSE))
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventkPost(): ShbCirWriteDataChunk2(U2K) -> 0x%X\n", ShbError);
Ret = kEplEventPostError;
goto Exit;
}
}
BENCHMARK_MOD_27_RESET(2);
#else
Ret = EplEventkProcess(pEvent_p);
#endif
break;
}
// userspace modules
case kEplEventSinkNmtu:
case kEplEventSinkNmtMnu:
case kEplEventSinkSdoAsySeq:
case kEplEventSinkApi:
case kEplEventSinkDlluCal:
case kEplEventSinkErru:
{
#ifndef EPL_NO_FIFO
// post message
// BENCHMARK_MOD_27_SET(3); // 74 µs until reset
ShbError = ShbCirAllocDataBlock (EplEventkInstance_g.m_pShbKernelToUserInstance,
&ShbCirChunk,
ulDataSize);
if(ShbError != kShbOk)
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventkPost(): ShbCirAllocDataBlock(K2U) -> 0x%X\n", ShbError);
Ret = kEplEventPostError;
goto Exit;
}
ShbError = ShbCirWriteDataChunk (EplEventkInstance_g.m_pShbKernelToUserInstance,
&ShbCirChunk,
pEvent_p,
sizeof (tEplEvent),
&fBufferCompleted);
if(ShbError != kShbOk)
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventkPost(): ShbCirWriteDataChunk(K2U) -> 0x%X\n", ShbError);
Ret = kEplEventPostError;
goto Exit;
}
if (fBufferCompleted == FALSE)
{
ShbError = ShbCirWriteDataChunk (EplEventkInstance_g.m_pShbKernelToUserInstance,
&ShbCirChunk,
pEvent_p->m_pArg,
(unsigned long) pEvent_p->m_uiSize,
&fBufferCompleted);
if ((ShbError != kShbOk) || (fBufferCompleted == FALSE))
{
EPL_DBGLVL_EVENTK_TRACE1("EplEventkPost(): ShbCirWriteDataChunk2(K2U) -> 0x%X\n", ShbError);
Ret = kEplEventPostError;
goto Exit;
}
}
// BENCHMARK_MOD_27_RESET(3); // 82 µs until ShbCirGetReadDataSize() in EplEventu
#else
Ret = EplEventuProcess(pEvent_p);
#endif
break;
}
default:
{
Ret = kEplEventUnknownSink;
}
}// end of switch(pEvent_p->m_EventSink)
#ifndef EPL_NO_FIFO
Exit:
#endif
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplEventkPostError
//
// Description: post error event from kernel part to API layer
//
// Parameters: EventSource_p = source-module of the error event
// EplError_p = code of occured error
// ArgSize_p = size of the argument
// pArg_p = pointer to the argument
//
// Returns: tEpKernel = errorcode
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplEventkPostError(tEplEventSource EventSource_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;
Ret = kEplSuccessful;
// 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];
// post errorevent
Ret = EplEventkPost(&EplEvent);
return Ret;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplEventkRxSignalHandlerCb()
//
// Description: Callback-function for events from user and kernel part
//
// Parameters: pShbRxInstance_p = Instance-pointer of buffer
// ulDataSize_p = size of data
//
// Returns: void
//
// State:
//
//---------------------------------------------------------------------------
#ifndef EPL_NO_FIFO
static void EplEventkRxSignalHandlerCb (
tShbInstance pShbRxInstance_p,
unsigned long ulDataSize_p)
{
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
TGT_DBG_SIGNAL_TRACE_POINT(20);
BENCHMARK_MOD_27_RESET(0);
// 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;
}
BENCHMARK_MOD_27_SET(0);
// call processfunction
EplEventkProcess(pEplEvent);
Exit:
return;
}
#endif
// EOF

View file

@ -0,0 +1,813 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for Epl-Userspace-Event-Modul
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplEventu.c,v $
$Author: D.Krueger $
$Revision: 1.8 $ $Date: 2008/11/17 16:40:39 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/20 k.t.: start of the implementation
****************************************************************************/
#include "user/EplEventu.h"
#include "user/EplNmtu.h"
#include "user/EplNmtMnu.h"
#include "user/EplSdoAsySequ.h"
#include "user/EplDlluCal.h"
#include "user/EplLedu.h"
#include "Benchmark.h"
#ifdef EPL_NO_FIFO
#include "kernel/EplEventk.h"
#else
#include "SharedBuff.h"
#endif
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
// 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)
#else
#define TGT_DBG_SIGNAL_TRACE_POINT(p)
#define TGT_DBG_POST_TRACE_VALUE(v)
#endif
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
typedef struct
{
#ifndef EPL_NO_FIFO
tShbInstance m_pShbKernelToUserInstance;
tShbInstance m_pShbUserToKernelInstance;
#endif
tEplProcessEventCb m_pfnApiProcessEventCb;
}tEplEventuInstance;
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
//#ifndef EPL_NO_FIFO
static tEplEventuInstance EplEventuInstance_g;
//#endif
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
#ifndef EPL_NO_FIFO
// callback function for incomming events
static void EplEventuRxSignalHandlerCb (
tShbInstance pShbRxInstance_p,
unsigned long ulDataSize_p);
#endif
/***************************************************************************/
/* */
/* */
/* C L A S S <Epl-User-Event> */
/* */
/* */
/***************************************************************************/
//
// Description:
//
//
/***************************************************************************/
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplEventuInit
//
// Description: function initialize the first instance
//
//
//
// Parameters: pfnApiProcessEventCb_p = function pointer for API event callback
//
//
// Returns: tEpKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplEventuInit(tEplProcessEventCb pfnApiProcessEventCb_p)
{
tEplKernel Ret;
Ret = EplEventuAddInstance(pfnApiProcessEventCb_p);
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplEventuAddInstance
//
// Description: function add one more instance
//
//
//
// Parameters: pfnApiProcessEventCb_p = function pointer for API event callback
//
//
// Returns: tEpKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplEventuAddInstance(tEplProcessEventCb pfnApiProcessEventCb_p)
{
tEplKernel Ret;
#ifndef EPL_NO_FIFO
tShbError ShbError;
unsigned int fShbNewCreated;
#endif
Ret = kEplSuccessful;
// 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;
}
// 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:
#endif
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplEventuDelInstance
//
// Description: function delete instance an free the bufferstructure
//
//
//
// Parameters:
//
//
// Returns: tEpKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplEventuDelInstance()
{
tEplKernel Ret;
#ifndef EPL_NO_FIFO
tShbError ShbError;
#endif
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;
}
// 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;
}
#endif
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplEventuProcess
//
// Description: Kernelthread that dispatches events in kernelspace
//
//
//
// Parameters: pEvent_p = pointer to event-structur from buffer
//
//
// Returns: tEpKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplEventuProcess(tEplEvent* pEvent_p)
{
tEplKernel Ret;
tEplEventSource EventSource;
Ret = kEplSuccessful;
// 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;
// Error event for API layer
EplEventuPostError(kEplEventSourceEventu,
Ret,
sizeof(EventSource),
&EventSource);
}
#endif
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;
// 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;
// Error event for API layer
EplEventuPostError(kEplEventSourceEventu,
Ret,
sizeof(EventSource),
&EventSource);
}
break;
}
#endif
// 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;
// Error event for API layer
EplEventuPostError(kEplEventSourceEventu,
Ret,
sizeof(EventSource),
&EventSource);
}
#endif
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;
// 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;
// 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;
// Error event for API layer
EplEventuPostError(kEplEventSourceEventu,
Ret,
sizeof(EventSource),
&EventSource);
}
*/
break;
}
// unknown sink
default:
{
Ret = kEplEventUnknownSink;
}
} // end of switch(pEvent_p->m_EventSink)
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplEventuPost
//
// Description: post events from userspace
//
//
//
// Parameters: pEvent_p = pointer to event-structur from buffer
//
//
// Returns: tEpKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplEventuPost(tEplEvent * pEvent_p)
{
tEplKernel Ret;
#ifndef EPL_NO_FIFO
tShbError ShbError;
tShbCirChunk ShbCirChunk;
unsigned long ulDataSize;
unsigned int fBufferCompleted;
#endif
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);
#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:
{
#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;
}
}
#else
Ret = EplEventkProcess(pEvent_p);
#endif
break;
}
// 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;
}
}
#else
Ret = EplEventuProcess(pEvent_p);
#endif
break;
}
default:
{
Ret = kEplEventUnknownSink;
}
}// end of switch(pEvent_p->m_EventSink)
#ifndef EPL_NO_FIFO
Exit:
#endif
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplEventuPostError
//
// Description: post errorevent from userspace
//
//
//
// Parameters: EventSource_p = source-module of the errorevent
// EplError_p = code of occured error
// uiArgSize_p = size of the argument
// pArg_p = pointer to the argument
//
//
// Returns: tEpKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplEventuPostError(tEplEventSource EventSource_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;
Ret = kEplSuccessful;
// 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];
// post errorevent
Ret = EplEventuPost(&EplEvent);
return Ret;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplEventuRxSignalHandlerCb()
//
// Description: Callback-function for evets from kernelspace
//
//
//
// Parameters: pShbRxInstance_p = Instance-pointer for buffer
// ulDataSize_p = size of data
//
//
// Returns: void
//
//
// State:
//
//---------------------------------------------------------------------------
#ifndef EPL_NO_FIFO
static void EplEventuRxSignalHandlerCb (
tShbInstance pShbRxInstance_p,
unsigned long ulDataSize_p)
{
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
TGT_DBG_SIGNAL_TRACE_POINT(21);
// d.k. not needed because it is already done in SharedBuff
/* do
{
BENCHMARK_MOD_28_SET(1); // 4 µs until reset
// get messagesize
ShbError = ShbCirGetReadDataSize (pShbRxInstance_p, &ulDataSize);
if(ShbError != kShbOk)
{
// error goto exit
goto Exit;
}
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;
}
// 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_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)
{
// error goto exit
goto Exit;
}
} while (ulBlockCount > 0);
*/
Exit:
return;
}
#endif
// EOF

View file

@ -0,0 +1,374 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for EPL frames
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplFrame.h,v $
$Author: D.Krueger $
$Revision: 1.5 $ $Date: 2008/06/23 14:56:33 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/05/22 d.k.: start of the implementation, version 1.00
****************************************************************************/
#ifndef _EPL_FRAME_H_
#define _EPL_FRAME_H_
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
// defines for EplFrame.m_wFlag
#define EPL_FRAME_FLAG1_RD 0x01 // ready (PReq, PRes)
#define EPL_FRAME_FLAG1_ER 0x02 // exception reset (error signalling) (SoA)
#define EPL_FRAME_FLAG1_EA 0x04 // exception acknowledge (error signalling) (PReq, SoA)
#define EPL_FRAME_FLAG1_EC 0x08 // exception clear (error signalling) (StatusRes)
#define EPL_FRAME_FLAG1_EN 0x10 // exception new (error signalling) (PRes, StatusRes)
#define EPL_FRAME_FLAG1_MS 0x20 // multiplexed slot (PReq)
#define EPL_FRAME_FLAG1_PS 0x40 // prescaled slot (SoC)
#define EPL_FRAME_FLAG1_MC 0x80 // multiplexed cycle completed (SoC)
#define EPL_FRAME_FLAG2_RS 0x07 // number of pending requests to send (PRes, StatusRes, IdentRes)
#define EPL_FRAME_FLAG2_PR 0x38 // priority of requested asynch. frame (PRes, StatusRes, IdentRes)
#define EPL_FRAME_FLAG2_PR_SHIFT 3 // shift of priority of requested asynch. frame
// error history/status entry types
#define EPL_ERR_ENTRYTYPE_STATUS 0x8000
#define EPL_ERR_ENTRYTYPE_HISTORY 0x0000
#define EPL_ERR_ENTRYTYPE_EMCY 0x4000
#define EPL_ERR_ENTRYTYPE_MODE_ACTIVE 0x1000
#define EPL_ERR_ENTRYTYPE_MODE_CLEARED 0x2000
#define EPL_ERR_ENTRYTYPE_MODE_OCCURRED 0x3000
#define EPL_ERR_ENTRYTYPE_MODE_MASK 0x3000
#define EPL_ERR_ENTRYTYPE_PROF_VENDOR 0x0001
#define EPL_ERR_ENTRYTYPE_PROF_EPL 0x0002
#define EPL_ERR_ENTRYTYPE_PROF_MASK 0x0FFF
// defines for EPL version / PDO version
#define EPL_VERSION_SUB 0x0F // sub version
#define EPL_VERSION_MAIN 0xF0 // main version
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
// $$$ d.k.: move this definition to global.h
// byte-align structures
#ifdef _MSC_VER
# pragma pack( push, packing )
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error you must byte-align these structures with the appropriate compiler directives
#endif
typedef struct
{
// Offset 17
BYTE m_le_bRes1; // reserved
// Offset 18
BYTE m_le_bFlag1; // Flags: MC, PS
// Offset 19
BYTE m_le_bFlag2; // Flags: res
// Offset 20
tEplNetTime m_le_NetTime; // supported if D_NMT_NetTimeIsRealTime_BOOL is set
// Offset 28
QWORD m_le_RelativeTime; // in us (supported if D_NMT_RelativeTime_BOOL is set)
} PACK_STRUCT tEplSocFrame;
typedef struct
{
// Offset 17
BYTE m_le_bRes1; // reserved
// Offset 18
BYTE m_le_bFlag1; // Flags: MS, EA, RD
// Offset 19
BYTE m_le_bFlag2; // Flags: res
// Offset 20
BYTE m_le_bPdoVersion;
// Offset 21
BYTE m_le_bRes2; // reserved
// Offset 22
WORD m_le_wSize;
// Offset 24
BYTE m_le_abPayload[256 /*D_NMT_IsochrRxMaxPayload_U16*/];
} PACK_STRUCT tEplPreqFrame;
typedef struct
{
// Offset 17
BYTE m_le_bNmtStatus; // NMT state
// Offset 18
BYTE m_le_bFlag1; // Flags: MS, EN, RD
// Offset 19
BYTE m_le_bFlag2; // Flags: PR, RS
// Offset 20
BYTE m_le_bPdoVersion;
// Offset 21
BYTE m_le_bRes2; // reserved
// Offset 22
WORD m_le_wSize;
// Offset 24
BYTE m_le_abPayload[256 /*D_NMT_IsochrRxMaxPayload_U16
/ D_NMT_IsochrTxMaxPayload_U16*/];
} PACK_STRUCT tEplPresFrame;
typedef struct
{
// Offset 17
BYTE m_le_bNmtStatus; // NMT state
// Offset 18
BYTE m_le_bFlag1; // Flags: EA, ER
// Offset 19
BYTE m_le_bFlag2; // Flags: res
// Offset 20
BYTE m_le_bReqServiceId;
// Offset 21
BYTE m_le_bReqServiceTarget;
// Offset 22
BYTE m_le_bEplVersion;
} PACK_STRUCT tEplSoaFrame;
typedef struct
{
WORD m_wEntryType;
WORD m_wErrorCode;
tEplNetTime m_TimeStamp;
BYTE m_abAddInfo[8];
} PACK_STRUCT tEplErrHistoryEntry;
typedef struct
{
// Offset 18
BYTE m_le_bFlag1; // Flags: EN, EC
BYTE m_le_bFlag2; // Flags: PR, RS
BYTE m_le_bNmtStatus; // NMT state
BYTE m_le_bRes1[3];
QWORD m_le_qwStaticError; // static error bit field
tEplErrHistoryEntry m_le_aErrHistoryEntry[14];
} PACK_STRUCT tEplStatusResponse;
typedef struct
{
// Offset 18
BYTE m_le_bFlag1; // Flags: res
BYTE m_le_bFlag2; // Flags: PR, RS
BYTE m_le_bNmtStatus; // NMT state
BYTE m_le_bIdentRespFlags; // Flags: FW
BYTE m_le_bEplProfileVersion;
BYTE m_le_bRes1;
DWORD m_le_dwFeatureFlags; // NMT_FeatureFlags_U32
WORD m_le_wMtu; // NMT_CycleTiming_REC.AsyncMTU_U16: C_IP_MIN_MTU - C_IP_MAX_MTU
WORD m_le_wPollInSize; // NMT_CycleTiming_REC.PReqActPayload_U16
WORD m_le_wPollOutSize; // NMT_CycleTiming_REC.PResActPayload_U16
DWORD m_le_dwResponseTime; // NMT_CycleTiming_REC.PResMaxLatency_U32
WORD m_le_wRes2;
DWORD m_le_dwDeviceType; // NMT_DeviceType_U32
DWORD m_le_dwVendorId; // NMT_IdentityObject_REC.VendorId_U32
DWORD m_le_dwProductCode; // NMT_IdentityObject_REC.ProductCode_U32
DWORD m_le_dwRevisionNumber; // NMT_IdentityObject_REC.RevisionNo_U32
DWORD m_le_dwSerialNumber; // NMT_IdentityObject_REC.SerialNo_U32
QWORD m_le_qwVendorSpecificExt1;
DWORD m_le_dwVerifyConfigurationDate; // CFM_VerifyConfiguration_REC.ConfDate_U32
DWORD m_le_dwVerifyConfigurationTime; // CFM_VerifyConfiguration_REC.ConfTime_U32
DWORD m_le_dwApplicationSwDate; // PDL_LocVerApplSw_REC.ApplSwDate_U32 on programmable device or date portion of NMT_ManufactSwVers_VS on non-programmable device
DWORD m_le_dwApplicationSwTime; // PDL_LocVerApplSw_REC.ApplSwTime_U32 on programmable device or time portion of NMT_ManufactSwVers_VS on non-programmable device
DWORD m_le_dwIpAddress;
DWORD m_le_dwSubnetMask;
DWORD m_le_dwDefaultGateway;
BYTE m_le_sHostname[32];
BYTE m_le_abVendorSpecificExt2[48];
} PACK_STRUCT tEplIdentResponse;
typedef struct
{
// Offset 18
BYTE m_le_bNmtCommandId;
BYTE m_le_bRes1;
BYTE m_le_abNmtCommandData[32];
} PACK_STRUCT tEplNmtCommandService;
typedef struct
{
BYTE m_le_bReserved;
BYTE m_le_bTransactionId;
BYTE m_le_bFlags;
BYTE m_le_bCommandId;
WORD m_le_wSegmentSize;
WORD m_le_wReserved;
BYTE m_le_abCommandData[8]; // just reserve a minimum number of bytes as a placeholder
}PACK_STRUCT tEplAsySdoCom;
// asynchronous SDO Sequence Header
typedef struct
{
BYTE m_le_bRecSeqNumCon;
BYTE m_le_bSendSeqNumCon;
BYTE m_le_abReserved[2];
tEplAsySdoCom m_le_abSdoSeqPayload;
} PACK_STRUCT tEplAsySdoSeq;
typedef struct
{
// Offset 18
BYTE m_le_bNmtCommandId;
BYTE m_le_bTargetNodeId;
BYTE m_le_abNmtCommandData[32];
} PACK_STRUCT tEplNmtRequestService;
typedef union
{
// Offset 18
tEplStatusResponse m_StatusResponse;
tEplIdentResponse m_IdentResponse;
tEplNmtCommandService m_NmtCommandService;
tEplNmtRequestService m_NmtRequestService;
tEplAsySdoSeq m_SdoSequenceFrame;
BYTE m_le_abPayload[256 /*D_NMT_ASndTxMaxPayload_U16
/ D_NMT_ASndRxMaxPayload_U16*/];
} tEplAsndPayload;
typedef struct
{
// Offset 17
BYTE m_le_bServiceId;
// Offset 18
tEplAsndPayload m_Payload;
} PACK_STRUCT tEplAsndFrame;
typedef union
{
// Offset 17
tEplSocFrame m_Soc;
tEplPreqFrame m_Preq;
tEplPresFrame m_Pres;
tEplSoaFrame m_Soa;
tEplAsndFrame m_Asnd;
} tEplFrameData;
typedef struct
{
// Offset 0
BYTE m_be_abDstMac[6]; // MAC address of the addressed nodes
// Offset 6
BYTE m_be_abSrcMac[6]; // MAC address of the transmitting node
// Offset 12
WORD m_be_wEtherType; // Ethernet message type (big endian)
// Offset 14
BYTE m_le_bMessageType; // EPL message type
// Offset 15
BYTE m_le_bDstNodeId; // EPL node ID of the addressed nodes
// Offset 16
BYTE m_le_bSrcNodeId; // EPL node ID of the transmitting node
// Offset 17
tEplFrameData m_Data;
} PACK_STRUCT tEplFrame;
// un-byte-align structures
#ifdef _MSC_VER
# pragma pack( pop, packing )
#endif
typedef enum
{
kEplMsgTypeNonEpl = 0x00,
kEplMsgTypeSoc = 0x01,
kEplMsgTypePreq = 0x03,
kEplMsgTypePres = 0x04,
kEplMsgTypeSoa = 0x05,
kEplMsgTypeAsnd = 0x06,
} tEplMsgType;
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#endif // #ifndef _EPL_FRAME_H_

View file

@ -0,0 +1,497 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for Identu-Module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplIdentu.c,v $
$Author: D.Krueger $
$Revision: 1.8 $ $Date: 2008/11/21 09:00:38 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/11/15 d.k.: start of the implementation
****************************************************************************/
#include "user/EplIdentu.h"
#include "user/EplDlluCal.h"
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
/***************************************************************************/
/* */
/* */
/* C L A S S <xxxxx> */
/* */
/* */
/***************************************************************************/
//
// Description:
//
//
/***************************************************************************/
//=========================================================================//
// //
// P R I V A T E D E F I N I T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
typedef struct
{
tEplIdentResponse* m_apIdentResponse[254]; // the IdentResponse are managed dynamically
tEplIdentuCbResponse m_apfnCbResponse[254];
} tEplIdentuInstance;
//---------------------------------------------------------------------------
// local vars
//---------------------------------------------------------------------------
static tEplIdentuInstance EplIdentuInstance_g;
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
static tEplKernel PUBLIC EplIdentuCbIdentResponse(tEplFrameInfo * pFrameInfo_p);
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplIdentuInit
//
// Description: init first instance of the module
//
//
//
// Parameters:
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplIdentuInit()
{
tEplKernel Ret;
Ret = EplIdentuAddInstance();
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplIdentuAddInstance
//
// Description: init other instances of the module
//
//
//
// Parameters:
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplIdentuAddInstance()
{
tEplKernel Ret;
Ret = kEplSuccessful;
// reset instance structure
EPL_MEMSET(&EplIdentuInstance_g, 0, sizeof (EplIdentuInstance_g));
// register IdentResponse callback function
Ret = EplDlluCalRegAsndService(kEplDllAsndIdentResponse, EplIdentuCbIdentResponse, kEplDllAsndFilterAny);
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplIdentuDelInstance
//
// Description: delete instance
//
//
//
// Parameters:
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplIdentuDelInstance()
{
tEplKernel Ret;
Ret = kEplSuccessful;
// deregister IdentResponse callback function
Ret = EplDlluCalRegAsndService(kEplDllAsndIdentResponse, NULL, kEplDllAsndFilterNone);
Ret = EplIdentuReset();
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplIdentuReset
//
// Description: resets this instance
//
//
//
// Parameters:
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplIdentuReset()
{
tEplKernel Ret;
int iIndex;
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]);
}
}
EPL_MEMSET(&EplIdentuInstance_g, 0, sizeof (EplIdentuInstance_g));
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplIdentuGetIdentResponse
//
// Description: returns the IdentResponse for the specified node.
//
// Parameters: uiNodeId_p = IN: node ID
// ppIdentResponse_p = OUT: pointer to pointer of IdentResponse
// equals NULL, if no IdentResponse available
//
// Return: tEplKernel = error code
//
// State: not tested
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplIdentuGetIdentResponse(
unsigned int uiNodeId_p,
tEplIdentResponse** ppIdentResponse_p)
{
tEplKernel Ret;
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;
}
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplIdentuRequestIdentResponse
//
// Description: returns the IdentResponse for the specified node.
//
// Parameters: uiNodeId_p = IN: node ID
// pfnCbResponse_p = IN: function pointer to callback function
// which will be called if IdentResponse is received
//
// Return: tEplKernel = error code
//
// State: not tested
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplIdentuRequestIdentResponse(
unsigned int uiNodeId_p,
tEplIdentuCbResponse pfnCbResponse_p)
{
tEplKernel Ret;
Ret = kEplSuccessful;
// 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);
}
#else
Ret = kEplInvalidOperation;
#endif
}
else
{ // invalid node ID specified
Ret = kEplInvalidNodeId;
}
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplIdentuGetRunningRequests
//
// Description: returns a bit field with the running requests for node-ID 1-32
// just for debugging purposes
//
//
// Parameters:
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT DWORD PUBLIC EplIdentuGetRunningRequests(void)
{
DWORD dwReqs = 0;
unsigned int uiIndex;
for (uiIndex = 0; uiIndex < 32; uiIndex++)
{
if (EplIdentuInstance_g.m_apfnCbResponse[uiIndex] != NULL)
{
dwReqs |= (1 << uiIndex);
}
}
return dwReqs;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplIdentuCbIdentResponse
//
// Description: callback funktion for IdentResponse
//
//
//
// Parameters: pFrameInfo_p = Frame with the IdentResponse
//
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
static tEplKernel PUBLIC EplIdentuCbIdentResponse(tEplFrameInfo * pFrameInfo_p)
{
tEplKernel Ret = kEplSuccessful;
unsigned int uiNodeId;
unsigned int uiIndex;
tEplIdentuCbResponse pfnCbResponse;
uiNodeId = AmiGetByteFromLe(&pFrameInfo_p->m_pFrame->m_le_bSrcNodeId);
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 (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;
}
// EOF

View file

@ -0,0 +1,398 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: basic include file for internal EPL stack modules
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplInc.h,v $
$Author: D.Krueger $
$Revision: 1.8 $ $Date: 2008/11/17 16:40:39 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/05/22 d.k.: start of the implementation, version 1.00
****************************************************************************/
#ifndef _EPL_INC_H_
#define _EPL_INC_H_
// ============================================================================
// include files
// ============================================================================
#if defined(WIN32) || defined(_WIN32)
#ifdef UNDER_RTSS
// RTX header
#include <windows.h>
#include <process.h>
#include <rtapi.h>
#elif __BORLANDC__
// borland C header
#include <windows.h>
#include <process.h>
#elif WINCE
#include <windows.h>
#else
// MSVC needs to include windows.h at first
// the following defines ar necessary for function prototypes for waitable timers
#define _WIN32_WINDOWS 0x0401
#define _WIN32_WINNT 0x0400
#include <windows.h>
#include <process.h>
#endif
#endif
// defines for module integration
// possible other include file needed
// These constants defines modules which can be included in the Epl application.
// Use this constants for define EPL_MODULE_INTEGRATION in file EplCfg.h.
#define EPL_MODULE_OBDK 0x00000001L // OBD kernel part module
#define EPL_MODULE_PDOK 0x00000002L // PDO kernel part module
#define EPL_MODULE_NMT_MN 0x00000004L // NMT MN module
#define EPL_MODULE_SDOS 0x00000008L // SDO Server module
#define EPL_MODULE_SDOC 0x00000010L // SDO Client module
#define EPL_MODULE_SDO_ASND 0x00000020L // SDO over Asnd module
#define EPL_MODULE_SDO_UDP 0x00000040L // SDO over UDP module
#define EPL_MODULE_SDO_PDO 0x00000080L // SDO in PDO module
#define EPL_MODULE_NMT_CN 0x00000100L // NMT CN module
#define EPL_MODULE_NMTU 0x00000200L // NMT user part module
#define EPL_MODULE_NMTK 0x00000400L // NMT kernel part module
#define EPL_MODULE_DLLK 0x00000800L // DLL kernel part module
#define EPL_MODULE_DLLU 0x00001000L // DLL user part module
#define EPL_MODULE_OBDU 0x00002000L // OBD user part module
#define EPL_MODULE_CFGMA 0x00004000L // Configuartioan Manager module
#define EPL_MODULE_VETH 0x00008000L // virtual ethernet driver module
#define EPL_MODULE_PDOU 0x00010000L // PDO user part module
#define EPL_MODULE_LEDU 0x00020000L // LED user part module
#include "EplCfg.h" // EPL configuration file (configuration from application)
#include "global.h" // global definitions
#include "EplDef.h" // EPL configuration file (default configuration)
#include "EplInstDef.h" // defines macros for instance types and table
#include "Debug.h" // debug definitions
#include "EplErrDef.h" // EPL error codes for API funtions
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
// IEEE 1588 conformant net time structure
typedef struct
{
DWORD m_dwSec;
DWORD m_dwNanoSec;
} tEplNetTime;
#include "EplTarget.h" // target specific functions and definitions
#include "EplAmi.h"
// -------------------------------------------------------------------------
// macros
// -------------------------------------------------------------------------
#define EPL_SPEC_VERSION 0x20 // ETHERNET Powerlink V. 2.0
#define EPL_STACK_VERSION(ver,rev,rel) ((((DWORD)(ver)) & 0xFF)|((((DWORD)(rev))&0xFF)<<8)|(((DWORD)(rel))<<16))
#define EPL_OBJ1018_VERSION(ver,rev,rel) ((((DWORD)(ver))<<16) |(((DWORD)(rev))&0xFFFF))
#define EPL_STRING_VERSION(ver,rev,rel) "V" #ver "." #rev " r" #rel
#include "EplVersion.h"
// defines for EPL FeatureFlags
#define EPL_FEATURE_ISOCHR 0x00000001
#define EPL_FEATURE_SDO_UDP 0x00000002
#define EPL_FEATURE_SDO_ASND 0x00000004
#define EPL_FEATURE_SDO_PDO 0x00000008
#define EPL_FEATURE_NMT_INFO 0x00000010
#define EPL_FEATURE_NMT_EXT 0x00000020
#define EPL_FEATURE_PDO_DYN 0x00000040
#define EPL_FEATURE_NMT_UDP 0x00000080
#define EPL_FEATURE_CFGMA 0x00000100
#define EPL_FEATURE_DLL_MULTIPLEX 0x00000200
#define EPL_FEATURE_NODEID_SW 0x00000400
#define EPL_FEATURE_NMT_BASICETH 0x00000800
#define EPL_FEATURE_RT1 0x00001000
#define EPL_FEATURE_RT2 0x00002000
// generate EPL NMT_FeatureFlags_U32
#ifndef EPL_DEF_FEATURE_ISOCHR
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
#define EPL_DEF_FEATURE_ISOCHR (EPL_FEATURE_ISOCHR)
#else
#define EPL_DEF_FEATURE_ISOCHR 0
#endif
#endif
#ifndef EPL_DEF_FEATURE_SDO_ASND
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDO_ASND)) != 0)
#define EPL_DEF_FEATURE_SDO_ASND (EPL_FEATURE_SDO_ASND)
#else
#define EPL_DEF_FEATURE_SDO_ASND 0
#endif
#endif
#ifndef EPL_DEF_FEATURE_SDO_UDP
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDO_UDP)) != 0)
#define EPL_DEF_FEATURE_SDO_UDP (EPL_FEATURE_SDO_UDP)
#else
#define EPL_DEF_FEATURE_SDO_UDP 0
#endif
#endif
#ifndef EPL_DEF_FEATURE_SDO_PDO
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDO_PDO)) != 0)
#define EPL_DEF_FEATURE_SDO_PDO (EPL_FEATURE_SDO_PDO)
#else
#define EPL_DEF_FEATURE_SDO_PDO 0
#endif
#endif
#ifndef EPL_DEF_FEATURE_PDO_DYN
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0)
#define EPL_DEF_FEATURE_PDO_DYN (EPL_FEATURE_PDO_DYN)
#else
#define EPL_DEF_FEATURE_PDO_DYN 0
#endif
#endif
#ifndef EPL_DEF_FEATURE_CFGMA
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_CFGMA)) != 0)
#define EPL_DEF_FEATURE_CFGMA (EPL_FEATURE_CFGMA)
#else
#define EPL_DEF_FEATURE_CFGMA 0
#endif
#endif
#define EPL_DEF_FEATURE_FLAGS (EPL_DEF_FEATURE_ISOCHR \
| EPL_DEF_FEATURE_SDO_ASND \
| EPL_DEF_FEATURE_SDO_UDP \
| EPL_DEF_FEATURE_SDO_PDO \
| EPL_DEF_FEATURE_PDO_DYN \
| EPL_DEF_FEATURE_CFGMA)
#ifndef tabentries
#define tabentries(a) (sizeof(a)/sizeof(*(a)))
#endif
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
// definitions for DLL export
#if ((DEV_SYSTEM == _DEV_WIN32_) || (DEV_SYSTEM == _DEV_WIN_CE_)) && defined (COP_LIB)
#define EPLDLLEXPORT __declspec (dllexport)
#else
#define EPLDLLEXPORT
#endif
// ============================================================================
// common debug macros
// ============================================================================
// for using macro DEBUG_TRACEx()
//
// Example:
// DEBUG_TRACE1 (EPL_DBGLVL_OBD, "Value is %d\n" , wObjectIndex);
//
// This message only will be printed if:
// - NDEBUG is not defined AND !!!
// - flag 0x00000004L is set in DEF_DEBUG_LVL (can be defined in copcfg.h)
//
// default level is defined in copdef.h
// debug-level and TRACE-macros // standard-level // flags for DEF_DEBUG_LVL
#define EPL_DBGLVL_EDRV DEBUG_LVL_01 // 0x00000001L
#define EPL_DBGLVL_EDRV_TRACE0 DEBUG_LVL_01_TRACE0
#define EPL_DBGLVL_EDRV_TRACE1 DEBUG_LVL_01_TRACE1
#define EPL_DBGLVL_EDRV_TRACE2 DEBUG_LVL_01_TRACE2
#define EPL_DBGLVL_EDRV_TRACE3 DEBUG_LVL_01_TRACE3
#define EPL_DBGLVL_EDRV_TRACE4 DEBUG_LVL_01_TRACE4
#define EPL_DBGLVL_DLL DEBUG_LVL_02 // 0x00000002L
#define EPL_DBGLVL_DLL_TRACE0 DEBUG_LVL_02_TRACE0
#define EPL_DBGLVL_DLL_TRACE1 DEBUG_LVL_02_TRACE1
#define EPL_DBGLVL_DLL_TRACE2 DEBUG_LVL_02_TRACE2
#define EPL_DBGLVL_DLL_TRACE3 DEBUG_LVL_02_TRACE3
#define EPL_DBGLVL_DLL_TRACE4 DEBUG_LVL_02_TRACE4
#define EPL_DBGLVL_OBD DEBUG_LVL_03 // 0x00000004L
#define EPL_DBGLVL_OBD_TRACE0 DEBUG_LVL_03_TRACE0
#define EPL_DBGLVL_OBD_TRACE1 DEBUG_LVL_03_TRACE1
#define EPL_DBGLVL_OBD_TRACE2 DEBUG_LVL_03_TRACE2
#define EPL_DBGLVL_OBD_TRACE3 DEBUG_LVL_03_TRACE3
#define EPL_DBGLVL_OBD_TRACE4 DEBUG_LVL_03_TRACE4
#define EPL_DBGLVL_NMTK DEBUG_LVL_04 // 0x00000008L
#define EPL_DBGLVL_NMTK_TRACE0 DEBUG_LVL_04_TRACE0
#define EPL_DBGLVL_NMTK_TRACE1 DEBUG_LVL_04_TRACE1
#define EPL_DBGLVL_NMTK_TRACE2 DEBUG_LVL_04_TRACE2
#define EPL_DBGLVL_NMTK_TRACE3 DEBUG_LVL_04_TRACE3
#define EPL_DBGLVL_NMTK_TRACE4 DEBUG_LVL_04_TRACE4
#define EPL_DBGLVL_NMTCN DEBUG_LVL_05 // 0x00000010L
#define EPL_DBGLVL_NMTCN_TRACE0 DEBUG_LVL_05_TRACE0
#define EPL_DBGLVL_NMTCN_TRACE1 DEBUG_LVL_05_TRACE1
#define EPL_DBGLVL_NMTCN_TRACE2 DEBUG_LVL_05_TRACE2
#define EPL_DBGLVL_NMTCN_TRACE3 DEBUG_LVL_05_TRACE3
#define EPL_DBGLVL_NMTCN_TRACE4 DEBUG_LVL_05_TRACE4
#define EPL_DBGLVL_NMTU DEBUG_LVL_06 // 0x00000020L
#define EPL_DBGLVL_NMTU_TRACE0 DEBUG_LVL_06_TRACE0
#define EPL_DBGLVL_NMTU_TRACE1 DEBUG_LVL_06_TRACE1
#define EPL_DBGLVL_NMTU_TRACE2 DEBUG_LVL_06_TRACE2
#define EPL_DBGLVL_NMTU_TRACE3 DEBUG_LVL_06_TRACE3
#define EPL_DBGLVL_NMTU_TRACE4 DEBUG_LVL_06_TRACE4
#define EPL_DBGLVL_NMTMN DEBUG_LVL_07 // 0x00000040L
#define EPL_DBGLVL_NMTMN_TRACE0 DEBUG_LVL_07_TRACE0
#define EPL_DBGLVL_NMTMN_TRACE1 DEBUG_LVL_07_TRACE1
#define EPL_DBGLVL_NMTMN_TRACE2 DEBUG_LVL_07_TRACE2
#define EPL_DBGLVL_NMTMN_TRACE3 DEBUG_LVL_07_TRACE3
#define EPL_DBGLVL_NMTMN_TRACE4 DEBUG_LVL_07_TRACE4
//...
#define EPL_DBGLVL_SDO DEBUG_LVL_25 // 0x01000000
#define EPL_DBGLVL_SDO_TRACE0 DEBUG_LVL_25_TRACE0
#define EPL_DBGLVL_SDO_TRACE1 DEBUG_LVL_25_TRACE1
#define EPL_DBGLVL_SDO_TRACE2 DEBUG_LVL_25_TRACE2
#define EPL_DBGLVL_SDO_TRACE3 DEBUG_LVL_25_TRACE3
#define EPL_DBGLVL_SDO_TRACE4 DEBUG_LVL_25_TRACE4
#define EPL_DBGLVL_VETH DEBUG_LVL_26 // 0x02000000
#define EPL_DBGLVL_VETH_TRACE0 DEBUG_LVL_26_TRACE0
#define EPL_DBGLVL_VETH_TRACE1 DEBUG_LVL_26_TRACE1
#define EPL_DBGLVL_VETH_TRACE2 DEBUG_LVL_26_TRACE2
#define EPL_DBGLVL_VETH_TRACE3 DEBUG_LVL_26_TRACE3
#define EPL_DBGLVL_VETH_TRACE4 DEBUG_LVL_26_TRACE4
#define EPL_DBGLVL_EVENTK DEBUG_LVL_27 // 0x04000000
#define EPL_DBGLVL_EVENTK_TRACE0 DEBUG_LVL_27_TRACE0
#define EPL_DBGLVL_EVENTK_TRACE1 DEBUG_LVL_27_TRACE1
#define EPL_DBGLVL_EVENTK_TRACE2 DEBUG_LVL_27_TRACE2
#define EPL_DBGLVL_EVENTK_TRACE3 DEBUG_LVL_27_TRACE3
#define EPL_DBGLVL_EVENTK_TRACE4 DEBUG_LVL_27_TRACE4
#define EPL_DBGLVL_EVENTU DEBUG_LVL_28 // 0x08000000
#define EPL_DBGLVL_EVENTU_TRACE0 DEBUG_LVL_28_TRACE0
#define EPL_DBGLVL_EVENTU_TRACE1 DEBUG_LVL_28_TRACE1
#define EPL_DBGLVL_EVENTU_TRACE2 DEBUG_LVL_28_TRACE2
#define EPL_DBGLVL_EVENTU_TRACE3 DEBUG_LVL_28_TRACE3
#define EPL_DBGLVL_EVENTU_TRACE4 DEBUG_LVL_28_TRACE4
// SharedBuff
#define EPL_DBGLVL_SHB DEBUG_LVL_29 // 0x10000000
#define EPL_DBGLVL_SHB_TRACE0 DEBUG_LVL_29_TRACE0
#define EPL_DBGLVL_SHB_TRACE1 DEBUG_LVL_29_TRACE1
#define EPL_DBGLVL_SHB_TRACE2 DEBUG_LVL_29_TRACE2
#define EPL_DBGLVL_SHB_TRACE3 DEBUG_LVL_29_TRACE3
#define EPL_DBGLVL_SHB_TRACE4 DEBUG_LVL_29_TRACE4
#define EPL_DBGLVL_ASSERT DEBUG_LVL_ASSERT // 0x20000000L
#define EPL_DBGLVL_ASSERT_TRACE0 DEBUG_LVL_ASSERT_TRACE0
#define EPL_DBGLVL_ASSERT_TRACE1 DEBUG_LVL_ASSERT_TRACE1
#define EPL_DBGLVL_ASSERT_TRACE2 DEBUG_LVL_ASSERT_TRACE2
#define EPL_DBGLVL_ASSERT_TRACE3 DEBUG_LVL_ASSERT_TRACE3
#define EPL_DBGLVL_ASSERT_TRACE4 DEBUG_LVL_ASSERT_TRACE4
#define EPL_DBGLVL_ERROR DEBUG_LVL_ERROR // 0x40000000L
#define EPL_DBGLVL_ERROR_TRACE0 DEBUG_LVL_ERROR_TRACE0
#define EPL_DBGLVL_ERROR_TRACE1 DEBUG_LVL_ERROR_TRACE1
#define EPL_DBGLVL_ERROR_TRACE2 DEBUG_LVL_ERROR_TRACE2
#define EPL_DBGLVL_ERROR_TRACE3 DEBUG_LVL_ERROR_TRACE3
#define EPL_DBGLVL_ERROR_TRACE4 DEBUG_LVL_ERROR_TRACE4
#define EPL_DBGLVL_ALWAYS DEBUG_LVL_ALWAYS // 0x80000000L
#define EPL_DBGLVL_ALWAYS_TRACE0 DEBUG_LVL_ALWAYS_TRACE0
#define EPL_DBGLVL_ALWAYS_TRACE1 DEBUG_LVL_ALWAYS_TRACE1
#define EPL_DBGLVL_ALWAYS_TRACE2 DEBUG_LVL_ALWAYS_TRACE2
#define EPL_DBGLVL_ALWAYS_TRACE3 DEBUG_LVL_ALWAYS_TRACE3
#define EPL_DBGLVL_ALWAYS_TRACE4 DEBUG_LVL_ALWAYS_TRACE4
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#endif // #ifndef _EPL_INC_H_

View file

@ -0,0 +1,386 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: definitions for generating instances
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplInstDef.h,v $
$Author: D.Krueger $
$Revision: 1.4 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
...
-------------------------------------------------------------------------
Revision History:
r.d.: first implementation
****************************************************************************/
#ifndef _EPLINSTDEF_H_
#define _EPLINSTDEF_H_
// =========================================================================
// types and macros for generating instances
// =========================================================================
typedef enum
{
kStateUnused = 0,
kStateDeleted = 1,
kStateUsed = 0xFF
} tInstState;
//------------------------------------------------------------------------------------------
typedef void MEM* tEplPtrInstance;
typedef BYTE tEplInstanceHdl;
// define const for illegale values
#define CCM_ILLINSTANCE NULL
#define CCM_ILLINSTANCE_HDL 0xFF
//------------------------------------------------------------------------------------------
// if more than one instance then use this macros
#if (EPL_MAX_INSTANCES > 1)
//--------------------------------------------------------------------------------------
// macro definition for instance table definition
//--------------------------------------------------------------------------------------
// memory attributes for instance table
#define INST_NEAR // faster access to variables
#define INST_FAR // variables wich have to located in xdata
#define STATIC // prevent warnings for variables with same name
#define INSTANCE_TYPE_BEGIN typedef struct {
#define INSTANCE_TYPE_END } tEplInstanceInfo;
//--------------------------------------------------------------------------------------
// macro definition for API interface
//--------------------------------------------------------------------------------------
// declaration:
// macros for declaration within function header or prototype of API functions
#define CCM_DECL_INSTANCE_HDL tEplInstanceHdl InstanceHandle
#define CCM_DECL_INSTANCE_HDL_ tEplInstanceHdl InstanceHandle,
// macros for declaration of pointer to instance handle within function header or prototype of API functions
#define CCM_DECL_PTR_INSTANCE_HDL tEplInstanceHdl MEM* pInstanceHandle
#define CCM_DECL_PTR_INSTANCE_HDL_ tEplInstanceHdl MEM* pInstanceHandle,
// macros for declaration instance as lokacl variable within functions
#define CCM_DECL_INSTANCE_PTR_LOCAL tCcmInstanceInfo MEM* pInstance;
#define CCM_DECL_PTR_INSTANCE_HDL_LOCAL tEplInstanceHdl MEM* pInstanceHandle;
// reference:
// macros for reference of instance handle for function parameters
#define CCM_INSTANCE_HDL InstanceHandle
#define CCM_INSTANCE_HDL_ InstanceHandle,
// macros for reference of instance parameter for function parameters
#define CCM_INSTANCE_PARAM(par) par
#define CCM_INSTANCE_PARAM_(par) par,
// macros for reference of instance parameter for writing or reading values
#define CCM_INST_ENTRY (*((tEplPtrInstance)pInstance))
// processing:
// macros for process instance handle
#define CCM_CHECK_INSTANCE_HDL() if (InstanceHandle >= EPL_MAX_INSTANCES) \
{return (kEplIllegalInstance);}
// macros for process pointer to instance handle
#define CCM_CHECK_PTR_INSTANCE_HDL() if (pInstanceHandle == NULL) \
{return (kEplInvalidInstanceParam);}
// This macro returned the handle and pointer to next free instance.
#define CCM_GET_FREE_INSTANCE_AND_HDL() pInstance = CcmGetFreeInstanceAndHandle (pInstanceHandle); \
ASSERT (*pInstanceHandle != CCM_ILLINSTANCE_HDL);
#define CCM_CHECK_INSTANCE_PTR() if (pInstance == CCM_ILLINSTANCE) \
{return (kEplNoFreeInstance);}
#define CCM_GET_INSTANCE_PTR() pInstance = CcmGetInstancePtr (InstanceHandle);
#define CCM_GET_FREE_INSTANCE_PTR() pInstance = GetFreeInstance (); \
ASSERT (pInstance != CCM_ILLINSTANCE);
//--------------------------------------------------------------------------------------
// macro definition for stack interface
//--------------------------------------------------------------------------------------
// macros for declaration within the function header, prototype or local var list
// Declaration of pointers within function paramater list must defined as void MEM*
// pointer.
#define EPL_MCO_DECL_INSTANCE_PTR void MEM* pInstance
#define EPL_MCO_DECL_INSTANCE_PTR_ void MEM* pInstance,
#define EPL_MCO_DECL_INSTANCE_PTR_LOCAL tEplPtrInstance pInstance;
// macros for reference of pointer to instance
// These macros are used for parameter passing to called function.
#define EPL_MCO_INSTANCE_PTR pInstance
#define EPL_MCO_INSTANCE_PTR_ pInstance,
#define EPL_MCO_ADDR_INSTANCE_PTR_ &pInstance,
// macro for access of struct members of one instance
// An access to a member of instance table must be casted by the local
// defined type of instance table.
#define EPL_MCO_INST_ENTRY (*(tEplPtrInstance)pInstance)
#define EPL_MCO_GLB_VAR(var) (((tEplPtrInstance)pInstance)->var)
// macros for process pointer to instance
#define EPL_MCO_GET_INSTANCE_PTR() pInstance = (tEplPtrInstance) GetInstancePtr (InstanceHandle);
#define EPL_MCO_GET_FREE_INSTANCE_PTR() pInstance = (tEplPtrInstance) GetFreeInstance (); \
ASSERT (pInstance != CCM_ILLINSTANCE);
// This macro should be used to check the passed pointer to an public function
#define EPL_MCO_CHECK_INSTANCE_STATE() ASSERT (pInstance != NULL); \
ASSERT (((tEplPtrInstance)pInstance)->m_InstState == kStateUsed);
// macros for declaration of pointer to instance pointer
#define EPL_MCO_DECL_PTR_INSTANCE_PTR void MEM* MEM* pInstancePtr
#define EPL_MCO_DECL_PTR_INSTANCE_PTR_ void MEM* MEM* pInstancePtr,
// macros for reference of pointer to instance pointer
// These macros are used for parameter passing to called function.
#define EPL_MCO_PTR_INSTANCE_PTR pInstancePtr
#define EPL_MCO_PTR_INSTANCE_PTR_ pInstancePtr,
// macros for process pointer to instance pointer
#define EPL_MCO_CHECK_PTR_INSTANCE_PTR() ASSERT (pInstancePtr != NULL);
#define EPL_MCO_SET_PTR_INSTANCE_PTR() (*pInstancePtr = pInstance);
#define EPL_MCO_INSTANCE_PARAM(a) (a)
#define EPL_MCO_INSTANCE_PARAM_(a) (a),
#define EPL_MCO_INSTANCE_PARAM_IDX_() EPL_MCO_INSTANCE_PARAM_ (EPL_MCO_GLB_VAR (m_bInstIndex))
#define EPL_MCO_INSTANCE_PARAM_IDX() EPL_MCO_INSTANCE_PARAM (EPL_MCO_GLB_VAR (m_bInstIndex))
#define EPL_MCO_WRITE_INSTANCE_STATE(a) EPL_MCO_GLB_VAR (m_InstState) = a;
// this macro deletes all instance entries as unused
#define EPL_MCO_DELETE_INSTANCE_TABLE() \
{ \
tEplInstanceInfo MEM* pInstance = &aEplInstanceTable_g[0]; \
tFastByte InstNumber = 0; \
tFastByte i = EPL_MAX_INSTANCES; \
do { \
pInstance->m_InstState = (BYTE) kStateUnused; \
pInstance->m_bInstIndex = (BYTE) InstNumber; \
pInstance++; InstNumber++; i--; \
} while (i != 0); \
}
// definition of functions which has to be defined in each module of CANopen stack
#define EPL_MCO_DEFINE_INSTANCE_FCT() \
static tEplPtrInstance GetInstancePtr (tEplInstanceHdl InstHandle_p); \
static tEplPtrInstance GetFreeInstance (void);
#define EPL_MCO_DECL_INSTANCE_FCT() \
static tEplPtrInstance GetInstancePtr (tEplInstanceHdl InstHandle_p) { \
return &aEplInstanceTable_g[InstHandle_p]; } \
static tEplPtrInstance GetFreeInstance (void) { \
tEplInstanceInfo MEM* pInstance = &aEplInstanceTable_g[0]; \
tFastByte i = EPL_MAX_INSTANCES; \
do { if (pInstance->m_InstState != kStateUsed) { \
return (tEplPtrInstance) pInstance; } \
pInstance++; i--; } \
while (i != 0); \
return CCM_ILLINSTANCE; }
// this macro defines the instance table. Each entry is reserved for an instance of CANopen.
#define EPL_MCO_DECL_INSTANCE_VAR() \
static tEplInstanceInfo MEM aEplInstanceTable_g [EPL_MAX_INSTANCES];
// this macro defines member variables in instance table which are needed in
// all modules of Epl stack
#define EPL_MCO_DECL_INSTANCE_MEMBER() \
STATIC BYTE m_InstState; \
STATIC BYTE m_bInstIndex;
#define EPL_MCO_INSTANCE_PARAM_IDX_() EPL_MCO_INSTANCE_PARAM_ (EPL_MCO_GLB_VAR (m_bInstIndex))
#define EPL_MCO_INSTANCE_PARAM_IDX() EPL_MCO_INSTANCE_PARAM (EPL_MCO_GLB_VAR (m_bInstIndex))
#else // only one instance is used
// Memory attributes for instance table.
#define INST_NEAR NEAR // faster access to variables
#define INST_FAR MEM // variables wich have to located in xdata
#define STATIC static // prevent warnings for variables with same name
#define INSTANCE_TYPE_BEGIN
#define INSTANCE_TYPE_END
// macros for declaration, initializing and member access for instance handle
// This class of macros are used by API function to inform CCM-modul which
// instance is to be used.
// macros for reference of instance handle
// These macros are used for parameter passing to CANopen API function.
#define CCM_INSTANCE_HDL
#define CCM_INSTANCE_HDL_
#define CCM_DECL_INSTANCE_PTR_LOCAL
// macros for declaration within the function header or prototype
#define CCM_DECL_INSTANCE_HDL void
#define CCM_DECL_INSTANCE_HDL_
// macros for process instance handle
#define CCM_CHECK_INSTANCE_HDL()
// macros for declaration of pointer to instance handle
#define CCM_DECL_PTR_INSTANCE_HDL void
#define CCM_DECL_PTR_INSTANCE_HDL_
// macros for process pointer to instance handle
#define CCM_CHECK_PTR_INSTANCE_HDL()
// This macro returned the handle and pointer to next free instance.
#define CCM_GET_FREE_INSTANCE_AND_HDL()
#define CCM_CHECK_INSTANCE_PTR()
#define CCM_GET_INSTANCE_PTR()
#define CCM_GET_FREE_INSTANCE_PTR()
#define CCM_INSTANCE_PARAM(par)
#define CCM_INSTANCE_PARAM_(par)
#define CCM_INST_ENTRY aCcmInstanceTable_g[0]
// macros for declaration, initializing and member access for instance pointer
// This class of macros are used by CANopen internal function to point to one instance.
// macros for declaration within the function header, prototype or local var list
#define EPL_MCO_DECL_INSTANCE_PTR void
#define EPL_MCO_DECL_INSTANCE_PTR_
#define EPL_MCO_DECL_INSTANCE_PTR_LOCAL
// macros for reference of pointer to instance
// These macros are used for parameter passing to called function.
#define EPL_MCO_INSTANCE_PTR
#define EPL_MCO_INSTANCE_PTR_
#define EPL_MCO_ADDR_INSTANCE_PTR_
// macros for process pointer to instance
#define EPL_MCO_GET_INSTANCE_PTR()
#define EPL_MCO_GET_FREE_INSTANCE_PTR()
// This macro should be used to check the passed pointer to an public function
#define EPL_MCO_CHECK_INSTANCE_STATE()
// macros for declaration of pointer to instance pointer
#define EPL_MCO_DECL_PTR_INSTANCE_PTR void
#define EPL_MCO_DECL_PTR_INSTANCE_PTR_
// macros for reference of pointer to instance pointer
// These macros are used for parameter passing to called function.
#define EPL_MCO_PTR_INSTANCE_PTR
#define EPL_MCO_PTR_INSTANCE_PTR_
// macros for process pointer to instance pointer
#define EPL_MCO_CHECK_PTR_INSTANCE_PTR()
#define EPL_MCO_SET_PTR_INSTANCE_PTR()
#define EPL_MCO_INSTANCE_PARAM(a)
#define EPL_MCO_INSTANCE_PARAM_(a)
#define EPL_MCO_INSTANCE_PARAM_IDX_()
#define EPL_MCO_INSTANCE_PARAM_IDX()
// macro for access of struct members of one instance
#define EPL_MCO_INST_ENTRY aEplInstanceTable_g[0]
#define EPL_MCO_GLB_VAR(var) (var)
#define EPL_MCO_WRITE_INSTANCE_STATE(a)
// this macro deletes all instance entries as unused
#define EPL_MCO_DELETE_INSTANCE_TABLE()
// definition of functions which has to be defined in each module of CANopen stack
#define EPL_MCO_DEFINE_INSTANCE_FCT()
#define EPL_MCO_DECL_INSTANCE_FCT()
// this macro defines the instance table. Each entry is reserved for an instance of CANopen.
#define EPL_MCO_DECL_INSTANCE_VAR()
// this macro defines member variables in instance table which are needed in
// all modules of CANopen stack
#define EPL_MCO_DECL_INSTANCE_MEMBER()
#endif
/*
#if (CDRV_MAX_INSTANCES > 1)
#define CDRV_REENTRANT REENTRANT
#else
#define CDRV_REENTRANT
#endif
*/
#endif // _EPLINSTDEF_H_
// 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).

View file

@ -0,0 +1,104 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for status and error LED
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplLed.h,v $
$Author: D.Krueger $
$Revision: 1.1 $ $Date: 2008/11/17 16:40:39 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2008/11/17 d.k.: start of the implementation
****************************************************************************/
#ifndef _EPLLED_H_
#define _EPLLED_H_
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
typedef enum
{
kEplLedTypeStatus = 0x00,
kEplLedTypeError = 0x01,
} tEplLedType;
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#endif // #ifndef _EPLLED_H_

View file

@ -0,0 +1,248 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: global include file for EPL-NMT-Modules
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplNmt.h,v $
$Author: D.Krueger $
$Revision: 1.6 $ $Date: 2008/11/17 16:40:39 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/09 k.t.: start of the implementation
****************************************************************************/
#ifndef _EPLNMT_H_
#define _EPLNMT_H_
#include "EplInc.h"
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
// define super-states and masks to identify a super-state
#define EPL_NMT_GS_POWERED 0x0008 // super state
#define EPL_NMT_GS_INITIALISATION 0x0009 // super state
#define EPL_NMT_GS_COMMUNICATING 0x000C // super state
#define EPL_NMT_CS_EPLMODE 0x000D // super state
#define EPL_NMT_MS_EPLMODE 0x000D // super state
#define EPL_NMT_SUPERSTATE_MASK 0x000F // mask to select state
#define EPL_NMT_TYPE_UNDEFINED 0x0000 // type of NMT state is still undefined
#define EPL_NMT_TYPE_CS 0x0100 // CS type of NMT state
#define EPL_NMT_TYPE_MS 0x0200 // MS type of NMT state
#define EPL_NMT_TYPE_MASK 0x0300 // mask to select type of NMT state (i.e. CS or MS)
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
// the lower Byte of the NMT-State is encoded
// like the values in the EPL-Standard
// the higher byte is used to encode MN
// (Bit 1 of the higher byte = 1) or CN (Bit 0 of the
// higher byte = 1)
// the super-states are not mentioned in this
// enum because they are no real states
// --> there are masks defined to indentify the
// super-states
typedef enum
{
kEplNmtGsOff = 0x0000,
kEplNmtGsInitialising = 0x0019,
kEplNmtGsResetApplication = 0x0029,
kEplNmtGsResetCommunication = 0x0039,
kEplNmtGsResetConfiguration = 0x0079,
kEplNmtCsNotActive = 0x011C,
kEplNmtCsPreOperational1 = 0x011D,
kEplNmtCsStopped = 0x014D,
kEplNmtCsPreOperational2 = 0x015D,
kEplNmtCsReadyToOperate = 0x016D,
kEplNmtCsOperational = 0x01FD,
kEplNmtCsBasicEthernet = 0x011E,
kEplNmtMsNotActive = 0x021C,
kEplNmtMsPreOperational1 = 0x021D,
kEplNmtMsPreOperational2 = 0x025D,
kEplNmtMsReadyToOperate = 0x026D,
kEplNmtMsOperational = 0x02FD,
kEplNmtMsBasicEthernet = 0x021E
} tEplNmtState;
// NMT-events
typedef enum
{
// Events from DLL
// Events defined by EPL V2 specification
kEplNmtEventNoEvent = 0x00,
// kEplNmtEventDllMePres = 0x01,
kEplNmtEventDllMePresTimeout = 0x02,
// kEplNmtEventDllMeAsnd = 0x03,
// kEplNmtEventDllMeAsndTimeout = 0x04,
kEplNmtEventDllMeSoaSent = 0x04,
kEplNmtEventDllMeSocTrig = 0x05,
kEplNmtEventDllMeSoaTrig = 0x06,
kEplNmtEventDllCeSoc = 0x07,
kEplNmtEventDllCePreq = 0x08,
kEplNmtEventDllCePres = 0x09,
kEplNmtEventDllCeSoa = 0x0A,
kEplNmtEventDllCeAsnd = 0x0B,
kEplNmtEventDllCeFrameTimeout = 0x0C,
// Events triggered by NMT-Commands
kEplNmtEventSwReset = 0x10, // NMT_GT1, NMT_GT2, NMT_GT8
kEplNmtEventResetNode = 0x11,
kEplNmtEventResetCom = 0x12,
kEplNmtEventResetConfig = 0x13,
kEplNmtEventEnterPreOperational2= 0x14,
kEplNmtEventEnableReadyToOperate= 0x15,
kEplNmtEventStartNode = 0x16, // NMT_CT7
kEplNmtEventStopNode = 0x17,
// Events triggered by higher layer
kEplNmtEventEnterResetApp = 0x20,
kEplNmtEventEnterResetCom = 0x21,
kEplNmtEventInternComError = 0x22, // NMT_GT6, internal communication error -> enter ResetCommunication
kEplNmtEventEnterResetConfig = 0x23,
kEplNmtEventEnterCsNotActive = 0x24,
kEplNmtEventEnterMsNotActive = 0x25,
kEplNmtEventTimerBasicEthernet = 0x26, // NMT_CT3; timer triggered state change (NotActive -> BasicEth)
kEplNmtEventTimerMsPreOp1 = 0x27, // enter PreOp1 on MN (NotActive -> MsPreOp1)
kEplNmtEventNmtCycleError = 0x28, // NMT_CT11, NMT_MT6; error during cycle -> enter PreOp1
kEplNmtEventTimerMsPreOp2 = 0x29, // enter PreOp2 on MN (MsPreOp1 -> MsPreOp2 if kEplNmtEventAllMandatoryCNIdent)
kEplNmtEventAllMandatoryCNIdent = 0x2A, // enter PreOp2 on MN if kEplNmtEventTimerMsPreOp2
kEplNmtEventEnterReadyToOperate = 0x2B, // application ready for the state ReadyToOp
kEplNmtEventEnterMsOperational = 0x2C, // enter Operational on MN
kEplNmtEventSwitchOff = 0x2D, // enter state Off
kEplNmtEventCriticalError = 0x2E, // enter state Off because of critical error
} tEplNmtEvent;
// type for argument of event kEplEventTypeNmtStateChange
typedef struct
{
tEplNmtState m_NewNmtState;
tEplNmtEvent m_NmtEvent;
} tEplEventNmtStateChange;
// structure for kEplEventTypeHeartbeat
typedef struct
{
unsigned int m_uiNodeId; // NodeId
tEplNmtState m_NmtState; // NMT state (remember distinguish between MN / CN)
WORD m_wErrorCode; // EPL error code in case of NMT state NotActive
} tEplHeartbeatEvent;
typedef enum
{
kEplNmtNodeEventFound = 0x00,
kEplNmtNodeEventUpdateSw = 0x01, // application shall update software on CN
kEplNmtNodeEventCheckConf = 0x02, // application / Configuration Manager shall check and update configuration on CN
kEplNmtNodeEventUpdateConf = 0x03, // application / Configuration Manager shall update configuration on CN (check was done by NmtMn module)
kEplNmtNodeEventVerifyConf = 0x04, // application / Configuration Manager shall verify configuration of CN
kEplNmtNodeEventReadyToStart= 0x05, // issued if EPL_NMTST_NO_STARTNODE set
// application must call EplNmtMnuSendNmtCommand(kEplNmtCmdStartNode) manually
kEplNmtNodeEventNmtState = 0x06,
kEplNmtNodeEventError = 0x07, // NMT error of CN
} tEplNmtNodeEvent;
typedef enum
{
kEplNmtNodeCommandBoot = 0x01, // if EPL_NODEASSIGN_START_CN not set it must be issued after kEplNmtNodeEventFound
kEplNmtNodeCommandSwOk = 0x02, // application updated software on CN successfully
kEplNmtNodeCommandSwUpdated = 0x03, // application updated software on CN successfully
kEplNmtNodeCommandConfOk = 0x04, // application / Configuration Manager has updated configuration on CN successfully
kEplNmtNodeCommandConfReset = 0x05, // application / Configuration Manager has updated configuration on CN successfully
// and CN needs ResetConf so that the configuration gets actived
kEplNmtNodeCommandConfErr = 0x06, // application / Configuration Manager failed on updating configuration on CN
kEplNmtNodeCommandStart = 0x07, // if EPL_NMTST_NO_STARTNODE set it must be issued after kEplNmtNodeEventReadyToStart
} tEplNmtNodeCommand;
typedef enum
{
kEplNmtBootEventBootStep1Finish = 0x00, // PreOp2 is possible
kEplNmtBootEventBootStep2Finish = 0x01, // ReadyToOp is possible
kEplNmtBootEventCheckComFinish = 0x02, // Operational is possible
kEplNmtBootEventOperational = 0x03, // all mandatory CNs are Operational
kEplNmtBootEventError = 0x04, // boot process halted because of an error
} tEplNmtBootEvent;
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#endif // #ifndef _EPLNMT_H_

View file

@ -0,0 +1,691 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for NMT-CN-Userspace-Module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplNmtCnu.c,v $
$Author: D.Krueger $
$Revision: 1.6 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/09 k.t.: start of the implementation
****************************************************************************/
#include "EplInc.h"
#include "user/EplNmtCnu.h"
#include "user/EplDlluCal.h"
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_CN)) != 0)
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
typedef struct
{
unsigned int m_uiNodeId;
tEplNmtuCheckEventCallback m_pfnCheckEventCb;
} tEplNmtCnuInstance;
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
static tEplNmtCnuInstance EplNmtCnuInstance_g;
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
static tEplNmtCommand EplNmtCnuGetNmtCommand(tEplFrameInfo * pFrameInfo_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 //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplNmtCnuInit
//
// Description: init the first instance of the module
//
//
//
// Parameters: uiNodeId_p = NodeId of the local node
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuInit(unsigned int uiNodeId_p)
{
tEplKernel Ret;
Ret = EplNmtCnuAddInstance(uiNodeId_p);
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplNmtCnuAddInstance
//
// Description: init the add new instance of the module
//
//
//
// Parameters: uiNodeId_p = NodeId of the local node
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuAddInstance(unsigned int uiNodeId_p)
{
tEplKernel Ret;
Ret = kEplSuccessful;
// reset instance structure
EPL_MEMSET(&EplNmtCnuInstance_g, 0, sizeof (EplNmtCnuInstance_g));
// save nodeid
EplNmtCnuInstance_g.m_uiNodeId = uiNodeId_p;
// register callback-function for NMT-commands
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
Ret = EplDlluCalRegAsndService(kEplDllAsndNmtCommand,
EplNmtCnuCommandCb,
kEplDllAsndFilterLocal);
#endif
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplNmtCnuDelInstance
//
// Description: delte instance of the module
//
//
//
// Parameters:
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuDelInstance()
{
tEplKernel Ret;
Ret = kEplSuccessful;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
// deregister callback function from DLL
Ret = EplDlluCalRegAsndService(kEplDllAsndNmtCommand,
NULL,
kEplDllAsndFilterNone);
#endif
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplNmtCnuSendNmtRequest
//
// Description: Send an NMT-Request to the MN
//
//
//
// Parameters: uiNodeId_p = NodeId of the local node
// NmtCommand_p = requested NMT-Command
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuSendNmtRequest(
unsigned int uiNodeId_p,
tEplNmtCommand NmtCommand_p)
{
tEplKernel Ret;
tEplFrameInfo NmtRequestFrameInfo;
tEplFrame NmtRequestFrame;
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 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
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
Ret = EplDlluCalAsyncSend(&NmtRequestFrameInfo, // pointer to frameinfo
kEplDllAsyncReqPrioNmt); // priority
#endif
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplNmtCnuRegisterStateChangeCb
//
// Description: register Callback-function go get informed about a
// NMT-Change-State-Event
//
//
//
// Parameters: pfnEplNmtStateChangeCb_p = functionpointer
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuRegisterCheckEventCb(
tEplNmtuCheckEventCallback pfnEplNmtCheckEventCb_p)
{
tEplKernel Ret;
Ret = kEplSuccessful;
// save callback-function in modul global var
EplNmtCnuInstance_g.m_pfnCheckEventCb = pfnEplNmtCheckEventCb_p;
return Ret;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplNmtCnuCommandCb
//
// Description: callback funktion for NMT-Commands
//
//
//
// Parameters: pFrameInfo_p = Frame with the NMT-Commando
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
static tEplKernel PUBLIC EplNmtCnuCommandCb(tEplFrameInfo * pFrameInfo_p)
{
tEplKernel Ret = kEplSuccessful;
tEplNmtCommand NmtCommand;
BOOL fNodeIdInList;
tEplNmtEvent NmtEvent = kEplNmtEventNoEvent;
if(pFrameInfo_p == NULL)
{
Ret = kEplNmtInvalidFramePointer;
goto Exit;
}
NmtCommand = EplNmtCnuGetNmtCommand(pFrameInfo_p);
// check NMT-Command
switch(NmtCommand)
{
//------------------------------------------------------------------------
// 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 kEplNmtCmdEnterPreOperational2:
{ // send NMT-Event to state maschine kEplNmtEventEnterPreOperational2
NmtEvent = kEplNmtEventEnterPreOperational2;
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 kEplNmtCmdResetCommunication:
{ // send NMT-Event to state maschine kEplNmtEventResetCom
NmtEvent = kEplNmtEventResetCom;
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;
}
//------------------------------------------------------------------------
// 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 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 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 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 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
// TODO: add functions to process managing command (optional)
case kEplNmtCmdNetHostNameSet:
{
break;
}
case kEplNmtCmdFlushArpEntry:
{
break;
}
//------------------------------------------------------------------------
// NMT info services
// TODO: forward event with infos to the application (optional)
case kEplNmtCmdPublishConfiguredCN:
{
break;
}
case kEplNmtCmdPublishActiveCN:
{
break;
}
case kEplNmtCmdPublishPreOperational1:
{
break;
}
case kEplNmtCmdPublishPreOperational2:
{
break;
}
case kEplNmtCmdPublishReadyToOperate:
{
break;
}
case kEplNmtCmdPublishOperational:
{
break;
}
case kEplNmtCmdPublishStopped:
{
break;
}
case kEplNmtCmdPublishEmergencyNew:
{
break;
}
case kEplNmtCmdPublishTime:
{
break;
}
//-----------------------------------------------------------------------
// error from MN
// -> requested command not supported by MN
case kEplNmtCmdInvalidService:
{
// TODO: errorevent to application
break;
}
//------------------------------------------------------------------------
// default
default:
{
Ret = kEplNmtUnknownCommand;
goto Exit;
}
}// 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(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTU)) != 0)
Ret = EplNmtuNmtEvent(NmtEvent);
#endif
}
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplNmtCnuGetNmtCommand()
//
// Description: returns the NMT-Command from the frame
//
//
//
// Parameters: pFrameInfo_p = pointer to the Frame
// with the NMT-Command
//
//
// Returns: tEplNmtCommand = NMT-Command
//
//
// State:
//
//---------------------------------------------------------------------------
static tEplNmtCommand EplNmtCnuGetNmtCommand(tEplFrameInfo * pFrameInfo_p)
{
tEplNmtCommand NmtCommand;
tEplNmtCommandService* pNmtCommandService;
pNmtCommandService = &pFrameInfo_p->m_pFrame->m_Data.m_Asnd.m_Payload.m_NmtCommandService;
NmtCommand = (tEplNmtCommand)AmiGetByteFromLe(&pNmtCommandService->m_le_bNmtCommandId);
return NmtCommand;
}
//---------------------------------------------------------------------------
//
// Function: EplNmtCnuNodeIdList()
//
// Description: check if the own nodeid is set in EPL Node List
//
//
//
// Parameters: pbNmtCommandDate_p = pointer to the data of the NMT Command
//
//
// Returns: BOOL = TRUE if nodeid is set in EPL Node List
// FALSE if nodeid not set in EPL Node List
//
//
// State:
//
//---------------------------------------------------------------------------
static BOOL EplNmtCnuNodeIdList(BYTE* pbNmtCommandDate_p)
{
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;
bNodeListByte = AmiGetByteFromLe(&pbNmtCommandDate_p[uiByteOffset]);
if((bNodeListByte & bBitOffset) == 0)
{
fNodeIdInList = FALSE;
}
else
{
fNodeIdInList = TRUE;
}
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

@ -0,0 +1,157 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for communication abstraction layer of the
NMT-Kernel-Module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplNmtkCal.c,v $
$Author: D.Krueger $
$Revision: 1.3 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
KEIL uVision 2
-------------------------------------------------------------------------
Revision History:
2006/06/16 -k.t.: start of the implementation
****************************************************************************/
#include "kernel/EplNmtkCal.h"
// TODO: init function needed to prepare EplNmtkGetNmtState for
// io-controll-call from EplNmtuCal-Modul
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function:
//
// Description:
//
//
//
// Parameters:
//
//
// Returns:
//
//
// State:
//
//---------------------------------------------------------------------------
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function:
//
// Description:
//
//
//
// Parameters:
//
//
// Returns:
//
//
// State:
//
//---------------------------------------------------------------------------
// EOF

View file

@ -0,0 +1,681 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for NMT-Userspace-Module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplNmtu.c,v $
$Author: D.Krueger $
$Revision: 1.8 $ $Date: 2008/11/10 17:17:42 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/09 k.t.: start of the implementation
****************************************************************************/
#include "EplInc.h"
#include "user/EplNmtu.h"
#include "user/EplObdu.h"
#include "user/EplTimeru.h"
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0)
#include "kernel/EplNmtk.h"
#endif
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTU)) != 0)
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
typedef struct
{
tEplNmtuStateChangeCallback m_pfnNmtChangeCb;
tEplTimerHdl m_TimerHdl;
} tEplNmtuInstance;
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
static tEplNmtuInstance EplNmtuInstance_g;
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplNmtuInit
//
// Description: init first instance of the module
//
//
//
// Parameters:
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtuInit()
{
tEplKernel Ret;
Ret = EplNmtuAddInstance();
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplNmtuAddInstance
//
// Description: init other instances of the module
//
//
//
// Parameters:
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtuAddInstance()
{
tEplKernel Ret;
Ret = kEplSuccessful;
EplNmtuInstance_g.m_pfnNmtChangeCb = NULL;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplNmtuDelInstance
//
// Description: delete instance
//
//
//
// Parameters:
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtuDelInstance()
{
tEplKernel Ret;
Ret = kEplSuccessful;
EplNmtuInstance_g.m_pfnNmtChangeCb = NULL;
// delete timer
Ret = EplTimeruDeleteTimer(&EplNmtuInstance_g.m_TimerHdl);
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplNmtuNmtEvent
//
// Description: sends the NMT-Event to the NMT-State-Maschine
//
//
//
// Parameters: NmtEvent_p = NMT-Event to send
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtuNmtEvent(tEplNmtEvent NmtEvent_p)
{
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);
Ret = EplEventuPost(&Event);
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplNmtuGetNmtState
//
// Description: returns the actuell NMT-State
//
//
//
// Parameters:
//
//
// Returns: tEplNmtState = NMT-State
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplNmtState PUBLIC EplNmtuGetNmtState()
{
tEplNmtState NmtState;
// $$$ call function of communication abstraction layer
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0)
NmtState = EplNmtkGetNmtState();
#else
NmtState = 0;
#endif
return NmtState;
}
//---------------------------------------------------------------------------
//
// Function: EplNmtuProcessEvent
//
// Description: processes events from event queue
//
//
//
// Parameters: pEplEvent_p = pointer to event
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtuProcessEvent(
tEplEvent* pEplEvent_p)
{
tEplKernel Ret;
Ret = kEplSuccessful;
// process event
switch(pEplEvent_p->m_EventType)
{
// state change of NMT-Module
case kEplEventTypeNmtStateChange:
{
tEplEventNmtStateChange* pNmtStateChange;
// delete timer
Ret = EplTimeruDeleteTimer(&EplNmtuInstance_g.m_TimerHdl);
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);
}
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;
}
// 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;
}
// build the configuration with infos from OD
case kEplNmtGsResetConfiguration:
{
unsigned int uiNodeId;
// 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);
#else
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
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
Ret = EplNmtuNmtEvent(kEplNmtEventEnterMsNotActive);
#else
TRACE0("EplNmtuProcess(): no MN functionality implemented\n");
#endif
}
else
{ // node shall be CN
Ret = EplNmtuNmtEvent(kEplNmtEventEnterCsNotActive);
}
break;
}
//-----------------------------------------------------------
// CN part of the state machine
// 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
// 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);
#else
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;
}
// node processes only async frames
case kEplNmtCsPreOperational1:
{
break;
}
// node processes isochronous and asynchronous frames
case kEplNmtCsPreOperational2:
{
Ret = EplNmtuNmtEvent(kEplNmtEventEnterReadyToOperate);
break;
}
// node should be configured und application is ready
case kEplNmtCsReadyToOperate:
{
break;
}
// normal work state
case kEplNmtCsOperational:
{
break;
}
// node stopped by MN
// -> only process asynchronous frames
case kEplNmtCsStopped:
{
break;
}
// no EPL cycle
// -> normal ethernet communication
case kEplNmtCsBasicEthernet:
{
break;
}
//-----------------------------------------------------------
// 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;
// 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);
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0) || (EPL_OBD_USE_KERNEL != FALSE)
Ret = EplObduReadEntry(EPL_MCO_PTR_INSTANCE_PTR_
0x1F80,
0x00,
&dwBuffer,
&ObdSize);
#else
Ret = kEplObdIndexNotExist;
#endif
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;
}
// 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);
#else
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;
}
// 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
// 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;
}
#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;
}
// node processes isochronous and asynchronous frames
case kEplNmtMsPreOperational2:
{
break;
}
// node should be configured und application is ready
case kEplNmtMsReadyToOperate:
{
break;
}
// normal work state
case kEplNmtMsOperational:
{
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;
}
EPL_DBGLVL_NMTU_TRACE0("EplNmtuProcessEvent(): NMT-State-Maschine announce change of NMT State\n");
break;
}
default:
{
Ret = kEplNmtInvalidEvent;
}
}
//Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplNmtuRegisterStateChangeCb
//
// Description: register Callback-function go get informed about a
// NMT-Change-State-Event
//
//
//
// Parameters: pfnEplNmtStateChangeCb_p = functionpointer
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplNmtuRegisterStateChangeCb(
tEplNmtuStateChangeCallback pfnEplNmtStateChangeCb_p)
{
tEplKernel Ret;
Ret = kEplSuccessful;
// save callback-function in modul global var
EplNmtuInstance_g.m_pfnNmtChangeCb = pfnEplNmtStateChangeCb_p;
return Ret;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function:
//
// Description:
//
//
//
// Parameters:
//
//
// Returns:
//
//
// State:
//
//---------------------------------------------------------------------------
#endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTU)) != 0)
// EOF

View file

@ -0,0 +1,164 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for communication abstraction layer of the
NMT-Userspace-Module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplNmtuCal.c,v $
$Author: D.Krueger $
$Revision: 1.4 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
KEIL uVision 2
-------------------------------------------------------------------------
Revision History:
2006/06/16 -k.t.: start of the implementation
****************************************************************************/
#include "user/EplNmtuCal.h"
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplNmtkCalGetNmtState
//
// Description: return current NMT-State
// -> encapsulate access to kernelspace
//
//
//
// Parameters:
//
//
// Returns: tEplNmtState = current NMT-State
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplNmtState PUBLIC EplNmtkCalGetNmtState()
{
tEplNmtState NmtState;
// for test direkt call for EplNmtkGetNmtState()
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0)
NmtState = EplNmtkGetNmtState();
#else
NmtState = 0;
#endif
return NmtState;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function:
//
// Description:
//
//
//
// Parameters:
//
//
// Returns:
//
//
// State:
//
//---------------------------------------------------------------------------
// EOF

3505
drivers/staging/epl/EplObd.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,504 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for api function of EplOBD-Module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplObd.h,v $
$Author: D.Krueger $
$Revision: 1.5 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
Microsoft VC7
-------------------------------------------------------------------------
Revision History:
2006/06/02 k.t.: start of the implementation, version 1.00
****************************************************************************/
#include "EplInc.h"
#ifndef _EPLOBD_H_
#define _EPLOBD_H_
// ============================================================================
// defines
// ============================================================================
#define EPL_OBD_TABLE_INDEX_END 0xFFFF
// for the usage of BOOLEAN in OD
#define OBD_TRUE 0x01
#define OBD_FALSE 0x00
// default OD index for Node id
#define EPL_OBD_NODE_ID_INDEX 0x1F93
// default subindex for NodeId in OD
#define EPL_OBD_NODE_ID_SUBINDEX 0x01
// default subindex for NodeIDByHW_BOOL
#define EPL_OBD_NODE_ID_HWBOOL_SUBINDEX 0x02
// ============================================================================
// enums
// ============================================================================
// directions for access to object dictionary
typedef enum
{
kEplObdDirInit = 0x00, // initialising after power on
kEplObdDirStore = 0x01, // store all object values to non volatile memory
kEplObdDirLoad = 0x02, // load all object values from non volatile memory
kEplObdDirRestore = 0x03, // deletes non volatile memory (restore)
kEplObdDirOBKCheck = 0xFF // reserved
}tEplObdDir;
// commands for store
typedef enum
{
kEplObdCommNothing = 0x00,
kEplObdCommOpenWrite = 0x01,
kEplObdCommWriteObj = 0x02,
kEplObdCommCloseWrite = 0x03,
kEplObdCommOpenRead = 0x04,
kEplObdCommReadObj = 0x05,
kEplObdCommCloseRead = 0x06,
kEplObdCommClear = 0x07,
kEplObdCommUnknown = 0xFF
}tEplObdCommand;
//-----------------------------------------------------------------------------------------------------------
// events of object callback function
typedef enum
{
// m_pArg points to
// ---------------------
kEplObdEvCheckExist = 0x06, // checking if object does exist (reading and writing) NULL
kEplObdEvPreRead = 0x00, // before reading an object source data buffer in OD
kEplObdEvPostRead = 0x01, // after reading an object destination data buffer from caller
kEplObdEvWrStringDomain = 0x07, // event for changing string/domain data pointer or size struct tEplObdVStringDomain in RAM
kEplObdEvInitWrite = 0x04, // initializes writing an object (checking object size) size of object in OD (tEplObdSize)
kEplObdEvPreWrite = 0x02, // before writing an object source data buffer from caller
kEplObdEvPostWrite = 0x03, // after writing an object destination data buffer in OD
// kEplObdEvAbortSdo = 0x05 // after an abort of an SDO transfer
} tEplObdEvent;
// part of OD (bit oriented)
typedef unsigned int tEplObdPart;
#define kEplObdPartNo 0x00 // nothing
#define kEplObdPartGen 0x01 // part (0x1000 - 0x1FFF)
#define kEplObdPartMan 0x02 // manufacturer part (0x2000 - 0x5FFF)
#define kEplObdPartDev 0x04 // device part (0x6000 - 0x9FFF)
#define kEplObdPartUsr 0x08 // dynamic part e.g. for ICE61131-3
// combinations
#define kEplObdPartApp ( kEplObdPartMan | kEplObdPartDev | kEplObdPartUsr) // manufacturer and device part (0x2000 - 0x9FFF) and user OD
#define kEplObdPartAll (kEplObdPartGen | kEplObdPartMan | kEplObdPartDev | kEplObdPartUsr) // whole OD
//-----------------------------------------------------------------------------------------------------------
// access types for objects
// must be a difine because bit-flags
typedef unsigned int tEplObdAccess;
#define kEplObdAccRead 0x01 // object can be read
#define kEplObdAccWrite 0x02 // object can be written
#define kEplObdAccConst 0x04 // object contains a constant value
#define kEplObdAccPdo 0x08 // object can be mapped in a PDO
#define kEplObdAccArray 0x10 // object contains an array of numerical values
#define kEplObdAccRange 0x20 // object contains lower and upper limit
#define kEplObdAccVar 0x40 // object data is placed in application
#define kEplObdAccStore 0x80 // object data can be stored to non volatile memory
// combinations (not all combinations are required)
#define kEplObdAccR (0 | 0 | 0 | 0 | 0 | 0 | kEplObdAccRead)
#define kEplObdAccW (0 | 0 | 0 | 0 | 0 | kEplObdAccWrite | 0 )
#define kEplObdAccRW (0 | 0 | 0 | 0 | 0 | kEplObdAccWrite | kEplObdAccRead)
#define kEplObdAccCR (0 | 0 | 0 | 0 | kEplObdAccConst | 0 | kEplObdAccRead)
#define kEplObdAccGR (0 | 0 | kEplObdAccRange | 0 | 0 | 0 | kEplObdAccRead)
#define kEplObdAccGW (0 | 0 | kEplObdAccRange | 0 | 0 | kEplObdAccWrite | 0 )
#define kEplObdAccGRW (0 | 0 | kEplObdAccRange | 0 | 0 | kEplObdAccWrite | kEplObdAccRead)
#define kEplObdAccVR (0 | kEplObdAccVar | 0 | 0 | 0 | 0 | kEplObdAccRead)
#define kEplObdAccVW (0 | kEplObdAccVar | 0 | 0 | 0 | kEplObdAccWrite | 0 )
#define kEplObdAccVRW (0 | kEplObdAccVar | 0 | 0 | 0 | kEplObdAccWrite | kEplObdAccRead)
#define kEplObdAccVPR (0 | kEplObdAccVar | 0 | kEplObdAccPdo | 0 | 0 | kEplObdAccRead)
#define kEplObdAccVPW (0 | kEplObdAccVar | 0 | kEplObdAccPdo | 0 | kEplObdAccWrite | 0 )
#define kEplObdAccVPRW (0 | kEplObdAccVar | 0 | kEplObdAccPdo | 0 | kEplObdAccWrite | kEplObdAccRead)
#define kEplObdAccVGR (0 | kEplObdAccVar | kEplObdAccRange | 0 | 0 | 0 | kEplObdAccRead)
#define kEplObdAccVGW (0 | kEplObdAccVar | kEplObdAccRange | 0 | 0 | kEplObdAccWrite | 0 )
#define kEplObdAccVGRW (0 | kEplObdAccVar | kEplObdAccRange | 0 | 0 | kEplObdAccWrite | kEplObdAccRead)
#define kEplObdAccVGPR (0 | kEplObdAccVar | kEplObdAccRange | kEplObdAccPdo | 0 | 0 | kEplObdAccRead)
#define kEplObdAccVGPW (0 | kEplObdAccVar | kEplObdAccRange | kEplObdAccPdo | 0 | kEplObdAccWrite | 0 )
#define kEplObdAccVGPRW (0 | kEplObdAccVar | kEplObdAccRange | kEplObdAccPdo | 0 | kEplObdAccWrite | kEplObdAccRead)
#define kEplObdAccSR (kEplObdAccStore | 0 | 0 | 0 | 0 | 0 | kEplObdAccRead)
#define kEplObdAccSW (kEplObdAccStore | 0 | 0 | 0 | 0 | kEplObdAccWrite | 0 )
#define kEplObdAccSRW (kEplObdAccStore | 0 | 0 | 0 | 0 | kEplObdAccWrite | kEplObdAccRead)
#define kEplObdAccSCR (kEplObdAccStore | 0 | 0 | 0 | kEplObdAccConst | 0 | kEplObdAccRead)
#define kEplObdAccSGR (kEplObdAccStore | 0 | kEplObdAccRange | 0 | 0 | 0 | kEplObdAccRead)
#define kEplObdAccSGW (kEplObdAccStore | 0 | kEplObdAccRange | 0 | 0 | kEplObdAccWrite | 0 )
#define kEplObdAccSGRW (kEplObdAccStore | 0 | kEplObdAccRange | 0 | 0 | kEplObdAccWrite | kEplObdAccRead)
#define kEplObdAccSVR (kEplObdAccStore | kEplObdAccVar | 0 | 0 | 0 | 0 | kEplObdAccRead)
#define kEplObdAccSVW (kEplObdAccStore | kEplObdAccVar | 0 | 0 | 0 | kEplObdAccWrite | 0 )
#define kEplObdAccSVRW (kEplObdAccStore | kEplObdAccVar | 0 | 0 | 0 | kEplObdAccWrite | kEplObdAccRead)
#define kEplObdAccSVPR (kEplObdAccStore | kEplObdAccVar | 0 | kEplObdAccPdo | 0 | 0 | kEplObdAccRead)
#define kEplObdAccSVPW (kEplObdAccStore | kEplObdAccVar | 0 | kEplObdAccPdo | 0 | kEplObdAccWrite | 0 )
#define kEplObdAccSVPRW (kEplObdAccStore | kEplObdAccVar | 0 | kEplObdAccPdo | 0 | kEplObdAccWrite | kEplObdAccRead)
#define kEplObdAccSVGR (kEplObdAccStore | kEplObdAccVar | kEplObdAccRange | 0 | 0 | 0 | kEplObdAccRead)
#define kEplObdAccSVGW (kEplObdAccStore | kEplObdAccVar | kEplObdAccRange | 0 | 0 | kEplObdAccWrite | 0 )
#define kEplObdAccSVGRW (kEplObdAccStore | kEplObdAccVar | kEplObdAccRange | 0 | 0 | kEplObdAccWrite | kEplObdAccRead)
#define kEplObdAccSVGPR (kEplObdAccStore | kEplObdAccVar | kEplObdAccRange | kEplObdAccPdo | 0 | 0 | kEplObdAccRead)
#define kEplObdAccSVGPW (kEplObdAccStore | kEplObdAccVar | kEplObdAccRange | kEplObdAccPdo | 0 | kEplObdAccWrite | 0 )
#define kEplObdAccSVGPRW (kEplObdAccStore | kEplObdAccVar | kEplObdAccRange | kEplObdAccPdo | 0 | kEplObdAccWrite | kEplObdAccRead)
typedef unsigned int tEplObdSize; // For all objects as objects size are used an unsigned int.
// -------------------------------------------------------------------------
// types for data types defined in DS301
// -------------------------------------------------------------------------
// types of objects in object dictionary
// DS-301 defines these types as WORD
typedef enum
{
// types which are always supported
kEplObdTypBool = 0x0001,
kEplObdTypInt8 = 0x0002,
kEplObdTypInt16 = 0x0003,
kEplObdTypInt32 = 0x0004,
kEplObdTypUInt8 = 0x0005,
kEplObdTypUInt16 = 0x0006,
kEplObdTypUInt32 = 0x0007,
kEplObdTypReal32 = 0x0008,
kEplObdTypVString = 0x0009,
kEplObdTypOString = 0x000A,
kEplObdTypDomain = 0x000F,
kEplObdTypInt24 = 0x0010,
kEplObdTypUInt24 = 0x0016,
kEplObdTypReal64 = 0x0011,
kEplObdTypInt40 = 0x0012,
kEplObdTypInt48 = 0x0013,
kEplObdTypInt56 = 0x0014,
kEplObdTypInt64 = 0x0015,
kEplObdTypUInt40 = 0x0018,
kEplObdTypUInt48 = 0x0019,
kEplObdTypUInt56 = 0x001A,
kEplObdTypUInt64 = 0x001B,
kEplObdTypTimeOfDay = 0x000C,
kEplObdTypTimeDiff = 0x000D
}tEplObdType;
// other types are not supported in this version
// -------------------------------------------------------------------------
// types for data types defined in DS301
// -------------------------------------------------------------------------
typedef unsigned char tEplObdBoolean; // 0001
typedef signed char tEplObdInteger8; // 0002
typedef signed short int tEplObdInteger16; // 0003
typedef signed long tEplObdInteger32; // 0004
typedef unsigned char tEplObdUnsigned8; // 0005
typedef unsigned short int tEplObdUnsigned16; // 0006
typedef unsigned long tEplObdUnsigned32; // 0007
typedef float tEplObdReal32; // 0008
typedef unsigned char tEplObdDomain; // 000F
typedef signed long tEplObdInteger24; // 0010
typedef unsigned long tEplObdUnsigned24; // 0016
typedef signed QWORD tEplObdInteger40; // 0012
typedef signed QWORD tEplObdInteger48; // 0013
typedef signed QWORD tEplObdInteger56; // 0014
typedef signed QWORD tEplObdInteger64; // 0015
typedef unsigned QWORD tEplObdUnsigned40; // 0018
typedef unsigned QWORD tEplObdUnsigned48; // 0019
typedef unsigned QWORD tEplObdUnsigned56; // 001A
typedef unsigned QWORD tEplObdUnsigned64; // 001B
typedef double tEplObdReal64; // 0011
typedef tTimeOfDay tEplObdTimeOfDay; // 000C
typedef tTimeOfDay tEplObdTimeDifference; // 000D
// -------------------------------------------------------------------------
// structur for defining a variable
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
typedef enum
{
kVarValidSize = 0x01,
kVarValidData = 0x02,
// kVarValidCallback = 0x04,
// kVarValidArg = 0x08,
kVarValidAll = 0x03 // currently only size and data are implemented and used
}tEplVarParamValid;
typedef tEplKernel (PUBLIC ROM* tEplVarCallback) (CCM_DECL_INSTANCE_HDL_
void * pParam_p);
typedef struct
{
tEplVarParamValid m_ValidFlag;
unsigned int m_uiIndex;
unsigned int m_uiSubindex;
tEplObdSize m_Size;
void MEM* m_pData;
// tEplVarCallback m_fpCallback;
// void * m_pArg;
} tEplVarParam;
typedef struct
{
void MEM* m_pData;
tEplObdSize m_Size;
/*
#if (EPL_PDO_USE_STATIC_MAPPING == FALSE)
tEplVarCallback m_fpCallback;
void * m_pArg;
#endif
*/
} tEplObdVarEntry;
typedef struct
{
tEplObdSize m_Size;
BYTE * m_pString;
} tEplObdOString; // 000C
typedef struct
{
tEplObdSize m_Size;
char * m_pString;
} tEplObdVString; // 000D
typedef struct
{
tEplObdSize m_Size;
char * m_pDefString; // $$$ d.k. it is unused, so we could delete it
char * m_pString;
} tEplObdVStringDef;
typedef struct
{
tEplObdSize m_Size;
BYTE * m_pDefString; // $$$ d.k. it is unused, so we could delete it
BYTE * m_pString;
} tEplObdOStringDef;
//r.d. parameter struct for changing object size and/or pointer to data of Strings or Domains
typedef struct
{
tEplObdSize m_DownloadSize; // download size from SDO or APP
tEplObdSize m_ObjSize; // current object size from OD - should be changed from callback function
void * m_pData; // current object ptr from OD - should be changed from callback function
} tEplObdVStringDomain; // 000D
// ============================================================================
// types
// ============================================================================
// -------------------------------------------------------------------------
// subindexstruct
// -------------------------------------------------------------------------
// Change not the order for this struct!!!
typedef struct
{
unsigned int m_uiSubIndex;
tEplObdType m_Type;
tEplObdAccess m_Access;
void * m_pDefault;
void MEM* m_pCurrent; // points always to RAM
} tEplObdSubEntry;
// r.d.: has always to be because new OBD-Macros for arrays
typedef tEplObdSubEntry * tEplObdSubEntryPtr;
// -------------------------------------------------------------------------
// callback function for objdictionary modul
// -------------------------------------------------------------------------
// parameters for callback function
typedef struct
{
tEplObdEvent m_ObdEvent;
unsigned int m_uiIndex;
unsigned int m_uiSubIndex;
void * m_pArg;
DWORD m_dwAbortCode;
} tEplObdCbParam;
// define type for callback function: pParam_p points to tEplObdCbParam
typedef tEplKernel (PUBLIC ROM* tEplObdCallback) (CCM_DECL_INSTANCE_HDL_
tEplObdCbParam MEM* pParam_p);
// do not change the order for this struct!!!
typedef struct
{
unsigned int m_uiIndex;
tEplObdSubEntryPtr m_pSubIndex;
unsigned int m_uiCount;
tEplObdCallback m_fpCallback; // function is called back if object access
} tEplObdEntry;
// allways pointer
typedef tEplObdEntry * tEplObdEntryPtr;
// -------------------------------------------------------------------------
// structur to initialize OBD module
// -------------------------------------------------------------------------
typedef struct
{
tEplObdEntryPtr m_pPart;
tEplObdEntryPtr m_pManufacturerPart;
tEplObdEntryPtr m_pDevicePart;
#if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE))
tEplObdEntryPtr m_pUserPart;
#endif
} tEplObdInitParam;
// -------------------------------------------------------------------------
// structur for parameters of STORE RESTORE command
// -------------------------------------------------------------------------
typedef struct
{
tEplObdCommand m_bCommand;
tEplObdPart m_bCurrentOdPart;
void MEM* m_pData;
tEplObdSize m_ObjSize;
} tEplObdCbStoreParam;
typedef tEplKernel (PUBLIC ROM* tInitTabEntryCallback) (
void MEM* pTabEntry_p,
unsigned int uiObjIndex_p);
typedef tEplKernel (PUBLIC ROM* tEplObdStoreLoadObjCallback) (CCM_DECL_INSTANCE_HDL_
tEplObdCbStoreParam MEM* pCbStoreParam_p);
// -------------------------------------------------------------------------
// this stucture is used for parameters for function ObdInitModuleTab()
// -------------------------------------------------------------------------
typedef struct
{
unsigned int m_uiLowerObjIndex; // lower limit of ObjIndex
unsigned int m_uiUpperObjIndex; // upper limit of ObjIndex
tInitTabEntryCallback m_fpInitTabEntry; // will be called if ObjIndex was found
void MEM* m_pTabBase; // base address of table
unsigned int m_uiEntrySize; // size of table entry // 25-feb-2005 r.d.: expansion from BYTE to WORD necessary for PDO bit mapping
unsigned int m_uiMaxEntries; // max. tabel entries
} tEplObdModulTabParam;
//-------------------------------------------------------------------
// enum for function EplObdSetNodeId
//-------------------------------------------------------------------
typedef enum
{
kEplObdNodeIdUnknown = 0x00, // unknown how the node id was set
kEplObdNodeIdSoftware = 0x01, // node id set by software
kEplObdNodeIdHardware = 0x02 // node id set by hardware
}tEplObdNodeIdType;
// ============================================================================
// global variables
// ============================================================================
// ============================================================================
// public functions
// ============================================================================
#endif // #ifndef _EPLOBD_H_

View file

@ -0,0 +1,362 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for macros of EplOBD-Module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplObdMacro.h,v $
$Author: D.Krueger $
$Revision: 1.4 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/05 k.t.: start of the implementation
-> based on CANopen ObdMacro.h
****************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
#if defined (EPL_OBD_DEFINE_MACRO)
//-------------------------------------------------------------------------------------------
#if defined (EPL_OBD_CREATE_ROM_DATA)
// #pragma message ("EPL_OBD_CREATE_ROM_DATA")
#define EPL_OBD_BEGIN() static DWORD dwObd_OBK_g = 0x0000;
#define EPL_OBD_END()
//---------------------------------------------------------------------------------------
#define EPL_OBD_BEGIN_PART_GENERIC()
#define EPL_OBD_BEGIN_PART_MANUFACTURER()
#define EPL_OBD_BEGIN_PART_DEVICE()
#define EPL_OBD_END_PART()
//---------------------------------------------------------------------------------------
#define EPL_OBD_BEGIN_INDEX_RAM(ind,cnt,call)
#define EPL_OBD_END_INDEX(ind)
#define EPL_OBD_RAM_INDEX_RAM_ARRAY(ind,cnt,call,typ,acc,dtyp,name,def) static tEplObdUnsigned8 xDef##ind##_0x00_g = (cnt); \
static dtyp xDef##ind##_0x01_g = (def);
#define EPL_OBD_RAM_INDEX_RAM_VARARRAY(ind,cnt,call,typ,acc,dtyp,name,def) static tEplObdUnsigned8 xDef##ind##_0x00_g = (cnt); \
static dtyp xDef##ind##_0x01_g = (def);
#define EPL_OBD_RAM_INDEX_RAM_VARARRAY_NOINIT(ind,cnt,call,typ,acc,dtyp,name) static tEplObdUnsigned8 xDef##ind##_0x00_g = (cnt);
//---------------------------------------------------------------------------------------
#define EPL_OBD_SUBINDEX_RAM_VAR(ind,sub,typ,acc,dtyp,name,val) static dtyp xDef##ind##_##sub##_g = val;
#define EPL_OBD_SUBINDEX_RAM_VAR_RG(ind,sub,typ,acc,dtyp,name,val,low,high) static dtyp xDef##ind##_##sub##_g[3] = {val,low,high};
#define EPL_OBD_SUBINDEX_RAM_VAR_NOINIT(ind,sub,typ,acc,dtyp,name)
#define EPL_OBD_SUBINDEX_RAM_VSTRING(ind,sub,acc,name,size,val) static char MEM szCur##ind##_##sub##_g[size+1]; \
static tEplObdVStringDef xDef##ind##_##sub##_g = {size, val, szCur##ind##_##sub##_g};
#define EPL_OBD_SUBINDEX_RAM_OSTRING(ind,sub,acc,name,size) static BYTE MEM bCur##ind##_##sub##_g[size]; \
static tEplObdOStringDef xDef##ind##_##sub##_g = {size, ((BYTE*)""), bCur##ind##_##sub##_g};
#define EPL_OBD_SUBINDEX_RAM_DOMAIN(ind,sub,acc,name)
#define EPL_OBD_SUBINDEX_RAM_USERDEF(ind,sub,typ,acc,dtyp,name,val) static dtyp xDef##ind##_##sub##_g = val;
#define EPL_OBD_SUBINDEX_RAM_USERDEF_RG(ind,sub,typ,acc,dtyp,name,val,low,high) static dtyp xDef##ind##_##sub##_g[3] = {val,low,high};
#define EPL_OBD_SUBINDEX_RAM_USERDEF_NOINIT(ind,sub,typ,acc,dtyp,name)
//-------------------------------------------------------------------------------------------
#elif defined (EPL_OBD_CREATE_RAM_DATA)
// #pragma message ("EPL_OBD_CREATE_RAM_DATA")
#define EPL_OBD_BEGIN()
#define EPL_OBD_END()
//---------------------------------------------------------------------------------------
#define EPL_OBD_BEGIN_PART_GENERIC()
#define EPL_OBD_BEGIN_PART_MANUFACTURER()
#define EPL_OBD_BEGIN_PART_DEVICE()
#define EPL_OBD_END_PART()
//---------------------------------------------------------------------------------------
#define EPL_OBD_BEGIN_INDEX_RAM(ind,cnt,call)
#define EPL_OBD_END_INDEX(ind)
#define EPL_OBD_RAM_INDEX_RAM_ARRAY(ind,cnt,call,typ,acc,dtyp,name,def) static dtyp MEM axCur##ind##_g[cnt];
#define EPL_OBD_RAM_INDEX_RAM_VARARRAY(ind,cnt,call,typ,acc,dtyp,name,def) static tEplObdVarEntry MEM aVarEntry##ind##_g[cnt];
#define EPL_OBD_RAM_INDEX_RAM_VARARRAY_NOINIT(ind,cnt,call,typ,acc,dtyp,name) static tEplObdVarEntry MEM aVarEntry##ind##_g[cnt];
//---------------------------------------------------------------------------------------
#define EPL_OBD_SUBINDEX_RAM_VAR(ind,sub,typ,acc,dtyp,name,val) static dtyp MEM xCur##ind##_##sub##_g;
#define EPL_OBD_SUBINDEX_RAM_VAR_RG(ind,sub,typ,acc,dtyp,name,val,low,high) static dtyp MEM xCur##ind##_##sub##_g;
#define EPL_OBD_SUBINDEX_RAM_VSTRING(ind,sub,acc,name,size,val) static tEplObdVString MEM xCur##ind##_##sub##_g;
#define EPL_OBD_SUBINDEX_RAM_OSTRING(ind,sub,acc,name,size) static tEplObdOString MEM xCur##ind##_##sub##_g;
#define EPL_OBD_SUBINDEX_RAM_VAR_NOINIT(ind,sub,typ,acc,dtyp,name) static dtyp MEM xCur##ind##_##sub##_g;
#define EPL_OBD_SUBINDEX_RAM_DOMAIN(ind,sub,acc,name) static tEplObdVarEntry MEM VarEntry##ind##_##sub##_g;
#define EPL_OBD_SUBINDEX_RAM_USERDEF(ind,sub,typ,acc,dtyp,name,val) static tEplObdVarEntry MEM VarEntry##ind##_##sub##_g;
#define EPL_OBD_SUBINDEX_RAM_USERDEF_RG(ind,sub,typ,acc,dtyp,name,val,low,high) static tEplObdVarEntry MEM VarEntry##ind##_##sub##_g;
#define EPL_OBD_SUBINDEX_RAM_USERDEF_NOINIT(ind,sub,typ,acc,dtyp,name) static tEplObdVarEntry MEM VarEntry##ind##_##sub##_g;
//-------------------------------------------------------------------------------------------
#elif defined (EPL_OBD_CREATE_SUBINDEX_TAB)
// #pragma message ("EPL_OBD_CREATE_SUBINDEX_TAB")
#define EPL_OBD_BEGIN()
#define EPL_OBD_END()
//---------------------------------------------------------------------------------------
#define EPL_OBD_BEGIN_PART_GENERIC()
#define EPL_OBD_BEGIN_PART_MANUFACTURER()
#define EPL_OBD_BEGIN_PART_DEVICE()
#define EPL_OBD_END_PART()
//---------------------------------------------------------------------------------------
#define EPL_OBD_BEGIN_INDEX_RAM(ind,cnt,call) static tEplObdSubEntry MEM aObdSubEntry##ind##Ram_g[cnt]= {
#define EPL_OBD_END_INDEX(ind) EPL_OBD_END_SUBINDEX()};
#define EPL_OBD_RAM_INDEX_RAM_ARRAY(ind,cnt,call,typ,acc,dtyp,name,def) static tEplObdSubEntry MEM aObdSubEntry##ind##Ram_g[]= { \
{0, kEplObdTypUInt8, kEplObdAccCR, &xDef##ind##_0x00_g, NULL}, \
{1, typ, (acc)|kEplObdAccArray, &xDef##ind##_0x01_g, &axCur##ind##_g[0]}, \
EPL_OBD_END_SUBINDEX()};
#define EPL_OBD_RAM_INDEX_RAM_VARARRAY(ind,cnt,call,typ,acc,dtyp,name,def) static tEplObdSubEntry MEM aObdSubEntry##ind##Ram_g[]= { \
{0, kEplObdTypUInt8, kEplObdAccCR, &xDef##ind##_0x00_g, NULL}, \
{1, typ, (acc)|kEplObdAccArray|kEplObdAccVar, &xDef##ind##_0x01_g, &aVarEntry##ind##_g[0]}, \
EPL_OBD_END_SUBINDEX()};
#define EPL_OBD_RAM_INDEX_RAM_VARARRAY_NOINIT(ind,cnt,call,typ,acc,dtyp,name) static tEplObdSubEntry MEM aObdSubEntry##ind##Ram_g[]= { \
{0, kEplObdTypUInt8, kEplObdAccCR, &xDef##ind##_0x00_g, NULL}, \
{1, typ, (acc)|kEplObdAccArray|kEplObdAccVar, NULL, &aVarEntry##ind##_g[0]}, \
EPL_OBD_END_SUBINDEX()};
//---------------------------------------------------------------------------------------
#define EPL_OBD_SUBINDEX_RAM_VAR(ind,sub,typ,acc,dtyp,name,val) {sub,typ, (acc), &xDef##ind##_##sub##_g, &xCur##ind##_##sub##_g},
#define EPL_OBD_SUBINDEX_RAM_VAR_RG(ind,sub,typ,acc,dtyp,name,val,low,high) {sub,typ, (acc)|kEplObdAccRange, &xDef##ind##_##sub##_g[0],&xCur##ind##_##sub##_g},
#define EPL_OBD_SUBINDEX_RAM_VAR_NOINIT(ind,sub,typ,acc,dtyp,name) {sub,typ, (acc), NULL, &xCur##ind##_##sub##_g},
#define EPL_OBD_SUBINDEX_RAM_VSTRING(ind,sub,acc,name,size,val) {sub,kEplObdTypVString,(acc)/*|kEplObdAccVar*/, &xDef##ind##_##sub##_g, &xCur##ind##_##sub##_g},
#define EPL_OBD_SUBINDEX_RAM_OSTRING(ind,sub,acc,name,size) {sub,kEplObdTypOString,(acc)/*|kEplObdAccVar*/, &xDef##ind##_##sub##_g, &xCur##ind##_##sub##_g},
#define EPL_OBD_SUBINDEX_RAM_DOMAIN(ind,sub,acc,name) {sub,kEplObdTypDomain, (acc)|kEplObdAccVar, NULL, &VarEntry##ind##_##sub##_g},
#define EPL_OBD_SUBINDEX_RAM_USERDEF(ind,sub,typ,acc,dtyp,name,val) {sub,typ, (acc)|kEplObdAccVar, &xDef##ind##_##sub##_g, &VarEntry##ind##_##sub##_g},
#define EPL_OBD_SUBINDEX_RAM_USERDEF_RG(ind,sub,typ,acc,dtyp,name,val,low,high) {sub,typ, (acc)|kEplObdAccVar|kEplObdAccRange,&xDef##ind##_##sub##_g[0],&VarEntry##ind##_##sub##_g},
#define EPL_OBD_SUBINDEX_RAM_USERDEF_NOINIT(ind,sub,typ,acc,dtyp,name) {sub,typ, (acc)|kEplObdAccVar, NULL, &VarEntry##ind##_##sub##_g},
//-------------------------------------------------------------------------------------------
#elif defined (EPL_OBD_CREATE_INDEX_TAB)
// #pragma message ("EPL_OBD_CREATE_INDEX_TAB")
#define EPL_OBD_BEGIN()
#define EPL_OBD_END()
//---------------------------------------------------------------------------------------
#define EPL_OBD_BEGIN_PART_GENERIC() static tEplObdEntry aObdTab_g[] = {
#define EPL_OBD_BEGIN_PART_MANUFACTURER() static tEplObdEntry aObdTabManufacturer_g[] = {
#define EPL_OBD_BEGIN_PART_DEVICE() static tEplObdEntry aObdTabDevice_g[] = {
#define EPL_OBD_END_PART() {EPL_OBD_TABLE_INDEX_END,(tEplObdSubEntryPtr)&dwObd_OBK_g,0,NULL}};
//---------------------------------------------------------------------------------------
#define EPL_OBD_BEGIN_INDEX_RAM(ind,cnt,call) {ind,(tEplObdSubEntryPtr)&aObdSubEntry##ind##Ram_g[0],cnt,(tEplObdCallback)call},
#define EPL_OBD_END_INDEX(ind)
#define EPL_OBD_RAM_INDEX_RAM_ARRAY(ind,cnt,call,typ,acc,dtyp,name,def) {ind,(tEplObdSubEntryPtr)&aObdSubEntry##ind##Ram_g[0],(cnt)+1,(tEplObdCallback)call},
#define EPL_OBD_RAM_INDEX_RAM_VARARRAY(ind,cnt,call,typ,acc,dtyp,name,def) {ind,(tEplObdSubEntryPtr)&aObdSubEntry##ind##Ram_g[0],(cnt)+1,(tEplObdCallback)call},
#define EPL_OBD_RAM_INDEX_RAM_VARARRAY_NOINIT(ind,cnt,call,typ,acc,dtyp,name) {ind,(tEplObdSubEntryPtr)&aObdSubEntry##ind##Ram_g[0],(cnt)+1,(tEplObdCallback)call},
//---------------------------------------------------------------------------------------
#define EPL_OBD_SUBINDEX_RAM_VAR(ind,sub,typ,acc,dtyp,name,val)
#define EPL_OBD_SUBINDEX_RAM_VAR_RG(ind,sub,typ,acc,dtyp,name,val,low,high)
#define EPL_OBD_SUBINDEX_RAM_VSTRING(ind,sub,acc,name,size,val)
#define EPL_OBD_SUBINDEX_RAM_OSTRING(ind,sub,acc,name,size)
#define EPL_OBD_SUBINDEX_RAM_VAR_NOINIT(ind,sub,typ,acc,dtyp,name)
#define EPL_OBD_SUBINDEX_RAM_DOMAIN(ind,sub,acc,name)
#define EPL_OBD_SUBINDEX_RAM_USERDEF(ind,sub,typ,acc,dtyp,name,val)
#define EPL_OBD_SUBINDEX_RAM_USERDEF_RG(ind,sub,typ,acc,dtyp,name,val,low,high)
#define EPL_OBD_SUBINDEX_RAM_USERDEF_NOINIT(ind,sub,typ,acc,dtyp,name)
//-------------------------------------------------------------------------------------------
#elif defined (EPL_OBD_CREATE_INIT_FUNCTION)
// #pragma message ("EPL_OBD_CREATE_INIT_FUNCTION")
#define EPL_OBD_BEGIN()
#define EPL_OBD_END()
//---------------------------------------------------------------------------------------
#define EPL_OBD_BEGIN_PART_GENERIC() pInitParam->m_pPart = (tEplObdEntryPtr) &aObdTab_g[0];
#define EPL_OBD_BEGIN_PART_MANUFACTURER() pInitParam->m_pManufacturerPart = (tEplObdEntryPtr) &aObdTabManufacturer_g[0];
#define EPL_OBD_BEGIN_PART_DEVICE() pInitParam->m_pDevicePart = (tEplObdEntryPtr) &aObdTabDevice_g[0];
#define EPL_OBD_END_PART()
//---------------------------------------------------------------------------------------
#define EPL_OBD_BEGIN_INDEX_RAM(ind,cnt,call)
#define EPL_OBD_END_INDEX(ind)
#define EPL_OBD_RAM_INDEX_RAM_ARRAY(ind,cnt,call,typ,acc,dtyp,name,def)
#define EPL_OBD_RAM_INDEX_RAM_VARARRAY(ind,cnt,call,typ,acc,dtyp,name,def)
#define EPL_OBD_RAM_INDEX_RAM_VARARRAY_NOINIT(ind,cnt,call,typ,acc,dtyp,name)
//---------------------------------------------------------------------------------------
#define EPL_OBD_SUBINDEX_RAM_VAR(ind,sub,typ,acc,dtyp,name,val)
#define EPL_OBD_SUBINDEX_RAM_VAR_RG(ind,sub,typ,acc,dtyp,name,val,low,high)
#define EPL_OBD_SUBINDEX_RAM_VSTRING(ind,sub,acc,name,size,val)
#define EPL_OBD_SUBINDEX_RAM_OSTRING(ind,sub,acc,name,size)
#define EPL_OBD_SUBINDEX_RAM_VAR_NOINIT(ind,sub,typ,acc,dtyp,name)
#define EPL_OBD_SUBINDEX_RAM_DOMAIN(ind,sub,acc,name)
#define EPL_OBD_SUBINDEX_RAM_USERDEF(ind,sub,typ,acc,dtyp,name,val)
#define EPL_OBD_SUBINDEX_RAM_USERDEF_RG(ind,sub,typ,acc,dtyp,name,val,low,high)
#define EPL_OBD_SUBINDEX_RAM_USERDEF_NOINIT(ind,sub,typ,acc,dtyp,name)
//-------------------------------------------------------------------------------------------
#elif defined (EPL_OBD_CREATE_INIT_SUBINDEX)
// #pragma message ("EPL_OBD_CREATE_INIT_SUBINDEX")
#define EPL_OBD_BEGIN()
#define EPL_OBD_END()
//---------------------------------------------------------------------------------------
#define EPL_OBD_BEGIN_PART_GENERIC()
#define EPL_OBD_BEGIN_PART_MANUFACTURER()
#define EPL_OBD_BEGIN_PART_DEVICE()
#define EPL_OBD_END_PART()
//---------------------------------------------------------------------------------------
#define EPL_OBD_BEGIN_INDEX_RAM(ind,cnt,call) //CCM_SUBINDEX_RAM_ONLY (EPL_MEMCPY (&aObdSubEntry##ind##Ram_g[0],&aObdSubEntry##ind##Rom_g[0],sizeof(aObdSubEntry##ind##Ram_g)));
#define EPL_OBD_END_INDEX(ind)
#define EPL_OBD_RAM_INDEX_RAM_ARRAY(ind,cnt,call,typ,acc,dtyp,name,def) //EPL_MEMCPY (&aObdSubEntry##ind##Ram_g[0],&aObdSubEntry##ind##Rom_g[0],sizeof(aObdSubEntry##ind##Ram_g));
#define EPL_OBD_RAM_INDEX_RAM_VARARRAY(ind,cnt,call,typ,acc,dtyp,name,def) //EPL_MEMCPY (&aObdSubEntry##ind##Ram_g[0],&aObdSubEntry##ind##Rom_g[0],sizeof(aObdSubEntry##ind##Ram_g));
#define EPL_OBD_RAM_INDEX_RAM_VARARRAY_NOINIT(ind,cnt,call,typ,acc,dtyp,name) //EPL_MEMCPY (&aObdSubEntry##ind##Ram_g[0],&aObdSubEntry##ind##Rom_g[0],sizeof(aObdSubEntry##ind##Ram_g));
//---------------------------------------------------------------------------------------
#define EPL_OBD_SUBINDEX_RAM_VAR(ind,sub,typ,acc,dtyp,name,val)
#define EPL_OBD_SUBINDEX_RAM_VAR_RG(ind,sub,typ,acc,dtyp,name,val,low,high)
#define EPL_OBD_SUBINDEX_RAM_VSTRING(ind,sub,acc,name,size,val)
#define EPL_OBD_SUBINDEX_RAM_OSTRING(ind,sub,acc,name,size)
#define EPL_OBD_SUBINDEX_RAM_VAR_NOINIT(ind,sub,typ,acc,dtyp,name)
#define EPL_OBD_SUBINDEX_RAM_DOMAIN(ind,sub,acc,name)
#define EPL_OBD_SUBINDEX_RAM_USERDEF(ind,sub,typ,acc,dtyp,name,val)
#define EPL_OBD_SUBINDEX_RAM_USERDEF_RG(ind,sub,typ,acc,dtyp,name,val,low,high)
#define EPL_OBD_SUBINDEX_RAM_USERDEF_NOINIT(ind,sub,typ,acc,dtyp,name)
//-------------------------------------------------------------------------------------------
#else
// #pragma message ("ELSE OF DEFINE")
#define EPL_OBD_BEGIN()
#define EPL_OBD_END()
//---------------------------------------------------------------------------------------
#define EPL_OBD_BEGIN_PART_GENERIC()
#define EPL_OBD_BEGIN_PART_MANUFACTURER()
#define EPL_OBD_BEGIN_PART_DEVICE()
#define EPL_OBD_END_PART()
//---------------------------------------------------------------------------------------
#define EPL_OBD_BEGIN_INDEX_RAM(ind,cnt,call)
#define EPL_OBD_END_INDEX(ind)
#define EPL_OBD_RAM_INDEX_RAM_ARRAY(ind,cnt,call,typ,acc,dtyp,name,def)
#define EPL_OBD_RAM_INDEX_RAM_VARARRAY(ind,cnt,call,typ,acc,dtyp,name,def)
#define EPL_OBD_RAM_INDEX_RAM_VARARRAY_NOINIT(ind,cnt,call,typ,acc,dtyp,name)
//---------------------------------------------------------------------------------------
#define EPL_OBD_SUBINDEX_RAM_VAR(ind,sub,typ,acc,dtyp,name,val)
#define EPL_OBD_SUBINDEX_RAM_VAR_RG(ind,sub,typ,acc,dtyp,name,val,low,high)
#define EPL_OBD_SUBINDEX_RAM_VSTRING(ind,sub,acc,name,sizes,val)
#define EPL_OBD_SUBINDEX_RAM_OSTRING(ind,sub,acc,name,size)
#define EPL_OBD_SUBINDEX_RAM_VAR_NOINIT(ind,sub,typ,acc,dtyp,name)
#define EPL_OBD_SUBINDEX_RAM_DOMAIN(ind,sub,acc,name)
#define EPL_OBD_SUBINDEX_RAM_USERDEF(ind,sub,typ,acc,dtyp,name,val)
#define EPL_OBD_SUBINDEX_RAM_USERDEF_RG(ind,sub,typ,acc,dtyp,name,val,low,high)
#define EPL_OBD_SUBINDEX_RAM_USERDEF_NOINIT(ind,sub,typ,acc,dtyp,name)
#endif
//-------------------------------------------------------------------------------------------
#elif defined (EPL_OBD_UNDEFINE_MACRO)
// #pragma message ("EPL_OBD_UNDEFINE_MACRO")
#undef EPL_OBD_BEGIN
#undef EPL_OBD_END
//---------------------------------------------------------------------------------------
#undef EPL_OBD_BEGIN_PART_GENERIC
#undef EPL_OBD_BEGIN_PART_MANUFACTURER
#undef EPL_OBD_BEGIN_PART_DEVICE
#undef EPL_OBD_END_PART
//---------------------------------------------------------------------------------------
#undef EPL_OBD_BEGIN_INDEX_RAM
#undef EPL_OBD_END_INDEX
#undef EPL_OBD_RAM_INDEX_RAM_ARRAY
#undef EPL_OBD_RAM_INDEX_RAM_VARARRAY
#undef EPL_OBD_RAM_INDEX_RAM_VARARRAY_NOINIT
//---------------------------------------------------------------------------------------
#undef EPL_OBD_SUBINDEX_RAM_VAR
#undef EPL_OBD_SUBINDEX_RAM_VAR_RG
#undef EPL_OBD_SUBINDEX_RAM_VSTRING
#undef EPL_OBD_SUBINDEX_RAM_OSTRING
#undef EPL_OBD_SUBINDEX_RAM_VAR_NOINIT
#undef EPL_OBD_SUBINDEX_RAM_DOMAIN
#undef EPL_OBD_SUBINDEX_RAM_USERDEF
#undef EPL_OBD_SUBINDEX_RAM_USERDEF_RG
#undef EPL_OBD_SUBINDEX_RAM_USERDEF_NOINIT
#else
#error "nothing defined"
#endif

View file

@ -0,0 +1,154 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for communication abstraction layer
for the Epl-Obd-Kernelspace-Modul
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplObdkCal.c,v $
$Author: D.Krueger $
$Revision: 1.3 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
KEIL uVision 2
-------------------------------------------------------------------------
Revision History:
2006/06/19 k.t.: start of the implementation
****************************************************************************/
#include "EplInc.h"
#include "kernel/EplObdkCal.h"
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function:
//
// Description:
//
//
//
// Parameters:
//
//
// Returns:
//
//
// State:
//
//---------------------------------------------------------------------------
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function:
//
// Description:
//
//
//
// Parameters:
//
//
// Returns:
//
//
// State:
//
//---------------------------------------------------------------------------
// EOF

View file

@ -0,0 +1,512 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for Epl-Obd-Userspace-module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplObdu.c,v $
$Author: D.Krueger $
$Revision: 1.5 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/19 k.t.: start of the implementation
****************************************************************************/
#include "EplInc.h"
#include "user/EplObdu.h"
#include "user/EplObduCal.h"
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0)
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplObduWriteEntry()
//
// Description: Function writes data to an OBD entry. Strings
// are stored with added '\0' character.
//
// Parameters: uiIndex_p = Index of the OD entry
// uiSubIndex_p = Subindex of the OD Entry
// pSrcData_p = Pointer to the data to write
// Size_p = Size of the data in Byte
//
// Return: tEplKernel = Errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduWriteEntry (unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void * pSrcData_p,
tEplObdSize Size_p)
{
tEplKernel Ret;
Ret = EplObduCalWriteEntry(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplObduReadEntry()
//
// Description: The function reads an object entry. The application
// can always read the data even if attrib kEplObdAccRead
// is not set. The attrib is only checked up for SDO transfer.
//
// Parameters: uiIndex_p = Index oof the OD entry to read
// uiSubIndex_p = Subindex to read
// pDstData_p = pointer to the buffer for data
// Offset_p = offset in data for read access
// pSize_p = IN: Size of the buffer
// OUT: number of readed Bytes
//
// Return: tEplKernel = errorcode
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduReadEntry (unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void * pDstData_p,
tEplObdSize* pSize_p)
{
tEplKernel Ret;
Ret = EplObduCalReadEntry(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplObdAccessOdPart()
//
// Description: restores default values of one part of OD
//
// Parameters: ObdPart_p = od-part to reset
// Direction_p = directory flag for
//
// Return: tEplKernel = errorcode
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduAccessOdPart (tEplObdPart ObdPart_p,
tEplObdDir Direction_p)
{
tEplKernel Ret;
Ret = EplObduCalAccessOdPart(ObdPart_p, Direction_p);
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplObduDefineVar()
//
// Description: defines a variable in OD
//
// Parameters: pEplVarParam_p = varentry
//
// Return: tEplKernel = errorcode
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduDefineVar (tEplVarParam MEM* pVarParam_p)
{
tEplKernel Ret;
Ret = EplObduCalDefineVar(pVarParam_p);
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplObduGetObjectDataPtr()
//
// Description: It returnes the current data pointer. But if object is an
// constant object it returnes the default pointer.
//
// Parameters: uiIndex_p = Index of the entry
// uiSubindex_p = Subindex of the entry
//
// Return: void * = pointer to object data
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT void* PUBLIC EplObduGetObjectDataPtr (unsigned int uiIndex_p,
unsigned int uiSubIndex_p)
{
void* pData;
pData = EplObduCalGetObjectDataPtr(uiIndex_p, uiSubIndex_p);
return pData;
}
//---------------------------------------------------------------------------
//
// Function: EplObduRegisterUserOd()
//
// Description: function registers the user OD
//
// Parameters: pUserOd_p =pointer to user ODd
//
// Return: tEplKernel = errorcode
//
// State:
//
//---------------------------------------------------------------------------
#if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE))
EPLDLLEXPORT tEplKernel PUBLIC EplObduRegisterUserOd (tEplObdEntryPtr pUserOd_p)
{
tEplKernel Ret;
Ret = EplObduCalRegisterUserOd(pUserOd_p);
return Ret;
}
#endif
//---------------------------------------------------------------------------
//
// Function: EplObduInitVarEntry()
//
// Description: function to initialize VarEntry dependened on object type
//
// Parameters: pVarEntry_p = pointer to var entry structure
// bType_p = object type
// ObdSize_p = size of object data
//
// Returns: none
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT void PUBLIC EplObduInitVarEntry (tEplObdVarEntry MEM* pVarEntry_p,
BYTE bType_p, tEplObdSize ObdSize_p)
{
EplObduCalInitVarEntry(pVarEntry_p, bType_p, ObdSize_p);
}
//---------------------------------------------------------------------------
//
// Function: EplObduGetDataSize()
//
// Description: function to initialize VarEntry dependened on object type
//
// gets the data size of an object
// for string objects it returnes the string length
//
// Parameters: uiIndex_p = Index
// uiSubIndex_p= Subindex
//
// Return: tEplObdSize
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplObdSize PUBLIC EplObduGetDataSize(unsigned int uiIndex_p,
unsigned int uiSubIndex_p)
{
tEplObdSize Size;
Size = EplObduCalGetDataSize(uiIndex_p, uiSubIndex_p);
return Size;
}
//---------------------------------------------------------------------------
//
// Function: EplObduGetNodeId()
//
// Description: function returns nodeid from entry 0x1F93
//
//
// Parameters:
//
// Return: unsigned int = Node Id
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT unsigned int PUBLIC EplObduGetNodeId()
{
unsigned int uiNodeId;
uiNodeId = EplObduCalGetNodeId();
return uiNodeId;
}
//---------------------------------------------------------------------------
//
// Function: EplObduSetNodeId()
//
// Description: function sets nodeid in entry 0x1F93
//
//
// Parameters: uiNodeId_p = Node Id to set
// NodeIdType_p= Type on which way the Node Id was set
//
// Return: tEplKernel = Errorcode
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduSetNodeId(unsigned int uiNodeId_p,
tEplObdNodeIdType NodeIdType_p)
{
tEplKernel Ret;
Ret = EplObduCalSetNodeId(uiNodeId_p, NodeIdType_p);
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplObduGetAccessType()
//
// Description: Function returns accesstype of the entry
//
// Parameters: uiIndex_p = Index of the OD entry
// uiSubIndex_p = Subindex of the OD Entry
// pAccessTyp_p = pointer to buffer to store accesstyp
//
// Return: tEplKernel = Errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduGetAccessType(unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
tEplObdAccess* pAccessTyp_p)
{
tEplObdAccess AccessType;
AccessType = EplObduCalGetAccessType(uiIndex_p, uiSubIndex_p, pAccessTyp_p);
return AccessType;
}
//---------------------------------------------------------------------------
//
// Function: EplObdReaduEntryToLe()
//
// Description: The function reads an object entry from the byteoder
// of the system to the little endian byteorder for numeric values.
// For other types a normal read will be processed. This is usefull for
// the PDO and SDO module. The application
// can always read the data even if attrib kEplObdAccRead
// is not set. The attrib is only checked up for SDO transfer.
//
// Parameters: EPL_MCO_DECL_INSTANCE_PTR_
// uiIndex_p = Index of the OD entry to read
// uiSubIndex_p = Subindex to read
// pDstData_p = pointer to the buffer for data
// Offset_p = offset in data for read access
// pSize_p = IN: Size of the buffer
// OUT: number of readed Bytes
//
// Return: tEplKernel
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduReadEntryToLe (unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void * pDstData_p,
tEplObdSize * pSize_p)
{
tEplKernel Ret;
Ret = EplObduCalReadEntryToLe(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplObduWriteEntryFromLe()
//
// Description: Function writes data to an OBD entry from a source with
// little endian byteorder to the od with system specuific
// byteorder. Not numeric values will only by copied. Strings
// are stored with added '\0' character.
//
// Parameters: EPL_MCO_DECL_INSTANCE_PTR_
// uiIndex_p = Index of the OD entry
// uiSubIndex_p = Subindex of the OD Entry
// pSrcData_p = Pointer to the data to write
// Size_p = Size of the data in Byte
//
// Return: tEplKernel = Errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduWriteEntryFromLe (unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void * pSrcData_p,
tEplObdSize Size_p)
{
tEplKernel Ret;
Ret = EplObduCalWriteEntryFromLe(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplObduSearchVarEntry()
//
// Description: gets variable from OD
//
// Parameters: uiIndex_p = index of the var entry to search
// uiSubindex_p = subindex of var entry to search
// ppVarEntry_p = pointer to the pointer to the varentry
//
// Return: tEplKernel
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduSearchVarEntry (EPL_MCO_DECL_INSTANCE_PTR_
unsigned int uiIndex_p,
unsigned int uiSubindex_p,
tEplObdVarEntry MEM** ppVarEntry_p)
{
tEplKernel Ret;
Ret = EplObduCalSearchVarEntry(uiIndex_p, uiSubindex_p, ppVarEntry_p);
return Ret;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function:
//
// Description:
//
//
//
// Parameters:
//
//
// Returns:
//
//
// State:
//
//---------------------------------------------------------------------------
#endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0)
// EOF

View file

@ -0,0 +1,562 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for communication abstraction layer
for the Epl-Obd-Userspace-Modul
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplObduCal.c,v $
$Author: D.Krueger $
$Revision: 1.6 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/19 k.t.: start of the implementation
****************************************************************************/
#include "EplInc.h"
#include "user/EplObduCal.h"
#include "kernel/EplObdk.h"
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0) && (EPL_OBD_USE_KERNEL != FALSE)
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplObduCalWriteEntry()
//
// Description: Function encapsulate access of function EplObdWriteEntry
//
// Parameters: uiIndex_p = Index of the OD entry
// uiSubIndex_p = Subindex of the OD Entry
// pSrcData_p = Pointer to the data to write
// Size_p = Size of the data in Byte
//
// Return: tEplKernel = Errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalWriteEntry (
unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void * pSrcData_p,
tEplObdSize Size_p)
{
tEplKernel Ret;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
Ret = EplObdWriteEntry(uiIndex_p,uiSubIndex_p,pSrcData_p,Size_p);
#else
Ret = kEplSuccessful;
#endif
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplObduCalReadEntry()
//
// Description: Function encapsulate access of function EplObdReadEntry
//
// Parameters: uiIndex_p = Index oof the OD entry to read
// uiSubIndex_p = Subindex to read
// pDstData_p = pointer to the buffer for data
// Offset_p = offset in data for read access
// pSize_p = IN: Size of the buffer
// OUT: number of readed Bytes
//
// Return: tEplKernel = errorcode
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalReadEntry (
unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void * pDstData_p,
tEplObdSize *pSize_p)
{
tEplKernel Ret;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
Ret = EplObdReadEntry(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
#else
Ret = kEplSuccessful;
#endif
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplObduCalAccessOdPart()
//
// Description: Function encapsulate access of function EplObdAccessOdPart
//
// Parameters: ObdPart_p = od-part to reset
// Direction_p = directory flag for
//
// Return: tEplKernel = errorcode
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalAccessOdPart (
tEplObdPart ObdPart_p,
tEplObdDir Direction_p)
{
tEplKernel Ret;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
Ret = EplObdAccessOdPart(ObdPart_p, Direction_p);
#else
Ret = kEplSuccessful;
#endif
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplObduCalDefineVar()
//
// Description: Function encapsulate access of function EplObdDefineVar
//
// Parameters: pEplVarParam_p = varentry
//
// Return: tEplKernel = errorcode
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalDefineVar (tEplVarParam MEM* pVarParam_p)
{
tEplKernel Ret;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
Ret = EplObdDefineVar(pVarParam_p);
#else
Ret = kEplSuccessful;
#endif
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplObduCalGetObjectDataPtr()
//
// Description: Function encapsulate access of function EplObdGetObjectDataPtr
//
// Parameters: uiIndex_p = Index of the entry
// uiSubindex_p = Subindex of the entry
//
// Return: void * = pointer to object data
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT void* PUBLIC EplObduCalGetObjectDataPtr ( unsigned int uiIndex_p,
unsigned int uiSubIndex_p)
{
void* pData;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
pData = EplObdGetObjectDataPtr(uiIndex_p, uiSubIndex_p);
#else
pData = NULL;
#endif
return pData;
}
//---------------------------------------------------------------------------
//
// Function: EplObduCalRegisterUserOd()
//
// Description: Function encapsulate access of function EplObdRegisterUserOd
//
// Parameters: pUserOd_p = pointer to user OD
//
// Return: tEplKernel = errorcode
//
// State:
//
//---------------------------------------------------------------------------
#if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE))
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalRegisterUserOd (tEplObdEntryPtr pUserOd_p)
{
tEplKernel Ret;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
Ret = EplObdRegisterUserOd(pUserOd_p);
#else
Ret = kEplSuccessful;
#endif
return Ret;
}
#endif
//---------------------------------------------------------------------------
//
// Function: EplObduCalInitVarEntry()
//
// Description: Function encapsulate access of function EplObdInitVarEntry
//
// Parameters: pVarEntry_p = pointer to var entry structure
// bType_p = object type
// ObdSize_p = size of object data
//
// Returns: none
//
// State:
//
//---------------------------------------------------------------------------
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);
#endif
}
//---------------------------------------------------------------------------
//
// Function: EplObduCalGetDataSize()
//
// Description: Function encapsulate access of function EplObdGetDataSize
//
// gets the data size of an object
// for string objects it returnes the string length
//
// Parameters: uiIndex_p = Index
// uiSubIndex_p= Subindex
//
// Return: tEplObdSize
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplObdSize PUBLIC EplObduCalGetDataSize(unsigned int uiIndex_p,
unsigned int uiSubIndex_p)
{
tEplObdSize Size;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
Size = EplObdGetDataSize(uiIndex_p, uiSubIndex_p);
#else
Size = 0;
#endif
return Size;
}
//---------------------------------------------------------------------------
//
// Function: EplObduCalGetNodeId()
//
// Description: Function encapsulate access of function EplObdGetNodeId
//
//
// Parameters:
//
// Return: unsigned int = Node Id
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT unsigned int PUBLIC EplObduCalGetNodeId()
{
unsigned int uiNodeId;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
uiNodeId = EplObdGetNodeId();
#else
uiNodeId = 0;
#endif
return uiNodeId;
}
//---------------------------------------------------------------------------
//
// Function: EplObduCalSetNodeId()
//
// Description: Function encapsulate access of function EplObdSetNodeId
//
//
// Parameters: uiNodeId_p = Node Id to set
// NodeIdType_p= Type on which way the Node Id was set
//
// Return: tEplKernel = Errorcode
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalSetNodeId(unsigned int uiNodeId_p,
tEplObdNodeIdType NodeIdType_p)
{
tEplKernel Ret;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
Ret = EplObdSetNodeId(uiNodeId_p, NodeIdType_p);
#else
Ret = kEplSuccessful;
#endif
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplObduCalGetAccessType()
//
// Description: Function encapsulate access of function EplObdGetAccessType
//
// Parameters: uiIndex_p = Index of the OD entry
// uiSubIndex_p = Subindex of the OD Entry
// pAccessTyp_p = pointer to buffer to store accesstype
//
// Return: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalGetAccessType(unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
tEplObdAccess* pAccessTyp_p)
{
tEplObdAccess AccesType;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
AccesType = EplObdGetAccessType(uiIndex_p, uiSubIndex_p, pAccessTyp_p);
#else
AccesType = 0;
#endif
return AccesType;
}
//---------------------------------------------------------------------------
//
// Function: EplObduCalReadEntryToLe()
//
// Description: Function encapsulate access of function EplObdReadEntryToLe
//
// Parameters: uiIndex_p = Index of the OD entry to read
// uiSubIndex_p = Subindex to read
// pDstData_p = pointer to the buffer for data
// Offset_p = offset in data for read access
// pSize_p = IN: Size of the buffer
// OUT: number of readed Bytes
//
// Return: tEplKernel
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalReadEntryToLe (unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void * pDstData_p,
tEplObdSize * pSize_p)
{
tEplKernel Ret;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
Ret = EplObdReadEntryToLe(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
#else
Ret = kEplSuccessful;
#endif
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplObduCalWriteEntryFromLe()
//
// Description: Function encapsulate access of function EplObdWriteEntryFromLe
//
// Parameters: uiIndex_p = Index of the OD entry
// uiSubIndex_p = Subindex of the OD Entry
// pSrcData_p = Pointer to the data to write
// Size_p = Size of the data in Byte
//
// Return: tEplKernel = Errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalWriteEntryFromLe (unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void * pSrcData_p,
tEplObdSize Size_p)
{
tEplKernel Ret;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
Ret = EplObdWriteEntryFromLe(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
#else
Ret = kEplSuccessful;
#endif
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplObduCalSearchVarEntry()
//
// Description: gets variable from OD
//
// Parameters: uiIndex_p = index of the var entry to search
// uiSubindex_p = subindex of var entry to search
// ppVarEntry_p = pointer to the pointer to the varentry
//
// Return: tEplKernel
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObduCalSearchVarEntry (EPL_MCO_DECL_INSTANCE_PTR_
unsigned int uiIndex_p,
unsigned int uiSubindex_p,
tEplObdVarEntry MEM** ppVarEntry_p)
{
tEplKernel Ret;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
Ret = EplObdSearchVarEntry(uiIndex_p, uiSubindex_p, ppVarEntry_p);
#else
Ret = kEplSuccessful;
#endif
return Ret;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function:
//
// Description:
//
//
//
// Parameters:
//
//
// Returns:
//
//
// State:
//
//---------------------------------------------------------------------------
#endif //(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0)
// EOF

View file

@ -0,0 +1,220 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: defines objdict dictionary
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplObjDef.h,v $
$Author: D.Krueger $
$Revision: 1.4 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/06 k.t.: take ObjDef.h from CANopen and modify for EPL
****************************************************************************/
#ifndef _EPLOBJDEF_H_
#define _EPLOBJDEF_H_
//---------------------------------------------------------------------------
// security checks
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// macros to help building OD
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
#if (defined (EPL_OBD_USE_VARIABLE_SUBINDEX_TAB) && (EPL_OBD_USE_VARIABLE_SUBINDEX_TAB != FALSE))
#define CCM_SUBINDEX_RAM_ONLY(a) a;
#define CCM_SUBINDEX_RAM_ONEOF(a,b) a
#else
#define CCM_SUBINDEX_RAM_ONLY(a)
#define CCM_SUBINDEX_RAM_ONEOF(a,b) b
#endif
//---------------------------------------------------------------------------
// To prevent unused memory in subindex tables we need this macro.
// But not all compilers support to preset the last struct value followed by a comma.
// Compilers which does not support a comma after last struct value has to place in a dummy subindex.
#if ((DEV_SYSTEM & _DEV_COMMA_EXT_) != 0)
#define EPL_OBD_END_SUBINDEX()
#define EPL_OBD_MAX_ARRAY_SUBENTRIES 2
#else
#define EPL_OBD_END_SUBINDEX() {0,0,0,NULL,NULL}
#define EPL_OBD_MAX_ARRAY_SUBENTRIES 3
#endif
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// globale vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// -------------------------------------------------------------------------
// creation of data in ROM memory
// -------------------------------------------------------------------------
#define EPL_OBD_CREATE_ROM_DATA
#include "objdict.h"
#undef EPL_OBD_CREATE_ROM_DATA
// -------------------------------------------------------------------------
// creation of data in RAM memory
// -------------------------------------------------------------------------
#define EPL_OBD_CREATE_RAM_DATA
#include "objdict.h"
#undef EPL_OBD_CREATE_RAM_DATA
// -------------------------------------------------------------------------
// creation of subindex tables in ROM and RAM
// -------------------------------------------------------------------------
#define EPL_OBD_CREATE_SUBINDEX_TAB
#include "objdict.h"
#undef EPL_OBD_CREATE_SUBINDEX_TAB
// -------------------------------------------------------------------------
// creation of index tables for generic, manufacturer and device part
// -------------------------------------------------------------------------
#define EPL_OBD_CREATE_INDEX_TAB
#include "objdict.h"
#undef EPL_OBD_CREATE_INDEX_TAB
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
// ----------------------------------------------------------------------------
//
// Function: EPL_OBD_INIT_RAM_NAME()
//
// Description: function to initialize object dictionary
//
// Parameters: pInitParam_p = pointer to init param struct of Epl
//
// Returns: tEplKernel = error code
//
// State:
//
// ----------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EPL_OBD_INIT_RAM_NAME (tEplObdInitParam MEM* pInitParam_p)
{
tEplObdInitParam MEM* pInitParam = pInitParam_p;
// check if pointer to parameter structure is valid
// if not then only copy subindex tables below
if (pInitParam != NULL)
{
// at first delete all parameters (all pointers will be set zu NULL)
EPL_MEMSET (pInitParam, 0, sizeof (tEplObdInitParam));
#define EPL_OBD_CREATE_INIT_FUNCTION
{
// inserts code to init pointer to index tables
#include "objdict.h"
}
#undef EPL_OBD_CREATE_INIT_FUNCTION
#if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE))
{
// to begin no user OD is defined
pInitParam_p->m_pUserPart = NULL;
}
#endif
}
#define EPL_OBD_CREATE_INIT_SUBINDEX
{
// inserts code to copy subindex tables
#include "objdict.h"
}
#undef EPL_OBD_CREATE_INIT_SUBINDEX
return kEplSuccessful;
}
#endif // _EPLOBJDEF_H_
// 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).

View file

@ -0,0 +1,126 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for PDO module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplPdo.h,v $
$Author: D.Krueger $
$Revision: 1.5 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/05/22 d.k.: start of the implementation, version 1.00
****************************************************************************/
#ifndef _EPL_PDO_H_
#define _EPL_PDO_H_
#include "EplInc.h"
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
// invalid PDO-NodeId
#define EPL_PDO_INVALID_NODE_ID 0xFF
// NodeId for PReq RPDO
#define EPL_PDO_PREQ_NODE_ID 0x00
// NodeId for PRes TPDO
#define EPL_PDO_PRES_NODE_ID 0x00
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
typedef struct
{
void* m_pVar;
WORD m_wOffset; // in Bits
WORD m_wSize; // in Bits
BOOL m_fNumeric; // numeric value -> use AMI functions
} tEplPdoMapping;
typedef struct
{
unsigned int m_uiSizeOfStruct;
unsigned int m_uiPdoId;
unsigned int m_uiNodeId;
// 0xFF=invalid, RPDO: 0x00=PReq, localNodeId=PRes, remoteNodeId=PRes
// TPDO: 0x00=PRes, MN: CnNodeId=PReq
BOOL m_fTxRx;
BYTE m_bMappingVersion;
unsigned int m_uiMaxMappingEntries; // maximum number of mapping entries, i.e. size of m_aPdoMapping
tEplPdoMapping m_aPdoMapping[1];
} tEplPdoParam;
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#endif // #ifndef _EPL_PDO_H_

View file

@ -0,0 +1,692 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for kernel PDO module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplPdok.c,v $
$Author: D.Krueger $
$Revision: 1.8 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/05/22 d.k.: start of the implementation, version 1.00
****************************************************************************/
#include "kernel/EplPdok.h"
#include "kernel/EplPdokCal.h"
#include "kernel/EplEventk.h"
#include "kernel/EplObdk.h"
#if (DEV_SYSTEM == _DEV_GNU_CF548X_)
#include "plccore.h"
#define PDO_LED 0x08
#endif
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0)
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) == 0)
#error 'ERROR: Missing DLLk-Modul!'
#endif
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) == 0)
#error 'ERROR: Missing OBDk-Modul!'
#endif
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
#define EPL_PDOK_OBD_IDX_RX_COMM_PARAM 0x1400
#define EPL_PDOK_OBD_IDX_RX_MAPP_PARAM 0x1600
#define EPL_PDOK_OBD_IDX_TX_COMM_PARAM 0x1800
#define EPL_PDOK_OBD_IDX_TX_MAPP_PARAM 0x1A00
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
/***************************************************************************/
/* */
/* */
/* C L A S S EplPdok */
/* */
/* */
/***************************************************************************/
//
// Description:
//
//
/***************************************************************************/
//=========================================================================//
// //
// P R I V A T E D E F I N I T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplPdokAddInstance()
//
// Description: add and initialize new instance of EPL stack
//
// Parameters: none
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel EplPdokAddInstance(void)
{
return kEplSuccessful;
}
//---------------------------------------------------------------------------
//
// Function: EplPdokDelInstance()
//
// Description: deletes an instance of EPL stack
//
// Parameters: none
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel EplPdokDelInstance(void)
{
return kEplSuccessful;
}
//---------------------------------------------------------------------------
//
// Function: EplPdokCbPdoReceived
//
// Description: This function is called by DLL if PRes or PReq frame was
// received. It posts the frame to the event queue.
// It is called in states NMT_CS_READY_TO_OPERATE and NMT_CS_OPERATIONAL.
// The passed PDO needs not to be valid.
//
// Parameters: pFrameInfo_p = pointer to frame info structure
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel EplPdokCbPdoReceived(tEplFrameInfo * pFrameInfo_p)
{
tEplKernel Ret = kEplSuccessful;
tEplEvent Event;
#if (DEV_SYSTEM == _DEV_GNU_CF548X_)
// 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);
#if (DEV_SYSTEM == _DEV_GNU_CF548X_)
// set LED
// MCF_GPIO_PODR_PCIBG |= PDO_LED; // Level
#endif
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplPdokCbPdoTransmitted
//
// Description: This function is called by DLL if PRes or PReq frame was
// sent. It posts the pointer to the frame to the event queue.
// It is called in NMT_CS_PRE_OPERATIONAL_2,
// NMT_CS_READY_TO_OPERATE and NMT_CS_OPERATIONAL.
//
// Parameters: pFrameInfo_p = pointer to frame info structure
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel EplPdokCbPdoTransmitted(tEplFrameInfo * pFrameInfo_p)
{
tEplKernel Ret = kEplSuccessful;
tEplEvent Event;
#if (DEV_SYSTEM == _DEV_GNU_CF548X_)
// 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);
#if (DEV_SYSTEM == _DEV_GNU_CF548X_)
// set LED
MCF_GPIO_PODR_PCIBG |= PDO_LED; // Level
#endif
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplPdokCbSoa
//
// Description: This function is called by DLL if SoA frame was
// received resp. sent. It posts this event to the event queue.
//
// Parameters: pFrameInfo_p = pointer to frame info structure
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel EplPdokCbSoa(tEplFrameInfo * pFrameInfo_p)
{
tEplKernel Ret = kEplSuccessful;
tEplEvent Event;
Event.m_EventSink = kEplEventSinkPdok;
Event.m_EventType = kEplEventTypePdoSoa;
Event.m_uiSize = 0;
Event.m_pArg = NULL;
Ret = EplEventkPost(&Event);
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplPdokProcess
//
// Description: This function processes all received and transmitted PDOs.
// This function must not be interrupted by any other task
// except ISRs (like the ethernet driver ISR, which may call
// EplPdokCbFrameReceived() or EplPdokCbFrameTransmitted()).
//
// Parameters: pEvent_p = pointer to event structure
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
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;
// 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;
// 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);
}
// 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
// retrieve PDO size
wPdoSize = AmiGetWordFromLe(&pFrame->m_Data.m_Pres.m_le_wSize);
// 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);
// 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;
}
}
// processing finished successfully
goto Exit;
}
break;
case kEplEventTypePdoTx: // TPDO transmitted
pFrameInfo = (tEplFrameInfo *) pEvent_p->m_pArg;
pFrame = pFrameInfo->m_pFrame;
// 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));
// 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
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);
// calculate PDO size
wPdoSize = 0;
// 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);
// 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;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function:
//
// Description:
//
//
//
// Parameters:
//
//
// Returns:
//
//
// State:
//
//---------------------------------------------------------------------------
#endif // #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0)
// EOF

View file

@ -0,0 +1,274 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for kernel PDO Communication Abstraction Layer module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplPdokCal.c,v $
$Author: D.Krueger $
$Revision: 1.6 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/27 d.k.: start of the implementation, version 1.00
****************************************************************************/
#include "kernel/EplPdokCal.h"
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0)
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
/***************************************************************************/
/* */
/* */
/* C L A S S EplPdokCal */
/* */
/* */
/***************************************************************************/
//
// Description:
//
//
/***************************************************************************/
//=========================================================================//
// //
// P R I V A T E D E F I N I T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
typedef struct
{
BOOL m_fTpdosValid;
} tEplPdokCalInstance;
//---------------------------------------------------------------------------
// local vars
//---------------------------------------------------------------------------
static tEplPdokCalInstance EplPdokCalInstance_g;
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplPdokCalAddInstance()
//
// Description: add and initialize new instance of EPL stack
//
// Parameters: none
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel EplPdokCalAddInstance(void)
{
EPL_MEMSET(&EplPdokCalInstance_g, 0, sizeof(EplPdokCalInstance_g));
return kEplSuccessful;
}
//---------------------------------------------------------------------------
//
// Function: EplPdokCalDelInstance()
//
// Description: deletes an instance of EPL stack
//
// Parameters: none
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel EplPdokCalDelInstance(void)
{
return kEplSuccessful;
}
//---------------------------------------------------------------------------
//
// Function: EplPdokCalSetTpdosValid()
//
// Description: This function sets the validity flag for TPDOs to the
// specified value.
//
// Parameters: fValid_p = validity flag
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel EplPdokCalSetTpdosValid(BOOL fValid_p)
{
tEplKernel Ret = kEplSuccessful;
EplPdokCalInstance_g.m_fTpdosValid = fValid_p;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplPdokCalAreTpdosValid()
//
// Description: This function returns the validity flag for TPDOs.
//
// Parameters: pfValid_p = OUT: validity flag
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel EplPdokCalAreTpdosValid(BOOL * pfValid_p)
{
tEplKernel Ret = kEplSuccessful;
*pfValid_p = EplPdokCalInstance_g.m_fTpdosValid;
return Ret;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function:
//
// Description:
//
//
//
// Parameters:
//
//
// Returns:
//
//
// State:
//
//---------------------------------------------------------------------------
#endif
// EOF

View file

@ -0,0 +1,608 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for user PDO module
Currently, this module just implements a OD callback function
to check if the PDO configuration is valid.
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplPdou.c,v $
$Author: D.Krueger $
$Revision: 1.5 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/05/22 d.k.: start of the implementation, version 1.00
****************************************************************************/
#include "EplInc.h"
//#include "user/EplPdouCal.h"
#include "user/EplObdu.h"
#include "user/EplPdou.h"
#include "EplSdoAc.h"
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOU)) != 0)
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) == 0) && (EPL_OBD_USE_KERNEL == FALSE)
#error "EPL PDOu module needs EPL module OBDU or OBDK!"
#endif
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
#define EPL_PDOU_OBD_IDX_RX_COMM_PARAM 0x1400
#define EPL_PDOU_OBD_IDX_RX_MAPP_PARAM 0x1600
#define EPL_PDOU_OBD_IDX_TX_COMM_PARAM 0x1800
#define EPL_PDOU_OBD_IDX_TX_MAPP_PARAM 0x1A00
#define EPL_PDOU_OBD_IDX_MAPP_PARAM 0x0200
#define EPL_PDOU_OBD_IDX_MASK 0xFF00
#define EPL_PDOU_PDO_ID_MASK 0x00FF
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
/***************************************************************************/
/* */
/* */
/* C L A S S EplPdou */
/* */
/* */
/***************************************************************************/
//
// Description:
//
//
/***************************************************************************/
//=========================================================================//
// //
// P R I V A T E D E F I N I T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
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);
static tEplKernel EplPdouCheckObjectMapping(QWORD qwObjectMapping_p,
tEplObdAccess AccessType_p,
DWORD* pdwAbortCode_p,
unsigned int* puiPdoSize_p);
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplPdouAddInstance()
//
// Description: add and initialize new instance of EPL stack
//
// Parameters: none
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel EplPdouAddInstance(void)
{
return kEplSuccessful;
}
//---------------------------------------------------------------------------
//
// Function: EplPdouDelInstance()
//
// Description: deletes an instance of EPL stack
//
// Parameters: none
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel EplPdouDelInstance(void)
{
return kEplSuccessful;
}
//---------------------------------------------------------------------------
//
// Function: EplPdouCbObdAccess
//
// Description: callback function for OD accesses
//
// Parameters: pParam_p = OBD parameter
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
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;
// 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;
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;
}
goto Exit;
}
case EPL_PDOU_OBD_IDX_RX_MAPP_PARAM:
{ // RPDO mapping parameter accessed
AccessType = kEplObdAccWrite;
break;
}
case EPL_PDOU_OBD_IDX_TX_MAPP_PARAM:
{ // TPDO mapping parameter accessed
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;
}
}
// RPDO and TPDO mapping parameter accessed
if (pParam_p->m_uiSubIndex == 0)
{ // object mapping count accessed
// PDO is enabled or disabled
bObjectCount = *((BYTE*) pParam_p->m_pArg);
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;
}
if (AccessType == kEplObdAccWrite)
{
uiSubIndex = 0x04; // PReqActPayloadLimit_U16
}
else
{
uiSubIndex = 0x05; // PResActPayloadLimit_U16
}
// 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 (uiCurPdoSize > wMaxPdoSize)
{ // mapping exceeds object size
pParam_p->m_dwAbortCode = EPL_SDOAC_GENERAL_ERROR;
Ret = kEplPdoVarNotFound;
}
}
}
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;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplPdouCheckPdoValidity
//
// Description: check if PDO is valid
//
// Parameters: pParam_p = OBD parameter
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
static tEplKernel EplPdouCheckPdoValidity(tEplObdCbParam MEM* pParam_p, unsigned int uiIndex_p)
{
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;
}
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplPdouDecodeObjectMapping
//
// Description: decodes the given object mapping entry into index, subindex,
// bit offset and bit size.
//
// Parameters: qwObjectMapping_p = object mapping entry
// puiIndex_p = [OUT] pointer to object index
// puiSubIndex_p = [OUT] pointer to subindex
// puiBitOffset_p = [OUT] pointer to bit offset
// puiBitSize_p = [OUT] pointer to bit size
//
// Returns: (void)
//
// State:
//
//---------------------------------------------------------------------------
static void EplPdouDecodeObjectMapping(QWORD qwObjectMapping_p,
unsigned int* puiIndex_p,
unsigned int* puiSubIndex_p,
unsigned int* puiBitOffset_p,
unsigned int* puiBitSize_p)
{
*puiIndex_p = (unsigned int)
(qwObjectMapping_p & 0x000000000000FFFFLL);
*puiSubIndex_p = (unsigned int)
((qwObjectMapping_p & 0x0000000000FF0000LL) >> 16);
*puiBitOffset_p = (unsigned int)
((qwObjectMapping_p & 0x0000FFFF00000000LL) >> 32);
*puiBitSize_p = (unsigned int)
((qwObjectMapping_p & 0xFFFF000000000000LL) >> 48);
}
//---------------------------------------------------------------------------
//
// Function: EplPdouCheckObjectMapping
//
// Description: checks the given object mapping entry.
//
// Parameters: qwObjectMapping_p = object mapping entry
// AccessType_p = access type to mapped object:
// write = RPDO and read = TPDO
// puiPdoSize_p = [OUT] pointer to covered PDO size
// (offset + size) in byte;
// 0 if mapping failed
// pdwAbortCode_p = [OUT] pointer to SDO abort code;
// 0 if mapping is possible
//
// Returns: tEplKernel = error code
//
// State:
//
//---------------------------------------------------------------------------
static tEplKernel EplPdouCheckObjectMapping(QWORD qwObjectMapping_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;
if (qwObjectMapping_p == 0)
{ // discard zero value
*puiPdoSize_p = 0;
goto Exit;
}
// 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 ((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 ((AccessType & kEplObdAccPdo) == 0)
{ // object is not mappable
*pdwAbortCode_p = EPL_SDOAC_OBJECT_NOT_MAPPABLE;
Ret = kEplPdoVarNotFound;
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;
}
ObdSize = EplObduGetDataSize(uiIndex, uiSubIndex);
if (ObdSize < (uiBitSize >> 3))
{ // object does not exist or has smaller size
*pdwAbortCode_p = EPL_SDOAC_GENERAL_ERROR;
Ret = kEplPdoVarNotFound;
}
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;
}
#endif // #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOU)) != 0)
// EOF

View file

@ -0,0 +1,271 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for api function of the sdo module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplSdo.h,v $
$Author: D.Krueger $
$Revision: 1.6 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/26 k.t.: start of the implementation
****************************************************************************/
#include "EplInc.h"
#include "EplFrame.h"
#include "EplSdoAc.h"
#ifndef _EPLSDO_H_
#define _EPLSDO_H_
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
// global defines
#ifndef EPL_SDO_MAX_PAYLOAD
#define EPL_SDO_MAX_PAYLOAD 256
#endif
// handle between Protocol Abstraction Layer and asynchronous SDO Sequence Layer
#define EPL_SDO_UDP_HANDLE 0x8000
#define EPL_SDO_ASND_HANDLE 0x4000
#define EPL_SDO_ASY_HANDLE_MASK 0xC000
#define EPL_SDO_ASY_INVALID_HDL 0x3FFF
// handle between SDO Sequence Layer and sdo command layer
#define EPL_SDO_ASY_HANDLE 0x8000
#define EPL_SDO_PDO_HANDLE 0x4000
#define EPL_SDO_SEQ_HANDLE_MASK 0xC000
#define EPL_SDO_SEQ_INVALID_HDL 0x3FFF
#define EPL_ASND_HEADER_SIZE 4
//#define EPL_SEQ_HEADER_SIZE 4
#define EPL_ETHERNET_HEADER_SIZE 14
#define EPL_SEQ_NUM_MASK 0xFC
// size for send buffer and history
#define EPL_MAX_SDO_FRAME_SIZE EPL_C_IP_MIN_MTU
// size for receive frame
// -> needed because SND-Kit sends up to 1518 Byte
// without Sdo-Command: Maximum Segment Size
#define EPL_MAX_SDO_REC_FRAME_SIZE EPL_C_IP_MAX_MTU
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
// handle between Protocol Abstraction Layer and asynchronuus SDO Sequence Layer
typedef unsigned int tEplSdoConHdl;
// callback function pointer for Protocol Abstraction Layer to call
// asynchronuus SDO Sequence Layer
typedef tEplKernel (PUBLIC* tEplSequLayerReceiveCb ) (
tEplSdoConHdl ConHdl_p,
tEplAsySdoSeq* pSdoSeqData_p,
unsigned int uiDataSize_p);
// handle between asynchronuus SDO Sequence Layer and SDO Command layer
typedef unsigned int tEplSdoSeqConHdl;
// callback function pointer for asynchronuus SDO Sequence Layer to call
// SDO Command layer for received data
typedef tEplKernel (PUBLIC* tEplSdoComReceiveCb) (
tEplSdoSeqConHdl SdoSeqConHdl_p,
tEplAsySdoCom* pAsySdoCom_p,
unsigned int uiDataSize_p);
// status of connection
typedef enum
{
kAsySdoConStateConnected = 0x00,
kAsySdoConStateInitError = 0x01,
kAsySdoConStateConClosed = 0x02,
kAsySdoConStateAckReceived = 0x03,
kAsySdoConStateFrameSended = 0x04,
kAsySdoConStateTimeout = 0x05
}tEplAsySdoConState;
// callback function pointer for asynchronuus SDO Sequence Layer to call
// SDO Command layer for connection status
typedef tEplKernel (PUBLIC* tEplSdoComConCb) (
tEplSdoSeqConHdl SdoSeqConHdl_p,
tEplAsySdoConState AsySdoConState_p);
// handle between SDO Command layer and application
typedef unsigned int tEplSdoComConHdl;
// status of connection
typedef enum
{
kEplSdoComTransferNotActive = 0x00,
kEplSdoComTransferRunning = 0x01,
kEplSdoComTransferTxAborted = 0x02,
kEplSdoComTransferRxAborted = 0x03,
kEplSdoComTransferFinished = 0x04,
kEplSdoComTransferLowerLayerAbort = 0x05
} tEplSdoComConState;
// SDO Services and Command-Ids from DS 1.0.0 p.152
typedef enum
{
kEplSdoServiceNIL = 0x00,
kEplSdoServiceWriteByIndex = 0x01,
kEplSdoServiceReadByIndex = 0x02
//--------------------------------
// the following services are optional and
// not supported now
/*
kEplSdoServiceWriteAllByIndex = 0x03,
kEplSdoServiceReadAllByIndex = 0x04,
kEplSdoServiceWriteByName = 0x05,
kEplSdoServiceReadByName = 0x06,
kEplSdoServiceFileWrite = 0x20,
kEplSdoServiceFileRead = 0x21,
kEplSdoServiceWriteMultiByIndex = 0x31,
kEplSdoServiceReadMultiByIndex = 0x32,
kEplSdoServiceMaxSegSize = 0x70
// 0x80 - 0xFF manufacturer specific
*/
} tEplSdoServiceType;
// describes if read or write access
typedef enum
{
kEplSdoAccessTypeRead = 0x00,
kEplSdoAccessTypeWrite = 0x01
} tEplSdoAccessType;
typedef enum
{
kEplSdoTypeAuto = 0x00,
kEplSdoTypeUdp = 0x01,
kEplSdoTypeAsnd = 0x02,
kEplSdoTypePdo = 0x03
}tEplSdoType;
typedef enum
{
kEplSdoTransAuto = 0x00,
kEplSdoTransExpedited = 0x01,
kEplSdoTransSegmented = 0x02
} tEplSdoTransType;
// structure to inform application about finish of SDO transfer
typedef struct
{
tEplSdoComConHdl m_SdoComConHdl;
tEplSdoComConState m_SdoComConState;
DWORD m_dwAbortCode;
tEplSdoAccessType m_SdoAccessType;
unsigned int m_uiNodeId; // NodeId of the target
unsigned int m_uiTargetIndex; // index which was accessed
unsigned int m_uiTargetSubIndex; // subindex which was accessed
unsigned int m_uiTransferredByte; // number of bytes transferred
void* m_pUserArg; // user definable argument pointer
} tEplSdoComFinished;
// callback function pointer to inform application about connection
typedef tEplKernel (PUBLIC* tEplSdoFinishedCb) (
tEplSdoComFinished* pSdoComFinished_p);
// structure to init SDO transfer to Read or Write by Index
typedef struct
{
tEplSdoComConHdl m_SdoComConHdl;
unsigned int m_uiIndex;
unsigned int m_uiSubindex;
void* m_pData;
unsigned int m_uiDataSize;
unsigned int m_uiTimeout; // not used in this version
tEplSdoAccessType m_SdoAccessType;
tEplSdoFinishedCb m_pfnSdoFinishedCb;
void* m_pUserArg; // user definable argument pointer
} tEplSdoComTransParamByIndex;
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#endif // #ifndef _EPLSDO_H_

View file

@ -0,0 +1,113 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: definitions for SDO Abort codes
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplSdoAc.h,v $
$Author: D.Krueger $
$Revision: 1.4 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
...
-------------------------------------------------------------------------
Revision History:
2006/06/30 k.t.: first implementation
****************************************************************************/
#ifndef _EPLSDOAC_H_
#define _EPLSDOAC_H_
// =========================================================================
// SDO abort codes
// =========================================================================
#define EPL_SDOAC_TIME_OUT 0x05040000L
#define EPL_SDOAC_UNKNOWN_COMMAND_SPECIFIER 0x05040001L
#define EPL_SDOAC_INVALID_BLOCK_SIZE 0x05040002L
#define EPL_SDOAC_INVALID_SEQUENCE_NUMBER 0x05040003L
#define EPL_SDOAC_OUT_OF_MEMORY 0x05040005L
#define EPL_SDOAC_UNSUPPORTED_ACCESS 0x06010000L
#define EPL_SDOAC_READ_TO_WRITE_ONLY_OBJ 0x06010001L
#define EPL_SDOAC_WRITE_TO_READ_ONLY_OBJ 0x06010002L
#define EPL_SDOAC_OBJECT_NOT_EXIST 0x06020000L
#define EPL_SDOAC_OBJECT_NOT_MAPPABLE 0x06040041L
#define EPL_SDOAC_PDO_LENGTH_EXCEEDED 0x06040042L
#define EPL_SDOAC_GEN_PARAM_INCOMPATIBILITY 0x06040043L
#define EPL_SDOAC_INVALID_HEARTBEAT_DEC 0x06040044L
#define EPL_SDOAC_GEN_INTERNAL_INCOMPATIBILITY 0x06040047L
#define EPL_SDOAC_ACCESS_FAILED_DUE_HW_ERROR 0x06060000L
#define EPL_SDOAC_DATA_TYPE_LENGTH_NOT_MATCH 0x06070010L
#define EPL_SDOAC_DATA_TYPE_LENGTH_TOO_HIGH 0x06070012L
#define EPL_SDOAC_DATA_TYPE_LENGTH_TOO_LOW 0x06070013L
#define EPL_SDOAC_SUB_INDEX_NOT_EXIST 0x06090011L
#define EPL_SDOAC_VALUE_RANGE_EXCEEDED 0x06090030L
#define EPL_SDOAC_VALUE_RANGE_TOO_HIGH 0x06090031L
#define EPL_SDOAC_VALUE_RANGE_TOO_LOW 0x06090032L
#define EPL_SDOAC_MAX_VALUE_LESS_MIN_VALUE 0x06090036L
#define EPL_SDOAC_GENERAL_ERROR 0x08000000L
#define EPL_SDOAC_DATA_NOT_TRANSF_OR_STORED 0x08000020L
#define EPL_SDOAC_DATA_NOT_TRANSF_DUE_LOCAL_CONTROL 0x08000021L
#define EPL_SDOAC_DATA_NOT_TRANSF_DUE_DEVICE_STATE 0x08000022L
#define EPL_SDOAC_OBJECT_DICTIONARY_NOT_EXIST 0x08000023L
#define EPL_SDOAC_CONFIG_DATA_EMPTY 0x08000024L
#endif // _EPLSDOAC_H_
// 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).

View file

@ -0,0 +1,509 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for SDO/Asnd-Protocolabstractionlayer module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplSdoAsndu.c,v $
$Author: D.Krueger $
$Revision: 1.7 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/07/07 k.t.: start of the implementation
****************************************************************************/
#include "user/EplSdoAsndu.h"
#include "user/EplDlluCal.h"
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDO_ASND)) != 0)
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
#ifndef EPL_SDO_MAX_CONNECTION_ASND
#define EPL_SDO_MAX_CONNECTION_ASND 5
#endif
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
// instance table
typedef struct
{
unsigned int m_auiSdoAsndConnection[EPL_SDO_MAX_CONNECTION_ASND];
tEplSequLayerReceiveCb m_fpSdoAsySeqCb;
} tEplSdoAsndInstance;
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
static tEplSdoAsndInstance SdoAsndInstance_g;
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoAsnduCb(tEplFrameInfo * pFrameInfo_p);
/***************************************************************************/
/* */
/* */
/* C L A S S <EPL SDO-Asnd Protocolabstraction layer> */
/* */
/* */
/***************************************************************************/
//
// Description: EPL SDO-Asnd Protocolabstraction layer
//
//
/***************************************************************************/
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplSdoAsnduInit
//
// Description: init first instance of the module
//
//
//
// Parameters: pReceiveCb_p = functionpointer to Sdo-Sequence layer
// callback-function
//
//
// Returns: tEplKernel = Errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoAsnduInit(tEplSequLayerReceiveCb fpReceiveCb_p)
{
tEplKernel Ret;
Ret = EplSdoAsnduAddInstance(fpReceiveCb_p);
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplSdoAsnduAddInstance
//
// Description: init additional instance of the module
//
//
//
// Parameters: pReceiveCb_p = functionpointer to Sdo-Sequence layer
// callback-function
//
//
// Returns: tEplKernel = Errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoAsnduAddInstance(tEplSequLayerReceiveCb fpReceiveCb_p)
{
tEplKernel Ret;
Ret = kEplSuccessful;
// 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;
}
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
Ret = EplDlluCalRegAsndService(kEplDllAsndSdo,
EplSdoAsnduCb,
kEplDllAsndFilterLocal);
#endif
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplSdoAsnduDelInstance
//
// Description: del instance of the module
// del socket and del Listen-Thread
//
//
//
// Parameters:
//
//
// Returns: tEplKernel = Errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoAsnduDelInstance()
{
tEplKernel Ret;
Ret = kEplSuccessful;
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
// deregister callback function from DLL
Ret = EplDlluCalRegAsndService(kEplDllAsndSdo,
NULL,
kEplDllAsndFilterNone);
#endif
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplSdoAsnduInitCon
//
// Description: init a new connect
//
//
//
// Parameters: pSdoConHandle_p = pointer for the new connection handle
// uiTargetNodeId_p = NodeId of the target node
//
//
// Returns: tEplKernel = Errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoAsnduInitCon(tEplSdoConHdl* pSdoConHandle_p,
unsigned int uiTargetNodeId_p)
{
tEplKernel Ret;
unsigned int uiCount;
unsigned int uiFreeCon;
unsigned int* puiConnection;
Ret = kEplSuccessful;
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 );
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 );
goto Exit;
}
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplSdoAsnduSendData
//
// Description: send data using exisiting connection
//
//
//
// Parameters: SdoConHandle_p = connection handle
// pSrcData_p = pointer to data
// dwDataSize_p = number of databyte
// -> without asnd-header!!!
//
// Returns: tEplKernel = Errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoAsnduSendData(tEplSdoConHdl SdoConHandle_p,
tEplFrame * pSrcData_p,
DWORD dwDataSize_p)
{
tEplKernel Ret;
unsigned int uiArray;
tEplFrameInfo FrameInfo;
Ret = kEplSuccessful;
uiArray = (SdoConHandle_p & ~EPL_SDO_ASY_HANDLE_MASK);
if(uiArray > EPL_SDO_MAX_CONNECTION_ASND)
{
Ret = kEplSdoAsndInvalidHandle;
goto Exit;
}
// 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);
// 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));
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
Ret = EplDlluCalAsyncSend(&FrameInfo,kEplDllAsyncReqPrioGeneric);
#endif
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplSdoAsnduDelCon
//
// Description: delete connection from intern structure
//
//
//
// Parameters: SdoConHandle_p = connection handle
//
// Returns: tEplKernel = Errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoAsnduDelCon(tEplSdoConHdl SdoConHandle_p)
{
tEplKernel Ret;
unsigned int uiArray;
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;
Exit:
return Ret;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplSdoAsnduCb
//
// Description: callback function for SDO ASnd frames
//
//
//
// Parameters: pFrameInfo_p = Frame with SDO payload
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
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;
pFrame = pFrameInfo_p->m_pFrame;
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++;
}
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 );
SdoAsndInstance_g.m_fpSdoAsySeqCb(SdoConHdl, &pFrame->m_Data.m_Asnd.m_Payload.m_SdoSequenceFrame, (pFrameInfo_p->m_uiFrameSize - 18));
}
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

@ -0,0 +1,821 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for SDO/UDP-Protocolabstractionlayer module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplSdoUdpu.c,v $
$Author: D.Krueger $
$Revision: 1.8 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/26 k.t.: start of the implementation
****************************************************************************/
#include "user/EplSdoUdpu.h"
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDO_UDP)) != 0)
#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
#include "SocketLinuxKernel.h"
#include <linux/completion.h>
#include <linux/sched.h>
#endif
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
#ifndef EPL_SDO_MAX_CONNECTION_UDP
#define EPL_SDO_MAX_CONNECTION_UDP 5
#endif
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
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;
#if (TARGET_SYSTEM == _WIN32_)
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;
#endif
} tEplSdoUdpInstance;
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
static tEplSdoUdpInstance SdoUdpInstance_g;
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
#if (TARGET_SYSTEM == _WIN32_)
static DWORD PUBLIC EplSdoUdpThread(LPVOID lpParameter);
#elif (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
static int EplSdoUdpThread(void * pArg_p);
#endif
/***************************************************************************/
/* */
/* */
/* C L A S S <EPL-SDO-UDP-Layer> */
/* */
/* */
/***************************************************************************/
//
// Description: Protocolabstraction layer for UDP
//
//
/***************************************************************************/
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplSdoUdpuInit
//
// Description: init first instance of the module
//
//
//
// Parameters: pReceiveCb_p = functionpointer to Sdo-Sequence layer
// callback-function
//
//
// Returns: tEplKernel = Errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoUdpuInit(tEplSequLayerReceiveCb fpReceiveCb_p)
{
tEplKernel Ret;
Ret = EplSdoUdpuAddInstance(fpReceiveCb_p);
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplSdoUdpuAddInstance
//
// Description: init additional instance of the module
// înit socket and start Listen-Thread
//
//
//
// Parameters: pReceiveCb_p = functionpointer to Sdo-Sequence layer
// callback-function
//
//
// Returns: tEplKernel = Errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoUdpuAddInstance(tEplSequLayerReceiveCb fpReceiveCb_p)
{
tEplKernel Ret;
#if (TARGET_SYSTEM == _WIN32_)
int iError;
WSADATA Wsa;
#endif
// set instance variables to 0
EPL_MEMSET(&SdoUdpInstance_g, 0x00, sizeof(SdoUdpInstance_g));
Ret = kEplSuccessful;
// save pointer to callback-function
if (fpReceiveCb_p != NULL)
{
SdoUdpInstance_g.m_fpSdoAsySeqCb = fpReceiveCb_p;
}
else
{
Ret = kEplSdoUdpMissCb;
goto Exit;
}
#if (TARGET_SYSTEM == _WIN32_)
// start winsock2 for win32
// windows specific start of socket
iError = WSAStartup(MAKEWORD(2,0),&Wsa);
if (iError != 0)
{
Ret = kEplSdoUdpNoSocket;
goto Exit;
}
// create critical section for 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;
#endif
SdoUdpInstance_g.m_ThreadHandle = 0;
SdoUdpInstance_g.m_UdpSocket = INVALID_SOCKET;
Ret = EplSdoUdpuConfig(INADDR_ANY, 0);
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplSdoUdpuDelInstance
//
// Description: del instance of the module
// del socket and del Listen-Thread
//
//
//
// Parameters:
//
//
// Returns: tEplKernel = Errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoUdpuDelInstance()
{
tEplKernel Ret;
#if (TARGET_SYSTEM == _WIN32_)
BOOL fTermError;
#endif
Ret = kEplSuccessful;
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;
}
#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);
#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;
}
#if (TARGET_SYSTEM == _WIN32_)
// delete critical section
DeleteCriticalSection(SdoUdpInstance_g.m_pCriticalSection);
#endif
#if (TARGET_SYSTEM == _WIN32_)
// for win 32
WSACleanup();
#endif
#if (TARGET_SYSTEM == _WIN32_)
Exit:
#endif
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplSdoUdpuConfig
//
// Description: reconfigurate socket with new IP-Address
// -> needed for NMT ResetConfiguration
//
// Parameters: ulIpAddr_p = IpAddress in platform byte order
// uiPort_p = port number in platform byte order
//
//
// Returns: tEplKernel = Errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoUdpuConfig(unsigned long ulIpAddr_p, unsigned int uiPort_p)
{
tEplKernel Ret;
struct sockaddr_in Addr;
int iError;
#if (TARGET_SYSTEM == _WIN32_)
BOOL fTermError;
unsigned long ulThreadId;
#endif
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 (SdoUdpInstance_g.m_ThreadHandle != 0)
{ // listen thread was started
// close old thread
#if (TARGET_SYSTEM == _WIN32_)
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;
#endif
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 (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;
}
#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;
}
#endif
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplSdoUdpuInitCon
//
// Description: init a new connect
//
//
//
// Parameters: pSdoConHandle_p = pointer for the new connection handle
// uiTargetNodeId_p = NodeId of the target node
//
//
// Returns: tEplKernel = Errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoUdpuInitCon(tEplSdoConHdl* pSdoConHandle_p,
unsigned int uiTargetNodeId_p)
{
tEplKernel Ret;
unsigned int uiCount;
unsigned int uiFreeCon;
tEplSdoUdpCon* pSdoUdpCon;
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);
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
// set handle
*pSdoConHandle_p = (uiFreeCon | EPL_SDO_UDP_HANDLE);
}
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplSdoUdpuSendData
//
// Description: send data using exisiting connection
//
//
//
// Parameters: SdoConHandle_p = connection handle
// pSrcData_p = pointer to data
// dwDataSize_p = number of databyte
// -> without asend-header!!!
//
// Returns: tEplKernel = Errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoUdpuSendData(tEplSdoConHdl SdoConHandle_p,
tEplFrame * pSrcData_p,
DWORD dwDataSize_p)
{
tEplKernel Ret;
int iError;
unsigned int uiArray;
struct sockaddr_in Addr;
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);
// calc size
dwDataSize_p += EPL_ASND_HEADER_SIZE;
// call sendto
Addr.sin_family = AF_INET;
#if (TARGET_SYSTEM == _WIN32_)
// 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;
#if (TARGET_SYSTEM == _WIN32_)
// 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;
}
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplSdoUdpuDelCon
//
// Description: delete connection from intern structure
//
//
//
// Parameters: SdoConHandle_p = connection handle
//
// Returns: tEplKernel = Errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplSdoUdpuDelCon(tEplSdoConHdl SdoConHandle_p)
{
tEplKernel Ret;
unsigned int uiArray;
uiArray = (SdoConHandle_p & ~EPL_SDO_ASY_HANDLE_MASK);
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;
Exit:
return Ret;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplSdoUdpThread
//
// Description: thread check socket for new data
//
//
//
// Parameters: lpParameter = pointer to parameter type tEplSdoUdpThreadPara
//
//
// Returns: DWORD = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
#if (TARGET_SYSTEM == _WIN32_)
static DWORD PUBLIC EplSdoUdpThread(LPVOID lpParameter)
#elif (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
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;
#if (TARGET_SYSTEM == _WIN32_)
pInstance = (tEplSdoUdpInstance*)lpParameter;
for (;;)
#elif (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
pInstance = (tEplSdoUdpInstance*)pArg_p;
daemonize("EplSdoUdpThread");
allow_signal( SIGTERM );
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);
#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
if (iError == -ERESTARTSYS)
{
break;
}
#endif
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);
#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;
}
if((pInstance->m_aSdoAbsUdpConnection[iCount].m_ulIpAddr == 0)
&& (pInstance->m_aSdoAbsUdpConnection[iCount].m_uiPort == 0)
&& (iFreeEntry == 0xFFFF))
{
iFreeEntry = 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 (TARGET_SYSTEM == _WIN32_)
// 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");
#if (TARGET_SYSTEM == _WIN32_)
// 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;
#if (TARGET_SYSTEM == _WIN32_)
// 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(;;)
#if (TARGET_SYSTEM == _LINUX_) && defined(__KERNEL__)
complete_and_exit(&SdoUdpInstance_g.m_CompletionUdpThread, 0);
#endif
return 0;
}
#endif // end of #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDO_UDP)) != 0)
// EOF

View file

@ -0,0 +1,387 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for Statusu-Module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplStatusu.c,v $
$Author: D.Krueger $
$Revision: 1.5 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/11/15 d.k.: start of the implementation
****************************************************************************/
#include "user/EplStatusu.h"
#include "user/EplDlluCal.h"
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
/***************************************************************************/
/* */
/* */
/* C L A S S <xxxxx> */
/* */
/* */
/***************************************************************************/
//
// Description:
//
//
/***************************************************************************/
//=========================================================================//
// //
// P R I V A T E D E F I N I T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
typedef struct
{
tEplStatusuCbResponse m_apfnCbResponse[254];
} tEplStatusuInstance;
//---------------------------------------------------------------------------
// local vars
//---------------------------------------------------------------------------
static tEplStatusuInstance EplStatusuInstance_g;
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
static tEplKernel PUBLIC EplStatusuCbStatusResponse(tEplFrameInfo * pFrameInfo_p);
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplStatusuInit
//
// Description: init first instance of the module
//
//
//
// Parameters:
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplStatusuInit()
{
tEplKernel Ret;
Ret = EplStatusuAddInstance();
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplStatusuAddInstance
//
// Description: init other instances of the module
//
//
//
// Parameters:
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplStatusuAddInstance()
{
tEplKernel Ret;
Ret = kEplSuccessful;
// reset instance structure
EPL_MEMSET(&EplStatusuInstance_g, 0, sizeof (EplStatusuInstance_g));
// register StatusResponse callback function
Ret = EplDlluCalRegAsndService(kEplDllAsndStatusResponse, EplStatusuCbStatusResponse, kEplDllAsndFilterAny);
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplStatusuDelInstance
//
// Description: delete instance
//
//
//
// Parameters:
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplStatusuDelInstance()
{
tEplKernel Ret;
Ret = kEplSuccessful;
// deregister StatusResponse callback function
Ret = EplDlluCalRegAsndService(kEplDllAsndStatusResponse, NULL, kEplDllAsndFilterNone);
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplStatusuReset
//
// Description: resets this instance
//
// Parameters:
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplStatusuReset()
{
tEplKernel Ret;
Ret = kEplSuccessful;
// reset instance structure
EPL_MEMSET(&EplStatusuInstance_g, 0, sizeof (EplStatusuInstance_g));
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplStatusuRequestStatusResponse
//
// Description: returns the StatusResponse for the specified node.
//
// Parameters: uiNodeId_p = IN: node ID
// pfnCbResponse_p = IN: function pointer to callback function
// which will be called if StatusResponse is received
//
// Return: tEplKernel = error code
//
// State: not tested
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplStatusuRequestStatusResponse(
unsigned int uiNodeId_p,
tEplStatusuCbResponse pfnCbResponse_p)
{
tEplKernel Ret;
Ret = kEplSuccessful;
// 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);
}
#else
Ret = kEplInvalidOperation;
#endif
}
else
{ // invalid node ID specified
Ret = kEplInvalidNodeId;
}
return Ret;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplStatusuCbStatusResponse
//
// Description: callback funktion for StatusResponse
//
//
//
// Parameters: pFrameInfo_p = Frame with the StatusResponse
//
//
// Returns: tEplKernel = error code
//
//
// State:
//
//---------------------------------------------------------------------------
static tEplKernel PUBLIC EplStatusuCbStatusResponse(tEplFrameInfo * pFrameInfo_p)
{
tEplKernel Ret = kEplSuccessful;
unsigned int uiNodeId;
unsigned int uiIndex;
tEplStatusuCbResponse pfnCbResponse;
uiNodeId = AmiGetByteFromLe(&pFrameInfo_p->m_pFrame->m_le_bSrcNodeId);
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 (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;
}
// EOF

View file

@ -0,0 +1,240 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for target api function
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplTarget.h,v $
$Author: D.Krueger $
$Revision: 1.5 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2005/12/05 -as: start of the implementation, version 1.00
****************************************************************************/
#ifndef _EPLTARGET_H_
#define _EPLTARGET_H_
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
// =========================================================================
// macros for memory access (depends on target system)
// =========================================================================
// NOTE:
// The following macros are used to combine standard library definitions. Some
// applications needs to use one common library function (e.g. memcpy()). So
// you can set (or change) it here.
#if (TARGET_SYSTEM == _WIN32_)
#define _WIN32_WINDOWS 0x0401
#define _WIN32_WINNT 0x0400
#include <stdlib.h>
#include <stdio.h>
//29.11.2004 f.j. sonst ist memcpy und memset unbekannt
#include <string.h>
#define EPL_MEMCPY(dst,src,siz) memcpy((void*)(dst),(const void*)(src),(size_t)(siz));
#define EPL_MEMSET(dst,val,siz) memset((void*)(dst),(int)(val),(size_t)(siz));
// f.j.: die Funktionen für <MemAlloc> und <MemFree> sind in WinMem.c definiert
//definition der Prototypen
void FAR* MemAlloc (DWORD dwMemSize_p);
void MemFree (void FAR* pMem_p);
#define EPL_MALLOC(siz) malloc((size_t)(siz))
#define EPL_FREE(ptr) free((void *)ptr)
#ifndef PRINTF0
void trace (const char* fmt, ...);
#define PRINTF TRACE
#define PRINTF0(arg) TRACE0(arg)
#define PRINTF1(arg,p1) TRACE1(arg,p1)
#define PRINTF2(arg,p1,p2) TRACE2(arg,p1,p2)
#define PRINTF3(arg,p1,p2,p3) TRACE3(arg,p1,p2,p3)
#define PRINTF4(arg,p1,p2,p3,p4) TRACE4(arg,p1,p2,p3,p4)
//#define PRINTF printf
//#define PRINTF0(arg) PRINTF(arg)
//#define PRINTF1(arg,p1) PRINTF(arg,p1)
//#define PRINTF2(arg,p1,p2) PRINTF(arg,p1,p2)
//#define PRINTF3(arg,p1,p2,p3) PRINTF(arg,p1,p2,p3)
//#define PRINTF4(arg,p1,p2,p3,p4) PRINTF(arg,p1,p2,p3,p4)
#endif
#ifdef ASSERTMSG
#undef ASSERTMSG
#endif
#define ASSERTMSG(expr,string) if (!(expr)) { \
MessageBox (NULL, string, "Assertion failed", MB_OK | MB_ICONERROR); \
exit (-1);}
#elif (TARGET_SYSTEM == _NO_OS_)
#include <stdlib.h>
#include <stdio.h>
//29.11.2004 f.j. sonst ist memcpy und memset unbekannt
// #include <string.h>
#define EPL_MEMCPY(dst,src,siz) memcpy((void*)(dst),(const void*)(src),(size_t)(siz));
#define EPL_MEMSET(dst,val,siz) memset((void*)(dst),(int)(val),(size_t)(siz));
#define EPL_MALLOC(siz) malloc((size_t)(siz))
#define EPL_FREE(ptr) free((void *)ptr)
#ifndef PRINTF0
#define PRINTF TRACE
#define PRINTF0(arg) TRACE0(arg)
#define PRINTF1(arg,p1) TRACE1(arg,p1)
#define PRINTF2(arg,p1,p2) TRACE2(arg,p1,p2)
#define PRINTF3(arg,p1,p2,p3) TRACE3(arg,p1,p2,p3)
#define PRINTF4(arg,p1,p2,p3,p4) TRACE4(arg,p1,p2,p3,p4)
//#define PRINTF printf
//#define PRINTF0(arg) PRINTF(arg)
//#define PRINTF1(arg,p1) PRINTF(arg,p1)
//#define PRINTF2(arg,p1,p2) PRINTF(arg,p1,p2)
//#define PRINTF3(arg,p1,p2,p3) PRINTF(arg,p1,p2,p3)
//#define PRINTF4(arg,p1,p2,p3,p4) PRINTF(arg,p1,p2,p3,p4)
#endif
#elif (TARGET_SYSTEM == _LINUX_)
#ifndef __KERNEL__
#include <stdlib.h>
#include <stdio.h>
#else
// #include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/major.h>
#include <linux/version.h>
#endif
//29.11.2004 f.j. sonst ist memcpy und memset unbekannt
// #include <string.h>
#define EPL_MEMCPY(dst,src,siz) memcpy((void*)(dst),(const void*)(src),(size_t)(siz));
#define EPL_MEMSET(dst,val,siz) memset((void*)(dst),(int)(val),(size_t)(siz));
#ifndef __KERNEL__
#define EPL_MALLOC(siz) malloc((size_t)(siz))
#define EPL_FREE(ptr) free((void *)ptr)
#else
#define EPL_MALLOC(siz) kmalloc((size_t)(siz), GFP_KERNEL)
#define EPL_FREE(ptr) kfree((void *)ptr)
#endif
#ifndef PRINTF0
#define PRINTF TRACE
#define PRINTF0(arg) TRACE0(arg)
#define PRINTF1(arg,p1) TRACE1(arg,p1)
#define PRINTF2(arg,p1,p2) TRACE2(arg,p1,p2)
#define PRINTF3(arg,p1,p2,p3) TRACE3(arg,p1,p2,p3)
#define PRINTF4(arg,p1,p2,p3,p4) TRACE4(arg,p1,p2,p3,p4)
//#define PRINTF printf
//#define PRINTF0(arg) PRINTF(arg)
//#define PRINTF1(arg,p1) PRINTF(arg,p1)
//#define PRINTF2(arg,p1,p2) PRINTF(arg,p1,p2)
//#define PRINTF3(arg,p1,p2,p3) PRINTF(arg,p1,p2,p3)
//#define PRINTF4(arg,p1,p2,p3,p4) PRINTF(arg,p1,p2,p3,p4)
#endif
#endif
#define EPL_TGT_INTMASK_ETH 0x0001 // ethernet interrupt
#define EPL_TGT_INTMASK_DMA 0x0002 // DMA interrupt
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
// currently no Timer functions are needed by EPL stack
// so they are not implemented yet
//void PUBLIC TgtTimerInit(void);
//DWORD PUBLIC TgtGetTickCount(void);
//void PUBLIC TgtGetNetTime(tEplNetTime * pNetTime_p);
// functions for ethernet driver
tEplKernel PUBLIC TgtInitEthIsr(void);
void PUBLIC TgtFreeEthIsr(void);
void PUBLIC TgtEnableGlobalInterrupt(BYTE fEnable_p);
void PUBLIC TgtEnableEthInterrupt0(BYTE fEnable_p, unsigned int uiInterruptMask_p);
void PUBLIC TgtEnableEthInterrupt1(BYTE fEnable_p, unsigned int uiInterruptMask_p);
#endif // #ifndef _EPLTARGET_H_

View file

@ -0,0 +1,125 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for Epl Timer-Module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplTimer.h,v $
$Author: D.Krueger $
$Revision: 1.4 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/07/06 k.t.: start of the implementation
****************************************************************************/
#include "EplInc.h"
#include "EplEvent.h"
#ifndef _EPLTIMER_H_
#define _EPLTIMER_H_
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
// type for timer handle
typedef unsigned long tEplTimerHdl;
typedef struct
{
tEplEventSink m_EventSink;
unsigned long m_ulArg; // d.k.: converted to unsigned long because
// it is never accessed as a pointer by the
// timer module and the data the
// pointer points to is not saved in any way.
// It is just a value. The user is responsible
// to store the data statically and convert
// the pointer between address spaces.
} tEplTimerArg;
typedef struct
{
tEplTimerHdl m_TimerHdl;
unsigned long m_ulArg; // d.k.: converted to unsigned long because
// it is never accessed as a pointer by the
// timer module and the data the
// pointer points to is not saved in any way.
// It is just a value.
} tEplTimerEventArg;
typedef tEplKernel (PUBLIC * tEplTimerkCallback) (
tEplTimerEventArg* pEventArg_p);
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#endif // #ifndef _EPLTIMER_H_

View file

@ -0,0 +1,472 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for EPL User Timermodule for Linux kernel module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplTimeruLinuxKernel.c,v $
$Author: D.Krueger $
$Revision: 1.6 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
KEIL uVision 2
-------------------------------------------------------------------------
Revision History:
2006/09/12 d.k.: start of the implementation
****************************************************************************/
#include "user/EplTimeru.h"
#include <linux/timer.h>
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
typedef struct
{
struct timer_list m_Timer;
tEplTimerArg TimerArgument;
} tEplTimeruData;
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
static void PUBLIC EplTimeruCbMs(unsigned long ulParameter_p);
/***************************************************************************/
/* */
/* */
/* C L A S S <Epl Userspace-Timermodule for Linux Kernel> */
/* */
/* */
/***************************************************************************/
//
// Description: Epl Userspace-Timermodule for Linux Kernel
//
//
/***************************************************************************/
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplTimeruInit
//
// Description: function inits first instance
//
// Parameters: void
//
// Returns: tEplKernel = errorcode
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruInit()
{
tEplKernel Ret;
Ret = EplTimeruAddInstance();
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruAddInstance
//
// Description: function inits additional instance
//
// Parameters: void
//
// Returns: tEplKernel = errorcode
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruAddInstance()
{
tEplKernel Ret;
Ret = kEplSuccessful;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruDelInstance
//
// Description: function deletes instance
// -> under Linux nothing to do
// -> no instance table needed
//
// Parameters: void
//
// Returns: tEplKernel = errorcode
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruDelInstance()
{
tEplKernel Ret;
Ret = kEplSuccessful;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruSetTimerMs
//
// Description: function creates a timer and returns the corresponding handle
//
// Parameters: pTimerHdl_p = pointer to a buffer to fill in the handle
// ulTime_p = time for timer in ms
// Argument_p = argument for timer
//
// Returns: tEplKernel = errorcode
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruSetTimerMs(tEplTimerHdl* pTimerHdl_p,
unsigned long ulTime_p,
tEplTimerArg Argument_p)
{
tEplKernel Ret = kEplSuccessful;
tEplTimeruData* pData;
// 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;
}
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));
add_timer(&pData->m_Timer);
*pTimerHdl_p = (tEplTimerHdl) pData;
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruModifyTimerMs
//
// Description: function changes a timer and returns the corresponding handle
//
// Parameters: pTimerHdl_p = pointer to a buffer to fill in the handle
// ulTime_p = time for timer in ms
// Argument_p = argument for timer
//
// Returns: tEplKernel = errorcode
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruModifyTimerMs(tEplTimerHdl* pTimerHdl_p,
unsigned long ulTime_p,
tEplTimerArg Argument_p)
{
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 = 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));
// 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
// *pTimerHdl_p = (tEplTimerHdl) pData;
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruDeleteTimer
//
// Description: function deletes a timer
//
// Parameters: pTimerHdl_p = pointer to a buffer to fill in the handle
//
// Returns: tEplKernel = errorcode
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruDeleteTimer(tEplTimerHdl* pTimerHdl_p)
{
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;
}
/* 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);
// uninitialize handle
*pTimerHdl_p = 0;
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruIsTimerActive
//
// Description: checks if the timer referenced by the handle is currently
// active.
//
// Parameters: TimerHdl_p = handle of the timer to check
//
// Returns: BOOL = TRUE, if active;
// FALSE, otherwise
//
// State:
//
//---------------------------------------------------------------------------
BOOL PUBLIC EplTimeruIsTimerActive(tEplTimerHdl TimerHdl_p)
{
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 if timer is running
if (timer_pending(&pData->m_Timer) == 0)
{ // timer is not running
goto Exit;
}
fActive = TRUE;
Exit:
return fActive;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplTimeruCbMs
//
// Description: function to process timer
//
//
//
// Parameters: lpParameter = pointer to structur of type tEplTimeruData
//
//
// Returns: (none)
//
//
// State:
//
//---------------------------------------------------------------------------
static void PUBLIC EplTimeruCbMs(unsigned long ulParameter_p)
{
tEplKernel Ret = kEplSuccessful;
tEplTimeruData* pData;
tEplEvent EplEvent;
tEplTimerEventArg TimerEventArg;
pData = (tEplTimeruData*) ulParameter_p;
// 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);
Ret = EplEventuPost(&EplEvent);
// d.k. do not free memory, user has to call EplTimeruDeleteTimer()
//kfree(pData);
}
// EOF

View file

@ -0,0 +1,323 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for Epl Userspace-Timermodule NULL-Implementation
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplTimeruNull.c,v $
$Author: D.Krueger $
$Revision: 1.3 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
KEIL uVision 2
-------------------------------------------------------------------------
Revision History:
2006/07/06 k.t.: start of the implementation
****************************************************************************/
#include "user/EplTimeru.h"
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
/***************************************************************************/
/* */
/* */
/* C L A S S <Epl Userspace-Timermodule NULL-Implementation> */
/* */
/* */
/***************************************************************************/
//
// Description: Epl Userspace-Timermodule NULL-Implementation
//
//
/***************************************************************************/
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplTimeruInit
//
// Description: function init first instance
//
//
//
// Parameters:
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruInit()
{
tEplKernel Ret;
Ret = EplTimeruAddInstance();
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruAddInstance
//
// Description: function init additional instance
//
//
//
// Parameters:
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruAddInstance()
{
tEplKernel Ret;
Ret = kEplSuccessful;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruDelInstance
//
// Description: function delte instance
// -> under Win32 nothing to do
// -> no instnace table needed
//
//
//
// Parameters:
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruDelInstance()
{
tEplKernel Ret;
Ret = kEplSuccessful;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruSetTimerMs
//
// Description: function create a timer and return a handle to the pointer
//
//
//
// Parameters: pTimerHdl_p = pointer to a buffer to fill in the handle
// ulTime_p = time for timer in ms
// Argument_p = argument for timer
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruSetTimerMs(tEplTimerHdl* pTimerHdl_p,
unsigned long ulTime_p,
tEplTimerArg Argument_p)
{
tEplKernel Ret;
Ret = kEplSuccessful;
// check handle
if(pTimerHdl_p == NULL)
{
Ret = kEplTimerInvalidHandle;
goto Exit;
}
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruModifyTimerMs
//
// Description: function change a timer and return a handle to the pointer
//
//
//
// Parameters: pTimerHdl_p = pointer to a buffer to fill in the handle
// ulTime_p = time for timer in ms
// Argument_p = argument for timer
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruModifyTimerMs(tEplTimerHdl* pTimerHdl_p,
unsigned long ulTime_p,
tEplTimerArg Argument_p)
{
tEplKernel Ret;
Ret = kEplSuccessful;
// check parameter
if(pTimerHdl_p == NULL)
{
Ret = kEplTimerInvalidHandle;
goto Exit;
}
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruDeleteTimer
//
// Description: function delte a timer
//
//
//
// Parameters: pTimerHdl_p = pointer to a buffer to fill in the handle
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruDeleteTimer(tEplTimerHdl* pTimerHdl_p)
{
tEplKernel Ret;
Ret = kEplSuccessful;
// check parameter
if(pTimerHdl_p == NULL)
{
Ret = kEplTimerInvalidHandle;
goto Exit;
}
// set handle invalide
*pTimerHdl_p = 0;
Exit:
return Ret;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
// EOF

View file

@ -0,0 +1,551 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: source file for Epl Userspace-Timermodule for Win32
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplTimeruWin32.c,v $
$Author: D.Krueger $
$Revision: 1.4 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/07/06 k.t.: start of the implementation
****************************************************************************/
#include "user/EplTimeru.h"
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
typedef struct
{
tEplTimerArg TimerArgument;
HANDLE DelteHandle;
unsigned long ulTimeout;
}tEplTimeruThread;
typedef struct
{
LPCRITICAL_SECTION m_pCriticalSection;
CRITICAL_SECTION m_CriticalSection;
}tEplTimeruInstance;
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
static tEplTimeruInstance EplTimeruInstance_g;
static tEplTimeruThread ThreadData_l;
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
DWORD PUBLIC EplSdoTimeruThreadms(LPVOID lpParameter);
/***************************************************************************/
/* */
/* */
/* C L A S S <Epl Userspace-Timermodule for Win32> */
/* */
/* */
/***************************************************************************/
//
// Description: Epl Userspace-Timermodule for Win32
//
//
/***************************************************************************/
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplTimeruInit
//
// Description: function init first instance
//
//
//
// Parameters:
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruInit()
{
tEplKernel Ret;
Ret = EplTimeruAddInstance();
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruAddInstance
//
// Description: function init additional instance
//
//
//
// Parameters:
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruAddInstance()
{
tEplKernel Ret;
Ret = kEplSuccessful;
// create critical section
EplTimeruInstance_g.m_pCriticalSection = &EplTimeruInstance_g.m_CriticalSection;
InitializeCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruDelInstance
//
// Description: function delte instance
// -> under Win32 nothing to do
// -> no instnace table needed
//
//
//
// Parameters:
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruDelInstance()
{
tEplKernel Ret;
Ret = kEplSuccessful;
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruSetTimerMs
//
// Description: function create a timer and return a handle to the pointer
//
//
//
// Parameters: pTimerHdl_p = pointer to a buffer to fill in the handle
// ulTime_p = time for timer in ms
// Argument_p = argument for timer
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruSetTimerMs(tEplTimerHdl* pTimerHdl_p,
unsigned long ulTime_p,
tEplTimerArg Argument_p)
{
tEplKernel Ret;
HANDLE DeleteHandle;
HANDLE ThreadHandle;
DWORD ThreadId;
Ret = kEplSuccessful;
// check handle
if(pTimerHdl_p == NULL)
{
Ret = kEplTimerInvalidHandle;
goto Exit;
}
// enter critical section
EnterCriticalSection(EplTimeruInstance_g.m_pCriticalSection);
// 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;
// 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;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruModifyTimerMs
//
// Description: function change a timer and return a handle to the pointer
//
//
//
// Parameters: pTimerHdl_p = pointer to a buffer to fill in the handle
// ulTime_p = time for timer in ms
// Argument_p = argument for timer
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruModifyTimerMs(tEplTimerHdl* pTimerHdl_p,
unsigned long ulTime_p,
tEplTimerArg Argument_p)
{
tEplKernel Ret;
HANDLE DeleteHandle;
HANDLE ThreadHandle;
DWORD ThreadId;
Ret = kEplSuccessful;
// check parameter
if(pTimerHdl_p == NULL)
{
Ret = kEplTimerInvalidHandle;
goto Exit;
}
DeleteHandle = (HANDLE)(*pTimerHdl_p);
// 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;
}
// 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;
// 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
Ret = kEplTimerNoTimerCreated;
goto Exit;
}
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimeruDeleteTimer
//
// Description: function delte a timer
//
//
//
// Parameters: pTimerHdl_p = pointer to a buffer to fill in the handle
//
//
// Returns: tEplKernel = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimeruDeleteTimer(tEplTimerHdl* pTimerHdl_p)
{
tEplKernel Ret;
HANDLE DeleteHandle;
Ret = kEplSuccessful;
// check parameter
if(pTimerHdl_p == NULL)
{
Ret = kEplTimerInvalidHandle;
goto Exit;
}
DeleteHandle = (HANDLE)(*pTimerHdl_p);
// set event to end timer task for this timer
SetEvent(DeleteHandle);
// set handle invalide
*pTimerHdl_p = 0;
Exit:
return Ret;
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplSdoTimeruThreadms
//
// Description: function to process timer as thread
//
//
//
// Parameters: lpParameter = pointer to structur of type tEplTimeruThread
//
//
// Returns: DWORD = Errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
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;
Ret = kEplSuccessful;
// 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);
// 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;
// wait for one of the events
ulEvent = WaitForMultipleObjects( 2,
&aHandles[0],
FALSE,
INFINITE);
if(ulEvent == WAIT_OBJECT_0)
{ // delte event
// 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;
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);
Ret = EplEventuPost(&EplEvent);
// 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;
}
// EOF

View file

@ -0,0 +1,100 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: This file defines the EPL version for the stack, as string
and for object 0x1018 within object dictionary.
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplVersion.h,v $
$Author: D.Krueger $
$Revision: 1.6 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
all
-------------------------------------------------------------------------
Revision History:
****************************************************************************/
#ifndef _EPL_VERSION_H_
#define _EPL_VERSION_H_
// NOTE:
// All version macros should contain the same version number. But do not use
// defines instead of the numbers. Because the macro EPL_STRING_VERSION() can not
// convert a define to a string.
//
// Format: maj.min.build
// maj = major version
// min = minor version (will be set to 0 if major version will be incremented)
// build = current build (will be set to 0 if minor version will be incremented)
//
#define DEFINED_STACK_VERSION EPL_STACK_VERSION (1, 3, 0)
#define DEFINED_OBJ1018_VERSION EPL_OBJ1018_VERSION (1, 3, 0)
#define DEFINED_STRING_VERSION EPL_STRING_VERSION (1, 3, 0)
// -----------------------------------------------------------------------------
#define EPL_PRODUCT_NAME "EPL V2"
#define EPL_PRODUCT_VERSION DEFINED_STRING_VERSION
#define EPL_PRODUCT_MANUFACTURER "SYS TEC electronic GmbH"
#define EPL_PRODUCT_KEY "SO-1083"
#define EPL_PRODUCT_DESCRIPTION "openPOWERLINK Protocol Stack Source"
#endif // _EPL_VERSION_H_
// 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).

View file

@ -0,0 +1,6 @@
config EPL
tristate "openPOWERLINK protocol stack"
depends on NET && HIGH_RES_TIMERS && X86
default N
---help---
Enable support for the openPOWERLINK network protocol stack.

View file

@ -0,0 +1,41 @@
obj-$(CONFIG_EPL) += epl.o
epl-objs := \
EplApiGeneric.o \
EplApiLinuxKernel.o \
EplApiProcessImage.o \
EplDllk.o \
EplDllkCal.o \
EplDlluCal.o \
EplErrorHandlerk.o \
EplEventk.o \
EplEventu.o \
EplIdentu.o \
EplNmtCnu.o \
EplNmtk.o \
EplNmtkCal.o \
EplNmtMnu.o \
EplNmtu.o \
EplNmtuCal.o \
EplObd.o \
EplObdkCal.o \
EplObdu.o \
EplObduCal.o \
EplPdok.o \
EplPdokCal.o \
EplPdou.o \
EplSdoAsndu.o \
EplSdoAsySequ.o \
EplSdoComu.o \
EplSdoUdpu.o \
EplStatusu.o \
EplTimeruLinuxKernel.o \
amix86.o \
SharedBuff.o \
ShbIpc-LinuxKernel.o \
TimerHighReskX86.o \
VirtualEthernetLinux.o \
SocketLinuxKernel.o \
proc_fs.o \
demo_main.o \
Edrv8139.o \

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,183 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: Project independend shared buffer (linear + circular)
Description: Declaration of platform independend part for the
shared buffer
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
2006/06/27 -rs: V 1.00 (initial version)
****************************************************************************/
#ifndef _SHAREDBUFF_H_
#define _SHAREDBUFF_H_
//---------------------------------------------------------------------------
// Type definitions
//---------------------------------------------------------------------------
typedef enum
{
kShbOk = 0,
kShbNoReadableData = 1,
kShbDataTruncated = 2,
kShbBufferFull = 3,
kShbDataOutsideBufferArea = 4,
kShbBufferAlreadyCompleted = 5,
kShbMemUsedByOtherProcs = 6,
kShbOpenMismatch = 7,
kShbInvalidBufferType = 8,
kShbInvalidArg = 9,
kShbBufferInvalid = 10,
kShbOutOfMem = 11,
kShbAlreadyReseting = 12,
kShbAlreadySignaling = 13,
kShbExceedDataSizeLimit = 14,
} tShbError;
// 2006/08/24 d.k.: Priority for threads (new data, job signaling)
typedef enum
{
kShbPriorityLow = 0,
kShbPriorityNormal = 1,
kshbPriorityHigh = 2
} tShbPriority;
typedef struct
{
unsigned int m_uiFullBlockSize; // real size of allocated block (incl. alignment fill bytes)
unsigned long m_ulAvailableSize; // still available size for data
unsigned long m_ulWrIndex; // current write index
unsigned int m_fBufferCompleted; // TRUE if allocated block is complete filled with data
} tShbCirChunk;
typedef void* tShbInstance;
typedef void (*tShbCirSigHndlrNewData) (tShbInstance pShbInstance_p, unsigned long ulDataBlockSize_p);
typedef void (*tShbCirSigHndlrReset) (tShbInstance pShbInstance_p, unsigned int fTimeOut_p);
//---------------------------------------------------------------------------
// Prototypes
//---------------------------------------------------------------------------
#ifdef __cplusplus
extern "C" {
#endif
/*#if defined(INLINE_FUNCTION_DEF)
#undef INLINE_FUNCTION
#define INLINE_FUNCTION INLINE_FUNCTION_DEF
#define INLINE_ENABLED TRUE
#define SHAREDBUFF_INLINED
#include "SharedBuff.c"
#endif
*/
tShbError ShbInit (void);
tShbError ShbExit (void);
// Circular Shared Buffer
tShbError ShbCirAllocBuffer (unsigned long ulBufferSize_p, const char* pszBufferID_p, tShbInstance* ppShbInstance_p, unsigned int* pfShbNewCreated_p);
tShbError ShbCirReleaseBuffer (tShbInstance pShbInstance_p);
#if !defined(INLINE_ENABLED)
tShbError ShbCirResetBuffer (tShbInstance pShbInstance_p, unsigned long ulTimeOut_p, tShbCirSigHndlrReset pfnSignalHandlerReset_p);
tShbError ShbCirWriteDataBlock (tShbInstance pShbInstance_p, const void* pSrcDataBlock_p, unsigned long ulDataBlockSize_p);
tShbError ShbCirAllocDataBlock (tShbInstance pShbInstance_p, tShbCirChunk* pShbCirChunk_p, unsigned long ulDataBufferSize_p);
tShbError ShbCirWriteDataChunk (tShbInstance pShbInstance_p, tShbCirChunk* pShbCirChunk_p, const void* pSrcDataChunk_p, unsigned long ulDataChunkSize_p, unsigned int* pfBufferCompleted_p);
tShbError ShbCirReadDataBlock (tShbInstance pShbInstance_p, void* pDstDataBlock_p, unsigned long ulRdBuffSize_p, unsigned long* pulDataBlockSize_p);
tShbError ShbCirGetReadDataSize (tShbInstance pShbInstance_p, unsigned long* pulDataBlockSize_p);
tShbError ShbCirGetReadBlockCount (tShbInstance pShbInstance_p, unsigned long* pulDataBlockCount_p);
tShbError ShbCirSetSignalHandlerNewData (tShbInstance pShbInstance_p, tShbCirSigHndlrNewData pfnShbSignalHandlerNewData_p, tShbPriority ShbPriority_p);
#endif
// Linear Shared Buffer
tShbError ShbLinAllocBuffer (unsigned long ulBufferSize_p, const char* pszBufferID_p, tShbInstance* ppShbInstance_p, unsigned int* pfShbNewCreated_p);
tShbError ShbLinReleaseBuffer (tShbInstance pShbInstance_p);
#if !defined(INLINE_ENABLED)
tShbError ShbLinWriteDataBlock (tShbInstance pShbInstance_p, unsigned long ulDstBufferOffs_p, const void* pSrcDataBlock_p, unsigned long ulDataBlockSize_p);
tShbError ShbLinReadDataBlock (tShbInstance pShbInstance_p, void* pDstDataBlock_p, unsigned long ulSrcBufferOffs_p, unsigned long ulDataBlockSize_p);
#endif
#ifndef NDEBUG
tShbError ShbCirTraceBuffer (tShbInstance pShbInstance_p);
tShbError ShbLinTraceBuffer (tShbInstance pShbInstance_p);
tShbError ShbTraceDump (const unsigned char* pabStartAddr_p, unsigned long ulDataSize_p, unsigned long ulAddrOffset_p, const char* pszInfoText_p);
#else
#define ShbCirTraceBuffer(p0)
#define ShbLinTraceBuffer(p0)
#define ShbTraceDump(p0, p1, p2, p3)
#endif
#undef INLINE_ENABLED // disable actual inlining of functions
#undef INLINE_FUNCTION
#define INLINE_FUNCTION // define INLINE_FUNCTION to nothing
#ifdef __cplusplus
}
#endif
#endif // #ifndef _SHAREDBUFF_H_

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,120 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: Project independend shared buffer (linear + circular)
Description: Declaration of platform specific part for the
shared buffer
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
2006/06/27 -rs: V 1.00 (initial version)
****************************************************************************/
#ifndef _SHBIPC_H_
#define _SHBIPC_H_
//---------------------------------------------------------------------------
// Type definitions
//---------------------------------------------------------------------------
typedef int (*tSigHndlrNewData) (tShbInstance pShbInstance_p);
typedef void (*tSigHndlrJobReady) (tShbInstance pShbInstance_p, unsigned int fTimeOut_p);
#if (TARGET_SYSTEM == _WIN32_)
#if defined(INLINE_FUNCTION_DEF)
#undef INLINE_FUNCTION
#define INLINE_FUNCTION INLINE_FUNCTION_DEF
#define SHBIPC_INLINE_ENABLED TRUE
#define SHBIPC_INLINED
#include "ShbIpc-Win32.c"
#endif
#elif (TARGET_SYSTEM == _LINUX_)
#if defined(INLINE_FUNCTION_DEF)
#undef INLINE_FUNCTION
#define INLINE_FUNCTION INLINE_FUNCTION_DEF
#define SHBIPC_INLINE_ENABLED TRUE
#define SHBIPC_INLINED
#include "ShbIpc-LinuxKernel.c"
#endif
#endif
//---------------------------------------------------------------------------
// Prototypes
//---------------------------------------------------------------------------
tShbError ShbIpcInit (void);
tShbError ShbIpcExit (void);
tShbError ShbIpcAllocBuffer (unsigned long ulBufferSize_p, const char* pszBufferID_p, tShbInstance* ppShbInstance_p, unsigned int* pfShbNewCreated_p);
tShbError ShbIpcReleaseBuffer (tShbInstance pShbInstance_p);
#if !defined(SHBIPC_INLINE_ENABLED)
tShbError ShbIpcEnterAtomicSection (tShbInstance pShbInstance_p);
tShbError ShbIpcLeaveAtomicSection (tShbInstance pShbInstance_p);
tShbError ShbIpcStartSignalingNewData (tShbInstance pShbInstance_p, tSigHndlrNewData pfnSignalHandlerNewData_p, tShbPriority ShbPriority_p);
tShbError ShbIpcStopSignalingNewData (tShbInstance pShbInstance_p);
tShbError ShbIpcSignalNewData (tShbInstance pShbInstance_p);
tShbError ShbIpcStartSignalingJobReady (tShbInstance pShbInstance_p, unsigned long ulTimeOut_p, tSigHndlrJobReady pfnSignalHandlerJobReady_p);
tShbError ShbIpcSignalJobReady (tShbInstance pShbInstance_p);
void* ShbIpcGetShMemPtr (tShbInstance pShbInstance_p);
#endif
#undef SHBIPC_INLINE_ENABLED // disable actual inlining of functions
#undef INLINE_FUNCTION
#define INLINE_FUNCTION // define INLINE_FUNCTION to nothing
#endif // #ifndef _SHBIPC_H_

View file

@ -0,0 +1,68 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: Project independend shared buffer (linear + circular)
Description: Declaration of platform specific part for the
shared buffer
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
2006/07/20 -rs: V 1.00 (initial version)
****************************************************************************/
#ifndef _SHBLINUXKERNEL_H_
#define _SHBLINUXKERNEL_H_
struct sShbMemTable{
int m_iBufferId;
void* m_pBuffer;
struct sShbMemTable *m_psNextMemTableElement;
};
extern struct sShbMemTable *psMemTableElementFirst_g;
#endif // _SHBLINUXKERNEL_H_

View file

@ -0,0 +1,210 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: Wrapper for BSD socket API for Linux kernel
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: SocketLinuxKernel.c,v $
$Author: D.Krueger $
$Revision: 1.3 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
Dev C++ and GNU-Compiler for m68k
-------------------------------------------------------------------------
Revision History:
2006/08/25 d.k.: start of implementation
****************************************************************************/
#include <linux/net.h>
#include <linux/in.h>
#include "SocketLinuxKernel.h"
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// 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 //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function:
//
// Description:
//
//
//
// Parameters:
//
//
// Returns:
//
//
// State:
//
//---------------------------------------------------------------------------
SOCKET socket(int af, int type, int protocol)
{
int rc;
SOCKET socket;
rc = sock_create_kern(af, type, protocol, &socket);
if (rc < 0)
{
socket = NULL;
goto Exit;
}
Exit:
return socket;
}
int bind(SOCKET socket_p, const struct sockaddr *addr, int addrlen)
{
int rc;
rc = socket_p->ops->bind(socket_p,
(struct sockaddr *)addr,
addrlen);
return rc;
}
int closesocket(SOCKET socket_p)
{
sock_release(socket_p);
return 0;
}
int recvfrom(SOCKET socket_p, char* buf, int len, int flags, struct sockaddr *from, int * fromlen)
{
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;
rc = kernel_recvmsg(socket_p, &msg, &iov, 1, iov.iov_len, 0);
return rc;
}
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;
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);
return rc;
}
// EOF

View file

@ -0,0 +1,108 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for BSD socket API for Linux kernel
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: SocketLinuxKernel.h,v $
$Author: D.Krueger $
$Revision: 1.3 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
KEIL uVision 2
-------------------------------------------------------------------------
Revision History:
2006/08/25 d.k.: start of the implementation
****************************************************************************/
#ifndef _SOCKETLINUXKERNEL_H_
#define _SOCKETLINUXKERNEL_H_
#include <linux/net.h>
#include <linux/in.h>
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
#define INVALID_SOCKET 0
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
typedef struct socket* SOCKET;
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
int bind(SOCKET s, const struct sockaddr *addr, int addrlen);
int closesocket(SOCKET s);
int recvfrom(SOCKET s, char* buf, int len, int flags, struct sockaddr *from, int * fromlen);
int sendto(SOCKET s, const char* buf, int len, int flags, const struct sockaddr *to, int tolen);
SOCKET socket(int af, int type, int protocol);
#endif // #ifndef _SOCKETLINUXKERNEL_H_

View file

@ -0,0 +1,555 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: target specific implementation of
high resolution timer module for X86 under Linux
The Linux kernel has to be compiled with high resolution
timers enabled. This is done by configuring the kernel
with CONFIG_HIGH_RES_TIMERS enabled.
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: TimerHighReskX86.c,v $
$Author: D.Krueger $
$Revision: 1.4 $ $Date: 2008/04/17 21:38:01 $
$State: Exp $
Build Environment:
GNU
-------------------------------------------------------------------------
Revision History:
****************************************************************************/
#include "EplInc.h"
#include "kernel/EplTimerHighResk.h"
#include "Benchmark.h"
//#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/hrtimer.h>
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// 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 PROVE_OVERRUN
#ifndef CONFIG_HIGH_RES_TIMERS
#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)
#else
#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) \
| (uiNodeId_p << 16) | wErrorCode_p)
#define TIMERHDL_MASK 0x0FFFFFFF
#define TIMERHDL_SHIFT 28
#define HDL_TO_IDX(Hdl) ((Hdl >> TIMERHDL_SHIFT) - 1)
#define HDL_INIT(Idx) ((Idx + 1) << TIMERHDL_SHIFT)
#define HDL_INC(Hdl) (((Hdl + 1) & TIMERHDL_MASK) \
| (Hdl & ~TIMERHDL_MASK))
//---------------------------------------------------------------------------
// modul global types
//---------------------------------------------------------------------------
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];
} tEplTimerHighReskInstance;
//---------------------------------------------------------------------------
// local vars
//---------------------------------------------------------------------------
static tEplTimerHighReskInstance EplTimerHighReskInstance_l;
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
enum hrtimer_restart EplTimerHighReskCallback (struct hrtimer* pTimer_p);
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: EplTimerHighReskInit()
//
// Description: initializes the high resolution timer module.
//
// Parameters: void
//
// Return: tEplKernel = error code
//
// State: not tested
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimerHighReskInit(void)
{
tEplKernel Ret;
Ret = EplTimerHighReskAddInstance();
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimerHighReskAddInstance()
//
// Description: initializes the high resolution timer module.
//
// Parameters: void
//
// Return: tEplKernel = error code
//
// State: not tested
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimerHighReskAddInstance(void)
{
tEplKernel Ret;
unsigned int uiIndex;
Ret = kEplSuccessful;
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;
#endif
/*
* 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);
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;
}
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimerHighReskDelInstance()
//
// Description: shuts down the high resolution timer module.
//
// Parameters: void
//
// Return: tEplKernel = error code
//
// State: not tested
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimerHighReskDelInstance(void)
{
tEplTimerHighReskTimerInfo* pTimerInfo;
tEplKernel Ret;
unsigned int uiIndex;
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);
}
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimerHighReskModifyTimerNs()
//
// Description: modifies the timeout of the timer with the specified handle.
// If the handle the pointer points to is zero, the timer must
// be created first.
// If it is not possible to stop the old timer,
// this function always assures that the old timer does not
// trigger the callback function with the same handle as the new
// timer. That means the callback function must check the passed
// handle with the one returned by this function. If these are
// unequal, the call can be discarded.
//
// Parameters: pTimerHdl_p = pointer to timer handle
// ullTimeNs_p = relative timeout in [ns]
// pfnCallback_p = callback function, which is called mutual
// exclusive with the Edrv callback functions
// (Rx and Tx).
// ulArgument_p = user-specific argument
// fContinuously_p = if TRUE, callback function will be called
// continuously;
// otherwise, it is a oneshot timer.
//
// Return: tEplKernel = error code
//
// State: not tested
//
//---------------------------------------------------------------------------
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;
Ret = kEplSuccessful;
// check pointer to handle
if(pTimerHdl_p == NULL)
{
Ret = kEplTimerInvalidHandle;
goto Exit;
}
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;
}
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];
}
/*
* 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;
}
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);
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimerHighReskDeleteTimer()
//
// Description: deletes the timer with the specified handle. Afterward the
// handle is set to zero.
//
// Parameters: pTimerHdl_p = pointer to timer handle
//
// Return: tEplKernel = error code
//
// State: not tested
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimerHighReskDeleteTimer(tEplTimerHdl* pTimerHdl_p)
{
tEplKernel Ret = kEplSuccessful;
unsigned int uiIndex;
tEplTimerHighReskTimerInfo* pTimerInfo;
// 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;
}
}
*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);
Exit:
return Ret;
}
//---------------------------------------------------------------------------
//
// Function: EplTimerHighReskCallback()
//
// Description: Callback function commonly used for all timers.
//
// Parameters: pTimer_p = pointer to hrtimer
//
// Return:
//
// State: not tested
//
//---------------------------------------------------------------------------
enum hrtimer_restart EplTimerHighReskCallback (struct hrtimer* pTimer_p)
{
unsigned int uiIndex;
tEplTimerHighReskTimerInfo* pTimerInfo;
tEplTimerHdl OrgTimerHdl;
enum hrtimer_restart Ret;
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;
}
/*
* 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_fContinuously)
{
ktime_t Interval;
#ifdef PROVE_OVERRUN
ktime_t Now;
unsigned long Overruns;
#endif
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);
}
#else
pTimer_p->expires = ktime_add_ns(pTimer_p->expires,
pTimerInfo->m_ullPeriod);
#endif
Ret = HRTIMER_RESTART;
}
Exit:
BENCHMARK_MOD_24_RESET(4);
return Ret;
}

View file

@ -0,0 +1,358 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: Virtual Ethernet Driver for Linux
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: VirtualEthernetLinux.c,v $
$Author: D.Krueger $
$Revision: 1.8 $ $Date: 2008/11/20 17:06:51 $
$State: Exp $
Build Environment:
-------------------------------------------------------------------------
Revision History:
2006/06/12 -ar: start of the implementation, version 1.00
2006/09/18 d.k.: integration into EPL DLLk module
ToDo:
void netif_carrier_off(struct net_device *dev);
void netif_carrier_on(struct net_device *dev);
****************************************************************************/
#include <linux/version.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/if_arp.h>
#include <net/arp.h>
#include <net/protocol.h>
#include <net/pkt_sched.h>
#include <linux/if_ether.h>
#include <linux/in.h>
#include <linux/ip.h>
#include <linux/udp.h>
#include <linux/mm.h>
#include <linux/types.h>
#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)
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// 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
#endif
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
static struct net_device * pVEthNetDevice_g = NULL;
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
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 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 //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function:
//
// Description:
//
//
//
// Parameters:
//
//
// Returns:
//
//
// State:
//
//---------------------------------------------------------------------------
static int VEthOpen(struct net_device *pNetDevice_p)
{
tEplKernel Ret = kEplSuccessful;
//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);
// register callback function in DLL
Ret = EplDllkRegAsyncHandler(VEthRecvFrame);
EPL_DBGLVL_VETH_TRACE1("VEthOpen: EplDllkRegAsyncHandler returned 0x%02X\n", Ret);
return 0;
}
static int VEthClose(struct net_device *pNetDevice_p)
{
tEplKernel Ret = kEplSuccessful;
EPL_DBGLVL_VETH_TRACE0("VEthClose\n");
Ret = EplDllkDeregAsyncHandler(VEthRecvFrame);
//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;
//transmit function
struct net_device_stats* pStats = (struct net_device_stats*)pNetDevice_p->priv;
//save timestemp
pNetDevice_p->trans_start = jiffies;
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);
//set stats for the device
pStats->tx_packets++;
pStats->tx_bytes += FrameInfo.m_uiFrameSize;
}
Exit:
return 0;
}
static struct net_device_stats* VEthGetStats(struct net_device *pNetDevice_p)
{
EPL_DBGLVL_VETH_TRACE0("VEthGetStats\n");
return (struct net_device_stats *)pNetDevice_p->priv;
}
static void VEthTimeout(struct net_device *pNetDevice_p)
{
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);
}
}
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;
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;
skb_reserve(pSkb, 2);
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;
// 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));
// update receive statistics
pStats->rx_packets++;
pStats->rx_bytes += pFrameInfo_p->m_uiFrameSize;
Exit:
return Ret;
}
tEplKernel PUBLIC VEthAddInstance(tEplDllkInitParam * pInitParam_p)
{
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);
// pVEthNetDevice_g = alloc_etherdev(sizeof (struct net_device_stats));
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;
// 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");
}
Exit:
return Ret;
}
tEplKernel PUBLIC VEthDelInstance(void)
{
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;
}
return Ret;
}
#endif // (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_VETH)) != 0)

View file

@ -0,0 +1,945 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: Abstract Memory Interface for x86 compatible
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: amix86.c,v $
$Author: D.Krueger $
$Revision: 1.3 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
...
-------------------------------------------------------------------------
Revision History:
r.s.: first implemetation
2006-06-13 d.k.: duplicate functions for little endian and big endian
****************************************************************************/
//#include "global.h"
//#include "EplAmi.h"
#include "EplInc.h"
#if (!defined(EPL_AMI_INLINED)) || defined(INLINE_ENABLED)
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
typedef struct
{
WORD m_wWord;
} twStruct;
typedef struct
{
DWORD m_dwDword;
} tdwStruct;
typedef struct
{
QWORD m_qwQword;
} tqwStruct;
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: AmiSetXXXToBe()
//
// Description: writes the specified value to the absolute address in
// big endian
//
// Parameters: pAddr_p = absolute address
// xXXXVal_p = value
//
// Returns: (none)
//
// State:
//
//---------------------------------------------------------------------------
//------------< write BYTE in big endian >--------------------------
/*
void PUBLIC AmiSetByteToBe (void FAR* pAddr_p, BYTE bByteVal_p)
{
*(BYTE FAR*)pAddr_p = bByteVal_p;
}
*/
//------------< write WORD in big endian >--------------------------
INLINE_FUNCTION void PUBLIC AmiSetWordToBe (void FAR* pAddr_p, WORD wWordVal_p)
{
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
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)
{
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
pdwStruct = (tdwStruct FAR*)pAddr_p;
pdwStruct->m_dwDword = dwValue.m_dwDword;
}
//---------------------------------------------------------------------------
//
// Function: AmiSetXXXToLe()
//
// Description: writes the specified value to the absolute address in
// little endian
//
// Parameters: pAddr_p = absolute address
// xXXXVal_p = value
//
// Returns: (none)
//
// State:
//
//---------------------------------------------------------------------------
//------------< write BYTE in little endian >--------------------------
/*
void PUBLIC AmiSetByteToLe (void FAR* pAddr_p, BYTE bByteVal_p)
{
*(BYTE FAR*)pAddr_p = bByteVal_p;
}
*/
//------------< write WORD in little endian >--------------------------
INLINE_FUNCTION void PUBLIC AmiSetWordToLe (void FAR* pAddr_p, WORD wWordVal_p)
{
twStruct FAR* pwStruct;
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)
{
tdwStruct FAR* pdwStruct;
pdwStruct = (tdwStruct FAR*)pAddr_p;
pdwStruct->m_dwDword = dwDwordVal_p;
}
//---------------------------------------------------------------------------
//
// Function: AmiGetXXXFromBe()
//
// Description: reads the specified value from the absolute address in
// big endian
//
// Parameters: pAddr_p = absolute address
//
// Returns: XXX = value
//
// State:
//
//---------------------------------------------------------------------------
//------------< read BYTE in big endian >---------------------------
/*
BYTE PUBLIC AmiGetByteFromBe (void FAR* pAddr_p)
{
return ( *(BYTE FAR*)pAddr_p );
}
*/
//------------< read WORD in big endian >---------------------------
INLINE_FUNCTION WORD PUBLIC AmiGetWordFromBe (void FAR* pAddr_p)
{
twStruct FAR* pwStruct;
twStruct wValue;
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
return ( wValue.m_wWord );
}
//------------< read DWORD in big endian >--------------------------
INLINE_FUNCTION DWORD PUBLIC AmiGetDwordFromBe (void FAR* pAddr_p)
{
tdwStruct FAR* pdwStruct;
tdwStruct dwValue;
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
return ( dwValue.m_dwDword );
}
//---------------------------------------------------------------------------
//
// Function: AmiGetXXXFromLe()
//
// Description: reads the specified value from the absolute address in
// little endian
//
// Parameters: pAddr_p = absolute address
//
// Returns: XXX = value
//
// State:
//
//---------------------------------------------------------------------------
//------------< read BYTE in little endian >---------------------------
/*
BYTE PUBLIC AmiGetByteFromLe (void FAR* pAddr_p)
{
return ( *(BYTE FAR*)pAddr_p );
}
*/
//------------< read WORD in little endian >---------------------------
INLINE_FUNCTION WORD PUBLIC AmiGetWordFromLe (void FAR* pAddr_p)
{
twStruct FAR* pwStruct;
pwStruct = (twStruct FAR*)pAddr_p;
return ( pwStruct->m_wWord );
}
//------------< read DWORD in little endian >--------------------------
INLINE_FUNCTION DWORD PUBLIC AmiGetDwordFromLe (void FAR* pAddr_p)
{
tdwStruct FAR* pdwStruct;
pdwStruct = (tdwStruct FAR*)pAddr_p;
return ( pdwStruct->m_dwDword );
}
//---------------------------------------------------------------------------
//
// Function: AmiSetDword24ToBe()
//
// Description: sets a 24 bit value to a buffer in big endian
//
// Parameters: pAddr_p = pointer to destination buffer
// dwDwordVal_p = value to set
//
// Return: void
//
// State: not tested
//
//---------------------------------------------------------------------------
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];
}
//---------------------------------------------------------------------------
//
// Function: AmiSetDword24ToLe()
//
// Description: sets a 24 bit value to a buffer in little endian
//
// Parameters: pAddr_p = pointer to destination buffer
// dwDwordVal_p = value to set
//
// Return: void
//
// State: not tested
//
//---------------------------------------------------------------------------
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];
}
//---------------------------------------------------------------------------
//
// Function: AmiGetDword24FromBe()
//
// Description: reads a 24 bit value from a buffer in big endian
//
// Parameters: pAddr_p = pointer to source buffer
//
// Return: DWORD = read value
//
// State: not tested
//
//---------------------------------------------------------------------------
INLINE_FUNCTION DWORD PUBLIC AmiGetDword24FromBe (void FAR* pAddr_p)
{
tdwStruct dwStruct;
dwStruct.m_dwDword = AmiGetDwordFromBe (pAddr_p);
dwStruct.m_dwDword >>= 8;
return ( dwStruct.m_dwDword );
}
//---------------------------------------------------------------------------
//
// Function: AmiGetDword24FromLe()
//
// Description: reads a 24 bit value from a buffer in little endian
//
// Parameters: pAddr_p = pointer to source buffer
//
// Return: DWORD = read value
//
// State: not tested
//
//---------------------------------------------------------------------------
INLINE_FUNCTION DWORD PUBLIC AmiGetDword24FromLe (void FAR* pAddr_p)
{
tdwStruct dwStruct;
dwStruct.m_dwDword = AmiGetDwordFromLe (pAddr_p);
dwStruct.m_dwDword &= 0x00FFFFFF;
return ( dwStruct.m_dwDword );
}
//#ifdef USE_VAR64
//---------------------------------------------------------------------------
//
// Function: AmiSetQword64ToBe()
//
// Description: sets a 64 bit value to a buffer in big endian
//
// Parameters: pAddr_p = pointer to destination buffer
// qwQwordVal_p = quadruple word value
//
// Return: void
//
// State: not tested
//
//---------------------------------------------------------------------------
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];
}
//---------------------------------------------------------------------------
//
// Function: AmiSetQword64ToLe()
//
// Description: sets a 64 bit value to a buffer in little endian
//
// Parameters: pAddr_p = pointer to destination buffer
// qwQwordVal_p = quadruple word value
//
// Return: void
//
// State: not tested
//
//---------------------------------------------------------------------------
INLINE_FUNCTION void PUBLIC AmiSetQword64ToLe (void FAR* pAddr_p, QWORD qwQwordVal_p)
{
QWORD FAR* pqwDst;
pqwDst = (QWORD FAR*) pAddr_p;
*pqwDst = qwQwordVal_p;
}
//---------------------------------------------------------------------------
//
// Function: AmiGetQword64FromBe()
//
// Description: reads a 64 bit value from a buffer in big endian
//
// Parameters: pAddr_p = pointer to source buffer
//
// Return: void
//
// State: not tested
//
//---------------------------------------------------------------------------
INLINE_FUNCTION QWORD PUBLIC AmiGetQword64FromBe (void FAR* pAddr_p)
{
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];
return ( qwStruct.m_qwQword );
}
//---------------------------------------------------------------------------
//
// Function: AmiGetQword64FromLe()
//
// Description: reads a 64 bit value from a buffer in little endian
//
// Parameters: pAddr_p = pointer to source buffer
//
// Return: void
//
// State: not tested
//
//---------------------------------------------------------------------------
INLINE_FUNCTION QWORD PUBLIC AmiGetQword64FromLe (void FAR* pAddr_p)
{
tqwStruct FAR* pqwStruct;
tqwStruct qwStruct;
pqwStruct = (tqwStruct FAR*) pAddr_p;
qwStruct.m_qwQword = pqwStruct->m_qwQword;
return ( qwStruct.m_qwQword );
}
//---------------------------------------------------------------------------
//
// Function: AmiSetQword40ToBe()
//
// Description: sets a 40 bit value to a buffer in big endian
//
// Parameters: pAddr_p = pointer to destination buffer
// qwQwordVal_p = quadruple word value
//
// Return: void
//
// State: not tested
//
//---------------------------------------------------------------------------
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];
}
//---------------------------------------------------------------------------
//
// Function: AmiSetQword40ToLe()
//
// Description: sets a 40 bit value to a buffer in little endian
//
// Parameters: pAddr_p = pointer to destination buffer
// qwQwordVal_p = quadruple word value
//
// Return: void
//
// State: not tested
//
//---------------------------------------------------------------------------
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];
}
//---------------------------------------------------------------------------
//
// Function: AmiGetQword40FromBe()
//
// Description: reads a 40 bit value from a buffer in big endian
//
// Parameters: pAddr_p = pointer to source buffer
//
// Return: QWORD
//
// State: not tested
//
//---------------------------------------------------------------------------
INLINE_FUNCTION QWORD PUBLIC AmiGetQword40FromBe (void FAR* pAddr_p)
{
tqwStruct qwStruct;
qwStruct.m_qwQword = AmiGetQword64FromBe (pAddr_p);
qwStruct.m_qwQword >>= 24;
return ( qwStruct.m_qwQword );
}
//---------------------------------------------------------------------------
//
// Function: AmiGetQword40FromLe()
//
// Description: reads a 40 bit value from a buffer in little endian
//
// Parameters: pAddr_p = pointer to source buffer
//
// Return: QWORD
//
// State: not tested
//
//---------------------------------------------------------------------------
INLINE_FUNCTION QWORD PUBLIC AmiGetQword40FromLe (void FAR* pAddr_p)
{
tqwStruct qwStruct;
qwStruct.m_qwQword = AmiGetQword64FromLe (pAddr_p);
qwStruct.m_qwQword &= 0x000000FFFFFFFFFFLL;
return ( qwStruct.m_qwQword );
}
//---------------------------------------------------------------------------
//
// Function: AmiSetQword48ToBe()
//
// Description: sets a 48 bit value to a buffer in big endian
//
// Parameters: pAddr_p = pointer to destination buffer
// qwQwordVal_p = quadruple word value
//
// Return: void
//
// State: not tested
//
//---------------------------------------------------------------------------
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];
}
//---------------------------------------------------------------------------
//
// Function: AmiSetQword48ToLe()
//
// Description: sets a 48 bit value to a buffer in little endian
//
// Parameters: pAddr_p = pointer to destination buffer
// qwQwordVal_p = quadruple word value
//
// Return: void
//
// State: not tested
//
//---------------------------------------------------------------------------
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];
}
//---------------------------------------------------------------------------
//
// Function: AmiGetQword48FromBe()
//
// Description: reads a 48 bit value from a buffer in big endian
//
// Parameters: pAddr_p = pointer to source buffer
//
// Return: QWORD
//
// State: not tested
//
//---------------------------------------------------------------------------
INLINE_FUNCTION QWORD PUBLIC AmiGetQword48FromBe (void FAR* pAddr_p)
{
tqwStruct qwStruct;
qwStruct.m_qwQword = AmiGetQword64FromBe (pAddr_p);
qwStruct.m_qwQword >>= 16;
return ( qwStruct.m_qwQword );
}
//---------------------------------------------------------------------------
//
// Function: AmiGetQword48FromLe()
//
// Description: reads a 48 bit value from a buffer in little endian
//
// Parameters: pAddr_p = pointer to source buffer
//
// Return: QWORD
//
// State: not tested
//
//---------------------------------------------------------------------------
INLINE_FUNCTION QWORD PUBLIC AmiGetQword48FromLe (void FAR* pAddr_p)
{
tqwStruct qwStruct;
qwStruct.m_qwQword = AmiGetQword64FromLe (pAddr_p);
qwStruct.m_qwQword &= 0x0000FFFFFFFFFFFFLL;
return ( qwStruct.m_qwQword );
}
//---------------------------------------------------------------------------
//
// Function: AmiSetQword56ToBe()
//
// Description: sets a 56 bit value to a buffer in big endian
//
// Parameters: pAddr_p = pointer to destination buffer
// qwQwordVal_p = quadruple word value
//
// Return: void
//
// State: not tested
//
//---------------------------------------------------------------------------
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];
}
//---------------------------------------------------------------------------
//
// Function: AmiSetQword56ToLe()
//
// Description: sets a 56 bit value to a buffer in little endian
//
// Parameters: pAddr_p = pointer to destination buffer
// qwQwordVal_p = quadruple word value
//
// Return: void
//
// State: not tested
//
//---------------------------------------------------------------------------
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];
}
//---------------------------------------------------------------------------
//
// Function: AmiGetQword56FromBe()
//
// Description: reads a 56 bit value from a buffer in big endian
//
// Parameters: pAddr_p = pointer to source buffer
//
// Return: QWORD
//
// State: not tested
//
//---------------------------------------------------------------------------
INLINE_FUNCTION QWORD PUBLIC AmiGetQword56FromBe (void FAR* pAddr_p)
{
tqwStruct qwStruct;
qwStruct.m_qwQword = AmiGetQword64FromBe (pAddr_p);
qwStruct.m_qwQword >>= 8;
return ( qwStruct.m_qwQword );
}
//---------------------------------------------------------------------------
//
// Function: AmiGetQword56FromLe()
//
// Description: reads a 56 bit value from a buffer in little endian
//
// Parameters: pAddr_p = pointer to source buffer
//
// Return: QWORD
//
// State: not tested
//
//---------------------------------------------------------------------------
INLINE_FUNCTION QWORD PUBLIC AmiGetQword56FromLe (void FAR* pAddr_p)
{
tqwStruct qwStruct;
qwStruct.m_qwQword = AmiGetQword64FromLe (pAddr_p);
qwStruct.m_qwQword &= 0x00FFFFFFFFFFFFFFLL;
return ( qwStruct.m_qwQword );
}
//---------------------------------------------------------------------------
//
// Function: AmiSetTimeOfDay()
//
// Description: sets a TIME_OF_DAY (CANopen) value to a buffer
//
// Parameters: pAddr_p = pointer to destination buffer
// pTimeOfDay_p = pointer to struct TIME_OF_DAY
//
// Return: void
//
// State: not tested
//
//---------------------------------------------------------------------------
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);
}
//---------------------------------------------------------------------------
//
// Function: AmiGetTimeOfDay()
//
// Description: reads a TIME_OF_DAY (CANopen) value from a buffer
//
// Parameters: pAddr_p = pointer to source buffer
// pTimeOfDay_p = pointer to struct TIME_OF_DAY
//
// Return: void
//
// State: not tested
//
//---------------------------------------------------------------------------
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);
}
#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).

View file

@ -0,0 +1,937 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: demoapplication for EPL MN (with SDO over UDP)
under Linux on X86 with RTL8139 Ethernet controller
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: demo_main.c,v $
$Author: D.Krueger $
$Revision: 1.10 $ $Date: 2008/11/19 18:11:43 $
$State: Exp $
Build Environment:
GCC
-------------------------------------------------------------------------
Revision History:
2006/09/01 d.k.: start of implementation
****************************************************************************/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/major.h>
#include <linux/version.h>
#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/atomic.h>
#include <linux/sched.h>
#include <linux/kmod.h>
#include <linux/slab.h>
#include <linux/pci.h>
#include <linux/proc_fs.h>
#include "Epl.h"
#include "proc_fs.h"
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
// remove ("make invisible") obsolete symbols for kernel versions 2.6
// and higher
#define MOD_INC_USE_COUNT
#define MOD_DEC_USE_COUNT
#define EXPORT_NO_SYMBOLS
#else
#error "This driver needs a 2.6.x kernel or higher"
#endif
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
// Metainformation
MODULE_LICENSE("Dual BSD/GPL");
#ifdef MODULE_AUTHOR
MODULE_AUTHOR("Daniel.Krueger@SYSTEC-electronic.com");
MODULE_DESCRIPTION("EPL MN demo");
#endif
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
// TracePoint support for realtime-debugging
#ifdef _DBG_TRACE_POINTS_
void PUBLIC TgtDbgSignalTracePoint (BYTE bTracePointNumber_p);
#define TGT_DBG_SIGNAL_TRACE_POINT(p) TgtDbgSignalTracePoint(p)
#else
#define TGT_DBG_SIGNAL_TRACE_POINT(p)
#endif
#define NODEID 0xF0 //=> MN
#define CYCLE_LEN 5000 // [us]
#define IP_ADDR 0xc0a86401 // 192.168.100.1
#define SUBNET_MASK 0xFFFFFF00 // 255.255.255.0
#define HOSTNAME "SYS TEC electronic EPL Stack "
#define IF_ETH EPL_VETH_NAME
// LIGHT EFFECT
#define DEFAULT_MAX_CYCLE_COUNT 20 // 6 is very fast
#define APP_DEFAULT_MODE 0x01
#define APP_LED_COUNT 5 // number of LEDs in one row
#define APP_LED_MASK ((1 << APP_LED_COUNT) - 1)
#define APP_DOUBLE_LED_MASK ((1 << (APP_LED_COUNT * 2)) - 1)
#define APP_MODE_COUNT 5
#define APP_MODE_MASK ((1 << APP_MODE_COUNT) - 1)
//---------------------------------------------------------------------------
// local types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// modul globale vars
//---------------------------------------------------------------------------
CONST BYTE abMacAddr[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
BYTE bVarIn1_l;
BYTE bVarOut1_l;
BYTE bVarOut1Old_l;
BYTE bModeSelect_l; // state of the pushbuttons to select the mode
BYTE bSpeedSelect_l; // state of the pushbuttons to increase/decrease the speed
BYTE bSpeedSelectOld_l; // old state of the pushbuttons
DWORD dwLeds_l; // current state of all LEDs
BYTE bLedsRow1_l; // current state of the LEDs in row 1
BYTE bLedsRow2_l; // current state of the LEDs in row 2
BYTE abSelect_l[3]; // pushbuttons from CNs
DWORD dwMode_l; // current mode
int iCurCycleCount_l; // current cycle count
int iMaxCycleCount_l; // maximum cycle count (i.e. number of cycles until next light movement step)
int iToggle; // indicates the light movement direction
BYTE abDomain_l[3000];
static wait_queue_head_t WaitQueueShutdown_g; // wait queue for tEplNmtEventSwitchOff
static atomic_t AtomicShutdown_g = ATOMIC_INIT(FALSE);
static DWORD dw_le_CycleLen_g;
static uint uiNodeId_g = EPL_C_ADR_INVALID;
module_param_named(nodeid, uiNodeId_g, uint, 0);
static uint uiCycleLen_g = CYCLE_LEN;
module_param_named(cyclelen, uiCycleLen_g, uint, 0);
//---------------------------------------------------------------------------
// local function prototypes
//---------------------------------------------------------------------------
// This function is the entry point for your object dictionary. It is defined
// in OBJDICT.C by define EPL_OBD_INIT_RAM_NAME. Use this function name to define
// this function prototype here. If you want to use more than one Epl
// instances then the function name of each object dictionary has to differ.
tEplKernel PUBLIC EplObdInitRam (tEplObdInitParam MEM* pInitParam_p);
tEplKernel PUBLIC AppCbEvent(
tEplApiEventType EventType_p, // IN: event type (enum)
tEplApiEventArg* pEventArg_p, // IN: event argument (union)
void GENERIC* pUserArg_p);
tEplKernel PUBLIC AppCbSync(void);
static int __init EplLinInit (void);
static void __exit EplLinExit (void);
//---------------------------------------------------------------------------
// Kernel Module specific Data Structures
//---------------------------------------------------------------------------
EXPORT_NO_SYMBOLS;
//module_init(EplLinInit);
//module_exit(EplLinExit);
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function:
//
// Description:
//
//
//
// Parameters:
//
//
// Returns:
//
//
// State:
//
//---------------------------------------------------------------------------
static int __init EplLinInit (void)
{
tEplKernel EplRet;
int iRet;
static tEplApiInitParam EplApiInitParam = {0};
char* sHostname = HOSTNAME;
char* argv[4], *envp[3];
char sBuffer[16];
unsigned int uiVarEntries;
tEplObdSize ObdSize;
atomic_set(&AtomicShutdown_g, TRUE);
// get node ID from insmod command line
EplApiInitParam.m_uiNodeId = uiNodeId_g;
if (EplApiInitParam.m_uiNodeId == EPL_C_ADR_INVALID)
{ // invalid node ID set
// set default node ID
EplApiInitParam.m_uiNodeId = NODEID;
}
uiNodeId_g = EplApiInitParam.m_uiNodeId;
// calculate IP address
EplApiInitParam.m_dwIpAddress = (0xFFFFFF00 & IP_ADDR) | EplApiInitParam.m_uiNodeId;
EplApiInitParam.m_fAsyncOnly = FALSE;
EplApiInitParam.m_uiSizeOfStruct = sizeof (EplApiInitParam);
EPL_MEMCPY(EplApiInitParam.m_abMacAddress, abMacAddr, sizeof (EplApiInitParam.m_abMacAddress));
// EplApiInitParam.m_abMacAddress[5] = (BYTE) EplApiInitParam.m_uiNodeId;
EplApiInitParam.m_dwFeatureFlags = -1;
EplApiInitParam.m_dwCycleLen = uiCycleLen_g; // required for error detection
EplApiInitParam.m_uiIsochrTxMaxPayload = 100; // const
EplApiInitParam.m_uiIsochrRxMaxPayload = 100; // const
EplApiInitParam.m_dwPresMaxLatency = 50000; // const; only required for IdentRes
EplApiInitParam.m_uiPreqActPayloadLimit = 36; // required for initialisation (+28 bytes)
EplApiInitParam.m_uiPresActPayloadLimit = 36; // required for initialisation of Pres frame (+28 bytes)
EplApiInitParam.m_dwAsndMaxLatency = 150000; // const; only required for IdentRes
EplApiInitParam.m_uiMultiplCycleCnt = 0; // required for error detection
EplApiInitParam.m_uiAsyncMtu = 1500; // required to set up max frame size
EplApiInitParam.m_uiPrescaler = 2; // required for sync
EplApiInitParam.m_dwLossOfFrameTolerance = 500000;
EplApiInitParam.m_dwAsyncSlotTimeout = 3000000;
EplApiInitParam.m_dwWaitSocPreq = 150000;
EplApiInitParam.m_dwDeviceType = -1; // NMT_DeviceType_U32
EplApiInitParam.m_dwVendorId = -1; // NMT_IdentityObject_REC.VendorId_U32
EplApiInitParam.m_dwProductCode = -1; // NMT_IdentityObject_REC.ProductCode_U32
EplApiInitParam.m_dwRevisionNumber = -1; // NMT_IdentityObject_REC.RevisionNo_U32
EplApiInitParam.m_dwSerialNumber = -1; // NMT_IdentityObject_REC.SerialNo_U32
EplApiInitParam.m_dwSubnetMask = SUBNET_MASK;
EplApiInitParam.m_dwDefaultGateway = 0;
EPL_MEMCPY(EplApiInitParam.m_sHostname, sHostname, sizeof(EplApiInitParam.m_sHostname));
// currently unset parameters left at default value 0
//EplApiInitParam.m_qwVendorSpecificExt1;
//EplApiInitParam.m_dwVerifyConfigurationDate; // CFM_VerifyConfiguration_REC.ConfDate_U32
//EplApiInitParam.m_dwVerifyConfigurationTime; // CFM_VerifyConfiguration_REC.ConfTime_U32
//EplApiInitParam.m_dwApplicationSwDate; // PDL_LocVerApplSw_REC.ApplSwDate_U32 on programmable device or date portion of NMT_ManufactSwVers_VS on non-programmable device
//EplApiInitParam.m_dwApplicationSwTime; // PDL_LocVerApplSw_REC.ApplSwTime_U32 on programmable device or time portion of NMT_ManufactSwVers_VS on non-programmable device
//EplApiInitParam.m_abVendorSpecificExt2[48];
// set callback functions
EplApiInitParam.m_pfnCbEvent = AppCbEvent;
EplApiInitParam.m_pfnCbSync = AppCbSync;
printk("\n\n Hello, I'm a simple POWERLINK node running as %s!\n (build: %s / %s)\n\n",
(uiNodeId_g == EPL_C_ADR_MN_DEF_NODE_ID ?
"Managing Node" : "Controlled Node"),
__DATE__, __TIME__);
// initialize the Linux a wait queue for shutdown of this module
init_waitqueue_head(&WaitQueueShutdown_g);
// initialize the procfs device
EplRet = EplLinProcInit();
if (EplRet != kEplSuccessful)
{
goto Exit;
}
// initialize POWERLINK stack
EplRet = EplApiInitialize(&EplApiInitParam);
if(EplRet != kEplSuccessful)
{
goto Exit;
}
// link process variables used by CN to object dictionary
ObdSize = sizeof(bVarIn1_l);
uiVarEntries = 1;
EplRet = EplApiLinkObject(0x6000, &bVarIn1_l, &uiVarEntries, &ObdSize, 0x01);
if (EplRet != kEplSuccessful)
{
goto Exit;
}
ObdSize = sizeof(bVarOut1_l);
uiVarEntries = 1;
EplRet = EplApiLinkObject(0x6200, &bVarOut1_l, &uiVarEntries, &ObdSize, 0x01);
if (EplRet != kEplSuccessful)
{
goto Exit;
}
// link process variables used by MN to object dictionary
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
ObdSize = sizeof(bLedsRow1_l);
uiVarEntries = 1;
EplRet = EplApiLinkObject(0x2000, &bLedsRow1_l, &uiVarEntries, &ObdSize, 0x01);
if (EplRet != kEplSuccessful)
{
goto Exit;
}
ObdSize = sizeof(bLedsRow2_l);
uiVarEntries = 1;
EplRet = EplApiLinkObject(0x2000, &bLedsRow2_l, &uiVarEntries, &ObdSize, 0x02);
if (EplRet != kEplSuccessful)
{
goto Exit;
}
ObdSize = sizeof(bSpeedSelect_l);
uiVarEntries = 1;
EplRet = EplApiLinkObject(0x2000, &bSpeedSelect_l, &uiVarEntries, &ObdSize, 0x03);
if (EplRet != kEplSuccessful)
{
goto Exit;
}
ObdSize = sizeof(bSpeedSelectOld_l);
uiVarEntries = 1;
EplRet = EplApiLinkObject(0x2000, &bSpeedSelectOld_l, &uiVarEntries, &ObdSize, 0x04);
if (EplRet != kEplSuccessful)
{
goto Exit;
}
ObdSize = sizeof(abSelect_l[0]);
uiVarEntries = sizeof(abSelect_l);
EplRet = EplApiLinkObject(0x2200, &abSelect_l[0], &uiVarEntries, &ObdSize, 0x01);
if (EplRet != kEplSuccessful)
{
goto Exit;
}
#endif
// link a DOMAIN to object 0x6100, but do not exit, if it is missing
ObdSize = sizeof(abDomain_l);
uiVarEntries = 1;
EplRet = EplApiLinkObject(0x6100, &abDomain_l, &uiVarEntries, &ObdSize, 0x00);
if (EplRet != kEplSuccessful)
{
printk("EplApiLinkObject(0x6100): returns 0x%X\n", EplRet);
}
// reset old process variables
bVarOut1Old_l = 0;
bSpeedSelectOld_l = 0;
dwMode_l = APP_DEFAULT_MODE;
iMaxCycleCount_l = DEFAULT_MAX_CYCLE_COUNT;
// configure IP address of virtual network interface
// for TCP/IP communication over the POWERLINK network
sprintf(sBuffer, "%lu.%lu.%lu.%lu", (EplApiInitParam.m_dwIpAddress >> 24), ((EplApiInitParam.m_dwIpAddress >> 16) & 0xFF), ((EplApiInitParam.m_dwIpAddress >> 8) & 0xFF), (EplApiInitParam.m_dwIpAddress & 0xFF));
/* set up a minimal environment */
iRet = 0;
envp[iRet++] = "HOME=/";
envp[iRet++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
envp[iRet] = NULL;
/* set up the argument list */
iRet = 0;
argv[iRet++] = "/sbin/ifconfig";
argv[iRet++] = IF_ETH;
argv[iRet++] = sBuffer;
argv[iRet] = NULL;
/* call ifconfig to configure the virtual network interface */
iRet = call_usermodehelper(argv[0], argv, envp, 1);
printk("ifconfig %s %s returned %d\n", argv[1], argv[2], iRet);
// start the NMT state machine
EplRet = EplApiExecNmtCommand(kEplNmtEventSwReset);
atomic_set(&AtomicShutdown_g, FALSE);
Exit:
printk("EplLinInit(): returns 0x%X\n", EplRet);
return EplRet;
}
static void __exit EplLinExit (void)
{
tEplKernel EplRet;
// halt the NMT state machine
// so the processing of POWERLINK frames stops
EplRet = EplApiExecNmtCommand(kEplNmtEventSwitchOff);
// wait until NMT state machine is shut down
wait_event_interruptible(WaitQueueShutdown_g,
(atomic_read(&AtomicShutdown_g) == TRUE));
/* if ((iErr != 0) || (atomic_read(&AtomicShutdown_g) == EVENT_STATE_IOCTL))
{ // waiting was interrupted by signal or application called wrong function
EplRet = kEplShutdown;
}*/
// delete instance for all modules
EplRet = EplApiShutdown();
printk("EplApiShutdown(): 0x%X\n", EplRet);
// deinitialize proc fs
EplRet = EplLinProcFree();
printk("EplLinProcFree(): 0x%X\n", EplRet);
}
//=========================================================================//
// //
// P R I V A T E F U N C T I O N S //
// //
//=========================================================================//
//---------------------------------------------------------------------------
//
// Function: AppCbEvent
//
// Description: event callback function called by EPL API layer within
// user part (low priority).
//
// Parameters: EventType_p = event type
// pEventArg_p = pointer to union, which describes
// the event in detail
// pUserArg_p = user specific argument
//
// Returns: tEplKernel = error code,
// kEplSuccessful = no error
// kEplReject = reject further processing
// otherwise = post error event to API layer
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC AppCbEvent(
tEplApiEventType EventType_p, // IN: event type (enum)
tEplApiEventArg* pEventArg_p, // IN: event argument (union)
void GENERIC* pUserArg_p)
{
tEplKernel EplRet = kEplSuccessful;
// check if NMT_GS_OFF is reached
switch (EventType_p)
{
case kEplApiEventNmtStateChange:
{
switch (pEventArg_p->m_NmtStateChange.m_NewNmtState)
{
case kEplNmtGsOff:
{ // NMT state machine was shut down,
// because of user signal (CTRL-C) or critical EPL stack error
// -> also shut down EplApiProcess() and main()
EplRet = kEplShutdown;
printk("AppCbEvent(kEplNmtGsOff) originating event = 0x%X\n", pEventArg_p->m_NmtStateChange.m_NmtEvent);
// wake up EplLinExit()
atomic_set(&AtomicShutdown_g, TRUE);
wake_up_interruptible(&WaitQueueShutdown_g);
break;
}
case kEplNmtGsResetCommunication:
{
DWORD dwBuffer;
// configure OD for MN in state ResetComm after reseting the OD
// TODO: setup your own network configuration here
dwBuffer = (EPL_NODEASSIGN_NODE_IS_CN | EPL_NODEASSIGN_NODE_EXISTS); // 0x00000003L
EplRet = EplApiWriteLocalObject(0x1F81, 0x01, &dwBuffer, 4);
EplRet = EplApiWriteLocalObject(0x1F81, 0x02, &dwBuffer, 4);
EplRet = EplApiWriteLocalObject(0x1F81, 0x03, &dwBuffer, 4);
EplRet = EplApiWriteLocalObject(0x1F81, 0x04, &dwBuffer, 4);
EplRet = EplApiWriteLocalObject(0x1F81, 0x05, &dwBuffer, 4);
EplRet = EplApiWriteLocalObject(0x1F81, 0x06, &dwBuffer, 4);
EplRet = EplApiWriteLocalObject(0x1F81, 0x07, &dwBuffer, 4);
EplRet = EplApiWriteLocalObject(0x1F81, 0x08, &dwBuffer, 4);
EplRet = EplApiWriteLocalObject(0x1F81, 0x20, &dwBuffer, 4);
EplRet = EplApiWriteLocalObject(0x1F81, 0xFE, &dwBuffer, 4);
EplRet = EplApiWriteLocalObject(0x1F81, 0x6E, &dwBuffer, 4);
// dwBuffer |= EPL_NODEASSIGN_MANDATORY_CN; // 0x0000000BL
// EplRet = EplApiWriteLocalObject(0x1F81, 0x6E, &dwBuffer, 4);
dwBuffer = (EPL_NODEASSIGN_MN_PRES | EPL_NODEASSIGN_NODE_EXISTS); // 0x00010001L
EplRet = EplApiWriteLocalObject(0x1F81, 0xF0, &dwBuffer, 4);
// continue
}
case kEplNmtGsResetConfiguration:
{
unsigned int uiSize;
// fetch object 0x1006 NMT_CycleLen_U32 from local OD (in little endian byte order)
// for configuration of remote CN
uiSize = 4;
EplRet = EplApiReadObject(NULL, 0, 0x1006, 0x00, &dw_le_CycleLen_g, &uiSize, kEplSdoTypeAsnd, NULL);
if (EplRet != kEplSuccessful)
{ // local OD access failed
break;
}
// continue
}
case kEplNmtMsPreOperational1:
{
printk("AppCbEvent(0x%X) originating event = 0x%X\n",
pEventArg_p->m_NmtStateChange.m_NewNmtState,
pEventArg_p->m_NmtStateChange.m_NmtEvent);
// continue
}
case kEplNmtGsInitialising:
case kEplNmtGsResetApplication:
case kEplNmtMsNotActive:
case kEplNmtCsNotActive:
case kEplNmtCsPreOperational1:
{
break;
}
case kEplNmtCsOperational:
case kEplNmtMsOperational:
{
break;
}
default:
{
break;
}
}
/*
switch (pEventArg_p->m_NmtStateChange.m_NmtEvent)
{
case kEplNmtEventSwReset:
case kEplNmtEventResetNode:
case kEplNmtEventResetCom:
case kEplNmtEventResetConfig:
case kEplNmtEventInternComError:
case kEplNmtEventNmtCycleError:
{
printk("AppCbEvent(0x%X) originating event = 0x%X\n",
pEventArg_p->m_NmtStateChange.m_NewNmtState,
pEventArg_p->m_NmtStateChange.m_NmtEvent);
break;
}
default:
{
break;
}
}
*/
break;
}
case kEplApiEventCriticalError:
case kEplApiEventWarning:
{ // error or warning occured within the stack or the application
// on error the API layer stops the NMT state machine
printk("AppCbEvent(Err/Warn): Source=%02X EplError=0x%03X", pEventArg_p->m_InternalError.m_EventSource, pEventArg_p->m_InternalError.m_EplError);
// check additional argument
switch (pEventArg_p->m_InternalError.m_EventSource)
{
case kEplEventSourceEventk:
case kEplEventSourceEventu:
{ // error occured within event processing
// either in kernel or in user part
printk(" OrgSource=%02X\n", pEventArg_p->m_InternalError.m_Arg.m_EventSource);
break;
}
case kEplEventSourceDllk:
{ // error occured within the data link layer (e.g. interrupt processing)
// the DWORD argument contains the DLL state and the NMT event
printk(" val=%lX\n", pEventArg_p->m_InternalError.m_Arg.m_dwArg);
break;
}
default:
{
printk("\n");
break;
}
}
break;
}
case kEplApiEventNode:
{
// printk("AppCbEvent(Node): Source=%02X EplError=0x%03X", pEventArg_p->m_InternalError.m_EventSource, pEventArg_p->m_InternalError.m_EplError);
// check additional argument
switch (pEventArg_p->m_Node.m_NodeEvent)
{
case kEplNmtNodeEventCheckConf:
{
tEplSdoComConHdl SdoComConHdl;
// update object 0x1006 on CN
EplRet = EplApiWriteObject(&SdoComConHdl, pEventArg_p->m_Node.m_uiNodeId, 0x1006, 0x00, &dw_le_CycleLen_g, 4, kEplSdoTypeAsnd, NULL);
if (EplRet == kEplApiTaskDeferred)
{ // SDO transfer started
EplRet = kEplReject;
}
else if (EplRet == kEplSuccessful)
{ // local OD access (should not occur)
printk("AppCbEvent(Node) write to local OD\n");
}
else
{ // error occured
TGT_DBG_SIGNAL_TRACE_POINT(1);
EplRet = EplApiFreeSdoChannel(SdoComConHdl);
SdoComConHdl = 0;
EplRet = EplApiWriteObject(&SdoComConHdl, pEventArg_p->m_Node.m_uiNodeId, 0x1006, 0x00, &dw_le_CycleLen_g, 4, kEplSdoTypeAsnd, NULL);
if (EplRet == kEplApiTaskDeferred)
{ // SDO transfer started
EplRet = kEplReject;
}
else
{
printk("AppCbEvent(Node): EplApiWriteObject() returned 0x%02X\n", EplRet);
}
}
break;
}
default:
{
break;
}
}
break;
}
case kEplApiEventSdo:
{ // SDO transfer finished
EplRet = EplApiFreeSdoChannel(pEventArg_p->m_Sdo.m_SdoComConHdl);
if (EplRet != kEplSuccessful)
{
break;
}
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
if (pEventArg_p->m_Sdo.m_SdoComConState == kEplSdoComTransferFinished)
{ // continue boot-up of CN with NMT command Reset Configuration
EplRet = EplApiMnTriggerStateChange(pEventArg_p->m_Sdo.m_uiNodeId, kEplNmtNodeCommandConfReset);
}
else
{ // indicate configuration error CN
EplRet = EplApiMnTriggerStateChange(pEventArg_p->m_Sdo.m_uiNodeId, kEplNmtNodeCommandConfErr);
}
#endif
break;
}
default:
break;
}
return EplRet;
}
//---------------------------------------------------------------------------
//
// Function: AppCbSync
//
// Description: sync event callback function called by event module within
// kernel part (high priority).
// This function sets the outputs, reads the inputs and runs
// the control loop.
//
// Parameters: void
//
// Returns: tEplKernel = error code,
// kEplSuccessful = no error
// otherwise = post error event to API layer
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC AppCbSync(void)
{
tEplKernel EplRet = kEplSuccessful;
if (bVarOut1Old_l != bVarOut1_l)
{ // output variable has changed
bVarOut1Old_l = bVarOut1_l;
// set LEDs
// printk("bVarIn = 0x%02X bVarOut = 0x%02X\n", (WORD) bVarIn_l, (WORD) bVarOut_l);
}
if (uiNodeId_g != EPL_C_ADR_MN_DEF_NODE_ID)
{
bVarIn1_l++;
}
if (uiNodeId_g == EPL_C_ADR_MN_DEF_NODE_ID)
{ // we are the master and must run the control loop
// collect inputs from CNs and own input
bSpeedSelect_l = (bVarIn1_l | abSelect_l[0]) & 0x07;
bModeSelect_l = abSelect_l[1] | abSelect_l[2];
if ((bModeSelect_l & APP_MODE_MASK) != 0)
{
dwMode_l = bModeSelect_l & APP_MODE_MASK;
}
iCurCycleCount_l--;
if (iCurCycleCount_l <= 0)
{
if ((dwMode_l & 0x01) != 0)
{ // fill-up
if (iToggle)
{
if ((dwLeds_l & APP_DOUBLE_LED_MASK) == 0x00)
{
dwLeds_l = 0x01;
}
else
{
dwLeds_l <<= 1;
dwLeds_l++;
if (dwLeds_l >= APP_DOUBLE_LED_MASK)
{
iToggle = 0;
}
}
}
else
{
dwLeds_l <<= 1;
if ((dwLeds_l & APP_DOUBLE_LED_MASK) == 0x00)
{
iToggle = 1;
}
}
bLedsRow1_l = (unsigned char) (dwLeds_l & APP_LED_MASK);
bLedsRow2_l = (unsigned char) ((dwLeds_l >> APP_LED_COUNT) & APP_LED_MASK);
}
else if ((dwMode_l & 0x02) != 0)
{ // running light forward
dwLeds_l <<= 1;
if ((dwLeds_l > APP_DOUBLE_LED_MASK) || (dwLeds_l == 0x00000000L))
{
dwLeds_l = 0x01;
}
bLedsRow1_l = (unsigned char) (dwLeds_l & APP_LED_MASK);
bLedsRow2_l = (unsigned char) ((dwLeds_l >> APP_LED_COUNT) & APP_LED_MASK);
}
else if ((dwMode_l & 0x04) != 0)
{ // running light backward
dwLeds_l >>= 1;
if ((dwLeds_l > APP_DOUBLE_LED_MASK) || (dwLeds_l == 0x00000000L))
{
dwLeds_l = 1 << (APP_LED_COUNT * 2);
}
bLedsRow1_l = (unsigned char) (dwLeds_l & APP_LED_MASK);
bLedsRow2_l = (unsigned char) ((dwLeds_l >> APP_LED_COUNT) & APP_LED_MASK);
}
else if ((dwMode_l & 0x08) != 0)
{ // Knightrider
if (bLedsRow1_l == 0x00)
{
bLedsRow1_l = 0x01;
iToggle = 1;
}
else if (iToggle)
{
bLedsRow1_l <<= 1;
if ( bLedsRow1_l >= (1 << (APP_LED_COUNT - 1)) )
{
iToggle = 0;
}
}
else
{
bLedsRow1_l >>= 1;
if( bLedsRow1_l <= 0x01 )
{
iToggle = 1;
}
}
bLedsRow2_l = bLedsRow1_l;
}
else if ((dwMode_l & 0x10) != 0)
{ // Knightrider
if ((bLedsRow1_l == 0x00)
|| (bLedsRow2_l == 0x00)
|| ((bLedsRow2_l & ~APP_LED_MASK) != 0))
{
bLedsRow1_l = 0x01;
bLedsRow2_l = (1 << (APP_LED_COUNT - 1));
iToggle = 1;
}
else if (iToggle)
{
bLedsRow1_l <<= 1;
bLedsRow2_l >>= 1;
if ( bLedsRow1_l >= (1 << (APP_LED_COUNT - 1)) )
{
iToggle = 0;
}
}
else
{
bLedsRow1_l >>= 1;
bLedsRow2_l <<= 1;
if ( bLedsRow1_l <= 0x01 )
{
iToggle = 1;
}
}
}
// set own output
bVarOut1_l = bLedsRow1_l;
// bVarOut1_l = (bLedsRow1_l & 0x03) | (bLedsRow2_l << 2);
// restart cycle counter
iCurCycleCount_l = iMaxCycleCount_l;
}
if (bSpeedSelectOld_l == 0)
{
if ((bSpeedSelect_l & 0x01) != 0)
{
if (iMaxCycleCount_l < 200)
{
iMaxCycleCount_l++;
}
bSpeedSelectOld_l = bSpeedSelect_l;
}
else if ((bSpeedSelect_l & 0x02) != 0)
{
if (iMaxCycleCount_l > 1)
{
iMaxCycleCount_l--;
}
bSpeedSelectOld_l = bSpeedSelect_l;
}
else if ((bSpeedSelect_l & 0x04) != 0)
{
iMaxCycleCount_l = DEFAULT_MAX_CYCLE_COUNT;
bSpeedSelectOld_l = bSpeedSelect_l;
}
}
else if (bSpeedSelect_l == 0)
{
bSpeedSelectOld_l = 0;
}
}
TGT_DBG_SIGNAL_TRACE_POINT(1);
return EplRet;
}
// EOF

183
drivers/staging/epl/edrv.h Normal file
View file

@ -0,0 +1,183 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: interface for ethernetdriver
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: edrv.h,v $
$Author: D.Krueger $
$Revision: 1.6 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
Dev C++ and GNU-Compiler for m68k
-------------------------------------------------------------------------
Revision History:
2005/08/01 m.b.: start of implementation
****************************************************************************/
#ifndef _EDRV_H_
#define _EDRV_H_
#include "EplInc.h"
#include "EplFrame.h"
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
// --------------------------------------------------------------------------
#define MAX_ETH_DATA_SIZE 1500
#define MIN_ETH_DATA_SIZE 46
#define ETH_HDR_OFFSET 0 // Ethernet header at the top of the frame
#define ETH_HDR_SIZE 14 // size of Ethernet header
#define MIN_ETH_SIZE (MIN_ETH_DATA_SIZE + ETH_HDR_SIZE) // without CRC
#define ETH_CRC_SIZE 4 // size of Ethernet CRC, i.e. FCS
//---------------------------------------------------------------------------
// types
//---------------------------------------------------------------------------
// position of a buffer in an ethernet-frame
typedef enum
{
kEdrvBufferFirstInFrame = 0x01, // first data buffer in an ethernet frame
kEdrvBufferMiddleInFrame = 0x02, // a middle data buffer in an ethernet frame
kEdrvBufferLastInFrame = 0x04 // last data buffer in an ethernet frame
} tEdrvBufferInFrame;
// format of a tx-buffer
typedef struct _tEdrvTxBuffer
{
tEplMsgType m_EplMsgType; // IN: type of EPL message, set by calling function
unsigned int m_uiTxMsgLen; // IN: length of message to be send (set for each transmit call)
// ----------------------
unsigned int m_uiBufferNumber; // OUT: number of the buffer, set by ethernetdriver
BYTE * m_pbBuffer; // OUT: pointer to the buffer, set by ethernetdriver
tEplNetTime m_NetTime; // OUT: Timestamp of end of transmission, set by ethernetdriver
// ----------------------
unsigned int m_uiMaxBufferLen; // IN/OUT: maximum length of the buffer
} tEdrvTxBuffer;
// format of a rx-buffer
typedef struct _tEdrvRxBuffer
{
tEdrvBufferInFrame m_BufferInFrame; // OUT position of received buffer in an ethernet-frame
unsigned int m_uiRxMsgLen; // OUT: length of received buffer (without CRC)
BYTE * m_pbBuffer; // OUT: pointer to the buffer, set by ethernetdriver
tEplNetTime m_NetTime; // OUT: Timestamp of end of receiption
} tEdrvRxBuffer;
//typedef void (*tEdrvRxHandler) (BYTE bBufferInFrame_p, tBufferDescr * pbBuffer_p);
//typedef void (*tEdrvRxHandler) (BYTE bBufferInFrame_p, BYTE * pbEthernetData_p, WORD wDataLen_p);
typedef void (*tEdrvRxHandler) (tEdrvRxBuffer * pRxBuffer_p);
typedef void (*tEdrvTxHandler) (tEdrvTxBuffer * pTxBuffer_p);
// format of init structure
typedef struct
{
BYTE m_abMyMacAddr[6]; // the own MAC address
// BYTE m_bNoOfRxBuffDescr; // number of entries in rx bufferdescriptor table
// tBufferDescr * m_pRxBuffDescrTable; // rx bufferdescriptor table
// WORD m_wRxBufferSize; // size of the whole rx buffer
tEdrvRxHandler m_pfnRxHandler;
tEdrvTxHandler m_pfnTxHandler;
} tEdrvInitParam;
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
tEplKernel EdrvInit (tEdrvInitParam* pEdrvInitParam_p);
tEplKernel EdrvShutdown (void);
tEplKernel EdrvDefineRxMacAddrEntry (BYTE * pbMacAddr_p);
tEplKernel EdrvUndefineRxMacAddrEntry (BYTE * pbMacAddr_p);
//tEplKernel EdrvDefineUnicastEntry (BYTE * pbUCEntry_p);
//tEplKernel EdrvUndfineUnicastEntry (BYTE * pbUCEntry_p);
tEplKernel EdrvAllocTxMsgBuffer (tEdrvTxBuffer * pBuffer_p);
tEplKernel EdrvReleaseTxMsgBuffer (tEdrvTxBuffer * pBuffer_p);
//tEplKernel EdrvWriteMsg (tBufferDescr * pbBuffer_p);
tEplKernel EdrvSendTxMsg (tEdrvTxBuffer * pBuffer_p);
tEplKernel EdrvTxMsgReady (tEdrvTxBuffer * pBuffer_p);
tEplKernel EdrvTxMsgStart (tEdrvTxBuffer * pBuffer_p);
//tEplKernel EdrvReadMsg (void);
// interrupt handler called by target specific interrupt handler
void EdrvInterruptHandler (void);
#endif // #ifndef _EDRV_H_

1468
drivers/staging/epl/global.h Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,171 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for kernelspace DLL module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplDllk.h,v $
$Author: D.Krueger $
$Revision: 1.6 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/08 d.k.: start of the implementation, version 1.00
****************************************************************************/
#ifndef _EPL_DLLK_H_
#define _EPL_DLLK_H_
#include "../EplDll.h"
#include "../EplEvent.h"
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
typedef tEplKernel (* tEplDllkCbAsync) (tEplFrameInfo * pFrameInfo_p);
typedef struct
{
BYTE m_be_abSrcMac[6];
} tEplDllkInitParam;
// forward declaration
struct _tEdrvTxBuffer;
struct _tEplDllkNodeInfo
{
struct _tEplDllkNodeInfo* m_pNextNodeInfo;
struct _tEdrvTxBuffer* m_pPreqTxBuffer;
unsigned int m_uiNodeId;
DWORD m_dwPresTimeout;
unsigned long m_ulDllErrorEvents;
tEplNmtState m_NmtState;
WORD m_wPresPayloadLimit;
BYTE m_be_abMacAddr[6];
BYTE m_bSoaFlag1;
BOOL m_fSoftDelete; // delete node after error and ignore error
};
typedef struct _tEplDllkNodeInfo tEplDllkNodeInfo;
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
tEplKernel EplDllkAddInstance(tEplDllkInitParam * pInitParam_p);
tEplKernel EplDllkDelInstance(void);
// called before NMT_GS_COMMUNICATING will be entered to configure fixed parameters
tEplKernel EplDllkConfig(tEplDllConfigParam * pDllConfigParam_p);
// set identity of local node (may be at any time, e.g. in case of hostname change)
tEplKernel EplDllkSetIdentity(tEplDllIdentParam * pDllIdentParam_p);
// process internal events and do work that cannot be done in interrupt-context
tEplKernel EplDllkProcess(tEplEvent * pEvent_p);
// registers handler for non-EPL frames
tEplKernel EplDllkRegAsyncHandler(tEplDllkCbAsync pfnDllkCbAsync_p);
// deregisters handler for non-EPL frames
tEplKernel EplDllkDeregAsyncHandler(tEplDllkCbAsync pfnDllkCbAsync_p);
// register C_DLL_MULTICAST_ASND in ethernet driver if any AsndServiceId is registered
tEplKernel EplDllkSetAsndServiceIdFilter(tEplDllAsndServiceId ServiceId_p, tEplDllAsndFilter Filter_p);
// creates the buffer for a Tx frame and registers it to the ethernet driver
tEplKernel EplDllkCreateTxFrame(unsigned int * puiHandle_p,
tEplFrame ** ppFrame_p,
unsigned int * puiFrameSize_p,
tEplMsgType MsgType_p,
tEplDllAsndServiceId ServiceId_p);
tEplKernel EplDllkDeleteTxFrame(unsigned int uiHandle_p);
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
tEplKernel EplDllkAddNode(tEplDllNodeInfo * pNodeInfo_p);
tEplKernel EplDllkDeleteNode(unsigned int uiNodeId_p);
tEplKernel EplDllkSoftDeleteNode(unsigned int uiNodeId_p);
tEplKernel EplDllkSetFlag1OfNode(unsigned int uiNodeId_p, BYTE bSoaFlag1_p);
tEplKernel EplDllkGetFirstNodeInfo(tEplDllkNodeInfo** ppNodeInfo_p);
#endif //(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
#endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
#endif // #ifndef _EPL_DLLK_H_

View file

@ -0,0 +1,136 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for kernelspace DLL Communication Abstraction Layer module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplDllkCal.h,v $
$Author: D.Krueger $
$Revision: 1.6 $ $Date: 2008/11/13 17:13:09 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/13 d.k.: start of the implementation, version 1.00
****************************************************************************/
#ifndef _EPL_DLLKCAL_H_
#define _EPL_DLLKCAL_H_
#include "../EplDll.h"
#include "../EplEvent.h"
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
typedef struct
{
unsigned long m_ulCurTxFrameCountGen;
unsigned long m_ulCurTxFrameCountNmt;
unsigned long m_ulCurRxFrameCount;
unsigned long m_ulMaxTxFrameCountGen;
unsigned long m_ulMaxTxFrameCountNmt;
unsigned long m_ulMaxRxFrameCount;
} tEplDllkCalStatistics;
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
tEplKernel EplDllkCalAddInstance(void);
tEplKernel EplDllkCalDelInstance(void);
tEplKernel EplDllkCalAsyncGetTxCount(tEplDllAsyncReqPriority * pPriority_p, unsigned int * puiCount_p);
tEplKernel EplDllkCalAsyncGetTxFrame(void * pFrame_p, unsigned int * puiFrameSize_p, tEplDllAsyncReqPriority Priority_p);
// only frames with registered AsndServiceIds are passed to CAL
tEplKernel EplDllkCalAsyncFrameReceived(tEplFrameInfo * pFrameInfo_p);
tEplKernel EplDllkCalAsyncSend(tEplFrameInfo * pFrameInfo_p, tEplDllAsyncReqPriority Priority_p);
tEplKernel EplDllkCalAsyncClearBuffer(void);
tEplKernel EplDllkCalGetStatistics(tEplDllkCalStatistics ** ppStatistics);
tEplKernel EplDllkCalProcess(tEplEvent * pEvent_p);
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
tEplKernel EplDllkCalAsyncClearQueues(void);
tEplKernel EplDllkCalIssueRequest(tEplDllReqServiceId Service_p, unsigned int uiNodeId_p, BYTE bSoaFlag1_p);
tEplKernel EplDllkCalAsyncGetSoaRequest(tEplDllReqServiceId* pReqServiceId_p, unsigned int* puiNodeId_p);
tEplKernel EplDllkCalAsyncSetPendingRequests(unsigned int uiNodeId_p, tEplDllAsyncReqPriority AsyncReqPrio_p, unsigned int uiCount_p);
#endif //(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
#endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
#endif // #ifndef _EPL_DLLKCAL_H_

View file

@ -0,0 +1,104 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for kernel error handler module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplErrorHandlerk.h,v $
$Author: D.Krueger $
$Revision: 1.4 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/10/02 d.k.: start of the implementation, version 1.00
****************************************************************************/
#ifndef _EPL_ERRORHANDLERK_H_
#define _EPL_ERRORHANDLERK_H_
#include "../EplEvent.h"
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
// init function
tEplKernel PUBLIC EplErrorHandlerkInit(void);
// add instance
tEplKernel PUBLIC EplErrorHandlerkAddInstance(void);
// delete instance
tEplKernel PUBLIC EplErrorHandlerkDelInstance(void);
// processes error events
tEplKernel PUBLIC EplErrorHandlerkProcess(tEplEvent * pEvent_p);
#endif // #ifndef _EPL_ERRORHANDLERK_H_

View file

@ -0,0 +1,114 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for kernel event module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplEventk.h,v $
$Author: D.Krueger $
$Revision: 1.4 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/12 d.k.: start of the implementation, version 1.00
****************************************************************************/
#ifndef _EPL_EVENTK_H_
#define _EPL_EVENTK_H_
#include "../EplEvent.h"
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
// init function
tEplKernel PUBLIC EplEventkInit(tEplSyncCb fpSyncCb);
// add instance
tEplKernel PUBLIC EplEventkAddInstance(tEplSyncCb fpSyncCb);
// delete instance
tEplKernel PUBLIC EplEventkDelInstance(void);
// Kernelthread that dispatches events in kernelspace
tEplKernel PUBLIC EplEventkProcess(tEplEvent * pEvent_p);
// post events from kernelspace
tEplKernel PUBLIC EplEventkPost(tEplEvent * pEvent_p);
// post errorevents from kernelspace
tEplKernel PUBLIC EplEventkPostError(tEplEventSource EventSource_p,
tEplKernel EplError_p,
unsigned int uiArgSize_p,
void* pArg_p);
#endif // #ifndef _EPL_EVENTK_H_

View file

@ -0,0 +1,110 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for NMT-Kernelspace-Module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplNmtk.h,v $
$Author: D.Krueger $
$Revision: 1.5 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/09 k.t.: start of the implementation
****************************************************************************/
#ifndef _EPLNMTK_H_
#define _EPLNMTK_H_
#include "../EplNmt.h"
#include "EplEventk.h"
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0)
EPLDLLEXPORT tEplKernel PUBLIC EplNmtkInit(EPL_MCO_DECL_PTR_INSTANCE_PTR);
EPLDLLEXPORT tEplKernel PUBLIC EplNmtkAddInstance(EPL_MCO_DECL_PTR_INSTANCE_PTR);
EPLDLLEXPORT tEplKernel PUBLIC EplNmtkDelInstance(EPL_MCO_DECL_PTR_INSTANCE_PTR);
EPLDLLEXPORT tEplKernel PUBLIC EplNmtkProcess(EPL_MCO_DECL_PTR_INSTANCE_PTR_
tEplEvent * pEvent_p);
EPLDLLEXPORT tEplNmtState PUBLIC EplNmtkGetNmtState(EPL_MCO_DECL_PTR_INSTANCE_PTR);
#endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0)
#endif // #ifndef _EPLNMTK_H_

View file

@ -0,0 +1,96 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for communication abstraction layer of the
NMT-Kernel-Module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplNmtkCal.h,v $
$Author: D.Krueger $
$Revision: 1.3 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
KEIL uVision 2
-------------------------------------------------------------------------
Revision History:
2006/06/16 -k.t.: start of the implementation
****************************************************************************/
#include "EplNmtk.h"
#ifndef _EPLNMTKCAL_H_
#define _EPLNMTKCAL_H_
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#endif // #ifndef _EPLNMTKCAL_H_

View file

@ -0,0 +1,196 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for Epl-Obd-Kernel-Modul
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplObdk.h,v $
$Author: D.Krueger $
$Revision: 1.8 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/19 k.t.: start of the implementation
****************************************************************************/
#include "../EplObd.h"
#ifndef _EPLOBDK_H_
#define _EPLOBDK_H_
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// global variables
//---------------------------------------------------------------------------
extern BYTE MEM abEplObdTrashObject_g[8];
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
// ---------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObdInit (EPL_MCO_DECL_PTR_INSTANCE_PTR_
tEplObdInitParam MEM* pInitParam_p);
// ---------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObdAddInstance (EPL_MCO_DECL_PTR_INSTANCE_PTR_
tEplObdInitParam MEM* pInitParam_p);
// ---------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObdDeleteInstance (EPL_MCO_DECL_INSTANCE_PTR);
// ---------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObdWriteEntry (EPL_MCO_DECL_INSTANCE_PTR_
unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void * pSrcData_p,
tEplObdSize Size_p);
// ---------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObdReadEntry (EPL_MCO_DECL_INSTANCE_PTR_
unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void * pDstData_p,
tEplObdSize *pSize_p);
// ---------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObdSetStoreLoadObjCallback (EPL_MCO_DECL_INSTANCE_PTR_
tEplObdStoreLoadObjCallback fpCallback_p);
// ---------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObdAccessOdPart (EPL_MCO_DECL_INSTANCE_PTR_
tEplObdPart ObdPart_p,
tEplObdDir Direction_p);
// ---------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObdDefineVar (EPL_MCO_DECL_INSTANCE_PTR_
tEplVarParam MEM* pVarParam_p);
// ---------------------------------------------------------------------
EPLDLLEXPORT void* PUBLIC EplObdGetObjectDataPtr (EPL_MCO_DECL_INSTANCE_PTR_
unsigned int uiIndex_p,
unsigned int uiSubIndex_p);
// ---------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObdRegisterUserOd (EPL_MCO_DECL_INSTANCE_PTR_
tEplObdEntryPtr pUserOd_p);
// ---------------------------------------------------------------------
EPLDLLEXPORT void PUBLIC EplObdInitVarEntry (EPL_MCO_DECL_INSTANCE_PTR_
tEplObdVarEntry MEM* pVarEntry_p,
tEplObdType Type_p, tEplObdSize ObdSize_p);
// ---------------------------------------------------------------------
EPLDLLEXPORT tEplObdSize PUBLIC EplObdGetDataSize(EPL_MCO_DECL_INSTANCE_PTR_
unsigned int uiIndex_p,
unsigned int uiSubIndex_p);
// ---------------------------------------------------------------------
EPLDLLEXPORT unsigned int PUBLIC EplObdGetNodeId(EPL_MCO_DECL_INSTANCE_PTR);
// ---------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObdSetNodeId(EPL_MCO_DECL_INSTANCE_PTR_
unsigned int uiNodeId_p,
tEplObdNodeIdType NodeIdType_p);
// ---------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObdIsNumerical(EPL_MCO_DECL_INSTANCE_PTR_
unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
BOOL* pfEntryNumerical);
// ---------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObdWriteEntryFromLe (EPL_MCO_DECL_INSTANCE_PTR_
unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void * pSrcData_p,
tEplObdSize Size_p);
// ---------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObdReadEntryToLe (EPL_MCO_DECL_INSTANCE_PTR_
unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
void * pDstData_p,
tEplObdSize *pSize_p);
// ---------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObdGetAccessType(EPL_MCO_DECL_INSTANCE_PTR_
unsigned int uiIndex_p,
unsigned int uiSubIndex_p,
tEplObdAccess* pAccessTyp_p);
// ---------------------------------------------------------------------
EPLDLLEXPORT tEplKernel PUBLIC EplObdSearchVarEntry (EPL_MCO_DECL_INSTANCE_PTR_
unsigned int uiIndex_p,
unsigned int uiSubindex_p,
tEplObdVarEntry MEM** ppVarEntry_p);
#endif // end of #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
#endif // #ifndef _EPLOBDK_H_

View file

@ -0,0 +1,96 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for communication abstraction layer
for the Epl-Obd-Kernelspace-Modul
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplObdkCal.h,v $
$Author: D.Krueger $
$Revision: 1.4 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/19 k.t.: start of the implementation
****************************************************************************/
#include "../EplObd.h"
#ifndef _EPLOBDKCAL_H_
#define _EPLOBDKCAL_H_
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#endif // #ifndef _EPLOBDKCAL_H_

View file

@ -0,0 +1,116 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for kernel PDO module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplPdok.h,v $
$Author: D.Krueger $
$Revision: 1.5 $ $Date: 2008/06/23 14:56:33 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/05/22 d.k.: start of the implementation, version 1.00
****************************************************************************/
#ifndef _EPL_PDOK_H_
#define _EPL_PDOK_H_
#include "../EplPdo.h"
#include "../EplEvent.h"
#include "../EplDll.h"
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
// process events from queue (PDOs/frames and SoA for synchronization)
tEplKernel EplPdokProcess(tEplEvent * pEvent_p);
// copies RPDO to event queue for processing
// is called by DLL in NMT_CS_READY_TO_OPERATE and NMT_CS_OPERATIONAL
// PDO needs not to be valid
tEplKernel EplPdokCbPdoReceived(tEplFrameInfo * pFrameInfo_p);
// posts pointer and size of TPDO to event queue
// is called by DLL in NMT_CS_PRE_OPERATIONAL_2,
// NMT_CS_READY_TO_OPERATE and NMT_CS_OPERATIONAL
tEplKernel EplPdokCbPdoTransmitted(tEplFrameInfo * pFrameInfo_p);
// posts SoA event to queue
tEplKernel EplPdokCbSoa(tEplFrameInfo * pFrameInfo_p);
tEplKernel EplPdokAddInstance(void);
tEplKernel EplPdokDelInstance(void);
#endif // #ifndef _EPL_PDOK_H_

View file

@ -0,0 +1,106 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for kernel PDO Communication Abstraction Layer module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplPdokCal.h,v $
$Author: D.Krueger $
$Revision: 1.4 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/26 d.k.: start of the implementation, version 1.00
****************************************************************************/
#ifndef _EPL_PDOKCAL_H_
#define _EPL_PDOKCAL_H_
#include "../EplInc.h"
//#include "EplPdo.h"
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
tEplKernel EplPdokCalAddInstance(void);
tEplKernel EplPdokCalDelInstance(void);
// sets flag for validity of TPDOs in shared memory
tEplKernel EplPdokCalSetTpdosValid(BOOL fValid_p);
// gets flag for validity of TPDOs from shared memory
tEplKernel EplPdokCalAreTpdosValid(BOOL * pfValid_p);
#endif // #ifndef _EPL_PDOKCAL_H_

View file

@ -0,0 +1,112 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for EPL high resolution Timermodule
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplTimerHighResk.h,v $
$Author: D.Krueger $
$Revision: 1.3 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/09/29 d.k.: start of the implementation
****************************************************************************/
#include "../EplTimer.h"
#ifndef _EPLTIMERHIGHRESK_H_
#define _EPLTIMERHIGHRESK_H_
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplTimerHighReskInit(void);
tEplKernel PUBLIC EplTimerHighReskAddInstance(void);
tEplKernel PUBLIC EplTimerHighReskDelInstance(void);
tEplKernel PUBLIC EplTimerHighReskSetTimerNs(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 PUBLIC EplTimerHighReskDeleteTimer(tEplTimerHdl* pTimerHdl_p);
#endif // #ifndef _EPLTIMERHIGHRESK_H_

View file

@ -0,0 +1,122 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for EPL Kernel-Timermodule
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplTimerk.h,v $
$Author: D.Krueger $
$Revision: 1.4 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/07/06 k.t.: start of the implementation
****************************************************************************/
#include "../EplTimer.h"
#include "../user/EplEventu.h"
#ifndef _EPLTIMERK_H_
#define _EPLTIMERK_H_
#if EPL_TIMER_USE_USER != FALSE
#include "../user/EplTimeru.h"
#endif
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
#if EPL_TIMER_USE_USER != FALSE
#define EplTimerkInit EplTimeruInit
#define EplTimerkAddInstance EplTimeruAddInstance
#define EplTimerkDelInstance EplTimeruDelInstance
#define EplTimerkSetTimerMs EplTimeruSetTimerMs
#define EplTimerkModifyTimerMs EplTimeruModifyTimerMs
#define EplTimerkDeleteTimer EplTimeruDeleteTimer
#endif
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#if EPL_TIMER_USE_USER == FALSE
tEplKernel PUBLIC EplTimerkInit(void);
tEplKernel PUBLIC EplTimerkAddInstance(void);
tEplKernel PUBLIC EplTimerkDelInstance(void);
tEplKernel PUBLIC EplTimerkSetTimerMs(tEplTimerHdl* pTimerHdl_p,
unsigned long ulTime_p,
tEplTimerArg Argument_p);
tEplKernel PUBLIC EplTimerkModifyTimerMs(tEplTimerHdl* pTimerHdl_p,
unsigned long ulTime_p,
tEplTimerArg Argument_p);
tEplKernel PUBLIC EplTimerkDeleteTimer(tEplTimerHdl* pTimerHdl_p);
#endif
#endif // #ifndef _EPLTIMERK_H_

View file

@ -0,0 +1,101 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for virtual ethernet driver module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: VirtualEthernet.h,v $
$Author: D.Krueger $
$Revision: 1.4 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
KEIL uVision 2
-------------------------------------------------------------------------
Revision History:
2006/09/19 d.k.: start of the implementation, version 1.00
****************************************************************************/
#ifndef _EPL_VETH_H_
#define _EPL_VETH_H_
#include "EplDllk.h"
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_VETH)) != 0)
tEplKernel PUBLIC VEthAddInstance(tEplDllkInitParam * pInitParam_p);
tEplKernel PUBLIC VEthDelInstance(void);
#endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_VETH)) != 0)
#endif // #ifndef _EPL_VETH_H_

View file

@ -0,0 +1,420 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: proc fs entry with diagnostic information under Linux
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: proc_fs.c,v $
$Author: D.Krueger $
$Revision: 1.13 $ $Date: 2008/11/07 13:55:56 $
$State: Exp $
Build Environment:
GNU
-------------------------------------------------------------------------
Revision History:
2006/07/31 d.k.: start of implementation
****************************************************************************/
#include "kernel/EplNmtk.h"
#include "user/EplNmtu.h"
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
#include "user/EplNmtMnu.h"
#endif
#include "kernel/EplDllkCal.h"
//#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/major.h>
#include <linux/version.h>
#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/atomic.h>
#include <linux/proc_fs.h>
#include <linux/spinlock.h>
#ifdef CONFIG_COLDFIRE
#include <asm/coldfire.h>
#include "fec.h"
#endif
/***************************************************************************/
/* */
/* */
/* G L O B A L D E F I N I T I O N S */
/* */
/* */
/***************************************************************************/
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
#ifndef EPL_PROC_DEV_NAME
#define EPL_PROC_DEV_NAME "epl"
#endif
#ifndef DBG_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)
#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;
#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);
EPLDLLEXPORT DWORD PUBLIC EplIdentuGetRunningRequests(void);
//=========================================================================//
// //
// P U B L I C F U N C T I O N S //
// //
//=========================================================================//
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
}
else
{
return kEplNoResource;
}
#ifdef _DBG_TRACE_POINTS_
// initialize spinlock and circular buffer position
spin_lock_init(&spinlockDbgTraceValue_l);
uiDbgTraceValuePos_l = 0;
dwDbgTraceValueOld_l = 0;
#endif
return kEplSuccessful;
}
tEplKernel EplLinProcFree(void)
{
remove_proc_entry (EPL_PROC_DEV_NAME, NULL);
return kEplSuccessful;
}
//---------------------------------------------------------------------------
// Target specific event signaling (FEC Tx-/Rx-Interrupt, used by Edrv)
//---------------------------------------------------------------------------
#ifdef _DBG_TRACE_POINTS_
void PUBLIC TgtDbgSignalTracePoint (
BYTE bTracePointNumber_p)
{
if (bTracePointNumber_p >= (sizeof(aatmDbgTracePoint_l) / sizeof(aatmDbgTracePoint_l[0])))
{
goto Exit;
}
atomic_inc (&aatmDbgTracePoint_l[bTracePointNumber_p]);
Exit:
return;
}
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);
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)
{
int nSize;
int Eof;
tEplDllkCalStatistics* pDllkCalStats;
nSize = 0;
Eof = 0;
// count calls of this function
#ifdef _DBG_TRACE_POINTS_
TgtDbgSignalTracePoint(0);
#endif
//---------------------------------------------------------------
// 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);
//---------------------------------------------------------------
// generate process information
//---------------------------------------------------------------
// ---- EPL state ----
nSize += snprintf (pcBuffer_p + nSize, nBufferSize_p - nSize,
"NMT state: 0x%04X\n",
(WORD) EplNmtkGetNmtState());
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);
#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 state of NmtMnu module
{
unsigned int uiMandatorySlaveCount;
unsigned int uiSignalSlaveCount;
WORD 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);
}
#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
// ---- 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,
"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:
*pEof_p = Eof;
return (nSize);
}
//---------------------------------------------------------------------------
// Write function for PROC-FS write access
//---------------------------------------------------------------------------
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;
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);
return count;
}

View file

@ -0,0 +1,94 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: interface for proc fs entry under Linux
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: proc_fs.h,v $
$Author: D.Krueger $
$Revision: 1.3 $ $Date: 2008/04/17 21:36:33 $
$State: Exp $
Build Environment:
GNU
-------------------------------------------------------------------------
Revision History:
2006/07/31 d.k.: start of implementation
****************************************************************************/
#ifndef _EPLPROCFS_H_
#define _EPLPROCFS_H_
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// types
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
tEplKernel EplLinProcInit(void);
tEplKernel EplLinProcFree(void);
#endif // #ifndef _EPLPROCFS_H_

View file

@ -0,0 +1,299 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for Epl Configuration Manager Module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplCfgMau.h,v $
$Author: D.Krueger $
$Revision: 1.4 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
VC7
-------------------------------------------------------------------------
Revision History:
2006/07/14 k.t.: start of the implementation
-> based on CANopen CfgMa-Modul (CANopen version 5.34)
****************************************************************************/
#include "../EplInc.h"
#ifndef _EPLCFGMA_H_
#define _EPLCFGMA_H_
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_CFGMA)) != 0)
#include "EplObdu.h"
#include "EplSdoComu.h"
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
//define max number of timeouts for configuration of 1 device
#define EPL_CFGMA_MAX_TIMEOUT 3
//callbackfunction, called if configuration is finished
typedef void (PUBLIC* tfpEplCfgMaCb) (unsigned int uiNodeId_p,
tEplKernel Errorstate_p);
//State for configuartion manager Statemachine
typedef enum
{
// general states
kEplCfgMaIdle = 0x0000, // Configurationsprocess
// is idle
kEplCfgMaWaitForSdocEvent = 0x0001, // wait until the last
// SDOC is finisched
kEplCfgMaSkipMappingSub0 = 0x0002, // write Sub0 of mapping
// parameter with 0
kEplCfgMaFinished = 0x0004 // configuartion is finished
} tEplCfgState;
typedef enum
{
kEplCfgMaDcfTypSystecSeg = 0x00,
kEplCfgMaDcfTypConDcf = 0x01,
kEplCfgMaDcfTypDcf = 0x02, // not supported
kEplCfgMaDcfTypXdc = 0x03 // not supported
}tEplCfgMaDcfTyp;
typedef enum
{
kEplCfgMaCommon = 0, // all other index
kEplCfgMaPdoComm = 1, // communication index
kEplCfgMaPdoMapp = 2, // mapping index
kEplCfgMaPdoCommAfterMapp = 3, // write PDO Cob-Id after mapping subindex 0(set PDO valid)
} tEplCfgMaIndexType;
//bitcoded answer about the last sdo transfer saved in m_SdocState
// also used to singal start of the State Maschine
typedef enum
{
kEplCfgMaSdocBusy = 0x00, // SDOC activ
kEplCfgMaSdocReady = 0x01, // SDOC finished
kEplCfgMaSdocTimeout = 0x02, // SDOC Timeout
kEplCfgMaSdocAbortReceived = 0x04, // SDOC Abort, see Abortcode
kEplCfgMaSdocStart = 0x08 // start State Mschine
}tEplSdocState;
//internal structure (instancetable for modul configuration manager)
typedef struct
{
tEplCfgState m_CfgState; // state of the configuration state maschine
tEplSdoComConHdl m_SdoComConHdl; // handle for sdo connection
DWORD m_dwLastAbortCode;
unsigned int m_uiLastIndex; // last index of configuration, to compair with actual index
BYTE* m_pbConcise; // Ptr to concise DCF
BYTE* m_pbActualIndex; // Ptr to actual index in the DCF segment
tfpEplCfgMaCb m_pfnCfgMaCb; // Ptr to CfgMa Callback, is call if configuration finished
tEplKernel m_EplKernelError; // errorcode
DWORD m_dwNumValueCopy; // numeric values are copied in this variable
unsigned int m_uiPdoNodeId; // buffer for PDO node id
BYTE m_bNrOfMappedObject; // number of mapped objects
unsigned int m_uiNodeId; // Epl node addresse
tEplSdocState m_SdocState; // bitcoded state of the SDO transfer
unsigned int m_uiLastSubIndex; // last subindex of configuration
BOOL m_fOneTranferOk; // atleased one transfer was successful
BYTE m_bEventFlag; // for Eventsignaling to the State Maschine
DWORD m_dwCntObjectInDcf; // number of Objects in DCF
tEplCfgMaIndexType m_SkipCfg; // TRUE if a adsitional Configurationprocess
// have to insert e.g. PDO-mapping
WORD m_wTimeOutCnt; // Timeout Counter, break configuration is
// m_wTimeOutCnt == CFGMA_MAX_TIMEOUT
} tEplCfgMaNode;
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// Function: EplCfgMaInit()
//
// Description: Function creates first instance of Configuration Manager
//
// Parameters:
//
// Returns: tEplKernel = error code
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplCfgMaInit();
//---------------------------------------------------------------------------
// Function: EplCfgMaAddInstance()
//
// Description: Function creates additional instance of Configuration Manager
//
// Parameters:
//
// Returns: tEplKernel = error code
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplCfgMaAddInstance();
//---------------------------------------------------------------------------
// Function: EplCfgMaDelInstance()
//
// Description: Function delete instance of Configuration Manager
//
// Parameters:
//
// Returns: tEplKernel = error code
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplCfgMaDelInstance();
//---------------------------------------------------------------------------
// Function: EplCfgMaStartConfig()
//
// Description: Function starts the configuration process
// initialization the statemachine for CfgMa- process
//
// Parameters: uiNodeId_p = NodeId of the node to configure
// pbConcise_p = pointer to DCF
// fpCfgMaCb_p = pointer to callback function (should not be NULL)
// SizeOfConcise_p = size of DCF in BYTE -> for future use
// DcfType_p = type of the DCF
//
// Returns: tCopKernel = error code
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplCfgMaStartConfig(unsigned int uiNodeId_p,
BYTE* pbConcise_p,
tfpEplCfgMaCb fpCfgMaCb_p,
tEplObdSize SizeOfConcise_p,
tEplCfgMaDcfTyp DcfType_p);
//---------------------------------------------------------------------------
// Function: CfgMaStartConfigurationNode()
//
// Description: Function started the configuration process
// with the DCF from according OD-entry Subindex == bNodeId_p
//
// Parameters: uiNodeId_p = NodeId of the node to configure
// fpCfgMaCb_p = pointer to callback function (should not be NULL)
// DcfType_p = type of the DCF
//
// Returns: tCopKernel = error code
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplCfgMaStartConfigNode(unsigned int uiNodeId_p,
tfpEplCfgMaCb fpCfgMaCb_p,
tEplCfgMaDcfTyp DcfType_p);
//---------------------------------------------------------------------------
// Function: EplCfgMaStartConfigNodeDcf()
//
// Description: Function starts the configuration process
// and links the configuration data to the OD
//
// Parameters: uiNodeId_p = NodeId of the node to configure
// pbConcise_p = pointer to DCF
// fpCfgMaCb_p = pointer to callback function (should not be NULL)
// SizeOfConcise_p = size of DCF in BYTE -> for future use
// DcfType_p = type of the DCF
//
// Returns: tCopKernel = error code
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplCfgMaStartConfigNodeDcf(unsigned int uiNodeId_p,
BYTE* pbConcise_p,
tfpEplCfgMaCb fpCfgMaCb_p,
tEplObdSize SizeOfConcise_p,
tEplCfgMaDcfTyp DcfType_p);
//---------------------------------------------------------------------------
// Function: EplCfgMaLinkDcf()
//
// Description: Function links the configuration data to the OD
//
// Parameters: uiNodeId_p = NodeId of the node to configure
// pbConcise_p = pointer to DCF
// SizeOfConcise_p = size of DCF in BYTE -> for future use
// DcfType_p = type of the DCF
//
// Returns: tCopKernel = error code
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplCfgMaLinkDcf(unsigned int uiNodeId_p,
BYTE* pbConcise_p,
tEplObdSize SizeOfConcise_p,
tEplCfgMaDcfTyp DcfType_p);
//---------------------------------------------------------------------------
// Function: EplCfgMaCheckDcf()
//
// Description: Function check if there is allready a configuration file linked
// to the OD (type is given by DcfType_p)
//
// Parameters: uiNodeId_p = NodeId
// DcfType_p = type of the DCF
//
// Returns: tCopKernel = error code
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplCfgMaCheckDcf(unsigned int uiNodeId_p,
tEplCfgMaDcfTyp DcfType_p);
#endif // #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_CFGMA)) != 0)
#endif // _EPLCFGMA_H_
// EOF

View file

@ -0,0 +1,108 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for userspace DLL module for asynchronous communication
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplDllu.h,v $
$Author: D.Krueger $
$Revision: 1.5 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/20 d.k.: start of the implementation, version 1.00
****************************************************************************/
#ifndef _EPL_DLLU_H_
#define _EPL_DLLU_H_
#include "../EplDll.h"
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
typedef tEplKernel (PUBLIC * tEplDlluCbAsnd) (tEplFrameInfo * pFrameInfo_p);
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
tEplKernel EplDlluAddInstance(void);
tEplKernel EplDlluDelInstance(void);
tEplKernel EplDlluRegAsndService(tEplDllAsndServiceId ServiceId_p, tEplDlluCbAsnd pfnDlluCbAsnd_p, tEplDllAsndFilter Filter_p);
tEplKernel EplDlluAsyncSend(tEplFrameInfo * pFrameInfo_p, tEplDllAsyncReqPriority Priority_p);
// processes asynch frames
tEplKernel EplDlluProcess(tEplFrameInfo * pFrameInfo_p);
#endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLU)) != 0)
#endif // #ifndef _EPL_DLLU_H_

View file

@ -0,0 +1,120 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for DLL Communication Abstraction Layer module in EPL user part
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplDlluCal.h,v $
$Author: D.Krueger $
$Revision: 1.5 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/20 d.k.: start of the implementation, version 1.00
****************************************************************************/
#ifndef _EPL_DLLUCAL_H_
#define _EPL_DLLUCAL_H_
#include "../EplDll.h"
#include "../EplEvent.h"
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
typedef tEplKernel (PUBLIC * tEplDlluCbAsnd) (tEplFrameInfo * pFrameInfo_p);
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
tEplKernel EplDlluCalAddInstance(void);
tEplKernel EplDlluCalDelInstance(void);
tEplKernel EplDlluCalRegAsndService(tEplDllAsndServiceId ServiceId_p,
tEplDlluCbAsnd pfnDlluCbAsnd_p,
tEplDllAsndFilter Filter_p);
tEplKernel EplDlluCalAsyncSend(tEplFrameInfo * pFrameInfo, tEplDllAsyncReqPriority Priority_p);
tEplKernel EplDlluCalProcess(tEplEvent * pEvent_p);
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
tEplKernel EplDlluCalAddNode(tEplDllNodeInfo * pNodeInfo_p);
tEplKernel EplDlluCalDeleteNode(unsigned int uiNodeId_p);
tEplKernel EplDlluCalSoftDeleteNode(unsigned int uiNodeId_p);
tEplKernel EplDlluCalIssueRequest(tEplDllReqServiceId Service_p, unsigned int uiNodeId_p, BYTE bSoaFlag1_p);
#endif
#endif // #ifndef _EPL_DLLUCAL_H_

View file

@ -0,0 +1,115 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for kernel event module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplEventu.h,v $
$Author: D.Krueger $
$Revision: 1.4 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/12 d.k.: start of the implementation, version 1.00
****************************************************************************/
#ifndef _EPL_EVENTU_H_
#define _EPL_EVENTU_H_
#include "../EplEvent.h"
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
// init function
tEplKernel PUBLIC EplEventuInit(tEplProcessEventCb pfnApiProcessEventCb_p);
// add instance
tEplKernel PUBLIC EplEventuAddInstance(tEplProcessEventCb pfnApiProcessEventCb_p);
// delete instance
tEplKernel PUBLIC EplEventuDelInstance(void);
// Task that dispatches events in userspace
tEplKernel PUBLIC EplEventuProcess(tEplEvent * pEvent_p);
// post events from userspace
tEplKernel PUBLIC EplEventuPost(tEplEvent * pEvent_p);
// post errorevents from userspace
tEplKernel PUBLIC EplEventuPostError(tEplEventSource EventSource_p,
tEplKernel EplError_p,
unsigned int uiArgSize_p,
void* pArg_p);
#endif // #ifndef _EPL_EVENTU_H_

View file

@ -0,0 +1,113 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for Identu-Module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplIdentu.h,v $
$Author: D.Krueger $
$Revision: 1.3 $ $Date: 2008/04/17 21:36:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/11/15 d.k.: start of the implementation
****************************************************************************/
#include "../EplDll.h"
#ifndef _EPLIDENTU_H_
#define _EPLIDENTU_H_
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
typedef tEplKernel (PUBLIC * tEplIdentuCbResponse) (
unsigned int uiNodeId_p,
tEplIdentResponse* pIdentResponse_p);
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplIdentuInit(void);
tEplKernel PUBLIC EplIdentuAddInstance(void);
tEplKernel PUBLIC EplIdentuDelInstance(void);
tEplKernel PUBLIC EplIdentuReset(void);
tEplKernel PUBLIC EplIdentuGetIdentResponse(
unsigned int uiNodeId_p,
tEplIdentResponse** ppIdentResponse_p);
tEplKernel PUBLIC EplIdentuRequestIdentResponse(
unsigned int uiNodeId_p,
tEplIdentuCbResponse pfnCbResponse_p);
#endif // #ifndef _EPLIDENTU_H_

View file

@ -0,0 +1,116 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for status and error LED user part module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplLedu.h,v $
$Author: D.Krueger $
$Revision: 1.1 $ $Date: 2008/11/17 16:40:39 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2008/11/17 d.k.: start of the implementation
****************************************************************************/
#include "../EplLed.h"
#include "../EplNmt.h"
#include "EplEventu.h"
#ifndef _EPLLEDU_H_
#define _EPLLEDU_H_
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
typedef tEplKernel (PUBLIC * tEplLeduStateChangeCallback) (
tEplLedType LedType_p, BOOL fOn_p);
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_LEDU)) != 0)
tEplKernel PUBLIC EplLeduInit(tEplLeduStateChangeCallback pfnCbStateChange_p);
tEplKernel PUBLIC EplLeduAddInstance(tEplLeduStateChangeCallback pfnCbStateChange_p);
tEplKernel PUBLIC EplLeduDelInstance(void);
tEplKernel PUBLIC EplLeduCbNmtStateChange(tEplEventNmtStateChange NmtStateChange_p);
tEplKernel PUBLIC EplLeduProcessEvent(
tEplEvent* pEplEvent_p);
#endif // #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_LEDU)) != 0)
#endif // #ifndef _EPLLEDU_H_

View file

@ -0,0 +1,112 @@
/****************************************************************************
(c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
www.systec-electronic.com
Project: openPOWERLINK
Description: include file for NMT-CN-Userspace-Module
License:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of SYSTEC electronic GmbH nor the names of its
contributors may be used to endorse or promote products derived
from this software without prior written permission. For written
permission, please contact info@systec-electronic.com.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Severability Clause:
If a provision of this License is or becomes illegal, invalid or
unenforceable in any jurisdiction, that shall not affect:
1. the validity or enforceability in that jurisdiction of any other
provision of this License; or
2. the validity or enforceability in other jurisdictions of that or
any other provision of this License.
-------------------------------------------------------------------------
$RCSfile: EplNmtCnu.h,v $
$Author: D.Krueger $
$Revision: 1.5 $ $Date: 2008/10/17 15:32:32 $
$State: Exp $
Build Environment:
GCC V3.4
-------------------------------------------------------------------------
Revision History:
2006/06/09 k.t.: start of the implementation
****************************************************************************/
#include "EplNmtu.h"
#include "../EplDll.h"
#include "../EplFrame.h"
#ifndef _EPLNMTCNU_H_
#define _EPLNMTCNU_H_
//---------------------------------------------------------------------------
// const defines
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// typedef
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
// function prototypes
//---------------------------------------------------------------------------
#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_CN)) != 0)
EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuInit(unsigned int uiNodeId_p);
EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuAddInstance(unsigned int uiNodeId_p);
EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuDelInstance(void);
EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuSendNmtRequest (unsigned int uiNodeId_p,
tEplNmtCommand NmtCommand_p);
EPLDLLEXPORT tEplKernel PUBLIC EplNmtCnuRegisterCheckEventCb(
tEplNmtuCheckEventCallback pfnEplNmtCheckEventCb_p);
#endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_CN)) != 0)
#endif // #ifndef _EPLNMTCNU_H_

Some files were not shown because too many files have changed in this diff Show more