Merge branch 'prepare_for_master' of https://git.trustie.net/xuos/xiuos into xidatong

This commit is contained in:
Liu_Weichao 2022-07-07 18:22:38 +08:00
commit c5a0cbf95e
1906 changed files with 617471 additions and 306 deletions

@ -0,0 +1 @@
Subproject commit d7ac9f271158d1f8ed1ebaddcb8c2ce4b0927d19

View File

@ -0,0 +1,18 @@
import os
Import('RTT_ROOT')
from building import *
SOURCES = []
SOURCES = ['adapter_4g.c'] + SOURCES
objs = []
cwd = GetCurrentDir()
path = [cwd]
group = DefineGroup('4g', SOURCES, depend = [], CPPPATH = [cwd])
objs = objs + group
list = os.listdir(cwd)
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(path, 'SConscript'))
Return('objs')

View File

@ -111,3 +111,6 @@ int Adapter4GTest(void)
return 0;
}
// SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0)|SHELL_CMD_DISABLE_RETURN, Adapter4GTest, Adapter4GTest, show adapter 4G information);
#ifdef ADD_RTTHREAD_FETURES
MSH_CMD_EXPORT(Adapter4GTestRTThread,a 4G adpter sample);
#endif

View File

@ -3,19 +3,13 @@ config ADAPTER_4G_EC200T
default "ec200t"
if ADD_XIZI_FETURES
config ADAPTER_EC200T_USING_PWRKEY
bool "EC200T using PWRKEY pin number"
default n
config ADAPTER_EC200T_PWRKEY
int "EC200T PWRKEY pin number"
default "97"
if ADAPTER_EC200T_USING_PWRKEY
config ADAPTER_EC200T_PWRKEY
int "EC200T PWRKEY pin number"
default "97"
config ADAPTER_EC200T_PIN_DRIVER
string "EC200T device pin driver path"
default "/dev/pin_dev"
endif
config ADAPTER_EC200T_PIN_DRIVER
string "EC200T device pin driver path"
default "/dev/pin_dev"
config ADAPTER_EC200T_DRIVER_EXTUART
bool "Using extra uart to support 4G"
@ -45,5 +39,31 @@ if ADD_NUTTX_FETURES
endif
if ADD_RTTHREAD_FETURES
config ADAPTER_EC200T_PWRKEY
int "EC200T PWRKEY pin number"
default "97"
config ADAPTER_EC200T_PIN_DRIVER
string "EC200T device pin driver path"
default "/dev/pin_dev"
config ADAPTER_EC200T_DRIVER_EXTUART
bool "Using extra uart to support 4G"
default n
config ADAPTER_EC200T_DRIVER
string "EC200T device uart driver path"
default "/dev/usart8"
depends on !ADAPTER_EC200T_DRIVER_EXTUART
if ADAPTER_EC200T_DRIVER_EXTUART
config ADAPTER_EC200T_DRIVER
string "EC200T device extra uart driver path"
default "/dev/extuart_dev5"
config ADAPTER_EC200T_DRIVER_EXT_PORT
int "if EC200T device using extuart, choose port"
default "5"
endif
endif

View File

@ -0,0 +1,10 @@
from building import *
import os
cwd = GetCurrentDir()
src = []
if GetDepend(['ADAPTER_EC200T']):
src += ['ec200t.c']
group = DefineGroup('connection 4g ec200t', src, depend = [], CPPPATH = [cwd])
Return('group')

View File

@ -40,10 +40,12 @@
#ifdef ADD_NUTTX_FETURES
static void Ec200tPowerSet(void){ return; }
#else
static void Ec200tPowerSet(void)
{
#ifdef ADAPTER_EC200T_USING_PWRKEY
#else
#ifdef ADD_RTTHREAD_FETURES
static void Ec200tPowerSet(void){ return; }
#else
static void Ec200tPowerSet(void)
{
int pin_fd;
pin_fd = PrivOpen(ADAPTER_EC200T_PIN_DRIVER, O_RDWR);
if (pin_fd < 0) {
@ -74,8 +76,8 @@ static void Ec200tPowerSet(void)
PrivClose(pin_fd);
PrivTaskDelay(10000);
#endif
}
}
#endif
#endif
static int Ec200tOpen(struct Adapter *adapter)
@ -150,6 +152,9 @@ out:
#ifdef ADD_NUTTX_FETURES
static int Ec200tIoctl(struct Adapter *adapter, int cmd, void *args){ return 0;}
#else
#ifdef ADD_RTTHREAD_FETURES
static int Ec200tIoctl(struct Adapter *adapter, int cmd, void *args){ return 0;}
#else
static int Ec200tIoctl(struct Adapter *adapter, int cmd, void *args)
{
if (OPE_INT != cmd) {
@ -177,12 +182,14 @@ static int Ec200tIoctl(struct Adapter *adapter, int cmd, void *args)
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
ioctl_cfg.args = &serial_cfg;
PrivIoctl(adapter->fd, OPE_INT, &ioctl_cfg);
Ec200tPowerSet();
return 0;
}
#endif
#endif
static int Ec200tConnect(struct Adapter *adapter, enum NetRoleType net_role, const char *ip, const char *port, enum IpType ip_type)
{

View File

@ -5,3 +5,11 @@ config CONNECTION_ADAPTER_ETHERCAT
if CONNECTION_ADAPTER_ETHERCAT
source "$APP_DIR/Framework/connection/industrial_ethernet/ethercat/Kconfig"
endif
menuconfig POWERLINK_MN
bool "Using powerlink MN"
default n
menuconfig POWERLINK_CN
bool "Using powerlink CN"
default n

View File

@ -1,3 +1,55 @@
include $(KERNEL_ROOT)/.config
all: COMPILER
CUR_DIR := $(shell pwd)
OPLK_ROOT := $(CUR_DIR)/openPOWERLINK
LIBOPLKMN := $(OPLK_ROOT)/stack/lib/xiuos/arm/liboplkmn.a
LIBOPLKCN := $(OPLK_ROOT)/stack/lib/xiuos/arm/liboplkcn.a
LIBOPLK_BUILD_DIR := $(OPLK_ROOT)/stack/build/xiuos
OPLK_DEMO_MN_CONSOLE := $(OPLK_ROOT)/bin/xiuos/arm/demo_mn_console/libdemo_mn_console.a
OPLK_DEMO_CN_CONSOLE := $(OPLK_ROOT)/bin/xiuos/arm/demo_cn_console/libdemo_cn_console.a
OPLK_DEMO_MN_CONSOLE_BUILD_DIR := $(OPLK_ROOT)/apps/demo_mn_console/build/xiuos
OPLK_DEMO_CN_CONSOLE_BUILD_DIR := $(OPLK_ROOT)/apps/demo_cn_console/build/xiuos
OPLK_TOOLCHAIN := $(OPLK_ROOT)/cmake/toolchain-xiuos-arm-none-eabi-gnu.cmake
define oplk_build
cd $(1) && \
find . ! -name '.' ! -name '.gitignore' -exec rm -rf {} + && \
cmake -DCMAKE_TOOLCHAIN_FILE=$(OPLK_TOOLCHAIN) ../.. && \
cmake --build . --target install
endef
.PHONY: $(LIBOPLKMN) $(LIBOPLKCN)
$(LIBOPLKMN) $(LIBOPLKCN)&:
$(call oplk_build,$(LIBOPLK_BUILD_DIR))
$(LIBOPLKMN):
$(call oplk_build,$(LIBOPLK_BUILD_DIR))
$(LIBOPLKCN):
$(call oplk_build,$(LIBOPLK_BUILD_DIR))
.PHONY: $(OPLK_DEMO_MN_CONSOLE)
$(OPLK_DEMO_MN_CONSOLE): ${LIBOPLKMN}
$(call oplk_build,$(OPLK_DEMO_MN_CONSOLE_BUILD_DIR))
.PHONY: $(OPLK_DEMO_CN_CONSOLE)
$(OPLK_DEMO_CN_CONSOLE): ${LIBOPLKCN}
$(call oplk_build,$(OPLK_DEMO_CN_CONSOLE_BUILD_DIR))
LIBOPLKMN := $(LIBOPLKMN:$(CUR_DIR)/%=%)
LIBOPLKCN := $(LIBOPLKCN:$(CUR_DIR)/%=%)
OPLK_DEMO_MN_CONSOLE := $(OPLK_DEMO_MN_CONSOLE:$(CUR_DIR)/%=%)
OPLK_DEMO_CN_CONSOLE := $(OPLK_DEMO_CN_CONSOLE:$(CUR_DIR)/%=%)
SRC_FILES := powerlink_demo.c
ifeq ($(CONFIG_POWERLINK_MN)_$(CONFIG_POWERLINK_CN),y_)
SRC_FILES += $(OPLK_DEMO_MN_CONSOLE) $(LIBOPLKMN)
else ifeq ($(CONFIG_POWERLINK_MN)_$(CONFIG_POWERLINK_CN),_y)
SRC_FILES += $(OPLK_DEMO_CN_CONSOLE) $(LIBOPLKCN)
else ifeq ($(CONFIG_POWERLINK_MN)_$(CONFIG_POWERLINK_CN),y_y)
$(error CONFIG_POWERLINK_MN and CONFIG_POWERLINK_CN cannot be enabled simultaneously due to name conflict)
endif
ifeq ($(CONFIG_CONNECTION_ADAPTER_ETHERCAT),y)
SRC_DIR += ethercat
endif

View File

@ -0,0 +1,8 @@
.gitreview
.metadata/
.settings
.project
.cproject
*~
*.orig
*.bak

View File

@ -0,0 +1,89 @@
################################################################################
#
# \file .travis.yml
#
# \brief Configuration file for Travis continuous integration
#
# Copyright (c) 2017, B&R Industrial Automation GmbH
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * 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.
# * Neither the name of the copyright holders nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# 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 COPYRIGHT HOLDERS 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.
#
################################################################################
language: c
compiler:
- gcc
- clang
env:
global:
- GIT_COMMIT=$TRAVIS_COMMIT
- VERA_ROOT=/home/travis/build/OpenAutomationTechnologies/openPOWERLINK_V2/tools/checkstyle/.vera++/
addons:
apt:
packages:
- libpcap-dev
- cmake-data
- cmake
- qtbase5-dev
- libtcl8.5
- vera++
before_install:
# Execute commit message guidelines check
- chmod +x tools/checkstyle/checkcommit.sh
- ./tools/checkstyle/checkcommit.sh
before_script:
# Print build info that binary is compiled with
- echo $TRAVIS_COMMIT
- echo $TRAVIS_COMMIT_MESSAGE
- echo $TRAVIS_COMMIT_RANGE
- echo $TRAVIS_TAG
- echo $TRAVIS_BRANCH
- echo $TRAVIS_BUILD_NUMBER
- echo $TRAVIS_REPO_SLUG
# Run vera++ coding guidelines check
- cp -r /usr/lib/vera++ tools/checkstyle/.vera++
- cp /usr/bin/vera++ tools/checkstyle/.vera++/vera++
- chmod +x tools/checkstyle/checkoplkstyle.sh
- ./tools/checkstyle/checkoplkstyle.sh
script:
- cd drivers/linux/drv_kernelmod_edrv/build/
- cmake ..
- cd ../../../../stack/build/linux
- cmake ../..
- make install
- cd ../../../apps/demo_mn_console/build/linux
- cmake ../..
- make install
- cd ../../../demo_mn_qt/build/linux
- cmake ../..
- make install
- cd ../../../demo_cn_console/build/linux
- cmake ../..
- make install

View File

@ -0,0 +1,120 @@
################################################################################
#
# Altera Cyclone V ARM configuration options for openPOWERLINK stack
#
# Copyright (c) 2014, B&R Industrial Automation GmbH
# Copyright (c) 2015, Kalycito Infotech Private Limited
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * 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.
# * Neither the name of the copyright holders nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# 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 COPYRIGHT HOLDERS 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.
################################################################################
################################################################################
# Handle includes
SET(CMAKE_MODULE_PATH "${OPLK_BASE_DIR}/cmake" ${CMAKE_MODULE_PATH})
INCLUDE(setalteraarmboardconfig)
INCLUDE(listdir)
INCLUDE(geneclipsefilelist)
INCLUDE(geneclipseincludelist)
INCLUDE(geneclipseflaglist)
INCLUDE(geneclipselibrarylist)
################################################################################
# Path to the hardware library folder of your board example
SET(CFG_HW_LIB_PATH ${OPLK_BASE_DIR}/hardware/lib/${SYSTEM_NAME_DIR}/${SYSTEM_PROCESSOR_DIR}
CACHE PATH "Path to the hardware library folder")
SET(CPU_INST_NAME HOST)
# Get subdirectories (board/demo)
LIST_SUBDIRECTORIES(HW_BOARD_DEMOS ${CFG_HW_LIB_PATH} 2)
SET(CFG_HW_LIB altera-c5soc/mn-soc-shmem-gpio CACHE STRING
"Subfolder of hardware board demo")
SET_PROPERTY(CACHE CFG_HW_LIB PROPERTY STRINGS ${HW_BOARD_DEMOS})
SET(CFG_HW_LIB_DIR ${CFG_HW_LIB_PATH}/${CFG_HW_LIB})
################################################################################
# Include board specific settings file
# TODO Only source the options set during hardware build
SET_BOARD_CONFIGURATION(${CFG_HW_LIB_DIR})
################################################################################
# Get the driver binary and fpga bitstream files for booting from SD card
IF (DEFINED CFG_${CPU_INST_NAME}_BOOT_FROM_SDCARD AND CFG_${CPU_INST_NAME}_BOOT_FROM_SDCARD)
SET(CFG_DRV_BLD_PATH ${OPLK_BASE_DIR}/drivers/altera-nios2/drv_daemon/build
CACHE STRING "openPOWERLINK driver build path")
SET(CFG_DRV_BIN ${CFG_DRV_BLD_PATH}/drv_daemon.bin
CACHE STRING "openPOWERLINK driver executable")
SET(CFG_FPGA_RBF ${CFG_DRV_BLD_PATH}/fpga.rbf
CACHE STRING "Cylone V FPGA configuration(rbf) file")
ELSE()
UNSET(CFG_DRV_BLD_PATH CACHE)
UNSET(CFG_DRV_BIN CACHE)
UNSET(CFG_FPGA_RBF CACHE)
ENDIF ()
# Set variables
SET(ARCH_EXE_SUFFIX ".axf")
SET(ARCH_INSTALL_POSTFIX ${CFG_DEMO_BOARD_NAME}/${CFG_DEMO_NAME})
SET(ALT_TOOLS_DIR ${TOOLS_DIR}/altera-arm)
################################################################################
# Stack configuration
SET(CFG_BUILD_KERNEL_STACK "PCP Daemon Shared Memory Interface"
CACHE STRING "Configure how to build the kernel stack")
SET(KernelStackBuildTypes
"PCP Daemon Shared Memory Interface;None"
CACHE INTERNAL
"List of possible kernel stack build types")
SET_PROPERTY(CACHE CFG_BUILD_KERNEL_STACK
PROPERTY STRINGS ${KernelStackBuildTypes})
IF (CFG_BUILD_KERNEL_STACK STREQUAL "Link to Application")
SET(CFG_KERNEL_STACK_DIRECTLINK ON CACHE INTERNAL
"Link kernel stack directly into application (Single process solution)")
UNSET(CFG_KERNEL_STACK_PCP_HOSTIF_MODULE CACHE)
UNSET(CFG_KERNEL_DUALPROCSHM CACHE)
ELSEIF (CFG_BUILD_KERNEL_STACK STREQUAL "PCP Daemon Host-Interface")
SET(CFG_KERNEL_STACK_PCP_HOSTIF_MODULE ON CACHE INTERNAL
"Build kernel stack as PCP daemon (dual processor)")
UNSET(CFG_KERNEL_STACK_DIRECTLINK CACHE)
UNSET(CFG_KERNEL_DUALPROCSHM CACHE)
ELSEIF (CFG_BUILD_KERNEL_STACK STREQUAL "PCP Daemon Shared Memory Interface")
SET(CFG_KERNEL_DUALPROCSHM ON CACHE INTERNAL
"Build kernel stack as PCP daemon (dual processor)")
UNSET(CFG_KERNEL_STACK_DIRECTLINK CACHE)
UNSET(CFG_KERNEL_STACK_PCP_HOSTIF_MODULE CACHE)
ELSEIF (CFG_BUILD_KERNEL_STACK STREQUAL "None")
UNSET(CFG_KERNEL_STACK_PCP_HOSTIF_MODULE CACHE)
UNSET(CFG_KERNEL_STACK_DIRECTLINK CACHE)
UNSET(CFG_KERNEL_DUALPROCSHM CACHE)
ENDIF (CFG_BUILD_KERNEL_STACK STREQUAL "Link to Application")

View File

@ -0,0 +1,98 @@
################################################################################
#
# Linux configuration options for openPOWERLINK demo applications
#
# Copyright (c) 2014, B&R Industrial Automation GmbH
# Copyright (c) 2016, kalycito Infotech Private Limited
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * 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.
# * Neither the name of the copyright holders nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# 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 COPYRIGHT HOLDERS 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.
################################################################################
SET(CFG_BUILD_KERNEL_STACK "Link to Application"
CACHE STRING "Configure how to build the kernel stack")
SET(KernelStackBuildTypes
"Link to Application;Linux Userspace Daemon;Linux Kernel Module;Kernel stack on PCIe card;Kernel stack on Zynq PCP;None"
CACHE INTERNAL
"List of possible kernel stack build types")
SET_PROPERTY(CACHE CFG_BUILD_KERNEL_STACK
PROPERTY STRINGS ${KernelStackBuildTypes})
IF (CFG_BUILD_KERNEL_STACK STREQUAL "Link to Application")
SET (CFG_KERNEL_STACK_DIRECTLINK ON CACHE INTERNAL
"Link kernel stack directly into application (Single process solution)")
UNSET (CFG_KERNEL_STACK_USERSPACE_DAEMON CACHE)
UNSET (CFG_KERNEL_STACK_KERNEL_MODULE CACHE)
UNSET (CFG_KERNEL_STACK_PCIE_INTF CACHE)
UNSET (CFG_KERNEL_STACK_ZYNQ_INTF CACHE)
ELSEIF (CFG_BUILD_KERNEL_STACK STREQUAL "Linux Userspace Daemon")
SET (CFG_KERNEL_STACK_USERSPACE_DAEMON ON CACHE INTERNAL
"Build kernel stack as Linux userspace daemon")
UNSET (CFG_KERNEL_STACK_DIRECTLINK CACHE)
UNSET (CFG_KERNEL_STACK_KERNEL_MODULE CACHE)
UNSET (CFG_KERNEL_STACK_PCIE_INTF CACHE)
UNSET (CFG_KERNEL_STACK_ZYNQ_INTF CACHE)
ELSEIF (CFG_BUILD_KERNEL_STACK STREQUAL "Linux Kernel Module")
SET (CFG_KERNEL_STACK_KERNEL_MODULE ON CACHE INTERNAL
"Build kernel stack as Linux kernelspace module")
UNSET (CFG_KERNEL_STACK_USERSPACE_DAEMON CACHE)
UNSET (CFG_KERNEL_STACK_DIRECTLINK CACHE)
UNSET (CFG_KERNEL_STACK_PCIE_INTF CACHE)
UNSET (CFG_KERNEL_STACK_ZYNQ_INTF CACHE)
ELSEIF (CFG_BUILD_KERNEL_STACK STREQUAL "Kernel stack on PCIe card")
SET (CFG_KERNEL_STACK_PCIE_INTF ON CACHE INTERNAL
"Build kernel stack on an external PCIe device")
UNSET (CFG_KERNEL_STACK_USERSPACE_DAEMON CACHE)
UNSET (CFG_KERNEL_STACK_DIRECTLINK CACHE)
UNSET (CFG_KERNEL_STACK_KERNEL_MODULE CACHE)
UNSET (CFG_KERNEL_STACK_ZYNQ_INTF CACHE)
ELSEIF (CFG_BUILD_KERNEL_STACK STREQUAL "Kernel stack on Zynq PCP")
SET (CFG_KERNEL_STACK_ZYNQ_INTF ON CACHE INTERNAL
"Build kernel stack on an external zynq PCP device")
UNSET (CFG_KERNEL_STACK_USERSPACE_DAEMON CACHE)
UNSET (CFG_KERNEL_STACK_DIRECTLINK CACHE)
UNSET (CFG_KERNEL_STACK_KERNEL_MODULE CACHE)
UNSET (CFG_KERNEL_STACK_PCIE_INTF CACHE)
ELSEIF (CFG_BUILD_KERNEL_STACK STREQUAL "None")
UNSET (CFG_KERNEL_STACK_USERSPACE_DAEMON CACHE)
UNSET (CFG_KERNEL_STACK_KERNEL_MODULE CACHE)
UNSET (CFG_KERNEL_STACK_DIRECTLINK CACHE)
UNSET (CFG_KERNEL_STACK_PCIE_INTF CACHE)
UNSET (CFG_KERNEL_STACK_ZYNQ_INTF CACHE)
ENDIF (CFG_BUILD_KERNEL_STACK STREQUAL "Link to Application")

View File

@ -0,0 +1,93 @@
################################################################################
#
# Microblaze ISE configuration options for openPOWERLINK stack
#
# Copyright (c) 2014, B&R Industrial Automation GmbH
# Copyright (c) 2016, Kalycito Infotech Private Limited
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * 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.
# * Neither the name of the copyright holders nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# 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 COPYRIGHT HOLDERS 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.
################################################################################
################################################################################
# Handle includes
SET(CMAKE_MODULE_PATH "${OPLK_BASE_DIR}/cmake" ${CMAKE_MODULE_PATH})
INCLUDE(geneclipsefilelist)
INCLUDE(geneclipseincludelist)
INCLUDE(setmicroblazeiseboardconfig)
INCLUDE(listdir)
################################################################################
# Path to the hardware library folder of your board example
SET(CFG_HW_LIB_PATH ${OPLK_BASE_DIR}/hardware/lib/${SYSTEM_NAME_DIR}/${SYSTEM_PROCESSOR_DIR}
CACHE PATH "Path to the hardware library folder")
# Get subdirectories (board/demo)
LIST_SUBDIRECTORIES(HW_BOARD_DEMOS ${CFG_HW_LIB_PATH} 2)
SET(CFG_HW_LIB avnet-s6plkeb/cn-single-gpio CACHE STRING
"Subfolder of hardware board demo")
SET_PROPERTY(CACHE CFG_HW_LIB PROPERTY STRINGS ${HW_BOARD_DEMOS})
SET(CFG_HW_LIB_DIR ${CFG_HW_LIB_PATH}/${CFG_HW_LIB})
################################################################################
# Include board specific settings file
SET_BOARD_CONFIGURATION(${CFG_HW_LIB_DIR})
################################################################################
# Set variables
SET(ARCH_EXE_SUFFIX ".elf")
SET(ARCH_INSTALL_POSTFIX ${CFG_DEMO_BOARD_NAME}/${CFG_DEMO_NAME})
SET(XIL_TOOLS_DIR ${TOOLS_DIR}/xilinx-microblaze)
################################################################################
# Stack configuration
SET(CFG_BUILD_KERNEL_STACK "Link to Application"
CACHE STRING "Configure how to build the kernel stack")
SET(KernelStackBuildTypes
"Link to Application;PCP Daemon Host-Interface;None"
CACHE INTERNAL
"List of possible kernel stack build types")
SET_PROPERTY(CACHE CFG_BUILD_KERNEL_STACK
PROPERTY STRINGS ${KernelStackBuildTypes})
IF (CFG_BUILD_KERNEL_STACK STREQUAL "Link to Application")
SET(CFG_KERNEL_STACK_DIRECTLINK ON CACHE INTERNAL
"Link kernel stack directly into application (Single process solution)")
UNSET(CFG_KERNEL_STACK_PCP_HOSTIF_MODULE CACHE)
ELSEIF (CFG_BUILD_KERNEL_STACK STREQUAL "PCP Daemon Host-Interface")
SET(CFG_KERNEL_STACK_PCP_HOSTIF_MODULE ON CACHE INTERNAL
"Build kernel stack as PCP daemon (dual processor)")
UNSET(CFG_KERNEL_STACK_DIRECTLINK CACHE)
ELSEIF (CFG_BUILD_KERNEL_STACK STREQUAL "None")
UNSET(CFG_KERNEL_STACK_PCP_HOSTIF_MODULE CACHE)
UNSET(CFG_KERNEL_STACK_DIRECTLINK CACHE)
ENDIF (CFG_BUILD_KERNEL_STACK STREQUAL "Link to Application")

View File

@ -0,0 +1,72 @@
################################################################################
#
# Windows configuration options for openPOWERLINK stack
#
# Copyright (c) 2015, Kalycito Infotech Private Limited
# Copyright (c) 2014, B&R Industrial Automation GmbH
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * 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.
# * Neither the name of the copyright holders nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# 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 COPYRIGHT HOLDERS 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.
################################################################################
SET (CFG_BUILD_KERNEL_STACK "Link to Application"
CACHE STRING "Configure how to build the kernel stack")
SET (KernelStackBuildTypes
"Link to Application;Kernel stack on PCIe card;Windows Kernel Module;None"
CACHE INTERNAL
"List of possible kernel stack build types")
SET_PROPERTY(CACHE CFG_BUILD_KERNEL_STACK
PROPERTY STRINGS ${KernelStackBuildTypes})
IF (CFG_BUILD_KERNEL_STACK STREQUAL "Link to Application")
SET (CFG_KERNEL_STACK_DIRECTLINK ON CACHE INTERNAL
"Link kernel stack directly into application (Single process solution)")
UNSET (CFG_KERNEL_STACK_USERSPACE_DAEMON CACHE)
UNSET (CFG_KERNEL_STACK_PCIE CACHE)
UNSET (CFG_KERNEL_STACK_KERNEL_MODULE CACHE)
ELSEIF (CFG_BUILD_KERNEL_STACK STREQUAL "Kernel stack on PCIe card")
SET (CFG_KERNEL_STACK_PCIE ON CACHE INTERNAL
"Build kernel stack on PCIe card")
UNSET (CFG_KERNEL_STACK_USERSPACE_DAEMON CACHE)
UNSET (CFG_KERNEL_STACK_DIRECTLINK CACHE)
ELSEIF (CFG_BUILD_KERNEL_STACK STREQUAL "Windows Kernel Module")
SET (CFG_KERNEL_STACK_KERNEL_MODULE ON CACHE INTERNAL
"Build kernel stack as Windows kernelspace driver")
UNSET (CFG_KERNEL_STACK_USERSPACE_DAEMON CACHE)
UNSET (CFG_KERNEL_STACK_DIRECTLINK CACHE)
UNSET (CFG_KERNEL_STACK_PCIE CACHE)
ELSEIF (CFG_BUILD_KERNEL_STACK STREQUAL "None")
UNSET (CFG_KERNEL_STACK_DIRECTLINK CACHE)
UNSET (CFG_KERNEL_STACK_USERSPACE_DAEMON CACHE)
UNSET (CFG_KERNEL_STACK_PCIE CACHE)
UNSET (CFG_KERNEL_STACK_KERNEL_MODULE CACHE)
ENDIF ()

View File

@ -0,0 +1,98 @@
################################################################################
#
# XiUOS configuration options for openPOWERLINK demo applications
#
# Copyright (c) 2014, B&R Industrial Automation GmbH
# Copyright (c) 2016, kalycito Infotech Private Limited
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * 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.
# * Neither the name of the copyright holders nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# 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 COPYRIGHT HOLDERS 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.
################################################################################
SET(CFG_BUILD_KERNEL_STACK "Link to Application"
CACHE STRING "Configure how to build the kernel stack")
SET(KernelStackBuildTypes
"Link to Application;Linux Userspace Daemon;Linux Kernel Module;Kernel stack on PCIe card;Kernel stack on Zynq PCP;None"
CACHE INTERNAL
"List of possible kernel stack build types")
SET_PROPERTY(CACHE CFG_BUILD_KERNEL_STACK
PROPERTY STRINGS ${KernelStackBuildTypes})
IF (CFG_BUILD_KERNEL_STACK STREQUAL "Link to Application")
SET (CFG_KERNEL_STACK_DIRECTLINK ON CACHE INTERNAL
"Link kernel stack directly into application (Single process solution)")
UNSET (CFG_KERNEL_STACK_USERSPACE_DAEMON CACHE)
UNSET (CFG_KERNEL_STACK_KERNEL_MODULE CACHE)
UNSET (CFG_KERNEL_STACK_PCIE_INTF CACHE)
UNSET (CFG_KERNEL_STACK_ZYNQ_INTF CACHE)
ELSEIF (CFG_BUILD_KERNEL_STACK STREQUAL "Linux Userspace Daemon")
SET (CFG_KERNEL_STACK_USERSPACE_DAEMON ON CACHE INTERNAL
"Build kernel stack as Linux userspace daemon")
UNSET (CFG_KERNEL_STACK_DIRECTLINK CACHE)
UNSET (CFG_KERNEL_STACK_KERNEL_MODULE CACHE)
UNSET (CFG_KERNEL_STACK_PCIE_INTF CACHE)
UNSET (CFG_KERNEL_STACK_ZYNQ_INTF CACHE)
ELSEIF (CFG_BUILD_KERNEL_STACK STREQUAL "Linux Kernel Module")
SET (CFG_KERNEL_STACK_KERNEL_MODULE ON CACHE INTERNAL
"Build kernel stack as Linux kernelspace module")
UNSET (CFG_KERNEL_STACK_USERSPACE_DAEMON CACHE)
UNSET (CFG_KERNEL_STACK_DIRECTLINK CACHE)
UNSET (CFG_KERNEL_STACK_PCIE_INTF CACHE)
UNSET (CFG_KERNEL_STACK_ZYNQ_INTF CACHE)
ELSEIF (CFG_BUILD_KERNEL_STACK STREQUAL "Kernel stack on PCIe card")
SET (CFG_KERNEL_STACK_PCIE_INTF ON CACHE INTERNAL
"Build kernel stack on an external PCIe device")
UNSET (CFG_KERNEL_STACK_USERSPACE_DAEMON CACHE)
UNSET (CFG_KERNEL_STACK_DIRECTLINK CACHE)
UNSET (CFG_KERNEL_STACK_KERNEL_MODULE CACHE)
UNSET (CFG_KERNEL_STACK_ZYNQ_INTF CACHE)
ELSEIF (CFG_BUILD_KERNEL_STACK STREQUAL "Kernel stack on Zynq PCP")
SET (CFG_KERNEL_STACK_ZYNQ_INTF ON CACHE INTERNAL
"Build kernel stack on an external zynq PCP device")
UNSET (CFG_KERNEL_STACK_USERSPACE_DAEMON CACHE)
UNSET (CFG_KERNEL_STACK_DIRECTLINK CACHE)
UNSET (CFG_KERNEL_STACK_KERNEL_MODULE CACHE)
UNSET (CFG_KERNEL_STACK_PCIE_INTF CACHE)
ELSEIF (CFG_BUILD_KERNEL_STACK STREQUAL "None")
UNSET (CFG_KERNEL_STACK_USERSPACE_DAEMON CACHE)
UNSET (CFG_KERNEL_STACK_KERNEL_MODULE CACHE)
UNSET (CFG_KERNEL_STACK_DIRECTLINK CACHE)
UNSET (CFG_KERNEL_STACK_PCIE_INTF CACHE)
UNSET (CFG_KERNEL_STACK_ZYNQ_INTF CACHE)
ENDIF (CFG_BUILD_KERNEL_STACK STREQUAL "Link to Application")

View File

@ -0,0 +1,123 @@
################################################################################
#
# CMake script for finding the openPOWERLINK library
#
# Copyright (c) 2014, B&R Industrial Automation GmbH
# Copyright (c) 2016, Kalycito Infotech Private Limited
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * 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.
# * Neither the name of the copyright holders nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# 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 COPYRIGHT HOLDERS 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.
################################################################################
MACRO(FIND_OPLK_LIBRARY OPLK_NODE_TYPE)
UNSET(OPLKLIB CACHE)
UNSET(OPLKLIB_DEBUG CACHE)
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
IF(CFG_KERNEL_STACK_DIRECTLINK)
SET(OPLKLIB_NAME oplk${OPLK_NODE_TYPE})
ELSEIF (CFG_KERNEL_STACK_USERSPACE_DAEMON)
SET(OPLKLIB_NAME oplk${OPLK_NODE_TYPE}app-userintf)
ELSEIF (CFG_KERNEL_STACK_KERNEL_MODULE)
SET(OPLKLIB_NAME oplk${OPLK_NODE_TYPE}app-kernelintf)
ELSEIF ((CFG_KERNEL_STACK_PCIE_INTF) OR (CFG_KERNEL_STACK_ZYNQ_INTF))
SET(OPLKLIB_NAME oplk${OPLK_NODE_TYPE}app-kernelpcp)
ENDIF (CFG_KERNEL_STACK_DIRECTLINK)
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
IF(CFG_KERNEL_STACK_DIRECTLINK)
SET(OPLKLIB_NAME oplk${OPLK_NODE_TYPE})
ELSEIF (CFG_KERNEL_STACK_PCIE)
SET(OPLKLIB_NAME oplk${OPLK_NODE_TYPE}app-pcieintf)
ELSEIF (CFG_KERNEL_STACK_KERNEL_MODULE)
SET(OPLKLIB_NAME oplk${OPLK_NODE_TYPE}app-kernelintf)
ENDIF (CFG_KERNEL_STACK_DIRECTLINK)
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "XiUOS")
SET(OPLKLIB_NAME oplk${OPLK_NODE_TYPE})
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Generic" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "Microblazeise")
IF (CFG_KERNEL_STACK_DIRECTLINK)
SET(OPLKLIB_NAME oplk${OPLK_NODE_TYPE})
ELSEIF (CFG_KERNEL_STACK_PCP_HOSTIF_MODULE)
SET(OPLKLIB_NAME oplk${OPLK_NODE_TYPE}app-hostif)
ENDIF (CFG_KERNEL_STACK_DIRECTLINK)
ELSEIF (CMAKE_SYSTEM_NAME STREQUAL "Generic" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "alterac5arm")
IF (CFG_KERNEL_STACK_DIRECTLINK)
SET(OPLKLIB_NAME oplk${OPLK_NODE_TYPE})
ELSEIF (CFG_KERNEL_STACK_PCP_HOSTIF_MODULE)
SET(OPLKLIB_NAME oplk${OPLK_NODE_TYPE}app-hostif)
ELSEIF(CFG_KERNEL_DUALPROCSHM)
SET(OPLKLIB_NAME oplk${OPLK_NODE_TYPE}app-dualprocshm)
ELSE()
MESSAGE("No configuration selected for ${CMAKE_SYSTEM_PROCESSOR}!!")
ENDIF (CFG_KERNEL_STACK_DIRECTLINK)
ELSE ()
MESSAGE(FATAL_ERROR "Unsupported CMAKE_SYSTEM_NAME ${CMAKE_SYSTEM_NAME} or CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR}")
ENDIF()
SET(OPLKLIB_DEBUG_NAME "${OPLKLIB_NAME}_d")
# Set oplk library directory
SET(OPLKLIB_DIR ${OPLK_BASE_DIR}/stack/lib/${SYSTEM_NAME_DIR}/${SYSTEM_PROCESSOR_DIR})
IF((CMAKE_GENERATOR MATCHES "Visual Studio") OR (CMAKE_BUILD_TYPE STREQUAL "Release"))
# Search for release library
UNSET(OPLKLIB CACHE)
MESSAGE(STATUS "Searching for LIBRARY ${OPLKLIB_NAME} in ${OPLKLIB_DIR}")
FIND_LIBRARY(OPLKLIB NAME ${OPLKLIB_NAME}
HINTS ${OPLKLIB_DIR} ${OPLKLIB_DIR}/${CFG_DEMO_BOARD_NAME}/${CFG_DEMO_NAME})
IF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
UNSET(OPLKDLL CACHE)
FIND_PROGRAM(OPLKDLL NAME ${OPLKLIB_NAME}.dll
HINTS ${OPLKLIB_DIR})
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
ENDIF()
IF((CMAKE_GENERATOR MATCHES "Visual Studio") OR (CMAKE_BUILD_TYPE STREQUAL "Debug"))
# Search for debug library
UNSET(OPLKLIB_DEBUG CACHE)
MESSAGE(STATUS "Searching for LIBRARY ${OPLKLIB_DEBUG_NAME} in ${OPLKLIB_DIR}")
FIND_LIBRARY(OPLKLIB_DEBUG NAME ${OPLKLIB_DEBUG_NAME}
HINTS ${OPLKLIB_DIR} ${OPLKLIB_DIR}/${CFG_DEMO_BOARD_NAME}/${CFG_DEMO_NAME})
IF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
UNSET(OPLKDLL_DEBUG CACHE)
FIND_PROGRAM(OPLKDLL_DEBUG NAME ${OPLKLIB_DEBUG_NAME}.dll
HINTS ${OPLKLIB_DIR})
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
ENDIF()
ENDMACRO(FIND_OPLK_LIBRARY)

View File

@ -0,0 +1,46 @@
################################################################################
#
# CMake file for the firmware manager module.
#
# Copyright (c) 2017, B&R Industrial Automation GmbH
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * 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.
# * Neither the name of the copyright holders nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# 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 COPYRIGHT HOLDERS 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.
################################################################################
################################################################################
# Setup module directory
SET(FIRMWARE_MANAGER_SOURCE_DIR ${COMMON_SOURCE_DIR}/firmwaremanager)
################################################################################
# Setup module sources
SET(FIRMWARE_MANAGER_SOURCES
${FIRMWARE_MANAGER_SOURCE_DIR}/firmwarestore-file.c
${FIRMWARE_MANAGER_SOURCE_DIR}/firmwareinfodecode-ascii.c
${FIRMWARE_MANAGER_SOURCE_DIR}/firmwareinfo.c
${FIRMWARE_MANAGER_SOURCE_DIR}/firmwareupdate.c
${FIRMWARE_MANAGER_SOURCE_DIR}/firmwarecheck.c
${FIRMWARE_MANAGER_SOURCE_DIR}/firmwaremanager.c
)

View File

@ -0,0 +1,41 @@
################################################################################
#
# CMake script for linking with the openPOWERLINK library
#
# Copyright (c) 2015, B&R Industrial Automation GmbH
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * 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.
# * Neither the name of the copyright holders nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# 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 COPYRIGHT HOLDERS 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.
################################################################################
MACRO(OPLK_LINK_LIBRARIES EXECUTABLE_NAME)
IF(CMAKE_GENERATOR MATCHES "Visual Studio")
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} optimized ${OPLKLIB} debug ${OPLKLIB_DEBUG})
ELSE()
IF(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} debug ${OPLKLIB_DEBUG})
ELSE ()
TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} optimized ${OPLKLIB})
ENDIF()
ENDIF()
ENDMACRO(OPLK_LINK_LIBRARIES)

View File

@ -0,0 +1,105 @@
################################################################################
#
# Generic CMake options openPOWERLINK demo applications
#
# Copyright (c) 2016, B&R Industrial Automation GmbH
# Copyright (c) 2016, Kalycito Infotech Private Limited
# Copyright (c) 2020, AIIT XUOS Lab
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * 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.
# * Neither the name of the copyright holders nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# 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 COPYRIGHT HOLDERS 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.
################################################################################
MESSAGE(STATUS "CMAKE_SYSTEM_NAME is ${CMAKE_SYSTEM_NAME}")
MESSAGE(STATUS "CMAKE_SYSTEM_PROCESSOR is ${CMAKE_SYSTEM_PROCESSOR}")
################################################################################
# Set global directories
################################################################################
SET(OPLK_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..)
SET(DEMO_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
SET(DEMO_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
SET(COMMON_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../common/src)
SET(OPENCONFIG_PROJ_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../common/openCONFIGURATOR_projects)
SET(CONTRIB_SOURCE_DIR ${OPLK_BASE_DIR}/contrib)
SET(OPLK_INCLUDE_DIR ${OPLK_BASE_DIR}/stack/include)
SET(TOOLS_DIR ${OPLK_BASE_DIR}/tools)
SET(BOARDS_DIR ${OPLK_BASE_DIR}/hardware/boards)
SET(OBJDICT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../common/objdicts)
################################################################################
# Include CMake Modules
################################################################################
SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../common/cmake ${CMAKE_MODULE_PATH})
# include standard cmake modules
INCLUDE(CMakeDependentOption)
# include project specific modules
INCLUDE(findoplklib)
INCLUDE(linkoplklib)
################################################################################
# Set options
################################################################################
STRING(TOLOWER "${CMAKE_SYSTEM_NAME}" SYSTEM_NAME_DIR)
STRING(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" SYSTEM_PROCESSOR_DIR)
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
SET(CMAKE_INSTALL_PREFIX
${OPLK_BASE_DIR}/bin/${SYSTEM_NAME_DIR}/${SYSTEM_PROCESSOR_DIR} CACHE PATH "openPOWERLINK apps install prefix" FORCE
)
ENDIF()
SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE INTERNAL "Available Build Configurations" FORCE)
IF(NOT CMAKE_GENERATOR MATCHES "Visual Studio")
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release"
FORCE)
ENDIF()
ENDIF()
SET(CFG_DEBUG_LVL "0xC0000000L" CACHE STRING "Debug Level for debug output")
# set global include directories
INCLUDE_DIRECTORIES (
${OPLK_INCLUDE_DIR}
${CONTRIB_SOURCE_DIR}
${COMMON_SOURCE_DIR}
${OBJDICT_DIR}
)
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
INCLUDE(configure-linux)
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
INCLUDE(configure-windows)
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "XiUOS")
INCLUDE(configure-xiuos)
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Generic" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "Microblazeise")
INCLUDE(configure-microblazeise)
ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Generic" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "alterac5arm")
INCLUDE(configure-c5socarm)
ENDIF()

View File

@ -0,0 +1,218 @@
/**
********************************************************************************
\file obdpi.c
\brief Process image setup function for CiA302-4
This file contains the implementation of the process image setup functions
for the CiA profile 302-4.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2017, B&R Industrial Automation GmbH
Copyright (c) 2013, SYSTEC electronic GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include "obdpi.h"
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P R I V A T E D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#define PI_SUBINDEX_COUNT 252
#ifndef tabentries
#define tabentries(aVar_p) (sizeof(aVar_p) / sizeof(*(aVar_p)))
#endif
//------------------------------------------------------------------------------
// local types
//------------------------------------------------------------------------------
/**
\brief Structure describing the object linking for the process image
This structure describes the object index range and its data type that shall be
linked into the process image.
*/
typedef struct
{
UINT objIndexStart; ///< Start index of a range
UINT objIndexEnd; ///< End index of a range
size_t offsetPI; ///< Starting offset within the process image
BOOL fOutputPI; ///< Describes whether the objects are linked into an output process image
tObdSize entrySize; ///< Size in Bytes of a single entry in the process image
UINT subindexCountPerIndex; ///< Number of subindexes for each index
} tProcessImageLink;
//------------------------------------------------------------------------------
// local vars
//------------------------------------------------------------------------------
tProcessImageLink processImageLink_l[] =
{
// IndexStart IndexEnd OffsetPI OutputPI EntrySize SubindexCount
{ 0xA000, 0xA00F, 0, FALSE, 1, PI_SUBINDEX_COUNT },
{ 0xA040, 0xA04F, 0, FALSE, 1, PI_SUBINDEX_COUNT },
{ 0xA0C0, 0xA0C7, 0, FALSE, 2, PI_SUBINDEX_COUNT },
{ 0xA100, 0xA107, 0, FALSE, 2, PI_SUBINDEX_COUNT },
{ 0xA1C0, 0xA1C3, 0, FALSE, 4, PI_SUBINDEX_COUNT },
{ 0xA200, 0xA203, 0, FALSE, 4, PI_SUBINDEX_COUNT },
{ 0xA240, 0xA247, 0, FALSE, 4, PI_SUBINDEX_COUNT },
{ 0xA400, 0xA401, 0, FALSE, 8, PI_SUBINDEX_COUNT },
{ 0xA440, 0xA441, 0, FALSE, 8, PI_SUBINDEX_COUNT },
{ 0xA480, 0xA48F, 0, TRUE, 1, PI_SUBINDEX_COUNT },
{ 0xA4C0, 0xA4CF, 0, TRUE, 1, PI_SUBINDEX_COUNT },
{ 0xA540, 0xA547, 0, TRUE, 2, PI_SUBINDEX_COUNT },
{ 0xA580, 0xA587, 0, TRUE, 2, PI_SUBINDEX_COUNT },
{ 0xA640, 0xA643, 0, TRUE, 4, PI_SUBINDEX_COUNT },
{ 0xA680, 0xA683, 0, TRUE, 4, PI_SUBINDEX_COUNT },
{ 0xA6C0, 0xA6C7, 0, TRUE, 4, PI_SUBINDEX_COUNT },
{ 0xA880, 0xA881, 0, TRUE, 8, PI_SUBINDEX_COUNT },
{ 0xA8C0, 0xA8C1, 0, TRUE, 8, PI_SUBINDEX_COUNT }
};
//------------------------------------------------------------------------------
// local function prototypes
//------------------------------------------------------------------------------
static UINT linkProcessImageRange(UINT objIndexStart_p, UINT objIndexEnd_p,
size_t offsetPI_p, BOOL fOutputPI_p, tObdSize entrySize_p,
UINT subindexCountPerIndex_p);
//============================================================================//
// P U B L I C F U N C T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Setup process image
The function sets up a process image according to the CiA profile 302-4.
\return The function returns the number of the index that failed to link or 0,
if no error occurred.
*/
//------------------------------------------------------------------------------
UINT obdpi_setupProcessImage(void)
{
UINT errorIndex = 0;
size_t i;
tProcessImageLink* pLink;
pLink = processImageLink_l;
for (i = 0; i < tabentries(processImageLink_l); i++, pLink++)
{
errorIndex = linkProcessImageRange(pLink->objIndexStart, pLink->objIndexEnd,
pLink->offsetPI, pLink->fOutputPI,
pLink->entrySize, pLink->subindexCountPerIndex);
if (errorIndex != 0)
break;
}
return errorIndex;
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
//------------------------------------------------------------------------------
/**
\brief Link process image range
The function links a range of variables to the object dictionary.
\param objIndexStart_p Start index of range to link.
\param objIndexEnd_p End index of range to link.
\param offsetPI_p Offset of range in the process image.
\param fOutputPI_p Determines if input image or output image should
be used: TRUE = output image, FALSE = imput image
\param entrySize_p The size of one process variable.
\param subindexCountPerIndex_p Number of subindexes per index to be linked.
\return The function returns the number of the index that failed to link or 0,
if no error occurred.
*/
//------------------------------------------------------------------------------
static UINT linkProcessImageRange(UINT objIndexStart_p, UINT objIndexEnd_p,
size_t offsetPI_p, BOOL fOutputPI_p,
tObdSize entrySize_p, UINT subindexCountPerIndex_p)
{
tOplkError ret = kErrorOk;
UINT errorIndex = 0;
UINT varEntries;
for (; objIndexStart_p <= objIndexEnd_p; objIndexStart_p++,
offsetPI_p += entrySize_p * subindexCountPerIndex_p)
{
varEntries = subindexCountPerIndex_p;
ret = oplk_linkProcessImageObject(objIndexStart_p, 1, offsetPI_p,
fOutputPI_p, entrySize_p, &varEntries);
if (((ret == kErrorOk) && (varEntries < subindexCountPerIndex_p)) ||
(ret == kErrorApiPISizeExceeded))
{
errorIndex = 0;
break;
}
if (ret != kErrorOk)
{
errorIndex = objIndexStart_p;
break;
}
}
return errorIndex;
}
/// \}

View File

@ -0,0 +1,71 @@
/**
********************************************************************************
\file obdpi.h
\brief Process image setup function for CiA302-4
This file contains the definition of the process image setup functions
for the CiA profile 302-4.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
Copyright (c) 2013, SYSTEC electronic GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
#ifndef _INC_obdpi_H_
#define _INC_obdpi_H_
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <oplk/oplk.h>
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// typedef
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// function prototypes
//------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
UINT obdpi_setupProcessImage(void);
#ifdef __cplusplus
}
#endif
#endif /* _INC_obdpi_H_ */

View File

@ -0,0 +1,506 @@
/**
********************************************************************************
\file objdicts/CiA401_CN/objdict.h
\brief Object dictionary according to CiA401
This file contains the object dictionary definition for the CANopen CiA401
device profile.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
Copyright (c) 2013, SYSTEC electronic GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
#define OBD_DEFINE_MACRO
#include <obdcreate/obdmacro.h>
#undef OBD_DEFINE_MACRO
#include <limits.h>
OBD_BEGIN()
/*************************************************************************
* Communication Profile Area (0x1000 - 0x1FFF)
*************************************************************************/
OBD_BEGIN_PART_GENERIC()
// Object 1000h: NMT_DeviceType_U32
OBD_BEGIN_INDEX_RAM(0x1000, 0x01, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1000, 0x00, kObdTypeUInt32, kObdAccR, tObdUnsigned32, NMT_DeviceType_U32, 0x000F0191)
OBD_END_INDEX(0x1000)
// Object 1001h: ERR_ErrorRegister_U8
OBD_BEGIN_INDEX_RAM(0x1001, 0x01, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1001, 0x00, kObdTypeUInt8, kObdAccR, tObdUnsigned8, ERR_ErrorRegister_U8, 0x00)
OBD_END_INDEX(0x1001)
/*
// Object 1003h: ERR_History_ADOM
OBD_RAM_INDEX_RAM_VARARRAY_NOINIT(0x1003, 10, FALSE, tObdDomain, kObdAccR, tObdDomain, ERR_History_ADOM)
*/
// Object 1006h: NMT_CycleLen_U32 in [us]
OBD_BEGIN_INDEX_RAM(0x1006, 0x01, FALSE)
OBD_SUBINDEX_RAM_VAR_RG(0x1006, 0x00, kObdTypeUInt32, kObdAccSGRW, tObdUnsigned32, NMT_CycleLen_U32, 0x00000000, 400, UINT_MAX) // in [us]
OBD_END_INDEX(0x1006)
// Object 1008h: NMT_ManufactDevName_VS
OBD_BEGIN_INDEX_RAM(0x1008, 0x01, FALSE)
OBD_SUBINDEX_RAM_VSTRING(0x1008, 0x00, kObdAccR, device_name, OBD_MAX_STRING_SIZE, "openPOWERLINK device")
OBD_END_INDEX(0x1008)
// Object 1009h: NMT_ManufactHwVers_VS
OBD_BEGIN_INDEX_RAM(0x1009, 0x01, FALSE)
OBD_SUBINDEX_RAM_VSTRING(0x1009, 0x00, kObdAccR, hardware_version, OBD_MAX_STRING_SIZE, "1.00")
OBD_END_INDEX(0x1009)
// Object 100Ah: NMT_ManufactSwVers_VS
OBD_BEGIN_INDEX_RAM(0x100A, 0x01, FALSE)
OBD_SUBINDEX_RAM_VSTRING(0x100A, 0x00, kObdAccR, software_version, OBD_MAX_STRING_SIZE, PLK_PRODUCT_NAME" "PLK_PRODUCT_VERSION)
OBD_END_INDEX(0x100A)
#if defined(CONFIG_APP_STORE_RESTORE)
// Object 1010h: NMT_StoreParam_REC
OBD_BEGIN_INDEX_RAM(0x1010, 0x05, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1010, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x04)
OBD_SUBINDEX_RAM_VAR_NOINIT(0x1010, 0x01, kObdTypeUInt32, kObdAccRW, tObdUnsigned32, AllParam_U32)
OBD_SUBINDEX_RAM_VAR_NOINIT(0x1010, 0x02, kObdTypeUInt32, kObdAccRW, tObdUnsigned32, CommunicationParam_U32)
OBD_SUBINDEX_RAM_VAR_NOINIT(0x1010, 0x03, kObdTypeUInt32, kObdAccRW, tObdUnsigned32, ApplicationParam_U32)
OBD_SUBINDEX_RAM_VAR_NOINIT(0x1010, 0x04, kObdTypeUInt32, kObdAccRW, tObdUnsigned32, ManufacturerParam_04h_U32)
OBD_END_INDEX(0x1010)
// Object 1011h: NMT_RestoreDefParam_REC
OBD_BEGIN_INDEX_RAM(0x1011, 0x05, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1011, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x04)
OBD_SUBINDEX_RAM_VAR_NOINIT(0x1011, 0x01, kObdTypeUInt32, kObdAccRW, tObdUnsigned32, AllParam_U32)
OBD_SUBINDEX_RAM_VAR_NOINIT(0x1011, 0x02, kObdTypeUInt32, kObdAccRW, tObdUnsigned32, CommunicationParam_U32)
OBD_SUBINDEX_RAM_VAR_NOINIT(0x1011, 0x03, kObdTypeUInt32, kObdAccRW, tObdUnsigned32, ApplicationParam_U32)
OBD_SUBINDEX_RAM_VAR_NOINIT(0x1011, 0x04, kObdTypeUInt32, kObdAccRW, tObdUnsigned32, ManufacturerParam_04h_U32)
OBD_END_INDEX(0x1011)
#endif
// Object 1018h: NMT_IdentityObject_REC
OBD_BEGIN_INDEX_RAM(0x1018, 0x05, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1018, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x04)
OBD_SUBINDEX_RAM_VAR(0x1018, 0x01, kObdTypeUInt32, kObdAccR, tObdUnsigned32, VendorId_U32, 0x00000000)
OBD_SUBINDEX_RAM_VAR(0x1018, 0x02, kObdTypeUInt32, kObdAccR, tObdUnsigned32, ProductCode_U32, 0x00000000)
OBD_SUBINDEX_RAM_VAR(0x1018, 0x03, kObdTypeUInt32, kObdAccR, tObdUnsigned32, RevisionNo_U32, PLK_DEFINED_OBJ1018_VERSION)
OBD_SUBINDEX_RAM_VAR(0x1018, 0x04, kObdTypeUInt32, kObdAccR, tObdUnsigned32, SerialNo_U32, 0x00000000)
OBD_END_INDEX(0x1018)
// Object 1020h: CFM_VerifyConfiguration_REC
OBD_BEGIN_INDEX_RAM(0x1020, 0x03, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1020, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x02)
OBD_SUBINDEX_RAM_VAR(0x1020, 0x01, kObdTypeUInt32, kObdAccSRW, tObdUnsigned32, ConfDate_U32, 0x00000000)
OBD_SUBINDEX_RAM_VAR(0x1020, 0x02, kObdTypeUInt32, kObdAccSRW, tObdUnsigned32, ConfTime_U32, 0x00000000)
// OBD_SUBINDEX_RAM_VAR(0x1020, 0x03, kObdTypeUInt32, kObdAccSRW, tObdUnsigned32, ConfId_U32, 0x00000000)
// OBD_SUBINDEX_RAM_VAR(0x1020, 0x04, kObdTypeBool, kObdAccR, tObdBoolean, VerifyConfInvalid_BOOL, 0x01)
OBD_END_INDEX(0x1020)
// Object 1030h: NMT_InterfaceGroup_Xh_REC
OBD_BEGIN_INDEX_RAM(0x1030, 0x0A, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1030, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x09)
OBD_SUBINDEX_RAM_VAR_RG(0x1030, 0x01, kObdTypeUInt16, kObdAccR, tObdUnsigned16, InterfaceIndex_U16, 0x01, 0x00, 0x0A)
OBD_SUBINDEX_RAM_VSTRING(0x1030, 0x02, kObdAccR, InterfaceDescription_VSTR, 0x20, "Interface 1")
OBD_SUBINDEX_RAM_VAR(0x1030, 0x03, kObdTypeUInt8, kObdAccR, tObdUnsigned8, InterfaceType_U8, 0x06)
OBD_SUBINDEX_RAM_VAR(0x1030, 0x04, kObdTypeUInt16, kObdAccR, tObdUnsigned16, InterfaceMtu_U16, 1518)
OBD_SUBINDEX_RAM_OSTRING(0x1030, 0x05, kObdAccR, InterfacePhysAddress_OSTR, 0x06)
OBD_SUBINDEX_RAM_VSTRING(0x1030, 0x06, kObdAccR, InterfaceName_VSTR, 0x20, "Interface 1")
OBD_SUBINDEX_RAM_VAR_RG(0x1030, 0x07, kObdTypeUInt8, kObdAccR, tObdUnsigned8, InterfaceOperStatus_U8, 0x01, 0x00, 0x01)
OBD_SUBINDEX_RAM_VAR_RG(0x1030, 0x08, kObdTypeUInt8, kObdAccGRW, tObdUnsigned8, InterfaceAdminState_U8, 0x01, 0x00, 0x01)
OBD_SUBINDEX_RAM_VAR(0x1030, 0x09, kObdTypeBool, kObdAccRW, tObdBoolean, Valid_BOOL, 0x01)
OBD_END_INDEX(0x1030)
#if (defined(CONFIG_DLL_PRES_CHAINING_CN) && (NMT_MAX_NODE_ID > 0))
// Object 1050h: NMT_RelativeLatencyDiff_AU32
OBD_RAM_INDEX_RAM_ARRAY(0x1050, NMT_MAX_NODE_ID, FALSE, kObdTypeUInt32, kObdAccR, tObdUnsigned32, NMT_RelativeLatencyDiff_AU32, 0)
#endif
// Object 1300h: SDO_SequLayerTimeout_U32 in [ms]
OBD_BEGIN_INDEX_RAM(0x1300, 0x01, FALSE)
OBD_SUBINDEX_RAM_VAR_RG(0x1300, 0x00, kObdTypeUInt32, kObdAccSGRW, tObdUnsigned32, SDO_SequLayerTimeout_U32, 15000, 100, 0xFFFFFFFF)
OBD_END_INDEX(0x1300)
// Object 1400h: PDO_RxCommParam_00h_REC
OBD_BEGIN_INDEX_RAM(0x1400, 0x03, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1400, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x02)
OBD_SUBINDEX_RAM_VAR_RG(0x1400, 0x01, kObdTypeUInt8, kObdAccSGRW, tObdUnsigned8, NodeID_U8, 0, 0, 254)
OBD_SUBINDEX_RAM_VAR(0x1400, 0x02, kObdTypeUInt8, kObdAccSRW, tObdUnsigned8, MappingVersion_U8, 0x00)
OBD_END_INDEX(0x1400)
// Object 1401h: PDO_RxCommParam_01h_REC
OBD_BEGIN_INDEX_RAM(0x1401, 0x03, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1401, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x02)
OBD_SUBINDEX_RAM_VAR_RG(0x1401, 0x01, kObdTypeUInt8, kObdAccSGRW, tObdUnsigned8, NodeID_U8, 0, 0, 254)
OBD_SUBINDEX_RAM_VAR(0x1401, 0x02, kObdTypeUInt8, kObdAccSRW, tObdUnsigned8, MappingVersion_U8, 0x00)
OBD_END_INDEX(0x1401)
// Object 1402h: PDO_RxCommParam_02h_REC
OBD_BEGIN_INDEX_RAM(0x1402, 0x03, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1402, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x02)
OBD_SUBINDEX_RAM_VAR_RG(0x1402, 0x01, kObdTypeUInt8, kObdAccSGRW, tObdUnsigned8, NodeID_U8, 0, 0, 254)
OBD_SUBINDEX_RAM_VAR(0x1402, 0x02, kObdTypeUInt8, kObdAccSRW, tObdUnsigned8, MappingVersion_U8, 0x00)
OBD_END_INDEX(0x1402)
// Object 1600h: PDO_RxMappParam_00h_AU64
OBD_BEGIN_INDEX_RAM(0x1600, 0x1A, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x00, kObdTypeUInt8, kObdAccSRW, tObdUnsigned8, NumberOfEntries, 0x00)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x01, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x02, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x03, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x04, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x05, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x06, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x07, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x08, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x09, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x0A, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x0B, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x0C, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x0D, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x0E, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x0F, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x10, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x11, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x12, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x13, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x14, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x15, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x16, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x17, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x18, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1600, 0x19, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_END_INDEX(0x1600)
// Object 1601h: PDO_RxMappParam_01h_AU64
OBD_BEGIN_INDEX_RAM(0x1601, 0x1A, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x00, kObdTypeUInt8, kObdAccSRW, tObdUnsigned8, NumberOfEntries, 0x00)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x01, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x02, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x03, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x04, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x05, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x06, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x07, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x08, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x09, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x0A, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x0B, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x0C, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x0D, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x0E, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x0F, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x10, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x11, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x12, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x13, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x14, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x15, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x16, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x17, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x18, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1601, 0x19, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_END_INDEX(0x1601)
// Object 1602h: PDO_RxMappParam_02h_AU64
OBD_BEGIN_INDEX_RAM(0x1602, 0x1A, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x00, kObdTypeUInt8, kObdAccSRW, tObdUnsigned8, NumberOfEntries, 0x00)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x01, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x02, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x03, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x04, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x05, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x06, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x07, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x08, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x09, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x0A, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x0B, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x0C, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x0D, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x0E, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x0F, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x10, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x11, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x12, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x13, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x14, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x15, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x16, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x17, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x18, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1602, 0x19, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_END_INDEX(0x1602)
// Object 1800h: PDO_TxCommParam_00h_REC
OBD_BEGIN_INDEX_RAM(0x1800, 0x03, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1800, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x02)
OBD_SUBINDEX_RAM_VAR_RG(0x1800, 0x01, kObdTypeUInt8, kObdAccSGRW, tObdUnsigned8, NodeID_U8, 0, 0, 254)
OBD_SUBINDEX_RAM_VAR(0x1800, 0x02, kObdTypeUInt8, kObdAccSRW, tObdUnsigned8, MappingVersion_U8, 0x00)
OBD_END_INDEX(0x1800)
// Object 1A00h: PDO_TxMappParam_00h_AU64
OBD_BEGIN_INDEX_RAM(0x1A00, 0x1A, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x00, kObdTypeUInt8, kObdAccSRW, tObdUnsigned8, NumberOfEntries, 0x00)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x01, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x02, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x03, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x04, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x05, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x06, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x07, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x08, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x09, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x0A, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x0B, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x0C, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x0D, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x0E, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x0F, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x10, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x11, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x12, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x13, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x14, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x15, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x16, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x17, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x18, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_SUBINDEX_RAM_VAR(0x1A00, 0x19, kObdTypeUInt64, kObdAccSRW, tObdUnsigned64, ObjectMapping, 0x0000000000000000LL)
OBD_END_INDEX(0x1A00)
// Object 1C0Bh: DLL_CNLossSoC_REC
OBD_BEGIN_INDEX_RAM(0x1C0B, 0x04, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1C0B, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 3)
OBD_SUBINDEX_RAM_USERDEF_NOINIT(0x1C0B, 0x01, kObdTypeUInt32, kObdAccRW, tObdUnsigned32, CumulativeCnt_U32)
OBD_SUBINDEX_RAM_USERDEF(0x1C0B, 0x02, kObdTypeUInt32, kObdAccR, tObdUnsigned32, ThresholdCnt_U32, 0)
OBD_SUBINDEX_RAM_USERDEF(0x1C0B, 0x03, kObdTypeUInt32, kObdAccSRW, tObdUnsigned32, Threshold_U32, 15)
OBD_END_INDEX(0x1C0B)
// Object 1C0Dh: DLL_CNLossPReq_REC
OBD_BEGIN_INDEX_RAM(0x1C0D, 0x04, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1C0D, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 3)
OBD_SUBINDEX_RAM_USERDEF_NOINIT(0x1C0D, 0x01, kObdTypeUInt32, kObdAccRW, tObdUnsigned32, CumulativeCnt_U32)
OBD_SUBINDEX_RAM_USERDEF(0x1C0D, 0x02, kObdTypeUInt32, kObdAccR, tObdUnsigned32, ThresholdCnt_U32, 0)
OBD_SUBINDEX_RAM_USERDEF(0x1C0D, 0x03, kObdTypeUInt32, kObdAccSRW, tObdUnsigned32, Threshold_U32, 15)
OBD_END_INDEX(0x1C0D)
// Object 1C0Fh: DLL_CNCRCError_REC
OBD_BEGIN_INDEX_RAM(0x1C0F, 0x04, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1C0F, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 3)
OBD_SUBINDEX_RAM_USERDEF_NOINIT(0x1C0F, 0x01, kObdTypeUInt32, kObdAccRW, tObdUnsigned32, CumulativeCnt_U32)
OBD_SUBINDEX_RAM_USERDEF(0x1C0F, 0x02, kObdTypeUInt32, kObdAccR, tObdUnsigned32, ThresholdCnt_U32, 0)
OBD_SUBINDEX_RAM_USERDEF(0x1C0F, 0x03, kObdTypeUInt32, kObdAccSRW, tObdUnsigned32, Threshold_U32, 15)
OBD_END_INDEX(0x1C0F)
// Object 1C14h: DLL_LossOfSocTolerance_U32 in [ns]
OBD_BEGIN_INDEX_RAM(0x1C14, 0x01, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1C14, 0x00, kObdTypeUInt32, kObdAccSRW, tObdUnsigned32, LossOfSocTolerance, 100000)
OBD_END_INDEX(0x1C14)
#if defined(CONFIG_INCLUDE_IP)
// Object 1E40h: NWL_IpAddrTable_0h_REC
OBD_BEGIN_INDEX_RAM(0x1E40, 0x06, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1E40, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x05)
OBD_SUBINDEX_RAM_VAR(0x1E40, 0x01, kObdTypeUInt16, kObdAccR, tObdUnsigned16, IfIndex_U16, 0x01)
OBD_SUBINDEX_RAM_VAR(0x1E40, 0x02, kObdTypeUInt32, kObdAccR, tObdUnsigned32, Addr_IPAD, 0xC0A86401)
OBD_SUBINDEX_RAM_VAR(0x1E40, 0x03, kObdTypeUInt32, kObdAccR, tObdUnsigned32, NetMask_IPAD, 0xFFFFFF00)
OBD_SUBINDEX_RAM_VAR(0x1E40, 0x04, kObdTypeUInt16, kObdAccR, tObdUnsigned16, ReasmMaxSize_U16, 50000)
OBD_SUBINDEX_RAM_VAR(0x1E40, 0x05, kObdTypeUInt32, kObdAccSRW, tObdUnsigned32, DefaultGateway_IPAD, 0xC0A864FE)
OBD_END_INDEX(0x1E40)
// Object 1E4Ah: NWL_IpGroup_REC
OBD_BEGIN_INDEX_RAM(0x1E4A, 0x06, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1E4A, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x03)
OBD_SUBINDEX_RAM_VAR(0x1E4A, 0x01, kObdTypeBool, kObdAccSRW, tObdBoolean, Forwarding_BOOL, 0x00)
OBD_SUBINDEX_RAM_VAR(0x1E4A, 0x02, kObdTypeUInt16, kObdAccSRW, tObdUnsigned16, DefaultTTL_U16, 64)
OBD_SUBINDEX_RAM_VAR(0x1E4A, 0x03, kObdTypeUInt32, kObdAccR, tObdUnsigned32, ForwardDatagrams_U32, 0x00000000)
OBD_END_INDEX(0x1E4A)
#endif
#if NMT_MAX_NODE_ID > 0
// Object 1F81h: NMT_NodeAssignment_AU32
OBD_RAM_INDEX_RAM_ARRAY_ALT(0x1F81, NMT_MAX_NODE_ID, FALSE, kObdTypeUInt32, kObdAccSRW, tObdUnsigned32, NMT_NodeAssignment_AU32, 0)
#endif
// Object 1F82h: NMT_FeatureFlags_U32
OBD_BEGIN_INDEX_RAM(0x1F82, 0x01, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1F82, 0x00, kObdTypeUInt32, kObdAccR, tObdUnsigned32, NMT_FeatureFlags_U32, PLK_DEF_FEATURE_FLAGS)
OBD_END_INDEX(0x1F82)
// Object 1F83h: NMT_EPLVersion_U8
OBD_BEGIN_INDEX_RAM(0x1F83, 0x01, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1F83, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NMT_EPLVersion_U8, 0x20)
OBD_END_INDEX(0x1F83)
// Object 1F8Ch: NMT_CurrNMTState_U8
OBD_BEGIN_INDEX_RAM(0x1F8C, 0x01, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1F8C, 0x00, kObdTypeUInt8, kObdAccR, tObdUnsigned8, NMT_CurrNMTState_U8, 0x1C)
OBD_END_INDEX(0x1F8C)
#if NMT_MAX_NODE_ID > 0
// Object 1F8Dh: NMT_PResPayloadLimitList_AU16
OBD_RAM_INDEX_RAM_ARRAY_ALT(0x1F8D, NMT_MAX_NODE_ID, FALSE, kObdTypeUInt16, kObdAccSRW, tObdUnsigned16, NMT_PResPayloadLimitList_AU16, 36)
#endif
// Object 1F93h: NMT_EPLNodeID_REC
OBD_BEGIN_INDEX_RAM(0x1F93, 0x03, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1F93, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x02)
OBD_SUBINDEX_RAM_VAR(0x1F93, 0x01, kObdTypeUInt8, kObdAccR, tObdUnsigned8, NodeID_U8, 0)
OBD_SUBINDEX_RAM_VAR(0x1F93, 0x02, kObdTypeBool, kObdAccR, tObdBoolean, NodeIDByHW_BOOL, 0x00)
OBD_END_INDEX(0x1F93)
// Object 1F98h: NMT_CycleTiming_REC
#if !defined(CONFIG_DLL_PRES_CHAINING_CN)
OBD_BEGIN_INDEX_RAM(0x1F98, 0x0A, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1F98, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x09)
#else
OBD_BEGIN_INDEX_RAM(0x1F98, 0x0F, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1F98, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x0E)
#endif
OBD_SUBINDEX_RAM_VAR(0x1F98, 0x01, kObdTypeUInt16, kObdAccR, tObdUnsigned16, IsochrTxMaxPayload_U16, 0)
OBD_SUBINDEX_RAM_VAR(0x1F98, 0x02, kObdTypeUInt16, kObdAccR, tObdUnsigned16, IsochrRxMaxPayload_U16, 0)
OBD_SUBINDEX_RAM_VAR(0x1F98, 0x03, kObdTypeUInt32, kObdAccR, tObdUnsigned32, PResMaxLatency_U32, 0) // in [ns]
OBD_SUBINDEX_RAM_VAR_RG(0x1F98, 0x04, kObdTypeUInt16, kObdAccSGRW, tObdUnsigned16, PReqActPayloadLimit_U16, 36, 36, C_DLL_ISOCHR_MAX_PAYL)
OBD_SUBINDEX_RAM_VAR_RG(0x1F98, 0x05, kObdTypeUInt16, kObdAccSGRW, tObdUnsigned16, PResActPayloadLimit_U16, 36, 36, C_DLL_ISOCHR_MAX_PAYL)
OBD_SUBINDEX_RAM_VAR(0x1F98, 0x06, kObdTypeUInt32, kObdAccR, tObdUnsigned32, ASndMaxLatency_U32, 0) // in [ns]
OBD_SUBINDEX_RAM_VAR(0x1F98, 0x07, kObdTypeUInt8, kObdAccSRW, tObdUnsigned8, MultiplCycleCnt_U8, 0x00)
OBD_SUBINDEX_RAM_VAR_RG(0x1F98, 0x08, kObdTypeUInt16, kObdAccSGRW, tObdUnsigned16, AsyncMTU_U16, C_DLL_MIN_ASYNC_MTU, C_DLL_MIN_ASYNC_MTU, C_DLL_MAX_ASYNC_MTU)
OBD_SUBINDEX_RAM_VAR_RG(0x1F98, 0x09, kObdTypeUInt16, kObdAccSRW, tObdUnsigned16, Prescaler_U16, 2, 0, 1000)
#if defined(CONFIG_DLL_PRES_CHAINING_CN)
OBD_SUBINDEX_RAM_VAR_RG(0x1F98, 0x0A, kObdTypeUInt8, kObdAccGR, tObdUnsigned8, PResMode_U8, 0x00, 0x00, 0x01)
OBD_SUBINDEX_RAM_VAR(0x1F98, 0x0B, kObdTypeUInt32, kObdAccR, tObdUnsigned32, PResTimeFirst_U32, 0) // in [ns]
OBD_SUBINDEX_RAM_VAR(0x1F98, 0x0C, kObdTypeUInt32, kObdAccR, tObdUnsigned32, PResTimeSecond_U32, 0) // in [ns]
OBD_SUBINDEX_RAM_VAR(0x1F98, 0x0D, kObdTypeUInt32, kObdAccR, tObdUnsigned32, SyncMNDelayFirst_U32, 0) // in [ns]
OBD_SUBINDEX_RAM_VAR(0x1F98, 0x0E, kObdTypeUInt32, kObdAccR, tObdUnsigned32, SyncMNDelaySecond_U32, 0) // in [ns]
#endif
OBD_END_INDEX(0x1F98)
// Object 1F99h: NMT_CNBasicEthernetTimeout_U32 in [us]
OBD_BEGIN_INDEX_RAM(0x1F99, 0x01, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1F99, 0x00, kObdTypeUInt32, kObdAccSRW, tObdUnsigned32, NMT_CNBasicEthernetTimeout_U32, 5000000) // in [us]
OBD_END_INDEX(0x1F99)
#if defined(CONFIG_INCLUDE_IP)
// Object 1F9Ah: NMT_HostName_VSTR
OBD_BEGIN_INDEX_RAM(0x1F9A, 0x01, FALSE)
OBD_SUBINDEX_RAM_VSTRING(0x1F9A, 0x00, kObdAccSRW, NMT_HostName_VSTR, 34, "")
OBD_END_INDEX(0x1F9A)
#endif
#if NMT_MAX_NODE_ID > 0
// Object 1F9Bh: NMT_MultiplCycleAssign_AU8
OBD_RAM_INDEX_RAM_ARRAY_ALT(0x1F9B, NMT_MAX_NODE_ID, FALSE, kObdTypeUInt8, kObdAccSRW, tObdUnsigned8, NMT_MultiplCycleAssign_AU8, 0)
#endif
// Object 1F9Eh: NMT_ResetCmd_U8
OBD_BEGIN_INDEX_RAM(0x1F9E, 0x01, FALSE)
OBD_SUBINDEX_RAM_VAR(0x1F9E, 0x00, kObdTypeUInt8, kObdAccRW, tObdUnsigned8, NMT_ResetCmd_U8, 0xFF)
OBD_END_INDEX(0x1F9E)
OBD_END_PART()
/*************************************************************************
* Manufacturer Specific Profile Area (0x2000 - 0x5FFF)
*************************************************************************/
OBD_BEGIN_PART_MANUFACTURER()
OBD_END_PART()
/*************************************************************************
* Standardised Device Profile Area (0x6000 - 0x9FFF)
*************************************************************************/
OBD_BEGIN_PART_DEVICE()
// DigitalInput_00h_AU8
OBD_BEGIN_INDEX_RAM(0x6000, 0x05, FALSE)
OBD_SUBINDEX_RAM_VAR(0x6000, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x04)
OBD_SUBINDEX_RAM_USERDEF(0x6000, 0x01, kObdTypeUInt8, kObdAccVPR, tObdUnsigned8, DigitalInput, 0x00)
OBD_SUBINDEX_RAM_USERDEF(0x6000, 0x02, kObdTypeUInt8, kObdAccVPR, tObdUnsigned8, DigitalInput, 0x00)
OBD_SUBINDEX_RAM_USERDEF(0x6000, 0x03, kObdTypeUInt8, kObdAccVPR, tObdUnsigned8, DigitalInput, 0x00)
OBD_SUBINDEX_RAM_USERDEF(0x6000, 0x04, kObdTypeUInt8, kObdAccVPR, tObdUnsigned8, DigitalInput, 0x00)
OBD_END_INDEX(0x6000)
// DigitalOutput_00h_AU8
OBD_BEGIN_INDEX_RAM(0x6200, 0x05, FALSE)
OBD_SUBINDEX_RAM_VAR(0x6200, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x04)
OBD_SUBINDEX_RAM_USERDEF(0x6200, 0x01, kObdTypeUInt8, kObdAccVPRW, tObdUnsigned8, DigitalOutput, 0x00)
OBD_SUBINDEX_RAM_USERDEF(0x6200, 0x02, kObdTypeUInt8, kObdAccVPRW, tObdUnsigned8, DigitalOutput, 0x00)
OBD_SUBINDEX_RAM_USERDEF(0x6200, 0x03, kObdTypeUInt8, kObdAccVPRW, tObdUnsigned8, DigitalOutput, 0x00)
OBD_SUBINDEX_RAM_USERDEF(0x6200, 0x04, kObdTypeUInt8, kObdAccVPRW, tObdUnsigned8, DigitalOutput, 0x00)
OBD_END_INDEX(0x6200)
// AnalogueInput_00h_AI8
OBD_BEGIN_INDEX_RAM(0x6400, 0x05, FALSE)
OBD_SUBINDEX_RAM_VAR(0x6400, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x04)
OBD_SUBINDEX_RAM_USERDEF(0x6400, 0x01, kObdTypeInt8, kObdAccVPR, tObdInteger8, AnalogueInput, 0x00)
OBD_SUBINDEX_RAM_USERDEF(0x6400, 0x02, kObdTypeInt8, kObdAccVPR, tObdInteger8, AnalogueInput, 0x00)
OBD_SUBINDEX_RAM_USERDEF(0x6400, 0x03, kObdTypeInt8, kObdAccVPR, tObdInteger8, AnalogueInput, 0x00)
OBD_SUBINDEX_RAM_USERDEF(0x6400, 0x04, kObdTypeInt8, kObdAccVPR, tObdInteger8, AnalogueInput, 0x00)
OBD_END_INDEX(0x6400)
// AnalogueInput_00h_AI16
OBD_BEGIN_INDEX_RAM(0x6401, 0x03, FALSE)
OBD_SUBINDEX_RAM_VAR(0x6401, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x02)
OBD_SUBINDEX_RAM_USERDEF(0x6401, 0x01, kObdTypeInt16, kObdAccVPR, tObdInteger16, AnalogueInput, 0x0000)
OBD_SUBINDEX_RAM_USERDEF(0x6401, 0x02, kObdTypeInt16, kObdAccVPR, tObdInteger16, AnalogueInput, 0x0000)
OBD_END_INDEX(0x6401)
// AnalogueInput_00h_AI32
OBD_BEGIN_INDEX_RAM(0x6402, 0x02, FALSE)
OBD_SUBINDEX_RAM_VAR(0x6402, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x01)
OBD_SUBINDEX_RAM_USERDEF(0x6402, 0x01, kObdTypeInt32, kObdAccVPR, tObdInteger32, AnalogueInput, 0x00000000)
OBD_END_INDEX(0x6402)
// AnalogueOutput_00h_AI8
OBD_BEGIN_INDEX_RAM(0x6410, 0x05, FALSE)
OBD_SUBINDEX_RAM_VAR(0x6410, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x04)
OBD_SUBINDEX_RAM_USERDEF(0x6410, 0x01, kObdTypeInt8, kObdAccVPRW, tObdInteger8, AnalogueOutput, 0x00)
OBD_SUBINDEX_RAM_USERDEF(0x6410, 0x02, kObdTypeInt8, kObdAccVPRW, tObdInteger8, AnalogueOutput, 0x00)
OBD_SUBINDEX_RAM_USERDEF(0x6410, 0x03, kObdTypeInt8, kObdAccVPRW, tObdInteger8, AnalogueOutput, 0x00)
OBD_SUBINDEX_RAM_USERDEF(0x6410, 0x04, kObdTypeInt8, kObdAccVPRW, tObdInteger8, AnalogueOutput, 0x00)
OBD_END_INDEX(0x6410)
// AnalogueOutput_00h_AI16
OBD_BEGIN_INDEX_RAM(0x6411, 0x03, FALSE)
OBD_SUBINDEX_RAM_VAR(0x6411, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x02)
OBD_SUBINDEX_RAM_USERDEF(0x6411, 0x01, kObdTypeInt16, kObdAccVPRW, tObdInteger16, AnalogueOutput, 0x0000)
OBD_SUBINDEX_RAM_USERDEF(0x6411, 0x02, kObdTypeInt16, kObdAccVPRW, tObdInteger16, AnalogueOutput, 0x0000)
OBD_END_INDEX(0x6411)
// AnalogueOutput_00h_AI32
OBD_BEGIN_INDEX_RAM(0x6412, 0x02, FALSE)
OBD_SUBINDEX_RAM_VAR(0x6412, 0x00, kObdTypeUInt8, kObdAccConst, tObdUnsigned8, NumberOfEntries, 0x01)
OBD_SUBINDEX_RAM_USERDEF(0x6412, 0x01, kObdTypeInt32, kObdAccVPRW, tObdInteger32, AnalogueOutput, 0x00000000)
OBD_END_INDEX(0x6412)
OBD_END_PART()
OBD_END()
#define OBD_UNDEFINE_MACRO
#include <obdcreate/obdmacro.h>
#undef OBD_UNDEFINE_MACRO

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<openCONFIGURATORProject xmlns="http://sourceforge.net/projects/openconf/configuration" xmlns:ns2="http://ethernet-powerlink.org/POWERLINK" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://sourceforge.net/projects/openconf/configuration openCONFIGURATOR.xsd">
<Generator vendor="Kalycito Infotech Private Limited &amp; B&amp;R Industrial Automation GmbH" toolName="Ethernet POWERLINK openCONFIGURATOR" toolVersion="2.2.1" createdBy="Priyadharshini" createdOn="2018-06-07T17:16:06.918+05:30" modifiedBy="Priyadharshini" modifiedOn="2018-06-11T16:04:52.706+05:30" />
<ProjectConfiguration activeAutoGenerationSetting="custom" activePathSetting="default">
<PathSettings id="default">
<Path id="CONFIG_TEXT" path="output" />
<Path id="CONFIG_BINARY" path="output" />
<Path id="CONFIG_CHAR_ARRAY" path="output" />
<Path id="XML_PROCESS_IMAGE" path="output" />
<Path id="C_PROCESS_IMAGE" path="output" />
<Path id="CSHARP_PROCESS_IMAGE" path="output" />
</PathSettings>
<AutoGenerationSettings id="all">
<Setting name="GENERATE_MN_MAPPING_FOR_NODES" value="" enabled="true" />
</AutoGenerationSettings>
<AutoGenerationSettings id="none" />
<AutoGenerationSettings id="custom">
<Setting name="GENERATE_MN_MAPPING_FOR_NODES" value="1;32;110" enabled="true" />
</AutoGenerationSettings>
</ProjectConfiguration>
<NetworkConfiguration lossOfSocTolerance="50000000">
<NodeCollection>
<MN name="openPOWERLINK_MN" nodeID="240" pathToXDC="deviceConfiguration/00000000_POWERLINK_CiA302-4_MN.xdc" isAsyncOnly="false" isType1Router="false" isType2Router="false" transmitsPRes="false" />
<CN name="CN_1" nodeID="1" pathToXDC="deviceConfiguration/00000000_POWERLINK_CiA401_CN_1.xdc" isMultiplexed="false" isChained="false" isMandatory="false" autostartNode="true" resetInOperational="false" verifyAppSwVersion="false" autoAppSwUpdateAllowed="false" isAsyncOnly="false" isType1Router="false" isType2Router="false">
<ForcedObjects>
<Object index="1F8D" subindex="F0" />
<Object index="1F98" subindex="05" />
<Object index="1F98" subindex="04" />
</ForcedObjects>
</CN>
<CN nodeID="32" name="CN_2" pathToXDC="deviceConfiguration/00000000_POWERLINK_CiA401_CN_32.xdc" forcedMultiplexedCycle="0" isMultiplexed="false" isChained="false" isAsyncOnly="false" isType1Router="false" isType2Router="false" isMandatory="false" autostartNode="true" resetInOperational="false" verifyAppSwVersion="false" autoAppSwUpdateAllowed="false" verifyDeviceType="true" verifyVendorId="false" verifyRevisionNumber="false" verifyProductCode="false" verifySerialNumber="false" enabled="true">
<ForcedObjects>
<Object index="1F8D" subindex="F0" />
<Object index="1F98" subindex="05" />
<Object index="1F98" subindex="04" />
</ForcedObjects>
</CN>
<CN nodeID="110" name="CN_3" pathToXDC="deviceConfiguration/00000000_POWERLINK_CiA401_CN_110.xdc" forcedMultiplexedCycle="0" isMultiplexed="false" isChained="false" isAsyncOnly="false" isType1Router="false" isType2Router="false" isMandatory="false" autostartNode="true" resetInOperational="false" verifyAppSwVersion="false" autoAppSwUpdateAllowed="false" verifyDeviceType="true" verifyVendorId="false" verifyRevisionNumber="false" verifyProductCode="false" verifySerialNumber="false" enabled="true">
<ForcedObjects>
<Object index="1F8D" subindex="F0" />
<Object index="1F98" subindex="05" />
<Object index="1F98" subindex="04" />
</ForcedObjects>
</CN>
</NodeCollection>
</NetworkConfiguration>
</openCONFIGURATORProject>

View File

@ -0,0 +1,45 @@
using System;
using System.Runtime.InteropServices;
/// <summary>
/// This file was autogenerated by openCONFIGURATOR-2.2.1_release on 11-Jun-2018 16:04:51
/// Project: Demo_3CN
/// Application process for openPOWERLINK_MN(240)
/// </summary>
namespace openPOWERLINK
{
/// <summary>
/// Struct : ProcessImage Out
/// </summary>
[StructLayout(LayoutKind.Explicit, Pack = 1, Size = 4)]
public struct AppProcessImageOut
{
[FieldOffset(0)]
public byte CN1_DigitalInput_00h_AU8_DigitalInput;
[FieldOffset(1)]
public byte CN32_DigitalInput_00h_AU8_DigitalInput;
[FieldOffset(2)]
public byte CN110_DigitalInput_00h_AU8_DigitalInput;
[FieldOffset(3)]
public byte PADDING_VAR_1;
}
/// <summary>
/// Struct : ProcessImage In
/// </summary>
[StructLayout(LayoutKind.Explicit, Pack = 1, Size = 4)]
public struct AppProcessImageIn
{
[FieldOffset(0)]
public byte CN1_DigitalOutput_00h_AU8_DigitalOutput;
[FieldOffset(1)]
public byte CN32_DigitalOutput_00h_AU8_DigitalOutput;
[FieldOffset(2)]
public byte CN110_DigitalOutput_00h_AU8_DigitalOutput;
[FieldOffset(3)]
public byte PADDING_VAR_1;
}
}

View File

@ -0,0 +1,114 @@
////
//// This file was autogenerated by openCONFIGURATOR-2.2.1_release on 11-Jun-2018 16:04:51
//// Project: Demo_3CN
//// NodeCount: 3
////
00000031
//// NodeId Assignment
1F81 01 00000004 00000007
//// NodeId Assignment
1F81 20 00000004 00000007
//// NodeId Assignment
1F81 6E 00000004 00000007
1600 00 00000001 00
1601 00 00000001 00
1602 00 00000001 00
1A00 00 00000001 00
1A01 00 00000001 00
1A02 00 00000001 00
1006 00 00000004 0000C350
1C02 03 00000004 00000028
1C09 01 00000004 00000028
1C09 20 00000004 00000028
1C09 6E 00000004 00000028
1C14 00 00000004 02FAF080
1F26 01 00000004 00003124
1F26 20 00000004 00003124
1F26 6E 00000004 00003124
1F27 01 00000004 03735955
1F27 20 00000004 03735955
1F27 6E 00000004 03735955
1F8A 02 00000004 0007A120
1F92 01 00000004 00030D40
1F92 20 00000004 00030D40
1F92 6E 00000004 00030D40
1400 01 00000001 01
1401 01 00000001 20
1402 01 00000001 6E
1600 01 00000008 000800000001A4C0
1601 01 00000008 000800000002A4C0
1602 01 00000008 000800000003A4C0
1800 01 00000001 01
1801 01 00000001 20
1802 01 00000001 6E
1A00 01 00000008 000800000001A040
1A01 01 00000008 000800000002A040
1A02 01 00000008 000800000003A040
1600 00 00000001 01
1601 00 00000001 01
1602 00 00000001 01
1A00 00 00000001 01
1A01 00 00000001 01
1A02 00 00000001 01
////Configuration Data for CN: CN_1(1)
1F22 01 00000096
0000000E
1600 00 00000001 00
1A00 00 00000001 00
1006 00 00000004 0000C350
1020 01 00000004 00003124
1020 02 00000004 03735955
1C0B 03 00000004 00000050
1C0D 03 00000004 00000050
1C14 00 00000004 02FAF080
1F98 04 00000002 0024
1F98 05 00000002 0024
1600 01 00000008 0008000000016200
1A00 01 00000008 0008000000016000
1600 00 00000001 01
1A00 00 00000001 01
////Configuration Data for CN: CN_2(32)
1F22 20 00000096
0000000E
1600 00 00000001 00
1A00 00 00000001 00
1006 00 00000004 0000C350
1020 01 00000004 00003124
1020 02 00000004 03735955
1C0B 03 00000004 00000050
1C0D 03 00000004 00000050
1C14 00 00000004 02FAF080
1F98 04 00000002 0024
1F98 05 00000002 0024
1600 01 00000008 0008000000016200
1A00 01 00000008 0008000000016000
1600 00 00000001 01
1A00 00 00000001 01
////Configuration Data for CN: CN_3(110)
1F22 6E 00000096
0000000E
1600 00 00000001 00
1A00 00 00000001 00
1006 00 00000004 0000C350
1020 01 00000004 00003124
1020 02 00000004 03735955
1C0B 03 00000004 00000050
1C0D 03 00000004 00000050
1C14 00 00000004 02FAF080
1F98 04 00000002 0024
1F98 05 00000002 0024
1600 01 00000008 0008000000016200
1A00 01 00000008 0008000000016000
1600 00 00000001 01
1A00 00 00000001 01
//// NodeId Reassignment
1F81 01 00000004 80000007
//// NodeId Reassignment
1F81 20 00000004 80000007
//// NodeId Reassignment
1F81 6E 00000004 80000007

View File

@ -0,0 +1,60 @@
0x31, 0x00, 0x00, 0x00, 0x81, 0x1F, 0x01, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x81,
0x1F, 0x20, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x81, 0x1F, 0x6E, 0x04, 0x00, 0x00,
0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x16, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1A, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x50, 0xC3, 0x00, 0x00,
0x02, 0x1C, 0x03, 0x04, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x09, 0x1C, 0x01, 0x04, 0x00,
0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x09, 0x1C, 0x20, 0x04, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00,
0x00, 0x09, 0x1C, 0x6E, 0x04, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x14, 0x1C, 0x00, 0x04,
0x00, 0x00, 0x00, 0x80, 0xF0, 0xFA, 0x02, 0x26, 0x1F, 0x01, 0x04, 0x00, 0x00, 0x00, 0x24, 0x31,
0x00, 0x00, 0x26, 0x1F, 0x20, 0x04, 0x00, 0x00, 0x00, 0x24, 0x31, 0x00, 0x00, 0x26, 0x1F, 0x6E,
0x04, 0x00, 0x00, 0x00, 0x24, 0x31, 0x00, 0x00, 0x27, 0x1F, 0x01, 0x04, 0x00, 0x00, 0x00, 0x55,
0x59, 0x73, 0x03, 0x27, 0x1F, 0x20, 0x04, 0x00, 0x00, 0x00, 0x55, 0x59, 0x73, 0x03, 0x27, 0x1F,
0x6E, 0x04, 0x00, 0x00, 0x00, 0x55, 0x59, 0x73, 0x03, 0x8A, 0x1F, 0x02, 0x04, 0x00, 0x00, 0x00,
0x20, 0xA1, 0x07, 0x00, 0x92, 0x1F, 0x01, 0x04, 0x00, 0x00, 0x00, 0x40, 0x0D, 0x03, 0x00, 0x92,
0x1F, 0x20, 0x04, 0x00, 0x00, 0x00, 0x40, 0x0D, 0x03, 0x00, 0x92, 0x1F, 0x6E, 0x04, 0x00, 0x00,
0x00, 0x40, 0x0D, 0x03, 0x00, 0x00, 0x14, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x14, 0x01,
0x01, 0x00, 0x00, 0x00, 0x20, 0x02, 0x14, 0x01, 0x01, 0x00, 0x00, 0x00, 0x6E, 0x00, 0x16, 0x01,
0x08, 0x00, 0x00, 0x00, 0xC0, 0xA4, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x16, 0x01, 0x08,
0x00, 0x00, 0x00, 0xC0, 0xA4, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x16, 0x01, 0x08, 0x00,
0x00, 0x00, 0xC0, 0xA4, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x18, 0x01, 0x01, 0x00, 0x00,
0x00, 0x01, 0x01, 0x18, 0x01, 0x01, 0x00, 0x00, 0x00, 0x20, 0x02, 0x18, 0x01, 0x01, 0x00, 0x00,
0x00, 0x6E, 0x00, 0x1A, 0x01, 0x08, 0x00, 0x00, 0x00, 0x40, 0xA0, 0x01, 0x00, 0x00, 0x00, 0x08,
0x00, 0x01, 0x1A, 0x01, 0x08, 0x00, 0x00, 0x00, 0x40, 0xA0, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00,
0x02, 0x1A, 0x01, 0x08, 0x00, 0x00, 0x00, 0x40, 0xA0, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02,
0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01,
0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x22,
0x1F, 0x01, 0x96, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04, 0x00, 0x00,
0x00, 0x50, 0xC3, 0x00, 0x00, 0x20, 0x10, 0x01, 0x04, 0x00, 0x00, 0x00, 0x24, 0x31, 0x00, 0x00,
0x20, 0x10, 0x02, 0x04, 0x00, 0x00, 0x00, 0x55, 0x59, 0x73, 0x03, 0x0B, 0x1C, 0x03, 0x04, 0x00,
0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x0D, 0x1C, 0x03, 0x04, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00,
0x00, 0x14, 0x1C, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFA, 0x02, 0x98, 0x1F, 0x04, 0x02,
0x00, 0x00, 0x00, 0x24, 0x00, 0x98, 0x1F, 0x05, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x16,
0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x62, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x1A, 0x01,
0x08, 0x00, 0x00, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x16, 0x00, 0x01,
0x00, 0x00, 0x00, 0x01, 0x00, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x22, 0x1F, 0x20, 0x96,
0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x50, 0xC3,
0x00, 0x00, 0x20, 0x10, 0x01, 0x04, 0x00, 0x00, 0x00, 0x24, 0x31, 0x00, 0x00, 0x20, 0x10, 0x02,
0x04, 0x00, 0x00, 0x00, 0x55, 0x59, 0x73, 0x03, 0x0B, 0x1C, 0x03, 0x04, 0x00, 0x00, 0x00, 0x50,
0x00, 0x00, 0x00, 0x0D, 0x1C, 0x03, 0x04, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x14, 0x1C,
0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFA, 0x02, 0x98, 0x1F, 0x04, 0x02, 0x00, 0x00, 0x00,
0x24, 0x00, 0x98, 0x1F, 0x05, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x16, 0x01, 0x08, 0x00,
0x00, 0x00, 0x00, 0x62, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x1A, 0x01, 0x08, 0x00, 0x00,
0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00,
0x01, 0x00, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x22, 0x1F, 0x6E, 0x96, 0x00, 0x00, 0x00,
0x0E, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x50, 0xC3, 0x00, 0x00, 0x20,
0x10, 0x01, 0x04, 0x00, 0x00, 0x00, 0x24, 0x31, 0x00, 0x00, 0x20, 0x10, 0x02, 0x04, 0x00, 0x00,
0x00, 0x55, 0x59, 0x73, 0x03, 0x0B, 0x1C, 0x03, 0x04, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
0x0D, 0x1C, 0x03, 0x04, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x14, 0x1C, 0x00, 0x04, 0x00,
0x00, 0x00, 0x80, 0xF0, 0xFA, 0x02, 0x98, 0x1F, 0x04, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x98,
0x1F, 0x05, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x16, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00,
0x62, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x1A, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x60,
0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x1A,
0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x81, 0x1F, 0x01, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00,
0x80, 0x81, 0x1F, 0x20, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x80, 0x81, 0x1F, 0x6E, 0x04,
0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x80

View File

@ -0,0 +1,27 @@
/*
* This file was autogenerated by openCONFIGURATOR-2.2.1_release on 11-Jun-2018 16:04:51
* Project: Demo_3CN
* Application process for openPOWERLINK_MN(240)
*/
#ifndef XAP_h
#define XAP_h
#define COMPUTED_PI_OUT_SIZE 4
typedef struct
{
unsigned CN1_DigitalInput_00h_AU8_DigitalInput:8;
unsigned CN32_DigitalInput_00h_AU8_DigitalInput:8;
unsigned CN110_DigitalInput_00h_AU8_DigitalInput:8;
unsigned PADDING_VAR_1:8;
} PI_OUT;
#define COMPUTED_PI_IN_SIZE 4
typedef struct
{
unsigned CN1_DigitalOutput_00h_AU8_DigitalOutput:8;
unsigned CN32_DigitalOutput_00h_AU8_DigitalOutput:8;
unsigned CN110_DigitalOutput_00h_AU8_DigitalOutput:8;
unsigned PADDING_VAR_1:8;
} PI_IN;
#endif

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This file was autogenerated by openCONFIGURATOR-2.2.1_release on 11-Jun-2018 16:04:51 -->
<!-- Project: Demo_3CN -->
<!-- Application process for openPOWERLINK_MN(240) -->
<ApplicationProcess xmlns="http://ethernet-powerlink.org/POWERLINK/PI">
<ProcessImage type="output" size="3">
<Channel Name="CN1.DigitalInput.00h.AU8.DigitalInput" dataType="Unsigned8" dataSize="8" PIOffset="0x0000"/>
<Channel Name="CN32.DigitalInput.00h.AU8.DigitalInput" dataType="Unsigned8" dataSize="8" PIOffset="0x0001"/>
<Channel Name="CN110.DigitalInput.00h.AU8.DigitalInput" dataType="Unsigned8" dataSize="8" PIOffset="0x0002"/>
</ProcessImage>
<ProcessImage type="input" size="3">
<Channel Name="CN1.DigitalOutput.00h.AU8.DigitalOutput" dataType="Unsigned8" dataSize="8" PIOffset="0x0000"/>
<Channel Name="CN32.DigitalOutput.00h.AU8.DigitalOutput" dataType="Unsigned8" dataSize="8" PIOffset="0x0001"/>
<Channel Name="CN110.DigitalOutput.00h.AU8.DigitalOutput" dataType="Unsigned8" dataSize="8" PIOffset="0x0002"/>
</ProcessImage>
</ApplicationProcess>

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<openCONFIGURATORProject xmlns="http://sourceforge.net/projects/openconf/configuration" xmlns:ns2="http://ethernet-powerlink.org/POWERLINK" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://sourceforge.net/projects/openconf/configuration openCONFIGURATOR.xsd">
<Generator vendor="Kalycito Infotech Private Limited &amp; B&amp;R Industrial Automation GmbH" toolName="Ethernet POWERLINK openCONFIGURATOR" toolVersion="2.2.1" createdBy="Priyadharshini" createdOn="2018-06-08T18:29:49.694+05:30" modifiedBy="Priyadharshini" modifiedOn="2018-09-06T14:40:34.446+05:30" />
<ProjectConfiguration activeAutoGenerationSetting="all" activePathSetting="default">
<PathSettings id="default">
<Path id="CONFIG_TEXT" path="output" />
<Path id="CONFIG_BINARY" path="output" />
<Path id="CONFIG_CHAR_ARRAY" path="output" />
<Path id="XML_PROCESS_IMAGE" path="output" />
<Path id="C_PROCESS_IMAGE" path="output" />
<Path id="CSHARP_PROCESS_IMAGE" path="output" />
</PathSettings>
<AutoGenerationSettings id="all">
<Setting name="GENERATE_MN_MAPPING_FOR_NODES" value="" enabled="true" />
</AutoGenerationSettings>
<AutoGenerationSettings id="none" />
<AutoGenerationSettings id="custom" />
</ProjectConfiguration>
<NetworkConfiguration lossOfSocTolerance="50000000">
<NodeCollection>
<MN name="openPOWERLINK_MN" nodeID="240" pathToXDC="deviceConfiguration/00000000_POWERLINK_CiA302-4_MN.xdc" isAsyncOnly="false" isType1Router="false" isType2Router="false" transmitsPRes="false" />
<RMN nodeID="243" name="RMN 3" pathToXDC="deviceConfiguration/00000000_POWERLINK_CiA302-4_MN_243.xdc" isAsyncOnly="false" isType1Router="false" isType2Router="false" />
<RMN nodeID="242" name="RMN 2" pathToXDC="deviceConfiguration/00000000_POWERLINK_CiA302-4_MN_242.xdc" isAsyncOnly="false" isType1Router="false" isType2Router="false" />
<RMN nodeID="241" name="RMN 1" pathToXDC="deviceConfiguration/00000000_POWERLINK_CiA302-4_MN_241.xdc" isAsyncOnly="false" isType1Router="false" isType2Router="false" />
<CN nodeID="1" name="CN_1" pathToXDC="deviceConfiguration/00000000_POWERLINK_CiA401_CN_1.xdc" forcedMultiplexedCycle="0" isMultiplexed="false" isChained="false" isAsyncOnly="false" isType1Router="false" isType2Router="false" isMandatory="false" autostartNode="true" resetInOperational="false" verifyAppSwVersion="false" autoAppSwUpdateAllowed="false" verifyDeviceType="true" verifyVendorId="false" verifyRevisionNumber="false" verifyProductCode="false" verifySerialNumber="false" enabled="true">
<ForcedObjects>
<Object index="1F98" subindex="05" />
<Object index="1F98" subindex="04" />
</ForcedObjects>
</CN>
<CN nodeID="32" name="CN_2" pathToXDC="deviceConfiguration/00000000_POWERLINK_CiA401_CN_32.xdc" forcedMultiplexedCycle="0" isMultiplexed="false" isChained="false" isAsyncOnly="false" isType1Router="false" isType2Router="false" isMandatory="false" autostartNode="true" resetInOperational="false" verifyAppSwVersion="false" autoAppSwUpdateAllowed="false" verifyDeviceType="true" verifyVendorId="false" verifyRevisionNumber="false" verifyProductCode="false" verifySerialNumber="false" enabled="true">
<ForcedObjects>
<Object index="1F98" subindex="05" />
<Object index="1F98" subindex="04" />
</ForcedObjects>
</CN>
<CN nodeID="110" name="CN_3" pathToXDC="deviceConfiguration/00000000_POWERLINK_CiA401_CN_110.xdc" forcedMultiplexedCycle="0" isMultiplexed="false" isChained="false" isAsyncOnly="false" isType1Router="false" isType2Router="false" isMandatory="false" autostartNode="true" resetInOperational="false" verifyAppSwVersion="false" autoAppSwUpdateAllowed="false" verifyDeviceType="true" verifyVendorId="false" verifyRevisionNumber="false" verifyProductCode="false" verifySerialNumber="false" enabled="true">
<ForcedObjects>
<Object index="1F98" subindex="05" />
<Object index="1F98" subindex="04" />
</ForcedObjects>
</CN>
</NodeCollection>
</NetworkConfiguration>
</openCONFIGURATORProject>

View File

@ -0,0 +1,45 @@
using System;
using System.Runtime.InteropServices;
/// <summary>
/// This file was autogenerated by openCONFIGURATOR-2.2.1_release on 06-Sep-2018 14:40:27
/// Project: Demo_RMN_3CN
/// Application process for openPOWERLINK_MN(240)
/// </summary>
namespace openPOWERLINK
{
/// <summary>
/// Struct : ProcessImage Out
/// </summary>
[StructLayout(LayoutKind.Explicit, Pack = 1, Size = 4)]
public struct AppProcessImageOut
{
[FieldOffset(0)]
public byte CN1_DigitalInput_00h_AU8_DigitalInput;
[FieldOffset(1)]
public byte CN32_DigitalInput_00h_AU8_DigitalInput;
[FieldOffset(2)]
public byte CN110_DigitalInput_00h_AU8_DigitalInput;
[FieldOffset(3)]
public byte PADDING_VAR_1;
}
/// <summary>
/// Struct : ProcessImage In
/// </summary>
[StructLayout(LayoutKind.Explicit, Pack = 1, Size = 4)]
public struct AppProcessImageIn
{
[FieldOffset(0)]
public byte CN1_DigitalOutput_00h_AU8_DigitalOutput;
[FieldOffset(1)]
public byte CN32_DigitalOutput_00h_AU8_DigitalOutput;
[FieldOffset(2)]
public byte CN110_DigitalOutput_00h_AU8_DigitalOutput;
[FieldOffset(3)]
public byte PADDING_VAR_1;
}
}

View File

@ -0,0 +1,331 @@
////
//// This file was autogenerated by openCONFIGURATOR-2.2.1_release on 06-Sep-2018 14:40:27
//// Project: Demo_RMN_3CN
//// NodeCount: 6
////
00000041
//// NodeId Assignment
1F81 01 00000004 00000007
//// NodeId Assignment
1F81 20 00000004 00000007
//// NodeId Assignment
1F81 6E 00000004 00000007
//// NodeId Assignment
1F81 F1 00000004 00000003
//// NodeId Assignment
1F81 F2 00000004 00000003
//// NodeId Assignment
1F81 F3 00000004 00000003
1600 00 00000001 00
1601 00 00000001 00
1602 00 00000001 00
1A00 00 00000001 00
1A01 00 00000001 00
1A02 00 00000001 00
1006 00 00000004 0000C350
1C02 01 00000004 00000028
1C02 03 00000004 00000028
1C09 01 00000004 00000028
1C09 20 00000004 00000028
1C09 6E 00000004 00000028
1C14 00 00000004 02FAF080
1F26 01 00000004 0000317B
1F26 20 00000004 0000317B
1F26 6E 00000004 0000317B
1F26 F1 00000004 0000317B
1F26 F2 00000004 0000317B
1F26 F3 00000004 0000317B
1F27 01 00000004 03261416
1F27 20 00000004 03261416
1F27 6E 00000004 03261416
1F27 F1 00000004 03261416
1F27 F2 00000004 03261416
1F27 F3 00000004 03261416
1F80 00 00000004 00004800
1F92 01 00000004 00030D40
1F92 20 00000004 00030D40
1F92 6E 00000004 00030D40
1F92 F1 00000004 00006978
1F92 F2 00000004 00006978
1F92 F3 00000004 00006978
1400 01 00000001 01
1401 01 00000001 20
1402 01 00000001 6E
1600 01 00000008 000800000001A4C0
1601 01 00000008 000800000002A4C0
1602 01 00000008 000800000003A4C0
1800 01 00000001 01
1801 01 00000001 20
1802 01 00000001 6E
1A00 01 00000008 000800000001A040
1A01 01 00000008 000800000002A040
1A02 01 00000008 000800000003A040
1600 00 00000001 01
1601 00 00000001 01
1602 00 00000001 01
1A00 00 00000001 01
1A01 00 00000001 01
1A02 00 00000001 01
////Configuration Data for CN: CN_1(1)
1F22 01 00000096
0000000E
1600 00 00000001 00
1A00 00 00000001 00
1006 00 00000004 0000C350
1020 01 00000004 0000317B
1020 02 00000004 03261416
1C0B 03 00000004 00000050
1C0D 03 00000004 00000050
1C14 00 00000004 02FAF080
1F98 04 00000002 0024
1F98 05 00000002 0024
1600 01 00000008 0008000000016200
1A00 01 00000008 0008000000016000
1600 00 00000001 01
1A00 00 00000001 01
////Configuration Data for CN: CN_2(32)
1F22 20 00000096
0000000E
1600 00 00000001 00
1A00 00 00000001 00
1006 00 00000004 0000C350
1020 01 00000004 0000317B
1020 02 00000004 03261416
1C0B 03 00000004 00000050
1C0D 03 00000004 00000050
1C14 00 00000004 02FAF080
1F98 04 00000002 0024
1F98 05 00000002 0024
1600 01 00000008 0008000000016200
1A00 01 00000008 0008000000016000
1600 00 00000001 01
1A00 00 00000001 01
////Configuration Data for CN: CN_3(110)
1F22 6E 00000096
0000000E
1600 00 00000001 00
1A00 00 00000001 00
1006 00 00000004 0000C350
1020 01 00000004 0000317B
1020 02 00000004 03261416
1C0B 03 00000004 00000050
1C0D 03 00000004 00000050
1C14 00 00000004 02FAF080
1F98 04 00000002 0024
1F98 05 00000002 0024
1600 01 00000008 0008000000016200
1A00 01 00000008 0008000000016000
1600 00 00000001 01
1A00 00 00000001 01
////Configuration Data for RMN: RMN 1(241)
1F22 F1 0000029B
0000003F
1F81 01 00000004 00000007
1F81 20 00000004 00000007
1F81 6E 00000004 00000007
1F81 F1 00000004 00000003
1F81 F2 00000004 00000003
1F81 F3 00000004 00000003
1600 00 00000001 00
1601 00 00000001 00
1602 00 00000001 00
1A00 00 00000001 00
1A01 00 00000001 00
1A02 00 00000001 00
1006 00 00000004 0000C350
1020 01 00000004 0000317B
1020 02 00000004 03261416
1C02 01 00000004 00000028
1C02 03 00000004 00000028
1C09 01 00000004 00000028
1C09 20 00000004 00000028
1C09 6E 00000004 00000028
1C0B 03 00000004 00000050
1C0D 03 00000004 00000050
1C14 00 00000004 02FAF080
1F26 01 00000004 0000317B
1F26 20 00000004 0000317B
1F26 6E 00000004 0000317B
1F26 F1 00000004 0000317B
1F26 F2 00000004 0000317B
1F26 F3 00000004 0000317B
1F27 01 00000004 03261416
1F27 20 00000004 03261416
1F27 6E 00000004 03261416
1F27 F1 00000004 03261416
1F27 F2 00000004 03261416
1F27 F3 00000004 03261416
1F80 00 00000004 00004800
1F92 01 00000004 00030D40
1F92 20 00000004 00030D40
1F92 6E 00000004 00030D40
1F92 F1 00000004 00006978
1F92 F2 00000004 00006978
1F92 F3 00000004 00006978
1400 01 00000001 01
1401 01 00000001 20
1402 01 00000001 6E
1600 01 00000008 000800000001A4C0
1601 01 00000008 000800000002A4C0
1602 01 00000008 000800000003A4C0
1800 01 00000001 01
1801 01 00000001 20
1802 01 00000001 6E
1A00 01 00000008 000800000001A040
1A01 01 00000008 000800000002A040
1A02 01 00000008 000800000003A040
1600 00 00000001 01
1601 00 00000001 01
1602 00 00000001 01
1A00 00 00000001 01
1A01 00 00000001 01
1A02 00 00000001 01
1F81 01 00000004 80000007
1F81 20 00000004 80000007
1F81 6E 00000004 80000007
////Configuration Data for RMN: RMN 2(242)
1F22 F2 0000029B
0000003F
1F81 01 00000004 00000007
1F81 20 00000004 00000007
1F81 6E 00000004 00000007
1F81 F1 00000004 00000003
1F81 F2 00000004 00000003
1F81 F3 00000004 00000003
1600 00 00000001 00
1601 00 00000001 00
1602 00 00000001 00
1A00 00 00000001 00
1A01 00 00000001 00
1A02 00 00000001 00
1006 00 00000004 0000C350
1020 01 00000004 0000317B
1020 02 00000004 03261416
1C02 01 00000004 00000028
1C02 03 00000004 00000028
1C09 01 00000004 00000028
1C09 20 00000004 00000028
1C09 6E 00000004 00000028
1C0B 03 00000004 00000050
1C0D 03 00000004 00000050
1C14 00 00000004 02FAF080
1F26 01 00000004 0000317B
1F26 20 00000004 0000317B
1F26 6E 00000004 0000317B
1F26 F1 00000004 0000317B
1F26 F2 00000004 0000317B
1F26 F3 00000004 0000317B
1F27 01 00000004 03261416
1F27 20 00000004 03261416
1F27 6E 00000004 03261416
1F27 F1 00000004 03261416
1F27 F2 00000004 03261416
1F27 F3 00000004 03261416
1F80 00 00000004 00004800
1F92 01 00000004 00030D40
1F92 20 00000004 00030D40
1F92 6E 00000004 00030D40
1F92 F1 00000004 00006978
1F92 F2 00000004 00006978
1F92 F3 00000004 00006978
1400 01 00000001 01
1401 01 00000001 20
1402 01 00000001 6E
1600 01 00000008 000800000001A4C0
1601 01 00000008 000800000002A4C0
1602 01 00000008 000800000003A4C0
1800 01 00000001 01
1801 01 00000001 20
1802 01 00000001 6E
1A00 01 00000008 000800000001A040
1A01 01 00000008 000800000002A040
1A02 01 00000008 000800000003A040
1600 00 00000001 01
1601 00 00000001 01
1602 00 00000001 01
1A00 00 00000001 01
1A01 00 00000001 01
1A02 00 00000001 01
1F81 01 00000004 80000007
1F81 20 00000004 80000007
1F81 6E 00000004 80000007
////Configuration Data for RMN: RMN 3(243)
1F22 F3 0000029B
0000003F
1F81 01 00000004 00000007
1F81 20 00000004 00000007
1F81 6E 00000004 00000007
1F81 F1 00000004 00000003
1F81 F2 00000004 00000003
1F81 F3 00000004 00000003
1600 00 00000001 00
1601 00 00000001 00
1602 00 00000001 00
1A00 00 00000001 00
1A01 00 00000001 00
1A02 00 00000001 00
1006 00 00000004 0000C350
1020 01 00000004 0000317B
1020 02 00000004 03261416
1C02 01 00000004 00000028
1C02 03 00000004 00000028
1C09 01 00000004 00000028
1C09 20 00000004 00000028
1C09 6E 00000004 00000028
1C0B 03 00000004 00000050
1C0D 03 00000004 00000050
1C14 00 00000004 02FAF080
1F26 01 00000004 0000317B
1F26 20 00000004 0000317B
1F26 6E 00000004 0000317B
1F26 F1 00000004 0000317B
1F26 F2 00000004 0000317B
1F26 F3 00000004 0000317B
1F27 01 00000004 03261416
1F27 20 00000004 03261416
1F27 6E 00000004 03261416
1F27 F1 00000004 03261416
1F27 F2 00000004 03261416
1F27 F3 00000004 03261416
1F80 00 00000004 00004800
1F92 01 00000004 00030D40
1F92 20 00000004 00030D40
1F92 6E 00000004 00030D40
1F92 F1 00000004 00006978
1F92 F2 00000004 00006978
1F92 F3 00000004 00006978
1400 01 00000001 01
1401 01 00000001 20
1402 01 00000001 6E
1600 01 00000008 000800000001A4C0
1601 01 00000008 000800000002A4C0
1602 01 00000008 000800000003A4C0
1800 01 00000001 01
1801 01 00000001 20
1802 01 00000001 6E
1A00 01 00000008 000800000001A040
1A01 01 00000008 000800000002A040
1A02 01 00000008 000800000003A040
1600 00 00000001 01
1601 00 00000001 01
1602 00 00000001 01
1A00 00 00000001 01
1A01 00 00000001 01
1A02 00 00000001 01
1F81 01 00000004 80000007
1F81 20 00000004 80000007
1F81 6E 00000004 80000007
//// NodeId Reassignment
1F81 01 00000004 80000007
//// NodeId Reassignment
1F81 20 00000004 80000007
//// NodeId Reassignment
1F81 6E 00000004 80000007

View File

@ -0,0 +1,195 @@
0x41, 0x00, 0x00, 0x00, 0x81, 0x1F, 0x01, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x81,
0x1F, 0x20, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x81, 0x1F, 0x6E, 0x04, 0x00, 0x00,
0x00, 0x07, 0x00, 0x00, 0x00, 0x81, 0x1F, 0xF1, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x81, 0x1F, 0xF2, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x81, 0x1F, 0xF3, 0x04, 0x00,
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x16,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1A,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x50, 0xC3, 0x00,
0x00, 0x02, 0x1C, 0x01, 0x04, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x02, 0x1C, 0x03, 0x04,
0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x09, 0x1C, 0x01, 0x04, 0x00, 0x00, 0x00, 0x28, 0x00,
0x00, 0x00, 0x09, 0x1C, 0x20, 0x04, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x09, 0x1C, 0x6E,
0x04, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x14, 0x1C, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80,
0xF0, 0xFA, 0x02, 0x26, 0x1F, 0x01, 0x04, 0x00, 0x00, 0x00, 0x7B, 0x31, 0x00, 0x00, 0x26, 0x1F,
0x20, 0x04, 0x00, 0x00, 0x00, 0x7B, 0x31, 0x00, 0x00, 0x26, 0x1F, 0x6E, 0x04, 0x00, 0x00, 0x00,
0x7B, 0x31, 0x00, 0x00, 0x26, 0x1F, 0xF1, 0x04, 0x00, 0x00, 0x00, 0x7B, 0x31, 0x00, 0x00, 0x26,
0x1F, 0xF2, 0x04, 0x00, 0x00, 0x00, 0x7B, 0x31, 0x00, 0x00, 0x26, 0x1F, 0xF3, 0x04, 0x00, 0x00,
0x00, 0x7B, 0x31, 0x00, 0x00, 0x27, 0x1F, 0x01, 0x04, 0x00, 0x00, 0x00, 0x16, 0x14, 0x26, 0x03,
0x27, 0x1F, 0x20, 0x04, 0x00, 0x00, 0x00, 0x16, 0x14, 0x26, 0x03, 0x27, 0x1F, 0x6E, 0x04, 0x00,
0x00, 0x00, 0x16, 0x14, 0x26, 0x03, 0x27, 0x1F, 0xF1, 0x04, 0x00, 0x00, 0x00, 0x16, 0x14, 0x26,
0x03, 0x27, 0x1F, 0xF2, 0x04, 0x00, 0x00, 0x00, 0x16, 0x14, 0x26, 0x03, 0x27, 0x1F, 0xF3, 0x04,
0x00, 0x00, 0x00, 0x16, 0x14, 0x26, 0x03, 0x80, 0x1F, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x48,
0x00, 0x00, 0x92, 0x1F, 0x01, 0x04, 0x00, 0x00, 0x00, 0x40, 0x0D, 0x03, 0x00, 0x92, 0x1F, 0x20,
0x04, 0x00, 0x00, 0x00, 0x40, 0x0D, 0x03, 0x00, 0x92, 0x1F, 0x6E, 0x04, 0x00, 0x00, 0x00, 0x40,
0x0D, 0x03, 0x00, 0x92, 0x1F, 0xF1, 0x04, 0x00, 0x00, 0x00, 0x78, 0x69, 0x00, 0x00, 0x92, 0x1F,
0xF2, 0x04, 0x00, 0x00, 0x00, 0x78, 0x69, 0x00, 0x00, 0x92, 0x1F, 0xF3, 0x04, 0x00, 0x00, 0x00,
0x78, 0x69, 0x00, 0x00, 0x00, 0x14, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x14, 0x01, 0x01,
0x00, 0x00, 0x00, 0x20, 0x02, 0x14, 0x01, 0x01, 0x00, 0x00, 0x00, 0x6E, 0x00, 0x16, 0x01, 0x08,
0x00, 0x00, 0x00, 0xC0, 0xA4, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x16, 0x01, 0x08, 0x00,
0x00, 0x00, 0xC0, 0xA4, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x16, 0x01, 0x08, 0x00, 0x00,
0x00, 0xC0, 0xA4, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x18, 0x01, 0x01, 0x00, 0x00, 0x00,
0x01, 0x01, 0x18, 0x01, 0x01, 0x00, 0x00, 0x00, 0x20, 0x02, 0x18, 0x01, 0x01, 0x00, 0x00, 0x00,
0x6E, 0x00, 0x1A, 0x01, 0x08, 0x00, 0x00, 0x00, 0x40, 0xA0, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00,
0x01, 0x1A, 0x01, 0x08, 0x00, 0x00, 0x00, 0x40, 0xA0, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02,
0x1A, 0x01, 0x08, 0x00, 0x00, 0x00, 0x40, 0xA0, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x16,
0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, 0x16,
0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x1A,
0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x22, 0x1F,
0x01, 0x96, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00,
0x50, 0xC3, 0x00, 0x00, 0x20, 0x10, 0x01, 0x04, 0x00, 0x00, 0x00, 0x7B, 0x31, 0x00, 0x00, 0x20,
0x10, 0x02, 0x04, 0x00, 0x00, 0x00, 0x16, 0x14, 0x26, 0x03, 0x0B, 0x1C, 0x03, 0x04, 0x00, 0x00,
0x00, 0x50, 0x00, 0x00, 0x00, 0x0D, 0x1C, 0x03, 0x04, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
0x14, 0x1C, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFA, 0x02, 0x98, 0x1F, 0x04, 0x02, 0x00,
0x00, 0x00, 0x24, 0x00, 0x98, 0x1F, 0x05, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x16, 0x01,
0x08, 0x00, 0x00, 0x00, 0x00, 0x62, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x1A, 0x01, 0x08,
0x00, 0x00, 0x00, 0x00, 0x60, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x16, 0x00, 0x01, 0x00,
0x00, 0x00, 0x01, 0x00, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x22, 0x1F, 0x20, 0x96, 0x00,
0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x50, 0xC3, 0x00,
0x00, 0x20, 0x10, 0x01, 0x04, 0x00, 0x00, 0x00, 0x7B, 0x31, 0x00, 0x00, 0x20, 0x10, 0x02, 0x04,
0x00, 0x00, 0x00, 0x16, 0x14, 0x26, 0x03, 0x0B, 0x1C, 0x03, 0x04, 0x00, 0x00, 0x00, 0x50, 0x00,
0x00, 0x00, 0x0D, 0x1C, 0x03, 0x04, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x14, 0x1C, 0x00,
0x04, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFA, 0x02, 0x98, 0x1F, 0x04, 0x02, 0x00, 0x00, 0x00, 0x24,
0x00, 0x98, 0x1F, 0x05, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x16, 0x01, 0x08, 0x00, 0x00,
0x00, 0x00, 0x62, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x1A, 0x01, 0x08, 0x00, 0x00, 0x00,
0x00, 0x60, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
0x00, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x22, 0x1F, 0x6E, 0x96, 0x00, 0x00, 0x00, 0x0E,
0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A, 0x00, 0x01, 0x00,
0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x50, 0xC3, 0x00, 0x00, 0x20, 0x10,
0x01, 0x04, 0x00, 0x00, 0x00, 0x7B, 0x31, 0x00, 0x00, 0x20, 0x10, 0x02, 0x04, 0x00, 0x00, 0x00,
0x16, 0x14, 0x26, 0x03, 0x0B, 0x1C, 0x03, 0x04, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x0D,
0x1C, 0x03, 0x04, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x14, 0x1C, 0x00, 0x04, 0x00, 0x00,
0x00, 0x80, 0xF0, 0xFA, 0x02, 0x98, 0x1F, 0x04, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x98, 0x1F,
0x05, 0x02, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x16, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x62,
0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x1A, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x60, 0x01,
0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x1A, 0x00,
0x01, 0x00, 0x00, 0x00, 0x01, 0x22, 0x1F, 0xF1, 0x9B, 0x02, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00,
0x81, 0x1F, 0x01, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x81, 0x1F, 0x20, 0x04, 0x00,
0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x81, 0x1F, 0x6E, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00,
0x00, 0x81, 0x1F, 0xF1, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x81, 0x1F, 0xF2, 0x04,
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x81, 0x1F, 0xF3, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00,
0x00, 0x00, 0x00, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x16, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x02, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x01, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1A, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x06, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x50, 0xC3, 0x00, 0x00, 0x20, 0x10, 0x01,
0x04, 0x00, 0x00, 0x00, 0x7B, 0x31, 0x00, 0x00, 0x20, 0x10, 0x02, 0x04, 0x00, 0x00, 0x00, 0x16,
0x14, 0x26, 0x03, 0x02, 0x1C, 0x01, 0x04, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x02, 0x1C,
0x03, 0x04, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x09, 0x1C, 0x01, 0x04, 0x00, 0x00, 0x00,
0x28, 0x00, 0x00, 0x00, 0x09, 0x1C, 0x20, 0x04, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x09,
0x1C, 0x6E, 0x04, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x0B, 0x1C, 0x03, 0x04, 0x00, 0x00,
0x00, 0x50, 0x00, 0x00, 0x00, 0x0D, 0x1C, 0x03, 0x04, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
0x14, 0x1C, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFA, 0x02, 0x26, 0x1F, 0x01, 0x04, 0x00,
0x00, 0x00, 0x7B, 0x31, 0x00, 0x00, 0x26, 0x1F, 0x20, 0x04, 0x00, 0x00, 0x00, 0x7B, 0x31, 0x00,
0x00, 0x26, 0x1F, 0x6E, 0x04, 0x00, 0x00, 0x00, 0x7B, 0x31, 0x00, 0x00, 0x26, 0x1F, 0xF1, 0x04,
0x00, 0x00, 0x00, 0x7B, 0x31, 0x00, 0x00, 0x26, 0x1F, 0xF2, 0x04, 0x00, 0x00, 0x00, 0x7B, 0x31,
0x00, 0x00, 0x26, 0x1F, 0xF3, 0x04, 0x00, 0x00, 0x00, 0x7B, 0x31, 0x00, 0x00, 0x27, 0x1F, 0x01,
0x04, 0x00, 0x00, 0x00, 0x16, 0x14, 0x26, 0x03, 0x27, 0x1F, 0x20, 0x04, 0x00, 0x00, 0x00, 0x16,
0x14, 0x26, 0x03, 0x27, 0x1F, 0x6E, 0x04, 0x00, 0x00, 0x00, 0x16, 0x14, 0x26, 0x03, 0x27, 0x1F,
0xF1, 0x04, 0x00, 0x00, 0x00, 0x16, 0x14, 0x26, 0x03, 0x27, 0x1F, 0xF2, 0x04, 0x00, 0x00, 0x00,
0x16, 0x14, 0x26, 0x03, 0x27, 0x1F, 0xF3, 0x04, 0x00, 0x00, 0x00, 0x16, 0x14, 0x26, 0x03, 0x80,
0x1F, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x92, 0x1F, 0x01, 0x04, 0x00, 0x00,
0x00, 0x40, 0x0D, 0x03, 0x00, 0x92, 0x1F, 0x20, 0x04, 0x00, 0x00, 0x00, 0x40, 0x0D, 0x03, 0x00,
0x92, 0x1F, 0x6E, 0x04, 0x00, 0x00, 0x00, 0x40, 0x0D, 0x03, 0x00, 0x92, 0x1F, 0xF1, 0x04, 0x00,
0x00, 0x00, 0x78, 0x69, 0x00, 0x00, 0x92, 0x1F, 0xF2, 0x04, 0x00, 0x00, 0x00, 0x78, 0x69, 0x00,
0x00, 0x92, 0x1F, 0xF3, 0x04, 0x00, 0x00, 0x00, 0x78, 0x69, 0x00, 0x00, 0x00, 0x14, 0x01, 0x01,
0x00, 0x00, 0x00, 0x01, 0x01, 0x14, 0x01, 0x01, 0x00, 0x00, 0x00, 0x20, 0x02, 0x14, 0x01, 0x01,
0x00, 0x00, 0x00, 0x6E, 0x00, 0x16, 0x01, 0x08, 0x00, 0x00, 0x00, 0xC0, 0xA4, 0x01, 0x00, 0x00,
0x00, 0x08, 0x00, 0x01, 0x16, 0x01, 0x08, 0x00, 0x00, 0x00, 0xC0, 0xA4, 0x02, 0x00, 0x00, 0x00,
0x08, 0x00, 0x02, 0x16, 0x01, 0x08, 0x00, 0x00, 0x00, 0xC0, 0xA4, 0x03, 0x00, 0x00, 0x00, 0x08,
0x00, 0x00, 0x18, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x18, 0x01, 0x01, 0x00, 0x00, 0x00,
0x20, 0x02, 0x18, 0x01, 0x01, 0x00, 0x00, 0x00, 0x6E, 0x00, 0x1A, 0x01, 0x08, 0x00, 0x00, 0x00,
0x40, 0xA0, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x1A, 0x01, 0x08, 0x00, 0x00, 0x00, 0x40,
0xA0, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x1A, 0x01, 0x08, 0x00, 0x00, 0x00, 0x40, 0xA0,
0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x16,
0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x1A,
0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, 0x1A,
0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x81, 0x1F, 0x01, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00,
0x80, 0x81, 0x1F, 0x20, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x80, 0x81, 0x1F, 0x6E, 0x04,
0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x80, 0x22, 0x1F, 0xF2, 0x9B, 0x02, 0x00, 0x00, 0x3F, 0x00,
0x00, 0x00, 0x81, 0x1F, 0x01, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x81, 0x1F, 0x20,
0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x81, 0x1F, 0x6E, 0x04, 0x00, 0x00, 0x00, 0x07,
0x00, 0x00, 0x00, 0x81, 0x1F, 0xF1, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x81, 0x1F,
0xF2, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x81, 0x1F, 0xF3, 0x04, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x16, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x02, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x01, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1A, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x50, 0xC3, 0x00, 0x00, 0x20,
0x10, 0x01, 0x04, 0x00, 0x00, 0x00, 0x7B, 0x31, 0x00, 0x00, 0x20, 0x10, 0x02, 0x04, 0x00, 0x00,
0x00, 0x16, 0x14, 0x26, 0x03, 0x02, 0x1C, 0x01, 0x04, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
0x02, 0x1C, 0x03, 0x04, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x09, 0x1C, 0x01, 0x04, 0x00,
0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x09, 0x1C, 0x20, 0x04, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00,
0x00, 0x09, 0x1C, 0x6E, 0x04, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x0B, 0x1C, 0x03, 0x04,
0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x0D, 0x1C, 0x03, 0x04, 0x00, 0x00, 0x00, 0x50, 0x00,
0x00, 0x00, 0x14, 0x1C, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFA, 0x02, 0x26, 0x1F, 0x01,
0x04, 0x00, 0x00, 0x00, 0x7B, 0x31, 0x00, 0x00, 0x26, 0x1F, 0x20, 0x04, 0x00, 0x00, 0x00, 0x7B,
0x31, 0x00, 0x00, 0x26, 0x1F, 0x6E, 0x04, 0x00, 0x00, 0x00, 0x7B, 0x31, 0x00, 0x00, 0x26, 0x1F,
0xF1, 0x04, 0x00, 0x00, 0x00, 0x7B, 0x31, 0x00, 0x00, 0x26, 0x1F, 0xF2, 0x04, 0x00, 0x00, 0x00,
0x7B, 0x31, 0x00, 0x00, 0x26, 0x1F, 0xF3, 0x04, 0x00, 0x00, 0x00, 0x7B, 0x31, 0x00, 0x00, 0x27,
0x1F, 0x01, 0x04, 0x00, 0x00, 0x00, 0x16, 0x14, 0x26, 0x03, 0x27, 0x1F, 0x20, 0x04, 0x00, 0x00,
0x00, 0x16, 0x14, 0x26, 0x03, 0x27, 0x1F, 0x6E, 0x04, 0x00, 0x00, 0x00, 0x16, 0x14, 0x26, 0x03,
0x27, 0x1F, 0xF1, 0x04, 0x00, 0x00, 0x00, 0x16, 0x14, 0x26, 0x03, 0x27, 0x1F, 0xF2, 0x04, 0x00,
0x00, 0x00, 0x16, 0x14, 0x26, 0x03, 0x27, 0x1F, 0xF3, 0x04, 0x00, 0x00, 0x00, 0x16, 0x14, 0x26,
0x03, 0x80, 0x1F, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x92, 0x1F, 0x01, 0x04,
0x00, 0x00, 0x00, 0x40, 0x0D, 0x03, 0x00, 0x92, 0x1F, 0x20, 0x04, 0x00, 0x00, 0x00, 0x40, 0x0D,
0x03, 0x00, 0x92, 0x1F, 0x6E, 0x04, 0x00, 0x00, 0x00, 0x40, 0x0D, 0x03, 0x00, 0x92, 0x1F, 0xF1,
0x04, 0x00, 0x00, 0x00, 0x78, 0x69, 0x00, 0x00, 0x92, 0x1F, 0xF2, 0x04, 0x00, 0x00, 0x00, 0x78,
0x69, 0x00, 0x00, 0x92, 0x1F, 0xF3, 0x04, 0x00, 0x00, 0x00, 0x78, 0x69, 0x00, 0x00, 0x00, 0x14,
0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x14, 0x01, 0x01, 0x00, 0x00, 0x00, 0x20, 0x02, 0x14,
0x01, 0x01, 0x00, 0x00, 0x00, 0x6E, 0x00, 0x16, 0x01, 0x08, 0x00, 0x00, 0x00, 0xC0, 0xA4, 0x01,
0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x16, 0x01, 0x08, 0x00, 0x00, 0x00, 0xC0, 0xA4, 0x02, 0x00,
0x00, 0x00, 0x08, 0x00, 0x02, 0x16, 0x01, 0x08, 0x00, 0x00, 0x00, 0xC0, 0xA4, 0x03, 0x00, 0x00,
0x00, 0x08, 0x00, 0x00, 0x18, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x18, 0x01, 0x01, 0x00,
0x00, 0x00, 0x20, 0x02, 0x18, 0x01, 0x01, 0x00, 0x00, 0x00, 0x6E, 0x00, 0x1A, 0x01, 0x08, 0x00,
0x00, 0x00, 0x40, 0xA0, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x1A, 0x01, 0x08, 0x00, 0x00,
0x00, 0x40, 0xA0, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x1A, 0x01, 0x08, 0x00, 0x00, 0x00,
0x40, 0xA0, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
0x01, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
0x00, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
0x02, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x81, 0x1F, 0x01, 0x04, 0x00, 0x00, 0x00, 0x07,
0x00, 0x00, 0x80, 0x81, 0x1F, 0x20, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x80, 0x81, 0x1F,
0x6E, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x80, 0x22, 0x1F, 0xF3, 0x9B, 0x02, 0x00, 0x00,
0x3F, 0x00, 0x00, 0x00, 0x81, 0x1F, 0x01, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x81,
0x1F, 0x20, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x81, 0x1F, 0x6E, 0x04, 0x00, 0x00,
0x00, 0x07, 0x00, 0x00, 0x00, 0x81, 0x1F, 0xF1, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x81, 0x1F, 0xF2, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x81, 0x1F, 0xF3, 0x04, 0x00,
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x16,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1A,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1A,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x50, 0xC3, 0x00,
0x00, 0x20, 0x10, 0x01, 0x04, 0x00, 0x00, 0x00, 0x7B, 0x31, 0x00, 0x00, 0x20, 0x10, 0x02, 0x04,
0x00, 0x00, 0x00, 0x16, 0x14, 0x26, 0x03, 0x02, 0x1C, 0x01, 0x04, 0x00, 0x00, 0x00, 0x28, 0x00,
0x00, 0x00, 0x02, 0x1C, 0x03, 0x04, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x09, 0x1C, 0x01,
0x04, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x09, 0x1C, 0x20, 0x04, 0x00, 0x00, 0x00, 0x28,
0x00, 0x00, 0x00, 0x09, 0x1C, 0x6E, 0x04, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x0B, 0x1C,
0x03, 0x04, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x0D, 0x1C, 0x03, 0x04, 0x00, 0x00, 0x00,
0x50, 0x00, 0x00, 0x00, 0x14, 0x1C, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xFA, 0x02, 0x26,
0x1F, 0x01, 0x04, 0x00, 0x00, 0x00, 0x7B, 0x31, 0x00, 0x00, 0x26, 0x1F, 0x20, 0x04, 0x00, 0x00,
0x00, 0x7B, 0x31, 0x00, 0x00, 0x26, 0x1F, 0x6E, 0x04, 0x00, 0x00, 0x00, 0x7B, 0x31, 0x00, 0x00,
0x26, 0x1F, 0xF1, 0x04, 0x00, 0x00, 0x00, 0x7B, 0x31, 0x00, 0x00, 0x26, 0x1F, 0xF2, 0x04, 0x00,
0x00, 0x00, 0x7B, 0x31, 0x00, 0x00, 0x26, 0x1F, 0xF3, 0x04, 0x00, 0x00, 0x00, 0x7B, 0x31, 0x00,
0x00, 0x27, 0x1F, 0x01, 0x04, 0x00, 0x00, 0x00, 0x16, 0x14, 0x26, 0x03, 0x27, 0x1F, 0x20, 0x04,
0x00, 0x00, 0x00, 0x16, 0x14, 0x26, 0x03, 0x27, 0x1F, 0x6E, 0x04, 0x00, 0x00, 0x00, 0x16, 0x14,
0x26, 0x03, 0x27, 0x1F, 0xF1, 0x04, 0x00, 0x00, 0x00, 0x16, 0x14, 0x26, 0x03, 0x27, 0x1F, 0xF2,
0x04, 0x00, 0x00, 0x00, 0x16, 0x14, 0x26, 0x03, 0x27, 0x1F, 0xF3, 0x04, 0x00, 0x00, 0x00, 0x16,
0x14, 0x26, 0x03, 0x80, 0x1F, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x92, 0x1F,
0x01, 0x04, 0x00, 0x00, 0x00, 0x40, 0x0D, 0x03, 0x00, 0x92, 0x1F, 0x20, 0x04, 0x00, 0x00, 0x00,
0x40, 0x0D, 0x03, 0x00, 0x92, 0x1F, 0x6E, 0x04, 0x00, 0x00, 0x00, 0x40, 0x0D, 0x03, 0x00, 0x92,
0x1F, 0xF1, 0x04, 0x00, 0x00, 0x00, 0x78, 0x69, 0x00, 0x00, 0x92, 0x1F, 0xF2, 0x04, 0x00, 0x00,
0x00, 0x78, 0x69, 0x00, 0x00, 0x92, 0x1F, 0xF3, 0x04, 0x00, 0x00, 0x00, 0x78, 0x69, 0x00, 0x00,
0x00, 0x14, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x14, 0x01, 0x01, 0x00, 0x00, 0x00, 0x20,
0x02, 0x14, 0x01, 0x01, 0x00, 0x00, 0x00, 0x6E, 0x00, 0x16, 0x01, 0x08, 0x00, 0x00, 0x00, 0xC0,
0xA4, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x16, 0x01, 0x08, 0x00, 0x00, 0x00, 0xC0, 0xA4,
0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x16, 0x01, 0x08, 0x00, 0x00, 0x00, 0xC0, 0xA4, 0x03,
0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x18, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x18, 0x01,
0x01, 0x00, 0x00, 0x00, 0x20, 0x02, 0x18, 0x01, 0x01, 0x00, 0x00, 0x00, 0x6E, 0x00, 0x1A, 0x01,
0x08, 0x00, 0x00, 0x00, 0x40, 0xA0, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x1A, 0x01, 0x08,
0x00, 0x00, 0x00, 0x40, 0xA0, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, 0x1A, 0x01, 0x08, 0x00,
0x00, 0x00, 0x40, 0xA0, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x16, 0x00, 0x01, 0x00, 0x00,
0x00, 0x01, 0x01, 0x16, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, 0x16, 0x00, 0x01, 0x00, 0x00,
0x00, 0x01, 0x00, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x1A, 0x00, 0x01, 0x00, 0x00,
0x00, 0x01, 0x02, 0x1A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x81, 0x1F, 0x01, 0x04, 0x00, 0x00,
0x00, 0x07, 0x00, 0x00, 0x80, 0x81, 0x1F, 0x20, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x80,
0x81, 0x1F, 0x6E, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x80, 0x81, 0x1F, 0x01, 0x04, 0x00,
0x00, 0x00, 0x07, 0x00, 0x00, 0x80, 0x81, 0x1F, 0x20, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00,
0x80, 0x81, 0x1F, 0x6E, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x80

View File

@ -0,0 +1,27 @@
/*
* This file was autogenerated by openCONFIGURATOR-2.2.1_release on 06-Sep-2018 14:40:27
* Project: Demo_RMN_3CN
* Application process for openPOWERLINK_MN(240)
*/
#ifndef XAP_h
#define XAP_h
#define COMPUTED_PI_OUT_SIZE 4
typedef struct
{
unsigned CN1_DigitalInput_00h_AU8_DigitalInput:8;
unsigned CN32_DigitalInput_00h_AU8_DigitalInput:8;
unsigned CN110_DigitalInput_00h_AU8_DigitalInput:8;
unsigned PADDING_VAR_1:8;
} PI_OUT;
#define COMPUTED_PI_IN_SIZE 4
typedef struct
{
unsigned CN1_DigitalOutput_00h_AU8_DigitalOutput:8;
unsigned CN32_DigitalOutput_00h_AU8_DigitalOutput:8;
unsigned CN110_DigitalOutput_00h_AU8_DigitalOutput:8;
unsigned PADDING_VAR_1:8;
} PI_IN;
#endif

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This file was autogenerated by openCONFIGURATOR-2.2.1_release on 06-Sep-2018 14:40:27 -->
<!-- Project: Demo_RMN_3CN -->
<!-- Application process for openPOWERLINK_MN(240) -->
<ApplicationProcess xmlns="http://ethernet-powerlink.org/POWERLINK/PI">
<ProcessImage type="output" size="3">
<Channel Name="CN1.DigitalInput.00h.AU8.DigitalInput" dataType="Unsigned8" dataSize="8" PIOffset="0x0000"/>
<Channel Name="CN32.DigitalInput.00h.AU8.DigitalInput" dataType="Unsigned8" dataSize="8" PIOffset="0x0001"/>
<Channel Name="CN110.DigitalInput.00h.AU8.DigitalInput" dataType="Unsigned8" dataSize="8" PIOffset="0x0002"/>
</ProcessImage>
<ProcessImage type="input" size="3">
<Channel Name="CN1.DigitalOutput.00h.AU8.DigitalOutput" dataType="Unsigned8" dataSize="8" PIOffset="0x0000"/>
<Channel Name="CN32.DigitalOutput.00h.AU8.DigitalOutput" dataType="Unsigned8" dataSize="8" PIOffset="0x0001"/>
<Channel Name="CN110.DigitalOutput.00h.AU8.DigitalOutput" dataType="Unsigned8" dataSize="8" PIOffset="0x0002"/>
</ProcessImage>
</ApplicationProcess>

View File

@ -0,0 +1,92 @@
/**
********************************************************************************
\file arp-target.h
\brief ARP demo target header
This file contains the target specific definitions like endian conversion.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
#ifndef _INC_arp_target_H_
#define _INC_arp_target_H_
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <oplk/oplk.h>
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#if (TARGET_SYSTEM == _LINUX_)
#include <arpa/inet.h>
#else
#if CHECK_IF_BIG_ENDIAN()
// Big endian => no swap needed
#define htons(x) (x)
#define htonl(x) (x)
#define ntohs(x) (x)
#define ntohl(x) (x)
#else
// Little endian => swap needed
// Swap long: 0x00C0FFEE --> 0xEEFFC000
#define ARP_SWAPL(x) ((((x) >> 24) & 0x000000FF) | \
(((x) >> 8) & 0x0000FF00) | \
(((x) & 0x000000FF) << 24) | \
(((x) & 0x0000FF00) << 8))
// Swap short: 0xC0FE --> 0xFEC0
#define ARP_SWAPS(x) ((((x) >> 8) & 0x00FF) | \
(((x) << 8) & 0xFF00))
#define htons(x) ARP_SWAPS(x)
#define htonl(x) ARP_SWAPL(x)
#define ntohs(x) ARP_SWAPS(x)
#define ntohl(x) ARP_SWAPL(x)
#endif //CHECK_IF_BIG_ENDIAN
#endif //DEV_SYSTEM
//------------------------------------------------------------------------------
// typedef
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// function prototypes
//------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef __cplusplus
}
#endif
#endif /* _INC_arp_target_H_ */

View File

@ -0,0 +1,426 @@
/**
********************************************************************************
\file arp.c
\brief ARP demo implementation
This file implements an ARP demo for demo targets that have no IP stack.
\ingroup module_app_common
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include "arp.h"
#include "arp-target.h"
#include <oplk/oplk.h>
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P R I V A T E D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#define ARP_ETHERTYPE 0x0806 ///< ARP "EtherType"
#define ARP_HWTYPE_ETHERNET 1 ///< ARP hardware type Ethernet
#define ARP_PROTYPE_IPV4 0x0800 ///< ARP protocol type IP V4
#define ARP_HWADDR_LENGTH 6 ///< ARP hardware address length Ethernet
#define ARP_PROADDR_LENGTH 4 ///< ARP protocol address length IP V4
#define ARP_OP_REQUEST 1 ///< ARP operation request
#define ARP_OP_REPLY 2 ///< ARP operation reply
//------------------------------------------------------------------------------
// local types
//------------------------------------------------------------------------------
/**
* \brief Ethernet with ARP message
*
* This struct defines an Ethernet frame with ARP message payload.
*
*/
typedef struct
{
UINT8 aDstMac[ARP_HWADDR_LENGTH]; ///< Ethernet destination MAC address
UINT8 aSrcMac[ARP_HWADDR_LENGTH]; ///< Ethernet source MAC address
UINT16 etherType; ///< Ethernet "etherType"
UINT16 hardwareType; ///< ARP network protocol type
UINT16 protocolType; ///< ARP internetwork protocol type
UINT8 hardwareAddressLength; ///< ARP length of hardware address [octets]
UINT8 protocolAddressLength; ///< ARP length of internetwork address [octets]
UINT16 operation; ///< ARP operation
UINT8 aSenderHardwareAddress[ARP_HWADDR_LENGTH]; ///< ARP sender hardware address
UINT8 aSenderProtocolAddress[ARP_PROADDR_LENGTH]; ///< ARP sender internetwork address
UINT8 aTargetHardwareAddress[ARP_HWADDR_LENGTH]; ///< ARP target hardware address
UINT8 aTargetProtocolAddress[ARP_PROADDR_LENGTH]; ///< ARP target internetwork address
} tArpFrame;
/**
* \brief ARP instance
*
* This struct defines the ARP instance.
*
*/
typedef struct
{
tArpFrame frameTemplate; ///< ARP frame template
UINT8 nodeId; ///< The local node ID
UINT8 aMacAddr[ARP_HWADDR_LENGTH]; ///< The local node's MAC address in network order
UINT8 aIpAddr[ARP_PROADDR_LENGTH]; ///< The local node's IP address in network order
UINT8 aDefaultGwIp[ARP_PROADDR_LENGTH]; ///< Default gateway IP address in network order
UINT8 aDefaultGwMac[ARP_HWADDR_LENGTH]; ///< Default gateway MAC address in network order
} tArpInstance;
//------------------------------------------------------------------------------
// local vars
//------------------------------------------------------------------------------
static tArpInstance arpInstance_l;
//------------------------------------------------------------------------------
// local function prototypes
//------------------------------------------------------------------------------
static void handleReply(const tArpFrame* pFrame_p);
static int handleRequest(const tArpFrame* pFrame_p);
//============================================================================//
// P U B L I C F U N C T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Initialize ARP module
The function initializes the ARP module before being used.
\param[in] nodeId_p The local node ID
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void arp_init(UINT8 nodeId_p)
{
tArpFrame* pFrame;
memset(&arpInstance_l, 0, sizeof(tArpInstance));
arpInstance_l.nodeId = nodeId_p;
pFrame = &arpInstance_l.frameTemplate; // Set ARP frame template
pFrame->etherType = htons(ARP_ETHERTYPE); // EtherType: ARP
pFrame->hardwareType = htons(ARP_HWTYPE_ETHERNET); // Hardware Type: Ethernet
pFrame->protocolType = htons(ARP_PROTYPE_IPV4); // Protocol Type: IP V4
pFrame->hardwareAddressLength = ARP_HWADDR_LENGTH; // Hardware Address Length
pFrame->protocolAddressLength = ARP_PROADDR_LENGTH; // Protocol Address Length
}
//------------------------------------------------------------------------------
/**
\brief Shutdown ARP module
The function shuts down the ARP module.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void arp_exit(void)
{
}
//------------------------------------------------------------------------------
/**
\brief Set local node MAC address
The function sets the local node's MAC address.
\param[in] pMacAddr_p Pointer to buffer that holds the MAC address to be set
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void arp_setMacAddr(const UINT8* pMacAddr_p)
{
memcpy(&arpInstance_l.aMacAddr, pMacAddr_p, ARP_HWADDR_LENGTH);
}
//------------------------------------------------------------------------------
/**
\brief Set local node IP address
The function sets the local node's IP address.
\param[in] ipAddr_p IP address to be set
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void arp_setIpAddr(UINT32 ipAddr_p)
{
UINT32 ipAddr = htonl(ipAddr_p); // Swap to get network order
memcpy(arpInstance_l.aIpAddr, &ipAddr, ARP_PROADDR_LENGTH);
}
//------------------------------------------------------------------------------
/**
\brief Set default gateway address
The function sets the default gateway's IP address.
\param[in] defGateway_p Default gateway IP address
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void arp_setDefGateway(UINT32 defGateway_p)
{
UINT32 defGateway = htonl(defGateway_p); // Swap to get network order
memcpy(arpInstance_l.aDefaultGwIp, &defGateway, ARP_PROADDR_LENGTH);
// Invalidate default gateway's MAC address
memset(arpInstance_l.aDefaultGwMac, 0, ARP_HWADDR_LENGTH);
}
//------------------------------------------------------------------------------
/**
\brief Send ARP request to POWERLINK node
The function sends an ARP request to the given POWERLINK node.
\param[in] ipAddr_p IP address to destination node
\return The function returns 0 if the ARP request has been sent, otherwise -1.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
int arp_sendRequest(UINT32 ipAddr_p)
{
tArpFrame frameBuffer;
tArpFrame* pFrame = &frameBuffer;
UINT32 ipAddr = htonl(ipAddr_p); // Swap to get network order
// Copy ARP frame template to frame buffer
memcpy(pFrame, &arpInstance_l.frameTemplate, sizeof(tArpFrame));
// Set Destination MAC address (broadcast)
memset(pFrame->aDstMac, 0xFF, ARP_HWADDR_LENGTH);
// Set ARP operation
pFrame->operation = htons(ARP_OP_REQUEST);
// Sender IP Address
memcpy(pFrame->aSenderProtocolAddress, arpInstance_l.aIpAddr, ARP_PROADDR_LENGTH);
// Overwrite last byte with node ID
pFrame->aSenderProtocolAddress[3] = arpInstance_l.nodeId;
// Sender MAC Address
memcpy(pFrame->aSenderHardwareAddress, &arpInstance_l.aMacAddr[0], ARP_HWADDR_LENGTH);
// Target IP Address
memcpy(pFrame->aTargetProtocolAddress, &ipAddr, ARP_PROADDR_LENGTH);
if (oplk_sendEthFrame((tPlkFrame*)pFrame, sizeof(tArpFrame)) == kErrorOk)
return 0;
else
return -1;
}
//------------------------------------------------------------------------------
/**
\brief Process Ethernet ARP frames
The function processes a received Ethernet frame for ARP handling.
\param[in] pFrame_p Pointer to ARP frame
\param[in] size_p Size of the frame
\return The function returns 0 if an ARP frame has been received and handled
successfully, otherwise -1.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
int arp_processReceive(const tPlkFrame* pFrame_p,
UINT size_p)
{
int ret = 0;
tArpFrame* pFrame = (tArpFrame*)pFrame_p;
// Handle ARP frames: Check etherType and frame size
if ((ntohs(pFrame->etherType) == ARP_ETHERTYPE) &&
(size_p >= sizeof(tArpFrame)))
{
//Check for correct hardware, protocol type and length fields
if ((ntohs(pFrame->hardwareType) == ARP_HWTYPE_ETHERNET) &&
(ntohs(pFrame->protocolType) == ARP_PROTYPE_IPV4) &&
(pFrame->hardwareAddressLength == ARP_HWADDR_LENGTH) &&
(pFrame->protocolAddressLength == ARP_PROADDR_LENGTH))
{
switch (ntohs(pFrame->operation))
{
case ARP_OP_REPLY:
handleReply(pFrame);
break;
case ARP_OP_REQUEST:
handleRequest(pFrame);
break;
default:
break;
}
}
}
else
{
// It is no ARP frame => other protocol shall try...
ret = -1;
}
return ret;
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
//------------------------------------------------------------------------------
/**
\brief Handle ARP Reply frame
The function handles an ARP Reply frame.
\param[in] pFrame_p Pointer to ARP frame
*/
//------------------------------------------------------------------------------
static void handleReply(const tArpFrame* pFrame_p)
{
PRINTF("ARP: Node with IP Address %d.%d.%d.%d ",
pFrame_p->aSenderProtocolAddress[0],
pFrame_p->aSenderProtocolAddress[1],
pFrame_p->aSenderProtocolAddress[2],
pFrame_p->aSenderProtocolAddress[3]);
PRINTF("has MAC Address %02X:%02X:%02X:%02X:%02X:%02X ",
pFrame_p->aSenderHardwareAddress[0],
pFrame_p->aSenderHardwareAddress[1],
pFrame_p->aSenderHardwareAddress[2],
pFrame_p->aSenderHardwareAddress[3],
pFrame_p->aSenderHardwareAddress[4],
pFrame_p->aSenderHardwareAddress[5]);
if (memcmp(pFrame_p->aSenderProtocolAddress, arpInstance_l.aDefaultGwIp, ARP_PROADDR_LENGTH) == 0)
{
PRINTF("(default gateway)");
// Store default gateway's MAC address
memcpy(arpInstance_l.aDefaultGwMac, pFrame_p->aSenderHardwareAddress, ARP_HWADDR_LENGTH);
}
PRINTF("\n");
}
//------------------------------------------------------------------------------
/**
\brief Handle ARP Request frame
The function handles an ARP Request frame by sending the corresponding ARP reply.
\param[in] pFrame_p Pointer to ARP frame
\return The function returns 0 if the ARP request has been answered successfully,
otherwise -1.
*/
//------------------------------------------------------------------------------
static int handleRequest(const tArpFrame* pFrame_p)
{
int ret = 0;
// Reply if the request is addressing us
if (memcmp(pFrame_p->aTargetProtocolAddress, arpInstance_l.aIpAddr, ARP_PROADDR_LENGTH) == 0)
{
tArpFrame frameBuffer;
tArpFrame* pFrame = &frameBuffer;
const tArpFrame* pRxFrame = pFrame_p;
// Copy ARP frame template to frame buffer
memcpy(pFrame, &arpInstance_l.frameTemplate, sizeof(tArpFrame));
// Copy Destination MAC address to received Source MAC
memcpy(pFrame->aDstMac, pRxFrame->aSrcMac, ARP_HWADDR_LENGTH);
// Set ARP operation
pFrame->operation = htons(ARP_OP_REPLY);
// Sender IP Address
memcpy(pFrame->aSenderProtocolAddress, arpInstance_l.aIpAddr, ARP_PROADDR_LENGTH);
// Overwrite last byte with node ID
pFrame->aSenderProtocolAddress[3] = arpInstance_l.nodeId;
// Sender MAC Address
memcpy(pFrame->aSenderHardwareAddress, &arpInstance_l.aMacAddr[0], ARP_HWADDR_LENGTH);
// Copy received sender info to target info
memcpy(pFrame->aTargetHardwareAddress, pRxFrame->aSenderHardwareAddress, ARP_HWADDR_LENGTH);
memcpy(pFrame->aTargetProtocolAddress, pRxFrame->aSenderProtocolAddress, ARP_PROADDR_LENGTH);
if (oplk_sendEthFrame((tPlkFrame*)pFrame, sizeof(tArpFrame)) == kErrorOk)
ret = 0;
else
ret = -1;
}
return ret;
}
/// \}

View File

@ -0,0 +1,75 @@
/**
********************************************************************************
\file arp.h
\brief ARP demo implementation
This file contains the definitions for the ARP demo.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
#ifndef _INC_arp_H_
#define _INC_arp_H_
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <oplk/oplk.h>
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// typedef
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// function prototypes
//------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
void arp_init(UINT8 nodeId_p);
void arp_exit(void);
void arp_setMacAddr(const UINT8* pMacAddr_p);
void arp_setIpAddr(UINT32 ipAddr_p);
void arp_setDefGateway(UINT32 defGateway_p);
int arp_sendRequest(UINT32 ipAddr_p);
int arp_processReceive(const tPlkFrame* pFrame_p,
UINT size_p);
#ifdef __cplusplus
}
#endif
#endif /* _INC_arp_H_ */

View File

@ -0,0 +1,422 @@
/**
********************************************************************************
\file eventlog.c
\brief openPOWERLIK application event logger
This module implements an event logger for openPOWERLINK applications. It can
print system events in a defined format. It allows filtering of events via
categories and levels.
The module is intended to be used by openPOWERLINK C applications to print
uniform log output. The module uses the eventlog string module to generate the
log message strings.
\ingroup module_app_eventlog
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include "eventlog.h"
#include <oplk/debugstr.h>
#include <stdio.h>
#include <time.h>
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P R I V A T E D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#define EVENTLOG_MAX_LENGTH 256 ///< Maximum log message length
//------------------------------------------------------------------------------
// local types
//------------------------------------------------------------------------------
/**
* Instance of event log module
*
* This structure contains all valid information of an event log instance.
*/
typedef struct
{
tEventlogFormat format; ///< The format of the log output
///< (kEventlogFormatReadable or kEventlogFormatParsable)
tEventlogOutputCb pfnOutput; ///< Function pointer to the output function
UINT32 filterLevel; ///< The level filter. It contains a bitmask with all
///< levels to be printed.
UINT32 filterCategory; ///< The category filter. It contains a bitmask with all
///< categories to be printed.
} tEventlogInstance;
//------------------------------------------------------------------------------
// local vars
//------------------------------------------------------------------------------
static tEventlogInstance eventlogInstance_l;
//------------------------------------------------------------------------------
// local function prototypes
//------------------------------------------------------------------------------
static void printMessage(const char* message_p);
//============================================================================//
// P U B L I C F U N C T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Initialize event logger
The function initializes the event logger. It sets up the logging filter and
the logging format. A callback function that is used by the logger for
printing log messages must be provided.
\param[in] format_p Specifies the logging format.
\param[in] filterLevel_p Sets the filter for the logging level.
\param[in] filterCategory_p Sets the filter for the logging category.
\param[in] pfnOutput_p A callback function to be provided to the logger
for printing log messages.
\ingroup module_app_eventlog
*/
//------------------------------------------------------------------------------
void eventlog_init(tEventlogFormat format_p,
UINT32 filterLevel_p,
UINT32 filterCategory_p,
tEventlogOutputCb pfnOutput_p)
{
eventlogInstance_l.format = format_p;
eventlogInstance_l.pfnOutput = pfnOutput_p;
eventlogInstance_l.filterLevel = filterLevel_p;
eventlogInstance_l.filterCategory = filterCategory_p;
}
//------------------------------------------------------------------------------
/**
\brief Print a generic log message
The function can be used to print a generic log message. You can specify a
printf style format string for printing.
\param[in] level_p The log level to be used for the output.
\param[in] category_p The log category to be used for the output.
\param[in] fmt_p The printf style format string which specifies the
message.
\param[in] ... Required arguments according to the format string.
\ingroup module_app_eventlog
*/
//------------------------------------------------------------------------------
void eventlog_printMessage(tEventlogLevel level_p,
tEventlogCategory category_p,
const char* fmt_p,
...)
{
va_list arglist;
char logMsg[EVENTLOG_MAX_LENGTH];
if (!((eventlogInstance_l.filterLevel & (1 << level_p)) &&
(eventlogInstance_l.filterCategory & (1 << category_p))))
return;
va_start(arglist, fmt_p);
eventlog_createMessageString(logMsg,
EVENTLOG_MAX_LENGTH,
level_p,
category_p,
fmt_p,
arglist);
va_end(arglist);
printMessage(logMsg);
}
//------------------------------------------------------------------------------
/**
\brief Print a node event
The function is used to log openPOWERLINK node events.
\param[in] pNodeEvent_p The node event information to be logged.
\ingroup module_app_eventlog
*/
//------------------------------------------------------------------------------
void eventlog_printNodeEvent(const tOplkApiEventNode* pNodeEvent_p)
{
char logMsg[EVENTLOG_MAX_LENGTH];
if (!((eventlogInstance_l.filterLevel & (1 << kEventlogLevelEvent)) &&
(eventlogInstance_l.filterCategory & (1 << kEventlogCategoryNodeEvent))))
return;
eventlog_createNodeEventString(pNodeEvent_p,
eventlogInstance_l.format,
logMsg,
EVENTLOG_MAX_LENGTH);
printMessage(logMsg);
}
//------------------------------------------------------------------------------
/**
\brief Print a state change event
The function is used to log openPOWERLINK state change events.
\param[in] pStateChangeEvent_p The state change event information to be logged.
\ingroup module_app_eventlog
*/
//------------------------------------------------------------------------------
void eventlog_printStateEvent(const tEventNmtStateChange* pStateChangeEvent_p)
{
char logMsg[EVENTLOG_MAX_LENGTH];
if (!((eventlogInstance_l.filterLevel & (1 << kEventlogLevelEvent)) &&
(eventlogInstance_l.filterCategory & (1 << kEventlogCategoryStateChangeEvent))))
return;
eventlog_createStateEventString(pStateChangeEvent_p,
eventlogInstance_l.format,
logMsg,
EVENTLOG_MAX_LENGTH);
printMessage(logMsg);
}
//------------------------------------------------------------------------------
/**
\brief Print a CFM result event
The function is used to log openPOWERLINK CFM result events.
\param[in] nodeId_p The node ID of the node specified in the received
event.
\param[in] nodeCommand_p The nodeCommand of the received CFM result event.
\ingroup module_app_eventlog
*/
//------------------------------------------------------------------------------
void eventlog_printCfmResultEvent(UINT8 nodeId_p,
tNmtNodeCommand nodeCommand_p)
{
char logMsg[EVENTLOG_MAX_LENGTH];
if (!((eventlogInstance_l.filterLevel & (1 << kEventlogLevelEvent)) &&
(eventlogInstance_l.filterCategory & (1 << kEventlogCategoryCfmResultEvent))))
return;
eventlog_createCfmResultEventString(nodeId_p,
nodeCommand_p,
eventlogInstance_l.format,
logMsg,
EVENTLOG_MAX_LENGTH);
printMessage(logMsg);
}
//------------------------------------------------------------------------------
/**
\brief Print a CFM progress event
The function is used to log openPOWERLINK CFM progress events.
\param[in] pProgress_p The information about the received event.
\ingroup module_app_eventlog
*/
//------------------------------------------------------------------------------
void eventlog_printCfmProgressEvent(const tCfmEventCnProgress* pProgress_p)
{
char logMsg[EVENTLOG_MAX_LENGTH];
if (!((eventlogInstance_l.filterLevel & (1 << kEventlogLevelEvent)) &&
(eventlogInstance_l.filterCategory & (1 << kEventlogCategoryCfmProgressEvent))))
return;
eventlog_createCfmProgressEventString(pProgress_p,
eventlogInstance_l.format,
logMsg,
EVENTLOG_MAX_LENGTH);
printMessage(logMsg);
}
//------------------------------------------------------------------------------
/**
\brief Print a PDO change event
The function is used to log openPOWERLINK PDO change events.
\param[in] pPdoChange_p The information about the received event.
\ingroup module_app_eventlog
*/
//------------------------------------------------------------------------------
void eventlog_printPdoEvent(const tOplkApiEventPdoChange* pPdoChange_p)
{
char logMsg[EVENTLOG_MAX_LENGTH];
if (!((eventlogInstance_l.filterLevel & (1 << kEventlogLevelEvent)) &&
(eventlogInstance_l.filterCategory & (1 << kEventlogCategoryPdoEvent))))
return;
eventlog_createPdoEventString(pPdoChange_p,
eventlogInstance_l.format,
logMsg,
EVENTLOG_MAX_LENGTH);
printMessage(logMsg);
}
//------------------------------------------------------------------------------
/**
\brief Log a PDO mapping information
The function is used to log openPOWERLINK PDO mappings.
\param[in] mapObject_p The object index of the mapping object.
\param[in] subIndex_p The sub-index of the mapping object.
\param[in] mapping_p The 64bit mapping information.
\ingroup module_app_eventlog
*/
//------------------------------------------------------------------------------
void eventlog_printPdoMap(UINT16 mapObject_p,
UINT8 subIndex_p,
UINT64 mapping_p)
{
char logMsg[EVENTLOG_MAX_LENGTH];
if (!((eventlogInstance_l.filterLevel & (1 << kEventlogLevelInfo)) &&
(eventlogInstance_l.filterCategory & (1 << kEventlogCategoryPdoMap))))
return;
eventlog_createPdoMapString(mapObject_p,
subIndex_p,
mapping_p,
eventlogInstance_l.format,
logMsg,
EVENTLOG_MAX_LENGTH);
printMessage(logMsg);
}
//------------------------------------------------------------------------------
/**
\brief Log a history event
The function is used to log openPOWERLINK history events.
\param[in] pHistory_p The information about the history event to log.
\ingroup module_app_eventlog
*/
//------------------------------------------------------------------------------
void eventlog_printHistoryEvent(const tErrHistoryEntry* pHistory_p)
{
char logMsg[EVENTLOG_MAX_LENGTH];
if (!((eventlogInstance_l.filterLevel & (1 << kEventlogLevelEvent)) &&
(eventlogInstance_l.filterCategory & (1 << kEventlogCategoryHistoryEvent))))
return;
eventlog_createHistoryEventString(pHistory_p,
eventlogInstance_l.format,
logMsg,
EVENTLOG_MAX_LENGTH);
printMessage(logMsg);
}
//------------------------------------------------------------------------------
/**
\brief Log an error event
The function is used to log openPOWERLINK error/warning events.
\param[in] pError_p The information about the error event to log.
\ingroup module_app_eventlog
*/
//------------------------------------------------------------------------------
void eventlog_printErrorEvent(const tEventError* pError_p)
{
char logMsg[EVENTLOG_MAX_LENGTH];
if (!((eventlogInstance_l.filterLevel & (1 << kEventlogLevelEvent)) &&
(eventlogInstance_l.filterCategory & (1 << kEventlogCategoryErrorEvent))))
return;
eventlog_createErrorEventString(pError_p,
eventlogInstance_l.format,
logMsg,
EVENTLOG_MAX_LENGTH);
printMessage(logMsg);
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
//------------------------------------------------------------------------------
/**
\brief Print event log message
The function prints the eventlog message by calling the registered printing
callback function.
\param[in] message_p Event log message to be printed.
*/
//------------------------------------------------------------------------------
static void printMessage(const char* message_p)
{
if (eventlogInstance_l.pfnOutput != NULL)
{
eventlogInstance_l.pfnOutput(message_p);
eventlogInstance_l.pfnOutput("\n");
}
}
/// \}

View File

@ -0,0 +1,88 @@
/**
********************************************************************************
\file eventlog.h
\brief Definitions for event log module
This file contains definitions for the eventlog module.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
#ifndef _INC_eventlog_H_
#define _INC_eventlog_H_
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <oplk/oplk.h>
#include <oplk/nmt.h>
#include "eventlogstring.h"
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// typedef
//------------------------------------------------------------------------------
typedef int (*tEventlogOutputCb)(const char* fmt_p, ...);
//------------------------------------------------------------------------------
// function prototypes
//------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
void eventlog_init(tEventlogFormat format_p,
UINT32 filterLevel,
UINT32 filterCategory,
tEventlogOutputCb pfnOutput_p);
void eventlog_printMessage(tEventlogLevel level_p,
tEventlogCategory category_p,
const char* fmt_p,
...);
void eventlog_printNodeEvent(const tOplkApiEventNode* pNodeEvent_p);
void eventlog_printStateEvent(const tEventNmtStateChange* pStateChangeEvent_p);
void eventlog_printCfmResultEvent(UINT8 nodeId_p,
tNmtNodeCommand nodeCommand_p);
void eventlog_printCfmProgressEvent(const tCfmEventCnProgress* pProgress_p);
void eventlog_printPdoEvent(const tOplkApiEventPdoChange* pPdoChange_p);
void eventlog_printHistoryEvent(const tErrHistoryEntry* pHistory_p);
void eventlog_printErrorEvent(const tEventError* pError_p);
void eventlog_printPdoMap(UINT16 mapObject_p,
UINT8 subIndex_p,
UINT64 mapping_p);
#ifdef __cplusplus
}
#endif
#endif /* _INC_eventlog_H_ */

View File

@ -0,0 +1,782 @@
/**
********************************************************************************
\file eventlogstring.c
\brief openPOWERLIK application event logger - string functions
This module implements the string functions for the event logger. It creates
the output strings for the miscellaneous events which can be printed by the
event logger. The strings can be created according to the specified output
format. Two output formats are available. kEventlogFormatParsable specifies
a format that's intended to be parsed by evaluation and test tools.
kEventlogFormatReadable is intended to be read by humans.
\ingroup module_app_eventlogstring
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2017, B&R Industrial Automation GmbH
Copyright (c) 2017, Kalycito Infotech Private Limited
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include "eventlogstring.h"
#include <oplk/debugstr.h>
#include <stdio.h>
#include <time.h>
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P R I V A T E D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
/**
* String values for log levels
*
* The variable contains an array with all log level strings.
*/
static const char* const sEventlogLevel_l[] =
{
"FATAL ",
"ERROR ",
"WARNING ",
"INFO ",
"DEBUG ",
"EVENT ",
};
/**
* String values for log categories
*
* The variable contains an array with all log category strings.
*/
static const char* const sEventlogCategory_l[] =
{
// Generic
"GENERIC ",
"CONTROL ",
"APP ",
"PDOMAP ",
"OBDICT ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
//Events
"NODE ",
"CFM_RESULT ",
"CFM_PROGRESS ",
"STATE_CHANGE ",
"PDO_CHANGE ",
"HISTORY ",
"ERROR ",
"SDO ",
"USER ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
};
/**
* String values for node events
*
* The variable contains an array with all node event strings.
*/
static const char* const sLogEventNodeEvent_l[] =
{
"NmtNodeEventFound",
"NmtNodeEventUpdateSw",
"NmtNodeEventCheckConf",
"NmtNodeEventUpdateConf",
"NmtNodeEventVerifyConf",
"NmtNodeEventReadyToStart",
"NmtNodeEventNmtState",
"NmtNodeEventError",
"NmtNodeEventAmniReceived",
"NmtNodeEventConfDone"
};
//------------------------------------------------------------------------------
// local types
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// local vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// local function prototypes
//------------------------------------------------------------------------------
static size_t createTimeString(char* string_p,
size_t strlen_p);
static size_t createLogLevelString(char* string_p,
size_t strlen_p,
tEventlogLevel logLevel_p);
static size_t createLogCategoryString(char* string_p,
size_t strlen_p,
tEventlogCategory logCategory_p);
//============================================================================//
// P U B L I C F U N C T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Create a generic log message
The function can be used to print a generic log message. You can specify a
printf style format string for printing.
\param[out] message_p Pointer to the message which should be printed.
\param[in] messageSize_p Size of the message string to be printed.
\param[in] level_p The log level to be used for the output.
\param[in] category_p The log category to be used for the output.
\param[in] fmt_p The printf style format string which specifies the
message.
\param[in] arg_p Required arguments according to the format string.
\ingroup module_app_eventlogstring
*/
//------------------------------------------------------------------------------
void eventlog_createMessageString(char* message_p,
size_t messageSize_p,
tEventlogLevel level_p,
tEventlogCategory category_p,
const char* fmt_p,
va_list arg_p)
{
size_t len;
len = createTimeString(message_p, messageSize_p);
len += createLogLevelString(message_p + len, messageSize_p - len, level_p);
len += createLogCategoryString(message_p + len, messageSize_p - len, category_p);
len += vsnprintf(message_p + len, messageSize_p - len, fmt_p, arg_p);
}
//------------------------------------------------------------------------------
/**
\brief Create a node event string
The function is used to log openPOWERLINK node events.
\param[in] pNodeEvent_p The node event information to be logged.
\param[in] format_p The format of the created string (kEventlogFormatParsable
or kEventlogFormatReadable).
\param[out] message_p Buffer to store the created message string.
\param[in] messageSize_p Size of the message buffer.
\ingroup module_app_eventlogstring
*/
//------------------------------------------------------------------------------
void eventlog_createNodeEventString(const tOplkApiEventNode* pNodeEvent_p,
tEventlogFormat format_p,
char* message_p,
size_t messageSize_p)
{
size_t len;
len = createTimeString(message_p, messageSize_p);
len += createLogLevelString(message_p + len, messageSize_p - len, kEventlogLevelEvent);
len += createLogCategoryString(message_p + len, messageSize_p - len, kEventlogCategoryNodeEvent);
switch (format_p)
{
case kEventlogFormatParsable:
len += snprintf(message_p + len,
messageSize_p - len,
"%03d ",
pNodeEvent_p->nodeId);
len += snprintf(message_p + len,
messageSize_p - len,
"EVENT:0x%02X ",
pNodeEvent_p->nodeEvent);
len += snprintf(message_p + len,
messageSize_p - len,
"STATE:0x%02X ",
pNodeEvent_p->nmtState);
len += snprintf(message_p + len,
messageSize_p - len,
"ERROR:0x%04X MANDATORY:%d",
pNodeEvent_p->errorCode,
pNodeEvent_p->fMandatory);
break;
case kEventlogFormatReadable:
len = snprintf(message_p + len,
messageSize_p,
"Node=%3u, %s State:%s",
pNodeEvent_p->nodeId,
sLogEventNodeEvent_l[pNodeEvent_p->nodeEvent],
debugstr_getNmtStateStr(pNodeEvent_p->nmtState));
break;
}
}
//------------------------------------------------------------------------------
/**
\brief Print a state change event
The function is used to log openPOWERLINK state change events.
\param[in] pStateChangeEvent_p The state change event information to be logged.
\param[in] format_p The format of the created string (kEventlogFormatParsable
or kEventlogFormatReadable).
\param[out] message_p Buffer to store the created message string.
\param[in] messageSize_p Size of the message buffer.
\ingroup module_app_eventlogstring
*/
//------------------------------------------------------------------------------
void eventlog_createStateEventString(const tEventNmtStateChange* pStateChangeEvent_p,
tEventlogFormat format_p,
char* message_p,
size_t messageSize_p)
{
size_t len;
len = createTimeString(message_p, messageSize_p);
len += createLogLevelString(message_p + len, messageSize_p - len, kEventlogLevelEvent);
len += createLogCategoryString(message_p + len, messageSize_p - len, kEventlogCategoryStateChangeEvent);
switch (format_p)
{
case kEventlogFormatParsable:
len += snprintf(message_p + len,
messageSize_p - len,
"OLDSTATE:0x%03X NEWSTATE:0x%03X EVENT:0x%02X",
pStateChangeEvent_p->oldNmtState,
pStateChangeEvent_p->newNmtState,
pStateChangeEvent_p->nmtEvent);
break;
case kEventlogFormatReadable:
len += snprintf(message_p + len,
messageSize_p - len,
"%s->%s Originating event:%s",
debugstr_getNmtStateStr(pStateChangeEvent_p->oldNmtState),
debugstr_getNmtStateStr(pStateChangeEvent_p->newNmtState),
debugstr_getNmtEventStr(pStateChangeEvent_p->nmtEvent));
break;
}
}
//------------------------------------------------------------------------------
/**
\brief Create a CFM result event string
The function is used to log openPOWERLINK CFM result events.
\param[in] nodeId_p The node ID of the node specified in the received
event.
\param[in] nodeCommand_p The nodeCommand of the received CFM result event.
\param[in] format_p The format of the created string (kEventlogFormatParsable
or kEventlogFormatReadable).
\param[out] message_p Buffer to store the created message string.
\param[in] messageSize_p Size of the message buffer.
\ingroup module_app_eventlogstring
*/
//------------------------------------------------------------------------------
void eventlog_createCfmResultEventString(UINT8 nodeId_p,
tNmtNodeCommand nodeCommand_p,
tEventlogFormat format_p,
char* message_p,
size_t messageSize_p)
{
size_t len;
len = createTimeString(message_p, messageSize_p);
len += createLogLevelString(message_p + len, messageSize_p - len, kEventlogLevelEvent);
len += createLogCategoryString(message_p + len, messageSize_p - len, kEventlogCategoryCfmResultEvent);
switch (format_p)
{
case kEventlogFormatParsable:
len += snprintf(message_p + len, messageSize_p - len, "%03d ", nodeId_p);
len += snprintf(message_p + len, messageSize_p - len, "0x%02X ", nodeCommand_p);
break;
case kEventlogFormatReadable:
len += snprintf(message_p + len,
messageSize_p - len,
"Node=%3d, %s", nodeId_p,
debugstr_getNmtNodeCommandTypeStr(nodeCommand_p));
break;
}
}
//------------------------------------------------------------------------------
/**
\brief Create a CFM progress event
The function is used to log openPOWERLINK CFM progress events.
\param[in] pProgress_p The information about the CFM progress event.
\param[in] format_p The format of the created string (kEventlogFormatParsable
or kEventlogFormatReadable).
\param[out] message_p Buffer to store the created message string.
\param[in] messageSize_p Size of the message buffer.
\ingroup module_app_eventlogstring
*/
//------------------------------------------------------------------------------
void eventlog_createCfmProgressEventString(const tCfmEventCnProgress* pProgress_p,
tEventlogFormat format_p,
char* message_p,
size_t messageSize_p)
{
size_t len;
len = createTimeString(message_p, messageSize_p);
len += createLogLevelString(message_p + len, messageSize_p - len, kEventlogLevelEvent);
len += createLogCategoryString(message_p + len, messageSize_p - len, kEventlogCategoryCfmProgressEvent);
switch (format_p)
{
case kEventlogFormatParsable:
len += snprintf(message_p + len,
messageSize_p - len,
"%03d ",
pProgress_p->nodeId);
len += snprintf(message_p + len,
messageSize_p - len,
"OBJECT:0x%04X/%03d ",
pProgress_p->objectIndex,
pProgress_p->objectSubIndex);
len += snprintf(message_p + len,
messageSize_p - len,
"SIZE:%05lu DOWNLOADED:%04lu ",
(ULONG)pProgress_p->totalNumberOfBytes,
(ULONG)pProgress_p->bytesDownloaded);
len += snprintf(message_p + len,
messageSize_p - len,
"ABORTCODE:0x%08X ERROR:0x%04X ",
pProgress_p->sdoAbortCode,
pProgress_p->error);
break;
case kEventlogFormatReadable:
len += snprintf(message_p + len,
messageSize_p - len,
"Node=%3u, Object 0x%X/%03u, ",
pProgress_p->nodeId,
pProgress_p->objectIndex,
pProgress_p->objectSubIndex);
len += snprintf(message_p + len,
messageSize_p - len,
"%4lu/%4lu Bytes",
(ULONG)pProgress_p->bytesDownloaded,
(ULONG)pProgress_p->totalNumberOfBytes);
if ((pProgress_p->sdoAbortCode != 0) ||
(pProgress_p->error != kErrorOk))
{
len += snprintf(message_p + len,
messageSize_p - len,
" -> SDO Abort=%s(0x%08X), Error=0x%04X",
debugstr_getAbortCodeStr(pProgress_p->sdoAbortCode),
pProgress_p->sdoAbortCode,
pProgress_p->error);
}
break;
}
}
//------------------------------------------------------------------------------
/**
\brief Create a PDO change event string
The function creates a PDO change event string.
\param[in] pPdoChange_p The information about the PDO change event.
\param[in] format_p The format of the created string (kEventlogFormatParsable
or kEventlogFormatReadable).
\param[out] message_p Buffer to store the created message string.
\param[in] messageSize_p Size of the message buffer.
\ingroup module_app_eventlogstring
*/
//------------------------------------------------------------------------------
void eventlog_createPdoEventString(const tOplkApiEventPdoChange* pPdoChange_p,
tEventlogFormat format_p,
char* message_p,
size_t messageSize_p)
{
size_t len;
len = createTimeString(message_p, messageSize_p);
len += createLogLevelString(message_p + len, messageSize_p - len, kEventlogLevelEvent);
len += createLogCategoryString(message_p + len, messageSize_p - len, kEventlogCategoryPdoEvent);
switch (format_p)
{
case kEventlogFormatParsable:
len += snprintf(message_p + len,
messageSize_p - len,
(pPdoChange_p->fTx ? "TPDO " : "RPDO "));
len += snprintf(message_p + len,
messageSize_p - len,
"MAPOBJ:0x%04x NODE:%03d NUM:%d ",
pPdoChange_p->mappParamIndex,
pPdoChange_p->nodeId,
pPdoChange_p->mappObjectCount);
len += snprintf(message_p + len,
messageSize_p - len,
(pPdoChange_p->fActivated ? "ACTIVATE" : "DELETE"));
break;
case kEventlogFormatReadable:
len += snprintf(message_p + len,
messageSize_p - len,
"%sPDO = 0x%X to node %d with %d objects %s",
(pPdoChange_p->fTx ? "T" : "R"),
pPdoChange_p->mappParamIndex,
pPdoChange_p->nodeId,
pPdoChange_p->mappObjectCount,
(pPdoChange_p->fActivated ? "activated" : "deleted"));
break;
}
}
//------------------------------------------------------------------------------
/**
\brief Create a PDO mapping information string
The function creates a PDO mapping information string.
\param[in] mapObject_p The object index of the mapping object.
\param[in] subIndex_p The sub-index of the mapping object.
\param[in] mapping_p The 64 bit mapping information.
\param[in] format_p The format of the created string (kEventlogFormatParsable
or kEventlogFormatReadable).
\param[out] message_p Buffer to store the created message string.
\param[in] messageSize_p Size of the message buffer.
\ingroup module_app_eventlogstring
*/
//------------------------------------------------------------------------------
void eventlog_createPdoMapString(UINT16 mapObject_p,
UINT8 subIndex_p,
UINT64 mapping_p,
tEventlogFormat format_p,
char* message_p,
size_t messageSize_p)
{
size_t len;
len = createTimeString(message_p, messageSize_p);
len += createLogLevelString(message_p + len, messageSize_p - len, kEventlogLevelInfo);
len += createLogCategoryString(message_p + len, messageSize_p - len, kEventlogCategoryPdoMap);
switch (format_p)
{
case kEventlogFormatParsable:
len += snprintf(message_p + len,
messageSize_p - len,
"MAPOBJ:0x%04x/%d OBJECT:0x%04x/%d OFFSET:%d LEN:%d",
mapObject_p,
subIndex_p,
(UINT32)(mapping_p & 0x000000000000FFFFULL),
(UINT32)((mapping_p & 0x0000000000FF0000ULL) >> 16),
(UINT16)((mapping_p & 0x0000FFFF00000000ULL) >> 32),
(UINT16)((mapping_p & 0xFFFF000000000000ULL) >> 48));
break;
case kEventlogFormatReadable:
len += snprintf(message_p + len,
messageSize_p - len,
" 0x%04x/%d Mapped object 0x%X/%3d", mapObject_p, subIndex_p,
(UINT32)(mapping_p & 0x000000000000FFFFULL),
(UINT32)((mapping_p & 0x0000000000FF0000ULL) >> 16));
break;
}
}
//------------------------------------------------------------------------------
/**
\brief Create a history event string
The function creates a history event string.
\param[in] pHistory_p The information about the history event.
\param[in] format_p The format of the created string (kEventlogFormatParsable
or kEventlogFormatReadable).
\param[out] message_p Buffer to store the created message string.
\param[in] messageSize_p Size of the message buffer.
\ingroup module_app_eventlogstring
*/
//------------------------------------------------------------------------------
void eventlog_createHistoryEventString(const tErrHistoryEntry* pHistory_p,
tEventlogFormat format_p,
char* message_p,
size_t messageSize_p)
{
size_t len;
len = createTimeString(message_p, messageSize_p);
len += createLogLevelString(message_p + len, messageSize_p - len, kEventlogLevelEvent);
len += createLogCategoryString(message_p + len, messageSize_p - len, kEventlogCategoryHistoryEvent);
switch (format_p)
{
case kEventlogFormatParsable:
len += snprintf(message_p + len,
messageSize_p - len,
"TYPE:0x%04X CODE:0x%04X INFO:0x%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
pHistory_p->entryType,
pHistory_p->errorCode,
(UINT16)pHistory_p->aAddInfo[0],
(UINT16)pHistory_p->aAddInfo[1],
(UINT16)pHistory_p->aAddInfo[2],
(UINT16)pHistory_p->aAddInfo[3],
(UINT16)pHistory_p->aAddInfo[4],
(UINT16)pHistory_p->aAddInfo[5],
(UINT16)pHistory_p->aAddInfo[6],
(UINT16)pHistory_p->aAddInfo[7]);
break;
case kEventlogFormatReadable:
len += snprintf(message_p + len,
messageSize_p - len,
"HistoryEntry: Type=0x%04X Code=0x%04X (0x%02X %02X %02X %02X %02X %02X %02X %02X)",
pHistory_p->entryType,
pHistory_p->errorCode,
(UINT16)pHistory_p->aAddInfo[0],
(UINT16)pHistory_p->aAddInfo[1],
(UINT16)pHistory_p->aAddInfo[2],
(UINT16)pHistory_p->aAddInfo[3],
(UINT16)pHistory_p->aAddInfo[4],
(UINT16)pHistory_p->aAddInfo[5],
(UINT16)pHistory_p->aAddInfo[6],
(UINT16)pHistory_p->aAddInfo[7]);
break;
}
}
//------------------------------------------------------------------------------
/**
\brief Create an error event string
The function creates a string for openPOWERLINK error/warning events.
\param[in] pError_p The information about the error event.
\param[in] format_p The format of the created string (kEventlogFormatParsable
or kEventlogFormatReadable).
\param[out] message_p Buffer to store the created message string.
\param[in] messageSize_p Size of the message buffer.
\ingroup module_app_eventlogstring
*/
//------------------------------------------------------------------------------
void eventlog_createErrorEventString(const tEventError* pError_p,
tEventlogFormat format_p,
char* message_p,
size_t messageSize_p)
{
size_t len;
UINT i;
len = createTimeString(message_p, messageSize_p);
len += createLogLevelString(message_p + len, messageSize_p - len, kEventlogLevelEvent);
len += createLogCategoryString(message_p + len, messageSize_p - len, kEventlogCategoryHistoryEvent);
switch (format_p)
{
case kEventlogFormatParsable:
len += snprintf(message_p + len,
messageSize_p - len,
"SOURCE:0x%02X ERROR:0x%03X ARG",
pError_p->eventSource,
pError_p->oplkError);
for (i = 0; i < sizeof(pError_p->errorArg); ++i)
{
len += snprintf(message_p + len,
messageSize_p - len,
":0x%02X",
*((UINT8*)&pError_p->errorArg + i));
}
break;
case kEventlogFormatReadable:
len += snprintf(message_p + len,
messageSize_p - len,
"Source = %s (0x%02X) OplkError = %s (0x%03X) ",
debugstr_getEventSourceStr(pError_p->eventSource),
pError_p->eventSource,
debugstr_getRetValStr(pError_p->oplkError),
pError_p->oplkError);
// check additional argument
switch (pError_p->eventSource)
{
case kEventSourceEventk:
case kEventSourceEventu:
// error occurred within event processing
// either in kernel or in user part
len += snprintf(message_p + len,
messageSize_p - len,
"OrgSource = %s 0x%02X",
debugstr_getEventSourceStr(pError_p->errorArg.eventSource),
pError_p->errorArg.eventSource);
break;
case kEventSourceDllk:
// error occurred within the data link layer (e.g. interrupt processing)
// the DWORD argument contains the DLL state and the NMT event
len += snprintf(message_p + len,
messageSize_p - len,
"Val = 0x%X",
pError_p->errorArg.uintArg);
break;
}
break;
}
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
//------------------------------------------------------------------------------
/**
\brief Create timestamp string
The function creates the timestamp string.
\param[out] string_p String buffer to print to.
\param[in] strlen_p Length of string buffer.
\return The function returns the number of characters printed to the log string.
*/
//------------------------------------------------------------------------------
static size_t createTimeString(char* string_p,
size_t strlen_p)
{
time_t timeStamp;
struct tm* p_timeVal;
size_t len;
time(&timeStamp);
p_timeVal = localtime(&timeStamp);
len = strftime(string_p, strlen_p, "%Y/%m/%d-%H:%M:%S ", p_timeVal);
return len;
}
//------------------------------------------------------------------------------
/**
\brief Create log level string
The function creates the log level string.
\param[out] string_p String buffer to print to.
\param[in] strlen_p Length of string buffer.
\param[in] logLevel_p The log level to print.
\return The function returns the number of characters printed to the log string.
*/
//------------------------------------------------------------------------------
static size_t createLogLevelString(char* string_p,
size_t strlen_p,
tEventlogLevel logLevel_p)
{
size_t len;
len = snprintf(string_p,
strlen_p,
"%s ",
sEventlogLevel_l[logLevel_p]);
return len;
}
//------------------------------------------------------------------------------
/**
\brief Create log category string
The function creates the log category string.
\param[out] string_p String buffer to print to.
\param[in] strlen_p Length of string buffer.
\param[in] logCategory_p The log category to print.
\return The function returns the number of characters printed to the log string.
*/
//------------------------------------------------------------------------------
static size_t createLogCategoryString(char* string_p,
size_t strlen_p,
tEventlogCategory logCategory_p)
{
size_t len;
len = snprintf(string_p,
strlen_p,
"%s ",
sEventlogCategory_l[logCategory_p]);
return len;
}
/// \}

View File

@ -0,0 +1,190 @@
/**
********************************************************************************
\file eventlogstring.h
\brief Definitions for eventlog string functions
This file contains the definitions for the string functions of the eventlog
module.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
#ifndef _INC_eventlogstring_H_
#define _INC_eventlogstring_H_
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <oplk/oplk.h>
#include <oplk/nmt.h>
#include <stdarg.h>
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
// unfortunately older windows compilers don't support snprintf and vsnprintf
#if (TARGET_SYSTEM == _WIN32_)
#if (_MSC_VER < 1900)
#define snprintf _snprintf
#define vsnprintf _vsnprintf
#endif
#endif
//------------------------------------------------------------------------------
// typedef
//------------------------------------------------------------------------------
/**
* Enumeration for eventlog levels
*
* This enumeration specifies the valid eventlog levels. The eventlog levels
* are used to filter the eventlog output.
*/
typedef enum
{
kEventlogLevelFatal = 0, ///< Fatal errors
kEventlogLevelError, ///< Errors
kEventlogLevelWarning, ///< Warnings
kEventlogLevelInfo, ///< Information
kEventlogLevelDebug, ///< Debug information
kEventlogLevelEvent, ///< Events
} eEventlogLevel;
typedef UINT32 tEventlogLevel;
/**
* Enumeration for eventlog categories
*
* The eventlog is separated in different output categories. This enumeration
* lists the valid categories. The categories are used to filter the eventlog
* output.
*/
typedef enum
{
kEventlogCategoryGeneric = 0, ///< Generic information
kEventlogCategoryControl, ///< Control information
kEventlogCategoryApplication, ///< Information of the Application
kEventlogCategoryPdoMap, ///< PDO mapping information
kEventlogCategoryObjectDictionary, ///< Object dictionary information
kEventlogCategoryNodeEvent = 15, ///< Node events
kEventlogCategoryCfmResultEvent, ///< CfmResult events
kEventlogCategoryCfmProgressEvent, ///< CfmProgress events
kEventlogCategoryStateChangeEvent, ///< StateChange events
kEventlogCategoryPdoEvent, ///< Pdo events
kEventlogCategoryHistoryEvent, ///< History events
kEventlogCategoryErrorEvent, ///< Error events
kEventlogCategorySdoEvent, ///< Sdo events
kEventlogCategoryUserEvent, ///< User event
} eEventlogCategory;
typedef UINT32 tEventlogCategory;
/**
* Enumeration for CFM events
*
* This enumeration lists the valid CFM events.
*/
typedef enum
{
kLogEventCfmProgress = 0, ///< CFM progress event
kLogEventCfmResult ///< CFM result event
} eEventlogEventCfmType;
typedef UINT32 tEventlogEventCfmType;
/**
* Enumeration for eventlog output format
*
* This enumeration lists the valid eventlog output formats.
*/
typedef enum
{
kEventlogFormatParsable, ///< Parsable format. Intended for further processing.
kEventlogFormatReadable ///< Readable format. Optimized for easy reading by humans.
} eEventlogFormat;
typedef UINT32 tEventlogFormat;
//------------------------------------------------------------------------------
// function prototypes
//------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
void eventlog_createMessageString(char* message_p,
size_t messageSize_p,
tEventlogLevel level_p,
tEventlogCategory category_p,
const char* fmt_p,
va_list arg_p);
void eventlog_createNodeEventString(const tOplkApiEventNode* pNodeEvent_p,
tEventlogFormat format_p,
char* message_p,
size_t messageSize_p);
void eventlog_createStateEventString(const tEventNmtStateChange* pStateChangeEvent_p,
tEventlogFormat format_p,
char* message_p,
size_t messageSize_p);
void eventlog_createCfmResultEventString(UINT8 nodeId_p,
tNmtNodeCommand nodeCommand_p,
tEventlogFormat format_p,
char* message_p,
size_t messageSize_p);
void eventlog_createCfmProgressEventString(const tCfmEventCnProgress* pProgress_p,
tEventlogFormat format_p,
char* message_p,
size_t messageSize_p);
void eventlog_createPdoEventString(const tOplkApiEventPdoChange* pPdoChange_p,
tEventlogFormat format_p,
char* message_p,
size_t messageSize_p);
void eventlog_createHistoryEventString(const tErrHistoryEntry* pHistory_p,
tEventlogFormat format_p,
char* message_p,
size_t messageSize_p);
void eventlog_createErrorEventString(const tEventError* pError_p,
tEventlogFormat format_p,
char* message_p,
size_t messageSize_p);
void eventlog_createPdoMapString(UINT16 mapObject_p,
UINT8 subIndex_p,
UINT64 mapping_p,
tEventlogFormat format_p,
char* message_p,
size_t messageSize_p);
#ifdef __cplusplus
}
#endif
#endif /* _INC_eventlogstring_H_ */

View File

@ -0,0 +1,106 @@
/**
********************************************************************************
\file firmwarecheck.h
\brief Header file of the firmware check module
This header file contains the definitions of the firware check module.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2017, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
#ifndef _INC_firmwarecheck_H_
#define _INC_firmwarecheck_H_
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <oplk/oplk.h>
#include <firmwaremanager/firmwaremanager.h>
#include <firmwaremanager/firmwareinfo.h>
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#define FIRMWARECHECK_INVALID_NODEID C_ADR_INVALID
#define FIRMWARECHECK_MAX_NODEID C_ADR_BROADCAST
#define FIRMWARECHECK_INVALID_SDO ((UINT)-1)
#ifndef tabentries
#define tabentries(aVar_p) (sizeof(aVar_p) / sizeof(*(aVar_p)))
#endif
//------------------------------------------------------------------------------
// typedef
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/**
\brief No firmware update required
This function is called if a firmware update is not required for a certain node.
\param nodeId_p [in] ID of the already up-to-date node
\param pSdoConnection_p [in] Pointer to SDO connection handle
\return This functions returns a value of \ref tFirmwareRet.
*/
//------------------------------------------------------------------------------
typedef tFirmwareRet (*tNoFirmwareCheckNodeCb)(UINT nodeId_p,
tSdoComConHdl* pSdoConnection_p);
/**
\brief Firmware check configuration
*/
typedef struct
{
tFirmwareInfoHandle pFwInfo; ///< Handle of the firmware store instance
///< for accessing the firmware configuration
tNoFirmwareCheckNodeCb pfnNoUpdateRequired; ///< No update required callback
} tFirmwareCheckConfig;
//------------------------------------------------------------------------------
// function prototypes
//------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
tFirmwareRet firmwarecheck_init(const tFirmwareCheckConfig* pConfig_p);
void firmwarecheck_exit(void);
tFirmwareRet firmwarecheck_processNodeEvent(UINT nodeId_p);
tFirmwareRet firmwarecheck_processSdoEvent(const tSdoComFinished* pSdoComFinished_p);
tFirmwareRet firmwarecheck_checkModulesOfNextNode(void);
#ifdef __cplusplus
}
#endif
#endif /* _INC_firmwareinfo_H_ */

View File

@ -0,0 +1,292 @@
/**
********************************************************************************
\file firmwareinfo.c
\brief Source file of the firmware info module
This module implements an access to firmware information generated by the
openCONFIGURATOR.
\ingroup module_app_firmwaremanager
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2017, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <firmwaremanager/firmwareinfo.h>
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P R I V A T E D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// local types
//------------------------------------------------------------------------------
/**
\brief Firmware info instance
*/
typedef struct tFirmwareInfoInstance
{
tFirmwareInfoConfig config; ///< Firmware info configuration
tFirmwareInfoList pInfoList; ///< Firmware info list
} tFirmwareInfoInstance;
//------------------------------------------------------------------------------
// local vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// local function prototypes
//------------------------------------------------------------------------------
static tFirmwareRet initInfoList(tFirmwareInfoInstance* pHandle_p);
static tFirmwareInfo* findModuleInInfoList(tFirmwareInfoInstance* pHandle_p,
const tFirmwareModuleInfo * pModuleInfo_p);
//============================================================================//
// P U B L I C F U N C T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Create a firmware info instance
This function creates an instance of the firmware info module.
\param pConfig_p [in] Pointer to the configuration structure for instance
creation.
\param ppHandle_p [out] Pointer to a firmware info handle which is filled if
creation was successful.
\return This functions returns a value of \ref tFirmwareRet.
\ingroup module_app_firmwaremanager
*/
//------------------------------------------------------------------------------
tFirmwareRet firmwareinfo_create(const tFirmwareInfoConfig* pConfig_p,
tFirmwareInfoHandle* ppHandle_p)
{
tFirmwareRet ret = kFwReturnOk;
tFirmwareInfoInstance* instance = NULL;
if ((pConfig_p == NULL) || (ppHandle_p == NULL))
{
ret = kFwReturnInvalidParameter;
goto EXIT;
}
instance = (tFirmwareInfoInstance*)malloc(sizeof(tFirmwareInfoInstance));
if (instance == NULL)
{
ret = kFwReturnNoResource;
goto EXIT;
}
memset(instance, 0, sizeof(tFirmwareInfoInstance));
memcpy(&instance->config, pConfig_p, sizeof(tFirmwareInfoConfig));
ret = initInfoList(instance);
EXIT:
if (ret == kFwReturnOk)
{
*ppHandle_p = instance;
}
else
{
free(instance);
}
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Destroy a firmware info instance
This function destroys an instance of the firmware info module.
\param pHandle_p [in] Handle of the firmware info instance which shall be
destroyed.
\return This functions returns a value of \ref tFirmwareRet.
\ingroup module_app_firmwaremanager
*/
//------------------------------------------------------------------------------
tFirmwareRet firmwareinfo_destroy(tFirmwareInfoHandle pHandle_p)
{
tFirmwareRet ret = kFwReturnOk;
if (pHandle_p != NULL)
{
firmwareinfodecode_freeInfo(pHandle_p->pInfoList);
free(pHandle_p);
}
else
{
ret = kFwReturnInvalidInstance;
}
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Get the firmware info a specific module
This function gets the available firmware information for a specified module.
\param pHandle_p [in] Handle of the firmware info instance
\param pModuleInfo_p [in] Pointer to the module info specifying the requested
module.
\param ppFwInfo_p [out] Pointer to a firmware info pointer which is filled
if an associated firmware info is available for
the specified module.
\return This functions returns a value of \ref tFirmwareRet.
\ingroup module_app_firmwaremanager
*/
//------------------------------------------------------------------------------
tFirmwareRet firmwareinfo_getInfoForNode(tFirmwareInfoHandle pHandle_p,
const tFirmwareModuleInfo * pModuleInfo_p,
tFirmwareInfo** ppFwInfo_p)
{
tFirmwareRet ret = kFwReturnOk;
tFirmwareInfo* pInfo = NULL;
if (pHandle_p == NULL)
{
ret = kFwReturnInvalidInstance;
goto EXIT;
}
if ((pModuleInfo_p == NULL) || (ppFwInfo_p == NULL))
{
ret = kFwReturnInvalidParameter;
goto EXIT;
}
pInfo = findModuleInInfoList(pHandle_p, pModuleInfo_p);
if (pInfo != NULL)
{
*ppFwInfo_p = pInfo;
}
else
{
ret = kFwReturnModuleNotFound;
}
EXIT:
return ret;
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
//------------------------------------------------------------------------------
/**
\brief Initialize firmware info list
\param pHandle_p [in] Handle of the firmware info instance
\return This functions returns a value of \ref tFirmwareRet.
*/
//------------------------------------------------------------------------------
static tFirmwareRet initInfoList(tFirmwareInfoInstance* pHandle_p)
{
tFirmwareRet ret = kFwReturnOk;
ret = firmwareinfodecode_decodeInfo(pHandle_p->config.pFwStore,
&pHandle_p->pInfoList);
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Find module in firmware info list
\param pHandle_p [in] Handle of the firmware info instance
\param pModuleInfo_p [in] Pointer to module info
\return This functions returns a pointer to the firmware info list.
\retval NULL No firmware info is found
\retval !NULL Pointer to the found firmware info
*/
//------------------------------------------------------------------------------
static tFirmwareInfo* findModuleInInfoList(tFirmwareInfoInstance* pHandle_p,
const tFirmwareModuleInfo * pModuleInfo_p)
{
tFirmwareInfo* pInfo = NULL;
tFirmwareInfoEntry* pIter = pHandle_p->pInfoList;
while (pIter != NULL)
{
if (memcmp(pModuleInfo_p, &pIter->fwInfo.moduleInfo,
sizeof(tFirmwareModuleInfo)) == 0)
{
pInfo = &pIter->fwInfo;
break;
}
pIter = pIter->pNext;
}
return pInfo;
}
/// \}

View File

@ -0,0 +1,90 @@
/**
********************************************************************************
\file firmwareinfo.h
\brief Header file of the firmware info module
This header file contains the definitions of the firware info module.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2017, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
#ifndef _INC_firmwareinfo_H_
#define _INC_firmwareinfo_H_
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <firmwaremanager/firmwaremanager.h>
#include <firmwaremanager/firmwareinfodecode.h>
#include <firmwaremanager/firmwarestore.h>
#include <oplk/oplk.h>
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// typedef
//------------------------------------------------------------------------------
/**
* \brief Handle to a firmware info instance
*/
typedef struct tFirmwareInfoInstance* tFirmwareInfoHandle;
/**
* \brief Configuration structure for a firmware info instance
*/
typedef struct
{
tFirmwareStoreHandle pFwStore; ///< Handle of the firmware store instance
///< for accessing the firmware configuration
} tFirmwareInfoConfig;
//------------------------------------------------------------------------------
// function prototypes
//------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
tFirmwareRet firmwareinfo_create(const tFirmwareInfoConfig* pConfig_p,
tFirmwareInfoHandle* ppHandle_p);
tFirmwareRet firmwareinfo_destroy(tFirmwareInfoHandle pHandle_p);
tFirmwareRet firmwareinfo_getInfoForNode(tFirmwareInfoHandle pHandle_p,
const tFirmwareModuleInfo * pModuleInfo_p,
tFirmwareInfo** ppFwInfo_p);
#ifdef __cplusplus
}
#endif
#endif /* _INC_firmwareinfo_H_ */

View File

@ -0,0 +1,311 @@
/**
********************************************************************************
\file firmwareinfodecode-ascii.c
\brief Source file of the firmware info decode module for ASCII format
This module implements the decoding of the firmware informations stored as
ASCII information.
\ingroup module_app_firmwaremanager
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2017, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <firmwaremanager/firmwareinfodecode.h>
#include <firmwaremanager/firmwarestore.h>
#include <string.h>
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P R I V A T E D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#define FIRMWAREINFO_ASCII_LINE_SEPERATOR "\n"
#define FIRMWAREINFO_LINE_FORMAT "%x\t%x\t%x\t%x\t%x\t%x\t%x\t%255s"
#define FIRMWAREINFO_FW_IMAGE_PATH_LENGTH 256u
#define FIRMWAREINFO_NUMBER_OF_VALUES_PER_LINE 8
//------------------------------------------------------------------------------
// local types
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// local vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// local function prototypes
//------------------------------------------------------------------------------
static tFirmwareRet parseLine(tFirmwareStoreHandle pFwStore_p, char* pLine_p,
tFirmwareInfo* pInfo_p);
//============================================================================//
// P U B L I C F U N C T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Decode the firmware information
This function decodes the information contained in the passed storage. The
resulting information will be stored in a list returned via \ref ppInfoList_p.
The memory required for the firmware informations is allocated and must be freed
by calling \ref firmwareinfodecode_freeInfo.
\param pStore_p [in] Handle of the firmware store module accessing the
information storage.
\param ppInfoList_p [out] Pointer to a list of firmware infos which will be
filled with the decoded information.
\return This functions returns a value of \ref tFirmwareRet.
\ingroup module_app_firmwaremanager
*/
//------------------------------------------------------------------------------
tFirmwareRet firmwareinfodecode_decodeInfo(tFirmwareStoreHandle pStore_p,
tFirmwareInfoList* ppInfoList_p)
{
tFirmwareRet ret = kFwReturnOk;
size_t dataSize;
void* pData;
char* pFileString;
char* pLine;
tFirmwareInfoList pList = NULL;
tFirmwareInfoEntry** ppInsertIter = &pList;
tFirmwareInfoEntry* pEntry = NULL;
if (ppInfoList_p == NULL)
{
ret = kFwReturnInvalidParameter;
goto EXIT;
}
ret = firmwarestore_loadData(pStore_p);
if (ret != kFwReturnOk)
{
goto EXIT;
}
ret = firmwarestore_getData(pStore_p, &pData, &dataSize);
if (ret != kFwReturnOk)
{
goto EXIT;
}
pFileString = pData;
pLine = strtok(pFileString, FIRMWAREINFO_ASCII_LINE_SEPERATOR);
while (pLine != NULL)
{
pEntry = (tFirmwareInfoEntry*)malloc(sizeof(tFirmwareInfoEntry));
if (pEntry == NULL)
{
ret = kFwReturnNoResource;
goto EXIT;
}
memset(pEntry, 0, sizeof(tFirmwareInfoEntry));
ret = parseLine(pStore_p, pLine, &pEntry->fwInfo);
if (ret == kFwReturnOk)
{
if (*ppInsertIter != NULL)
{
(*ppInsertIter)->pNext = pEntry;
}
*ppInsertIter = pEntry;
ppInsertIter = &pEntry->pNext;
}
else
{
free(pEntry);
if (ret == kFwReturnIgnoreInfoFileLine)
{
ret = kFwReturnOk;
}
else
{
break;
}
}
pLine = strtok(NULL, FIRMWAREINFO_ASCII_LINE_SEPERATOR);
}
*ppInfoList_p = pList;
EXIT:
(void)firmwarestore_flushData(pStore_p);
if (ret != kFwReturnOk)
{
while (pList != NULL)
{
pEntry = pList;
pList = pEntry->pNext;
free(pEntry);
}
}
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Free the decoded firmware information
This function frees the by \ref firmwareinfodecode_decodeInfo previously
allocated resources.
\param pInfoList_p [int] List of firmware informations which shall be freed
\return This functions returns a value of \ref tFirmwareRet.
\ingroup module_app_firmwaremanager
*/
//------------------------------------------------------------------------------
tFirmwareRet firmwareinfodecode_freeInfo(tFirmwareInfoList pInfoList_p)
{
tFirmwareRet ret = kFwReturnOk;
tFirmwareInfoEntry* rem;
tFirmwareInfoList pInfoList = pInfoList_p;
if (pInfoList_p != NULL)
{
while (pInfoList != NULL)
{
rem = pInfoList;
pInfoList = rem->pNext;
free(rem);
}
}
else
{
ret = kFwReturnInvalidParameter;
}
return ret;
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
//------------------------------------------------------------------------------
/**
\brief Parse line of firmware info file
This function parses the given line of a firmware info file and returns the
firmware information.
\param pStore_p [in] Handle of the firmware store module accessing the
information storage.
\param pLine_p [in] Line to be parsed
\param pInfo_p [out] Pointer used to return the firmware information
\return This functions returns a value of \ref tFirmwareRet.
*/
//------------------------------------------------------------------------------
static tFirmwareRet parseLine(tFirmwareStoreHandle pFwStore_p, char* pLine_p,
tFirmwareInfo* pInfo_p)
{
tFirmwareRet ret = kFwReturnOk;
tFirmwareInfo info;
int result;
tFirmwareStoreConfig storeConfig;
char imagePath[FIRMWAREINFO_FW_IMAGE_PATH_LENGTH];
char completePath[FIRMWAREINFO_FW_IMAGE_PATH_LENGTH];
void* baseInfo;
memset(imagePath, 0, FIRMWAREINFO_FW_IMAGE_PATH_LENGTH);
result = sscanf(pLine_p, FIRMWAREINFO_LINE_FORMAT, (unsigned int*)&info.moduleInfo.nodeId,
&info.moduleInfo.vendorId, &info.moduleInfo.productId,
&info.moduleInfo.hwVariant, &info.appSwDate,
&info.appSwTime, (unsigned int*)&info.fFirmwareLocked, imagePath);
if (result != FIRMWAREINFO_NUMBER_OF_VALUES_PER_LINE)
{
ret = kFwReturnIgnoreInfoFileLine;
goto EXIT;
}
memset(&storeConfig, 0, sizeof(tFirmwareStoreConfig));
ret = firmwarestore_getBase(pFwStore_p, &baseInfo);
if (ret != kFwReturnOk)
{
goto EXIT;
}
sprintf(completePath, "%s%c%s", (char*)baseInfo, FIRMWARESTORE_PATH_DIR_SEP, imagePath);
storeConfig.pFilename = completePath;
ret = firmwarestore_create(&storeConfig, &info.pFwImage);
if (ret != kFwReturnOk)
{
goto EXIT;
}
memcpy(pInfo_p, &info, sizeof(tFirmwareInfo));
EXIT:
return ret;
}
/// \}

View File

@ -0,0 +1,111 @@
/**
********************************************************************************
\file firmwareinfodecode.h
\brief Header file of the firmware info decode module
This header file contains the definitions of the firware info decoe module.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2017, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
#ifndef _INC_firmwareinfodecode_H_
#define _INC_firmwareinfodecode_H_
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <firmwaremanager/firmwaremanager.h>
#include <firmwaremanager/firmwarestore.h>
#include <oplk/oplk.h>
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// typedef
//------------------------------------------------------------------------------
/**
\brief Information structure representing a module
*/
typedef struct
{
UINT8 nodeId; ///< ID of the node
UINT32 vendorId; ///< Vendor ID of the module
UINT32 productId; ///< Product ID of the module
UINT32 hwVariant; ///< Hardware variant of the module
} tFirmwareModuleInfo;
/**
\brief Structure containing information about the configured firmware
*/
typedef struct
{
tFirmwareModuleInfo moduleInfo; ///< Info of the associated module
UINT32 appSwDate; ///< Software date of the configured firmware
UINT32 appSwTime; ///< Software time of the configured firmware
BOOL fFirmwareLocked; ///< Flag for representation if the firmware
///< should be locked, this functionality is
///< currently not supported.
tFirmwareStoreHandle pFwImage; ///< Handle of the firmware store instance for
///< accessing the firmware
} tFirmwareInfo;
/**
\brief List entry for a firmware info
*/
typedef struct tFirmwareInfoEntry
{
tFirmwareInfo fwInfo; ///< Firmware info structure
struct tFirmwareInfoEntry* pNext; ///< Pointer to the next entry within list
} tFirmwareInfoEntry;
/**
\brief List of firmware info entries
*/
typedef tFirmwareInfoEntry* tFirmwareInfoList;
//------------------------------------------------------------------------------
// function prototypes
//------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
tFirmwareRet firmwareinfodecode_decodeInfo(tFirmwareStoreHandle pStore_p,
tFirmwareInfoList* ppInfoList_p);
tFirmwareRet firmwareinfodecode_freeInfo(tFirmwareInfoList pInfoList_p);
#ifdef __cplusplus
}
#endif
#endif /* _INC_firmwareinfodecode_H_ */

View File

@ -0,0 +1,541 @@
/**
********************************************************************************
\file firmwaremanager.c
\brief Source file of the firmware manager
This module implements the firmware manager.
\ingroup module_app_firmwaremanager
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2017, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <firmwaremanager/firmwaremanager.h>
#include <firmwaremanager/firmwaretrace.h>
#include <firmwaremanager/firmwarestore.h>
#include <firmwaremanager/firmwareinfo.h>
#include <firmwaremanager/firmwarecheck.h>
#include <firmwaremanager/firmwareupdate.h>
#include <oplk/oplk.h>
#include <oplk/debugstr.h>
#include <stdio.h>
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P R I V A T E D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#ifndef tabentries
#define tabentries(aVar_p) (sizeof(aVar_p) / sizeof(*(aVar_p)))
#endif
#define FIRMWARE_MANAGER_MAX_NODE_ID C_ADR_BROADCAST
#define FIRMWARE_MANAGER_PRINT_LINE_LENGTH 80
#define FIRMWARE_MANAGER_PRINT_NODE_LENGTH 6
//------------------------------------------------------------------------------
// local types
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/**
\brief Process SDO finished event
This function is called to process an SDO finish event triggered by openPOWERLINK.
\param pSdoComFinished_p [in] Pointer to SDO finished
\return This functions returns a value of \ref tFirmwareRet.
*/
//------------------------------------------------------------------------------
typedef tFirmwareRet (*tFirmwareProcessSdoEvent)(const tSdoComFinished* pSdoComFinished_p);
/**
\brief Firmware manager instance
*/
typedef struct
{
BOOL fInitialized; ///< Instance initialized flag
tFirmwareStoreHandle firmwareStore; ///< Firmware store handle
tFirmwareInfoHandle firmwareInfo; ///< Firmware info handle
BOOL fCheckModules; ///< Check modular devices (triggered by periodic thread)
} tFirmwareManagerInstance;
//------------------------------------------------------------------------------
// local vars
//------------------------------------------------------------------------------
static tFirmwareManagerInstance instance_l;
static tFirmwareProcessSdoEvent apfnProcessSdoEvent_l[] =
{
firmwarecheck_processSdoEvent,
firmwareupdate_processSdoEvent
};
//------------------------------------------------------------------------------
// local function prototypes
//------------------------------------------------------------------------------
static tFirmwareRet firmwareUpdateNotRequired(UINT nodeId_p,
tSdoComConHdl* pSdoConnection_p);
static tFirmwareRet nodeUpdateCompleteCb(UINT nodeId_p,
tSdoComConHdl* pSdoConnection_p);
static tFirmwareRet moduleUpdateCompleteCb(UINT nodeId_p,
tSdoComConHdl* pSdoConnection_p);
static tFirmwareRet errorDuringUpdate(UINT nodeId_p,
tSdoComConHdl* pSdoConnection_p);
static void cleanupSdo(tSdoComConHdl* pSdoConnection_p);
//============================================================================//
// P U B L I C F U N C T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Initialize the firmware manager
This function initializes the firmware manager.
\param fwInfoFileName_p [in] Firmware info file created by openCONFIGURATOR
\return This functions returns a value of \ref tFirmwareRet.
\ingroup module_app_firmwaremanager
*/
//------------------------------------------------------------------------------
tFirmwareRet firmwaremanager_init(const char* fwInfoFileName_p)
{
tFirmwareRet ret = kFwReturnOk;
tFirmwareStoreConfig storeConfig;
tFirmwareInfoConfig infoConfig;
tFirmwareCheckConfig checkConfig;
tFirmwareUpdateConfig updateConfig;
if (instance_l.fInitialized)
{
ret = kFwReturnAlreadyInitialized;
goto EXIT;
}
memset(&instance_l, 0, sizeof(tFirmwareManagerInstance));
memset(&storeConfig, 0, sizeof(tFirmwareStoreConfig));
storeConfig.pFilename = fwInfoFileName_p;
ret = firmwarestore_create(&storeConfig, &instance_l.firmwareStore);
if (ret != kFwReturnOk)
{
goto EXIT;
}
memset(&infoConfig, 0, sizeof(infoConfig));
infoConfig.pFwStore = instance_l.firmwareStore;
firmwareinfo_create(&infoConfig, &instance_l.firmwareInfo);
memset(&checkConfig, 0, sizeof(tFirmwareCheckConfig));
checkConfig.pFwInfo = instance_l.firmwareInfo;
checkConfig.pfnNoUpdateRequired = firmwareUpdateNotRequired;
ret = firmwarecheck_init(&checkConfig);
if (ret != kFwReturnOk)
{
goto EXIT;
}
memset(&updateConfig, 0, sizeof(tFirmwareUpdateConfig));
updateConfig.pfnNodeUpdateComplete = nodeUpdateCompleteCb;
updateConfig.pfnModuleUpdateComplete = moduleUpdateCompleteCb;
updateConfig.pfnError = errorDuringUpdate;
ret = firmwareupdate_init(&updateConfig);
if (ret != kFwReturnOk)
{
goto EXIT;
}
instance_l.fInitialized = TRUE;
EXIT:
if (ret != kFwReturnOk)
{
firmwareupdate_exit();
firmwarecheck_exit();
firmwareinfo_destroy(instance_l.firmwareInfo);
firmwarestore_destroy(instance_l.firmwareStore);
}
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Deinitialize the firmware manager
This function deinitializes the firmware manager.
\ingroup module_app_firmwaremanager
*/
//------------------------------------------------------------------------------
void firmwaremanager_exit(void)
{
firmwareupdate_exit();
firmwarecheck_exit();
firmwareinfo_destroy(instance_l.firmwareInfo);
firmwarestore_destroy(instance_l.firmwareStore);
instance_l.fInitialized = FALSE;
}
//------------------------------------------------------------------------------
/**
\brief Firmware manager thread
This function implements the firmware manager thread. It shall be called regularly
(e.g. every 5 seconds) to trigger checking the firmware of modular devices.
The function also polls the firmware update transmission status to trace the
firmware manager activity.
\return This functions returns a value of \ref tFirmwareRet.
\ingroup module_app_firmwaremanager
*/
//------------------------------------------------------------------------------
tOplkError firmwaremanager_thread(void)
{
tOplkError ret = kErrorOk;
UINT nodeId;
tFirmwareRet fwReturn;
tFirmwareUpdateTransmissionStatus status;
char line[FIRMWARE_MANAGER_PRINT_LINE_LENGTH];
char node[FIRMWARE_MANAGER_PRINT_NODE_LENGTH];
BOOL fFinalPrint = FALSE;
ret = oplk_postUserEvent((void*)&instance_l);
memset(line, 0, FIRMWARE_MANAGER_PRINT_LINE_LENGTH);
strcpy(line, "Updating node");
for (nodeId = 0u; nodeId < FIRMWARE_MANAGER_MAX_NODE_ID; nodeId++)
{
fwReturn = firmwareupdate_getTransmissionStatus(nodeId, &status);
if ((fwReturn == kFwReturnOk) && status.fTransmissionActive)
{
fFinalPrint = TRUE;
sprintf(node, " 0x%02X", (UINT8)(nodeId & 0xFF));
strcat(line, node);
if (strlen(line) > FIRMWARE_MANAGER_PRINT_LINE_LENGTH - FIRMWARE_MANAGER_PRINT_NODE_LENGTH)
{
FWM_TRACE("%s\n", line);
memset(line, 0, FIRMWARE_MANAGER_PRINT_LINE_LENGTH);
strcpy(line, "Updating node");
fFinalPrint = FALSE;
}
}
}
if (fFinalPrint)
{
FWM_TRACE("%s\n", line);
}
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Process openPOWERLINK events
This function processes openPOWERLINK events.
\param eventType_p [in] Event type
\param pEventArg_p [in] Pointer to event argument
\param pUserArg_p [in] User argument
\return This functions returns a value of \ref tOplkError.
\ingroup module_app_firmwaremanager
*/
//------------------------------------------------------------------------------
tOplkError firmwaremanager_processEvent(tOplkApiEventType eventType_p,
const tOplkApiEventArg* pEventArg_p,
void* pUserArg_p)
{
tOplkError ret = kErrorOk;
tFirmwareRet fwRet;
size_t iter;
UNUSED_PARAMETER(pUserArg_p);
switch (eventType_p)
{
case kOplkApiEventUserDef:
if ((pEventArg_p->pUserArg == &instance_l) && instance_l.fCheckModules)
{
fwRet = firmwarecheck_checkModulesOfNextNode();
if (fwRet != kFwReturnOk)
{
ret = kErrorGeneralError;
}
else
{
ret = kErrorOk;
}
}
break;
case kOplkApiEventSdo:
for (iter = 0; iter < tabentries(apfnProcessSdoEvent_l); iter++)
{
fwRet = apfnProcessSdoEvent_l[iter](&pEventArg_p->sdoInfo);
if (fwRet != kFwReturnInvalidSdoEvent)
{
break;
}
}
if (fwRet == kFwReturnInvalidSdoEvent)
{
// Event is ignored because no firmware module felt responsible for it.
ret = kErrorOk;
}
else if (fwRet != kFwReturnOk)
{
ret = kErrorGeneralError;
}
else
{
ret = kErrorOk;
}
break;
case kOplkApiEventNode:
if ((eventType_p == kOplkApiEventNode))
{
if (pEventArg_p->nodeEvent.nodeEvent == kNmtNodeEventUpdateSw)
{
fwRet = firmwarecheck_processNodeEvent(pEventArg_p->nodeEvent.nodeId);
if (fwRet == kFwReturnInterruptBoot)
{
ret = kErrorReject;
}
else if (fwRet != kFwReturnOk)
{
ret = kErrorGeneralError;
}
else
{
ret = kErrorOk;
}
}
else if (pEventArg_p->nodeEvent.nodeEvent == kNmtNodeEventConfDone)
{
instance_l.fCheckModules = TRUE;
}
}
break;
default:
break;
}
return ret;
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
//------------------------------------------------------------------------------
/**
\brief Firmware update not required callback
This function is called if a firmware update is not required for the given
node.
\param nodeId_p [in] Node ID
\param pSdoConnection_p [in] Pointer to SDO connection handle
\return This functions returns a value of \ref tFirmwareRet.
*/
//------------------------------------------------------------------------------
static tFirmwareRet firmwareUpdateNotRequired(UINT nodeId_p,
tSdoComConHdl* pSdoConnection_p)
{
tFirmwareRet ret = kFwReturnOk;
tOplkError result;
cleanupSdo(pSdoConnection_p);
FWM_TRACE("No firmware update required for node %d, continuing boot/operation\n",
nodeId_p);
result = oplk_triggerMnStateChange(nodeId_p, kNmtNodeCommandSwOk);
if (result != kErrorOk)
{
FWM_ERROR("(%s) - Triggering MN state change failed with %d\n",
__func__, result);
}
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Modular firmware update completed
This function is called if a modular firmware update is completed for the given
node.
\param nodeId_p [in] Node ID
\param pSdoConnection_p [in] Pointer to SDO connection handle
\return This functions returns a value of \ref tFirmwareRet.
*/
//------------------------------------------------------------------------------
static tFirmwareRet moduleUpdateCompleteCb(UINT nodeId_p,
tSdoComConHdl* pSdoConnection_p)
{
tFirmwareRet ret = kFwReturnOk;
cleanupSdo(pSdoConnection_p);
FWM_TRACE("Firmware update of modules complete for node %d\n", nodeId_p);
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Node firmware update completed
This function is called if a firmware update is completed for the given node.
\param nodeId_p [in] Node ID
\param pSdoConnection_p [in] Pointer to SDO connection handle
\return This functions returns a value of \ref tFirmwareRet.
*/
//------------------------------------------------------------------------------
static tFirmwareRet nodeUpdateCompleteCb(UINT nodeId_p,
tSdoComConHdl* pSdoConnection_p)
{
tFirmwareRet ret = kFwReturnOk;
tOplkError result;
cleanupSdo(pSdoConnection_p);
FWM_TRACE("Firmware update of node %d complete\n", nodeId_p);
result = oplk_triggerMnStateChange(nodeId_p, kNmtNodeCommandSwUpdated);
if (result != kErrorOk)
{
FWM_ERROR("(%s) - Triggering MN state change failed with %d\n",
__func__, result);
}
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Firmware update error
This function is called if an error happend during a firmware update for the
given node.
\param nodeId_p [in] Node ID
\param pSdoConnection_p [in] Pointer to SDO connection handle
\return This functions returns a value of \ref tFirmwareRet.
*/
//------------------------------------------------------------------------------
static tFirmwareRet errorDuringUpdate(UINT nodeId_p,
tSdoComConHdl* pSdoConnection_p)
{
tFirmwareRet ret = kFwReturnOk;
tOplkError result;
cleanupSdo(pSdoConnection_p);
FWM_TRACE("An error occurred during check/update for node %d\n", nodeId_p);
result = oplk_triggerMnStateChange(nodeId_p, kNmtNodeCommandSwErr);
if (result != kErrorOk)
{
FWM_ERROR("(%s) - Triggering MN state change failed with %d\n",
__func__, result);
}
return ret;
}
static void cleanupSdo(tSdoComConHdl* pSdoConnection_p)
{
oplk_freeSdoChannel(*pSdoConnection_p);
*pSdoConnection_p = FIRMWARECHECK_INVALID_SDO;
}
/// \}

View File

@ -0,0 +1,103 @@
/**
********************************************************************************
\file firmwaremanager.h
\brief Header file for the firmware manager modules
This header file contains the general definitions for all firmware manager
modules.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2017, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
#ifndef _INC_firmwaremanager_H_
#define _INC_firmwaremanager_H_
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <oplk/oplk.h>
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// typedef
//------------------------------------------------------------------------------
/**
\brief Enum with return values used by the firmware manager modules
*/
typedef enum
{
kFwReturnOk = 0, ///< Function call was successful
kFwReturnInvalidParameter, ///< An invalid parameter was passed
kFwReturnInvalidInstance, ///< An invalid instance was passed
kFwReturnNoResource, ///< The allocation of required resources failed
kFwReturnFileOperationFailed, ///< A File operation failed
kFwReturnInfoFormatError, ///< The supplied fw.info file in formated invalid
kFwReturnModuleNotFound, ///< The requested module was not found
kFwReturnAlreadyInitialized, ///< Firmware manager is already initialized
kFwReturnInvalidNodeId, ///< An invalid node ID was passed
kFwReturnSdoWriteFailed, ///< A SDO write command failed
kFwReturnInvalidSdoSize, ///< A SDO event returned an invalid number of transferred bytes
kFwReturnInvalidSdoEvent, ///< An invalid SDO finished event was passed
kFwReturnNoIdent, ///< Failed to get ident for node
kFwReturnOdError, ///< Failed to access local OD
kFwReturnInterruptBoot, ///< Signalize interruption of boot process
kFwReturnSdoWriteError, ///< Failed to issue an SDO write
kFwReturnSdoReadError, ///< Failed to issue an SDO read
kFwReturnInvalidNodeInfo, ///< An invalid node info was passed
kFwReturnResetNodeFailed, ///< Failed to send reset node
kFwReturnInvalidCheckState, ///< Invalid state in firmware check module
kFwReturnIgnoreInfoFileLine, ///< Ignore the current info file line
} tFirmwareRet;
//------------------------------------------------------------------------------
// function prototypes
//------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
tFirmwareRet firmwaremanager_init(const char* fwInfoFileName_p);
void firmwaremanager_exit(void);
tOplkError firmwaremanager_thread(void);
tOplkError firmwaremanager_processEvent(tOplkApiEventType eventType_p,
const tOplkApiEventArg* pEventArg_p,
void* pUserArg_p);
#ifdef __cplusplus
}
#endif
#endif /* _INC_firmwaremanager_H_ */

View File

@ -0,0 +1,467 @@
/**
********************************************************************************
\file firmwarestore-file.c
\brief Source file of the firmware store module using a file system
This module implements an access to stored informations and firmware images
provided by the openCONFIGURATOR.
\ingroup module_app_firmwaremanager
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2017, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <firmwaremanager/firmwarestore.h>
#include <stdio.h>
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P R I V A T E D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#define FWSTORE_READ_MODE "rb"
#define FWSTORE_FILEPATH_LENGTH 256u
//------------------------------------------------------------------------------
// local types
//------------------------------------------------------------------------------
/**
\brief Firmware store instance
*/
typedef struct tFirmwareStoreInstance
{
char aFilename[FWSTORE_FILEPATH_LENGTH]; ///< File name
char aPathToFile[FWSTORE_FILEPATH_LENGTH]; ///< Path to file
FILE* pStorageFd; ///< File descriptor
void* pData; ///< File data pointer
size_t dataSize; ///< File data size
} tFirmwareStoreInstance;
//------------------------------------------------------------------------------
// local vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// local function prototypes
//------------------------------------------------------------------------------
static tFirmwareRet allocAndReadData(FILE* pFile_p,
void** ppBuffer_p, size_t* pDataSize_p);
static tFirmwareRet flushData(tFirmwareStoreHandle pHandle_p);
static void getPathToFile(const char* pFilename_p, char* aPath_p);
//============================================================================//
// P U B L I C F U N C T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Create a firmware store instance
This function creates an instance of the firmware store module.
\param pConfig_p [in] Pointer to the configuration structure for the created
instance.
\param ppHandle_p [out] Pointer to an instance handle which is filled if
creation was successful.
\return This functions returns a value of \ref tFirmwareRet.
\ingroup module_app_firmwaremanager
*/
//------------------------------------------------------------------------------
tFirmwareRet firmwarestore_create(const tFirmwareStoreConfig* pConfig_p,
tFirmwareStoreHandle* ppHandle_p)
{
tFirmwareRet ret = kFwReturnOk;
tFirmwareStoreInstance* instance;
if ((pConfig_p == NULL) || (ppHandle_p == NULL))
{
ret = kFwReturnInvalidParameter;
}
instance = (tFirmwareStoreInstance*)malloc(sizeof(tFirmwareStoreInstance));
if (instance == NULL)
{
ret = kFwReturnNoResource;
goto EXIT;
}
memset(instance, 0, sizeof(tFirmwareStoreInstance));
strncpy(instance->aFilename, pConfig_p->pFilename, FWSTORE_FILEPATH_LENGTH);
getPathToFile(instance->aFilename, instance->aPathToFile);
*ppHandle_p = instance;
EXIT:
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Destroy a firmware store instance
This function destroys an instance of the firmware store module.
\param pHandle_p [in] Handle of the firmware store module which shall be
destroyed.
\return This functions returns a value of \ref tFirmwareRet.
\ingroup module_app_firmwaremanager
*/
//------------------------------------------------------------------------------
tFirmwareRet firmwarestore_destroy (tFirmwareStoreHandle pHandle_p)
{
tFirmwareRet ret = kFwReturnOk;
if (pHandle_p == NULL)
{
ret = kFwReturnInvalidInstance;
}
ret = flushData(pHandle_p);
if (ret == kFwReturnOk)
{
free (pHandle_p);
}
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Load data represented by the firmware store instance
This function acquires necessary resources and frees the data. All
acquired resources can be flushed manually by calling
\ref firmwarestore_flushData, unflushed resources will be freed within
\ref firmwarestore_destroy.
\param pHandle_p [in] Handle of the firmware store module
\return This functions returns a value of \ref tFirmwareRet.
\ingroup module_app_firmwaremanager
*/
//------------------------------------------------------------------------------
tFirmwareRet firmwarestore_loadData(tFirmwareStoreHandle pHandle_p)
{
tFirmwareRet ret = kFwReturnOk;
if (pHandle_p == NULL)
{
ret = kFwReturnInvalidInstance;
goto EXIT;
}
pHandle_p->pStorageFd = fopen(pHandle_p->aFilename, FWSTORE_READ_MODE);
if (pHandle_p->pStorageFd == NULL)
{
ret = kFwReturnFileOperationFailed;
goto EXIT;
}
ret = allocAndReadData(pHandle_p->pStorageFd, &pHandle_p->pData, &pHandle_p->dataSize);
EXIT:
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Flush data represented by the firmware store instance
This function frees necessary resources and frees the data.
\param pHandle_p [in] Handle of the firmware store module
\return This functions returns a value of \ref tFirmwareRet.
\ingroup module_app_firmwaremanager
*/
//------------------------------------------------------------------------------
tFirmwareRet firmwarestore_flushData(tFirmwareStoreHandle pHandle_p)
{
tFirmwareRet ret = kFwReturnOk;
if (pHandle_p != NULL)
{
ret = flushData(pHandle_p);
}
else
{
ret = kFwReturnInvalidInstance;
}
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Access the data provided by the firmware store instance
This function provides access to the data represented by the firmware store
module.
\param pHandle_p [in] Handle of the firmware store module
\param ppData_p [out] Pointer which will be filled with the data buffer
\param pDataSize_p [out] Pointer which will be filled with the available datasize
\return This functions returns a value of \ref tFirmwareRet.
\ingroup module_app_firmwaremanager
*/
//------------------------------------------------------------------------------
tFirmwareRet firmwarestore_getData(tFirmwareStoreHandle pHandle_p,
void** ppData_p, size_t* pDataSize_p)
{
tFirmwareRet ret = kFwReturnOk;
if (pHandle_p == NULL)
{
ret = kFwReturnInvalidInstance;
goto EXIT;
}
if ((ppData_p == NULL) || (pDataSize_p == NULL))
{
ret = kFwReturnInvalidParameter;
goto EXIT;
}
if (pHandle_p->pData == NULL)
{
ret = allocAndReadData(pHandle_p->pStorageFd, &pHandle_p->pData, &pHandle_p->dataSize);
}
if (ret == kFwReturnOk)
{
*ppData_p = pHandle_p->pData;
*pDataSize_p = pHandle_p->dataSize;
}
EXIT:
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Get the base of the represented storage
This function provides the base information of the storage, i.e. the base
address of a memory storage or the containing directory of a file.
\param pHandle_p [in] Handle of the firmware store module
\param ppData_p [out] Pointer which will be filled with the base information
\return This functions returns a value of \ref tFirmwareRet.
\ingroup module_app_firmwaremanager
*/
//------------------------------------------------------------------------------
tFirmwareRet firmwarestore_getBase(tFirmwareStoreHandle pHandle_p,
void** ppBase_p)
{
tFirmwareRet ret = kFwReturnOk;
if (pHandle_p == NULL)
{
ret = kFwReturnInvalidInstance;
goto EXIT;
}
if (ppBase_p == NULL)
{
ret = kFwReturnInvalidParameter;
goto EXIT;
}
*ppBase_p = pHandle_p->aPathToFile;
EXIT:
return ret;
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
//------------------------------------------------------------------------------
/**
\brief Allocate buffer and read data from file
\param pFile_p [in] File handle to be read
\param ppBuffer_p [out] Pointer to buffer allocated and filled with the read data
\param pDataSize [out] Pointer filled with the allocated buffer size
\return This functions returns a value of \ref tFirmwareRet.
*/
//------------------------------------------------------------------------------
static tFirmwareRet allocAndReadData(FILE* pFile_p,
void** ppBuffer_p, size_t* pDataSize_p)
{
tFirmwareRet ret = kFwReturnOk;
UINT8* pBuffer = NULL;
size_t fileSize;
size_t readBytes;
int result;
long tellResult;
result = fseek(pFile_p, 0, SEEK_END);
if (result < 0)
{
ret = kFwReturnFileOperationFailed;
goto EXIT;
}
tellResult = ftell(pFile_p);
if (tellResult < 0)
{
ret = kFwReturnFileOperationFailed;
goto EXIT;
}
fileSize = (size_t)tellResult;
pBuffer = (UINT8*)malloc(fileSize);
if (pBuffer == NULL)
{
ret = kFwReturnNoResource;
goto EXIT;
}
rewind(pFile_p);
readBytes = fread(pBuffer, 1u, fileSize, pFile_p);
if (readBytes != fileSize)
{
ret = kFwReturnFileOperationFailed;
}
*ppBuffer_p = pBuffer;
pBuffer = NULL;
*pDataSize_p = fileSize;
EXIT:
free(pBuffer);
rewind(pFile_p);
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Flush firmware store data
\param pHandle_p [in] Store handle
\return This functions returns a value of \ref tFirmwareRet.
*/
//------------------------------------------------------------------------------
static tFirmwareRet flushData(tFirmwareStoreHandle pHandle_p)
{
tFirmwareRet ret = kFwReturnOk;
int result;
if (pHandle_p->pStorageFd != NULL)
{
result = fclose(pHandle_p->pStorageFd);
if (result == 0)
{
pHandle_p->pStorageFd = NULL;
}
else
{
ret = kFwReturnFileOperationFailed;
}
}
free(pHandle_p->pData);
pHandle_p->pData = NULL;
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Get path to file
\param pFilename_p [in] File name
\param pPath_p [out] Pointer which will be filled with the path
*/
//------------------------------------------------------------------------------
static void getPathToFile(const char* pFilename_p, char* pPath_p)
{
char* pPos;
pPos = strrchr(pFilename_p, FIRMWARESTORE_PATH_DIR_SEP);
memset(pPath_p, 0, FWSTORE_FILEPATH_LENGTH);
if (pPos != NULL)
{
memcpy(pPath_p, pFilename_p, (pPos - pFilename_p));
}
else
{
pPath_p[0] = '.';
}
}
/// \}

View File

@ -0,0 +1,102 @@
/**
********************************************************************************
\file firmwarestore.h
\brief Header file of the firmware store module
This header file contains the definitions of the firware store module.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2017, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
#ifndef _INC_firmwarestore_H_
#define _INC_firmwarestore_H_
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <firmwaremanager/firmwaremanager.h>
#include <oplk/oplk.h>
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#if defined(_WIN32)
#define FIRMWARESTORE_PATH_DIR_SEP '\\'
#else
#define FIRMWARESTORE_PATH_DIR_SEP '/'
#endif
//------------------------------------------------------------------------------
// typedef
//------------------------------------------------------------------------------
/**
* \brief Handle to a firmware store instance
*/
typedef struct tFirmwareStoreInstance* tFirmwareStoreHandle;
/**
* \brief Configuration structure for a firmware store instance
*/
typedef struct
{
const char* pFilename; ///< Filename of the accessed file.
///< This member is only used by the file
///< system based implementation.
const void* pStorageBuffer; ///< Pointer to the memory holding the
///< accessed information. This member is
///< only used by the non file system
///< implementation.
} tFirmwareStoreConfig;
//------------------------------------------------------------------------------
// function prototypes
//------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
tFirmwareRet firmwarestore_create (const tFirmwareStoreConfig* pConfig_p,
tFirmwareStoreHandle* pHandle_p);
tFirmwareRet firmwarestore_destroy (tFirmwareStoreHandle pHandle_p);
tFirmwareRet firmwarestore_loadData(tFirmwareStoreHandle pHandle_p);
tFirmwareRet firmwarestore_flushData(tFirmwareStoreHandle pHandle_p);
tFirmwareRet firmwarestore_getData(tFirmwareStoreHandle pHandle_p,
void** ppData_p, size_t* pDataSize_p);
tFirmwareRet firmwarestore_getBase(tFirmwareStoreHandle pHandle_p,
void** ppBase_p);
#ifdef __cplusplus
}
#endif
#endif /* _INC_firmwarestore_H_ */

View File

@ -0,0 +1,87 @@
/**
********************************************************************************
\file firmwaretrace.h
\brief Header file for trace macros used within firmware manager modules
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2017, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
#ifndef _INC_firmwaretrace_H_
#define _INC_firmwaretrace_H_
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <stdio.h>
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#define FWM_TRACE_ENABLE
#if !defined(FWM_TRACE_PREFIX)
#define FWM_TRACE_PREFIX "FWM: "
#endif
#if !defined(FWM_ERROR_PREFIX)
#define FWM_ERROR_PREFIX "FWM-ERROR: "
#endif
#if defined(FWM_TRACE_ENABLE)
#define FWM_TRACE(...) printf(FWM_TRACE_PREFIX __VA_ARGS__)
#else
#define FWM_TRACE(...)
#endif
#if defined(FWM_TRACE_ENABLE)
#define FWM_ERROR(...) fprintf(stderr, FWM_ERROR_PREFIX __VA_ARGS__)
#else
#define FWM_ERROR(...)
#endif
//------------------------------------------------------------------------------
// typedef
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// function prototypes
//------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
#ifdef __cplusplus
}
#endif
#endif /* _INC_firmwaretrace_H_ */

View File

@ -0,0 +1,715 @@
/**
********************************************************************************
\file firmwareupdate.c
\brief Source file of the firmware update module
This module implements firmware updates of a node with wrong version.
\ingroup module_app_firmwaremanager
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2017, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <firmwaremanager/firmwaretrace.h>
#include <firmwaremanager/firmwareupdate.h>
#include <firmwaremanager/firmwarestore.h>
#include <oplk/oplk.h>
#include <stdio.h>
#include <errno.h>
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P R I V A T E D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#define FIRMWARE_UPDATE_MAX_NODE_ID C_ADR_BROADCAST ///< Maximum value of a node ID
#define FIRMWARE_UPDATE_SDO_TYPE kSdoTypeAsnd ///< SDO type used for firmware update
#define FIRMWARE_UPDATE_INVALID_SDO ((tSdoComConHdl)-1) ///< Invalid SDO handle
#if !defined(FIRMWARE_UPDATE_MAX_PARALLEL_TRANSMISSIONS)
#define FIRMWARE_UPDATE_MAX_PARALLEL_TRANSMISSIONS 5 ///< Number of parallel transmissions of firmware images
#endif
//------------------------------------------------------------------------------
// local types
//------------------------------------------------------------------------------
/**
\brief Firmware update transmission information
*/
typedef struct
{
BOOL fTranmissionActive; ///< Active transmission
tFirmwareUpdateList pUpdateList; ///< Firmware update list
void* pFirmwareImage; ///< Firmware image in progress
size_t firmwareSize; ///< Size of firmware image in progress
tSdoComConHdl sdoComCon; ///< SDO handle
} tFirmwareUpdateTransmissionInfo;
/**
\brief Firmware update instance
*/
typedef struct
{
BOOL fInitialized; ///< Instance initialized flag
tFirmwareUpdateConfig config; ///< Instance configuration
tFirmwareUpdateTransmissionInfo aTransmissions[FIRMWARE_UPDATE_MAX_NODE_ID]; ///< Node transmission array
size_t numberOfStartedTransmissions; ///< Number of started transmissions
size_t numberOfFinishedTransmissions; ///< Number of finished/aborted transmissions
} tFirmwareUpdateInstance;
//------------------------------------------------------------------------------
// local vars
//------------------------------------------------------------------------------
static tFirmwareUpdateInstance instance_l;
//------------------------------------------------------------------------------
// local function prototypes
//------------------------------------------------------------------------------
static tFirmwareRet checkPointerAndInstance(const void* pCheck_p);
static tFirmwareUpdateTransmissionInfo* getInfo(UINT nodeId_p);
static BOOL isExpectedSdoCompleteEvent(tFirmwareUpdateTransmissionInfo* pInfo_p,
const tSdoComFinished* pSdoComFinished_p);
static tFirmwareRet transmitFirmware(tFirmwareUpdateTransmissionInfo* pInfo_p);
static tFirmwareRet startTransmission(tFirmwareUpdateTransmissionInfo* pInfo_p);
static void transmissionFailed(tFirmwareUpdateTransmissionInfo* pInfo_p);
static tFirmwareRet transmissionSucceeded(tFirmwareUpdateTransmissionInfo* pInfo_p);
static void cleanupTransmission(tFirmwareUpdateTransmissionInfo* pInfo_p);
static void cleanupInstance(void);
static BOOL isTransmissionAllowed(tFirmwareUpdateTransmissionInfo* pInfo_p);
static tFirmwareUpdateTransmissionInfo* getNextPendingTransmission(void);
//============================================================================//
// P U B L I C F U N C T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Initialize the firmware update module
This function initializes the firmware update module.
\param pConfig_p [in] Pointer to the configuration structure for the
firmware update module.
\return This functions returns a value of \ref tFirmwareRet.
\ingroup module_app_firmwaremanager
*/
//------------------------------------------------------------------------------
tFirmwareRet firmwareupdate_init(const tFirmwareUpdateConfig* pConfig_p)
{
tFirmwareRet ret = kFwReturnOk;
if (instance_l.fInitialized)
{
ret = kFwReturnAlreadyInitialized;
goto EXIT;
}
memset(&instance_l, 0, sizeof(tFirmwareUpdateInstance));
memcpy(&instance_l.config, pConfig_p, sizeof(tFirmwareUpdateConfig));
instance_l.fInitialized = TRUE;
EXIT:
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Deinitialize the firmware update module
This function deinitializes the firmware update module.
\ingroup module_app_firmwaremanager
*/
//------------------------------------------------------------------------------
void firmwareupdate_exit(void)
{
instance_l.fInitialized = FALSE;
}
//------------------------------------------------------------------------------
/**
\brief Process the given list of firmware updates
This function processes the required firmware updates defined by the given list.
\param ppList_p [in, out] Pointer to List of required firmware updates, when
an error occurs the returned list contains entries
which were not freed.
\return This functions returns a value of \ref tFirmwareRet.
\ingroup module_app_firmwaremanager
*/
//------------------------------------------------------------------------------
tFirmwareRet firmwareupdate_processUpdateList(tFirmwareUpdateList* ppList_p)
{
tFirmwareRet ret = kFwReturnOk;
tFirmwareUpdateEntry** ppInsertIter;
tFirmwareUpdateTransmissionInfo* pInfo;
ret = checkPointerAndInstance(ppList_p);
if (ret != kFwReturnOk)
{
goto EXIT;
}
pInfo = &instance_l.aTransmissions[(*ppList_p)->nodeId];
ppInsertIter = &pInfo->pUpdateList;
while (*ppInsertIter != NULL)
{
ppInsertIter = &(*ppInsertIter)->pNext;
}
*ppInsertIter = (*ppList_p);
*ppList_p = NULL;
if (!pInfo->fTranmissionActive)
{
pInfo->sdoComCon = FIRMWARE_UPDATE_INVALID_SDO;
}
ret = startTransmission(pInfo);
EXIT:
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Process an SDO event
This function processes SDO events given by the passed \ref tSdoComFinished
structure. By processing the according events this module checks the result of
firmware transmissions and proceeds for further required updates.
\param pSdoComFinished_p [in] Structure of the SDO event
\return This functions returns a value of \ref tFirmwareRet.
\ingroup module_app_firmwaremanager
*/
//------------------------------------------------------------------------------
tFirmwareRet firmwareupdate_processSdoEvent(const tSdoComFinished* pSdoComFinished_p)
{
tFirmwareRet ret = kFwReturnOk;
tFirmwareUpdateTransmissionInfo* pInfo = NULL;
BOOL fSucceeded = TRUE;
ret = checkPointerAndInstance(pSdoComFinished_p);
if (ret != kFwReturnOk)
{
goto EXIT;
}
pInfo = &instance_l.aTransmissions[pSdoComFinished_p->nodeId];
if (!isExpectedSdoCompleteEvent(pInfo, pSdoComFinished_p))
{
ret = kFwReturnInvalidSdoEvent;
goto EXIT;
}
if (pSdoComFinished_p->sdoComConState != kSdoComTransferFinished)
{
FWM_ERROR("SDO write failed for node 0x%X with state: 0x%x and abort code 0x%x\n",
pSdoComFinished_p->nodeId, pSdoComFinished_p->sdoComConState, pSdoComFinished_p->abortCode);
fSucceeded = FALSE;
}
if (pSdoComFinished_p->transferredBytes != pInfo->firmwareSize)
{
FWM_ERROR("SDO written number of bytes does not match for node 0x%X: %lu - %lu\n",
pSdoComFinished_p->nodeId, (ULONG)pSdoComFinished_p->transferredBytes, (ULONG)pInfo->firmwareSize);
fSucceeded = FALSE;
}
if (pSdoComFinished_p->abortCode != 0)
{
FWM_ERROR("SDO event with abort code: 0x%x for node 0x%X\n", pSdoComFinished_p->abortCode, pSdoComFinished_p->nodeId);
fSucceeded = FALSE;
}
if (fSucceeded)
{
ret = transmissionSucceeded(pInfo);
}
else
{
transmissionFailed(pInfo);
}
ret = startTransmission(pInfo);
EXIT:
if (ret != kFwReturnOk)
{
cleanupInstance();
}
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Get update transmission status
This function returns the node's update transmission status.
\param pConfig_p [in] Pointer to the configuration structure for the
firmware update module.
\param nodeId_p [in] Node ID
\param pStatus_p [in] Pointer used to return the transmission status
\return This functions returns a value of \ref tFirmwareRet.
\ingroup module_app_firmwaremanager
*/
//------------------------------------------------------------------------------
tFirmwareRet firmwareupdate_getTransmissionStatus(UINT nodeId_p,
tFirmwareUpdateTransmissionStatus* pStatus_p)
{
tFirmwareRet ret = kFwReturnOk;
tFirmwareUpdateTransmissionInfo* pInfo;
tFirmwareUpdateEntry* pIter;
UINT count = 0u;
ret = checkPointerAndInstance(pStatus_p);
if (ret != kFwReturnOk)
{
goto EXIT;
}
pInfo = getInfo(nodeId_p);
if (pInfo == NULL)
{
ret = kFwReturnInvalidNodeId;
goto EXIT;
}
pIter = pInfo->pUpdateList;
while (pIter != NULL)
{
count++;
pIter = pIter->pNext;
}
pStatus_p->fTransmissionActive = pInfo->fTranmissionActive;
pStatus_p->numberOfPendingTransmissions = count;
EXIT:
return ret;
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
//------------------------------------------------------------------------------
/**
\brief Check pointer and instance
\param pCheck_p [in] Pointer checked
\return This functions returns a value of \ref tFirmwareRet.
*/
//------------------------------------------------------------------------------
static tFirmwareRet checkPointerAndInstance(const void* pCheck_p)
{
tFirmwareRet ret = kFwReturnOk;
if (!instance_l.fInitialized)
{
ret = kFwReturnInvalidInstance;
}
else if (pCheck_p == NULL)
{
ret = kFwReturnInvalidParameter;
}
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Get transmission information
\param nodeId_p [in] Node ID
\return This functions returns a pointer to the transmission information.
*/
//------------------------------------------------------------------------------
static tFirmwareUpdateTransmissionInfo* getInfo(UINT nodeId_p)
{
tFirmwareUpdateTransmissionInfo* pInfo = NULL;
if (nodeId_p <= FIRMWARE_UPDATE_MAX_NODE_ID)
{
pInfo = &instance_l.aTransmissions[nodeId_p];
}
return pInfo;
}
//------------------------------------------------------------------------------
/**
\brief Check SDO complete event's validity
\param pInfo_p [in] Pointer to transmission information
\param pSdoComFinished_p [in] Pointer to SDO finish
\return This functions returns a \ref BOOL.
*/
//------------------------------------------------------------------------------
static BOOL isExpectedSdoCompleteEvent(tFirmwareUpdateTransmissionInfo* pInfo_p,
const tSdoComFinished* pSdoComFinished_p)
{
return ((pSdoComFinished_p->pUserArg == &instance_l) &&
pInfo_p->fTranmissionActive &&
(pInfo_p->pUpdateList != NULL) &&
(pSdoComFinished_p->targetIndex == pInfo_p->pUpdateList->index) &&
(pSdoComFinished_p->targetSubIndex == pInfo_p->pUpdateList->subindex) &&
(pSdoComFinished_p->sdoComConHdl == pInfo_p->sdoComCon));
}
//------------------------------------------------------------------------------
/**
\brief Transmit firmware update image
\param pInfo_p [in] Pointer to transmission information
\return This functions returns a value of \ref tFirmwareRet.
*/
//------------------------------------------------------------------------------
static tFirmwareRet transmitFirmware(tFirmwareUpdateTransmissionInfo* pInfo_p)
{
tFirmwareRet ret = kFwReturnOk;
tOplkError oplkRet;
if (pInfo_p->fTranmissionActive)
{
goto EXIT;
}
if (!isTransmissionAllowed(pInfo_p))
{
FWM_TRACE("Postpone update for node: %u index: 0x%x subindex: 0x%x\n",
pInfo_p->pUpdateList->nodeId, pInfo_p->pUpdateList->index,
pInfo_p->pUpdateList->subindex);
goto EXIT;
}
FWM_TRACE("Start update for node: %u index: 0x%x subindex: 0x%x\n",
pInfo_p->pUpdateList->nodeId, pInfo_p->pUpdateList->index,
pInfo_p->pUpdateList->subindex);
ret = firmwarestore_loadData(pInfo_p->pUpdateList->pStoreHandle);
if (ret != kFwReturnOk)
{
FWM_ERROR("Loading image for transmission failed with %d and errno %d\n",
ret, errno);
goto EXIT;
}
ret = firmwarestore_getData(pInfo_p->pUpdateList->pStoreHandle,
&pInfo_p->pFirmwareImage,
&pInfo_p->firmwareSize);
if (ret != kFwReturnOk)
{
FWM_ERROR("Getting the image for transmission failed with %d and errno %d\n",
ret, errno);
goto EXIT;
}
oplkRet = oplk_writeObject(&pInfo_p->sdoComCon,
pInfo_p->pUpdateList->nodeId,
pInfo_p->pUpdateList->index,
pInfo_p->pUpdateList->subindex,
pInfo_p->pFirmwareImage,
(UINT)pInfo_p->firmwareSize,
FIRMWARE_UPDATE_SDO_TYPE,
&instance_l);
if ((oplkRet != kErrorApiTaskDeferred) && (pInfo_p->sdoComCon != FIRMWARE_UPDATE_INVALID_SDO))
{
FWM_ERROR("Writing the firmware object failed with 0x%X\n", oplkRet);
ret = kFwReturnSdoWriteFailed;
goto EXIT;
}
instance_l.numberOfStartedTransmissions++;
pInfo_p->fTranmissionActive = TRUE;
EXIT:
if (ret != kFwReturnOk)
{
firmwarestore_flushData(pInfo_p->pUpdateList->pStoreHandle);
}
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Start firmware update image transmission
\param pInfo_p [in] Pointer to transmission information
\return This functions returns a value of \ref tFirmwareRet.
*/
//------------------------------------------------------------------------------
static tFirmwareRet startTransmission(tFirmwareUpdateTransmissionInfo* pInfo_p)
{
tFirmwareRet ret = kFwReturnOk;
while (pInfo_p->pUpdateList != NULL)
{
ret = transmitFirmware(pInfo_p);
if (ret == kFwReturnOk)
{
break;
}
else
{
FWM_ERROR("Transmission of the firmware failed with %d\n", ret);
transmissionFailed(pInfo_p);
}
}
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Handle firmware update transmission failed
\param pInfo_p [in] Pointer to transmission information
\return This functions returns a value of \ref tFirmwareRet.
*/
//------------------------------------------------------------------------------
static void transmissionFailed(tFirmwareUpdateTransmissionInfo* pInfo_p)
{
pInfo_p->fTranmissionActive = FALSE;
instance_l.numberOfFinishedTransmissions++;
if (pInfo_p->pUpdateList->fIsNode)
{
if (instance_l.config.pfnError != NULL)
{
instance_l.config.pfnError(pInfo_p->pUpdateList->nodeId,
&pInfo_p->sdoComCon);
}
}
cleanupTransmission(pInfo_p);
}
//------------------------------------------------------------------------------
/**
\brief Handle firmware update transmission succeeded
\param pInfo_p [in] Pointer to transmission information
\return This functions returns a value of \ref tFirmwareRet.
*/
//------------------------------------------------------------------------------
static tFirmwareRet transmissionSucceeded(tFirmwareUpdateTransmissionInfo* pInfo_p)
{
tFirmwareRet ret = kFwReturnOk;
tFirmwareUpdateTransmissionInfo* pNextInfo;
FWM_TRACE("Update finished for node: %u index: 0x%x subindex: 0x%x\n",
pInfo_p->pUpdateList->nodeId, pInfo_p->pUpdateList->index,
pInfo_p->pUpdateList->subindex);
if (pInfo_p->pUpdateList->fIsNode)
{
// Node callback
if (instance_l.config.pfnNodeUpdateComplete != NULL)
{
ret = instance_l.config.pfnNodeUpdateComplete(pInfo_p->pUpdateList->nodeId,
&pInfo_p->sdoComCon);
}
}
else if (pInfo_p->pUpdateList->pNext == NULL)
{
// Module callback
if (instance_l.config.pfnModuleUpdateComplete != NULL)
{
ret = instance_l.config.pfnModuleUpdateComplete(pInfo_p->pUpdateList->nodeId,
&pInfo_p->sdoComCon);
}
}
instance_l.numberOfFinishedTransmissions++;
if (pInfo_p->pUpdateList->pNext == NULL)
{
pNextInfo = getNextPendingTransmission();
if (pNextInfo != NULL)
{
FWM_TRACE("Start next pending transmission for node 0x%X\n",
pNextInfo->pUpdateList->nodeId);
startTransmission(pNextInfo);
}
}
cleanupTransmission(pInfo_p);
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Clean up firmware update transmission
\param pInfo_p [in] Pointer to transmission information
*/
//------------------------------------------------------------------------------
static void cleanupTransmission(tFirmwareUpdateTransmissionInfo* pInfo_p)
{
tFirmwareUpdateEntry* pRem;
tFirmwareStoreHandle pFwStore;
pInfo_p->fTranmissionActive = FALSE;
pFwStore = pInfo_p->pUpdateList->pStoreHandle;
pRem = pInfo_p->pUpdateList;
pInfo_p->pUpdateList = pInfo_p->pUpdateList->pNext;
free(pRem);
firmwarestore_flushData(pFwStore);
}
//------------------------------------------------------------------------------
/**
\brief Clean up firmware update instance
*/
//------------------------------------------------------------------------------
static void cleanupInstance(void)
{
tFirmwareUpdateEntry* pRem;
size_t iter;
for (iter = 0u; iter < FIRMWARE_UPDATE_MAX_NODE_ID; iter++)
{
pRem = instance_l.aTransmissions[iter].pUpdateList;
while (pRem != NULL)
{
instance_l.aTransmissions[iter].pUpdateList = pRem->pNext;
free(pRem);
pRem = instance_l.aTransmissions[iter].pUpdateList;
}
}
}
static tFirmwareUpdateTransmissionInfo* getNextPendingTransmission(void)
{
tFirmwareUpdateTransmissionInfo* pInfo = NULL;
size_t i;
for (i = 0U; i < FIRMWARE_UPDATE_MAX_NODE_ID; i++)
{
if (!instance_l.aTransmissions[i].fTranmissionActive &&
(instance_l.aTransmissions[i].pUpdateList != NULL))
{
pInfo = &instance_l.aTransmissions[i];
break;
}
}
return pInfo;
}
//------------------------------------------------------------------------------
/**
\brief Check if the start of the given transmission is allowed
\return This functions returns a boolean value, which is true if the
transmission is allowed.
*/
//------------------------------------------------------------------------------
static BOOL isTransmissionAllowed(tFirmwareUpdateTransmissionInfo* pInfo_p)
{
size_t numberOfActiveTransmissions = instance_l.numberOfStartedTransmissions -
instance_l.numberOfFinishedTransmissions;
UNUSED_PARAMETER(pInfo_p);
return (numberOfActiveTransmissions < FIRMWARE_UPDATE_MAX_PARALLEL_TRANSMISSIONS);
}
/// \}

View File

@ -0,0 +1,128 @@
/**
********************************************************************************
\file firmwareupdate.h
\brief Header file of the firmware update module
This header file contains the definitions of the firware update module.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2017, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
#ifndef _INC_firmwareupdate_H_
#define _INC_firmwareupdate_H_
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <firmwaremanager/firmwaremanager.h>
#include <firmwaremanager/firmwareinfodecode.h>
#include <oplk/oplk.h>
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// typedef
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/**
\brief Firmware update node callback
This function is called by the firmware update module to inform about a node's
update completion.
\param nodeId_p [in] Node ID
\param pSdoConnection_p [in] Pointer to SDO connection used for this node
\return This functions returns a value of \ref tFirmwareRet.
*/
//------------------------------------------------------------------------------
typedef tFirmwareRet (*tFirmwareUpdateNodeCb)(UINT nodeId_p,
tSdoComConHdl* pSdoConnection_p);
/**
\brief Firmware update transmission status
*/
typedef struct
{
UINT numberOfPendingTransmissions; ///< Number of pending transmissions
BOOL fTransmissionActive; ///< Active transmission flag
} tFirmwareUpdateTransmissionStatus;
/**
\brief Firmware update configuration
*/
typedef struct
{
tFirmwareUpdateNodeCb pfnNodeUpdateComplete; ///< Node update complete callback
tFirmwareUpdateNodeCb pfnModuleUpdateComplete; ///< Modules of a node update complete callback
tFirmwareUpdateNodeCb pfnError; ///< Node update error callback
} tFirmwareUpdateConfig;
/**
\brief Firmware update entry
*/
typedef struct tFirmwareUpdateEntry
{
UINT nodeId; ///< Node ID
UINT index; ///< Index of remote domain object
UINT subindex; ///< Subindex of remote domain object
tFirmwareStoreHandle pStoreHandle; ///< Handle to firmware update file
BOOL fIsNode; ///< Flag for identification of node (Head) update
struct tFirmwareUpdateEntry* pNext; ///< Pointer to next update entry
} tFirmwareUpdateEntry;
/**
\brief Firmware update list
*/
typedef tFirmwareUpdateEntry* tFirmwareUpdateList;
//------------------------------------------------------------------------------
// function prototypes
//------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
tFirmwareRet firmwareupdate_init(const tFirmwareUpdateConfig* pConfig_p);
void firmwareupdate_exit(void);
tFirmwareRet firmwareupdate_processUpdateList(tFirmwareUpdateList* ppList_p);
tFirmwareRet firmwareupdate_processSdoEvent(const tSdoComFinished* pSdoComFinished_p);
tFirmwareRet firmwareupdate_getTransmissionStatus(UINT nodeId_p,
tFirmwareUpdateTransmissionStatus* pStatus_p);
#ifdef __cplusplus
}
#endif
#endif /* _INC_firmwareinfo_H_ */

View File

@ -0,0 +1,326 @@
/**
********************************************************************************
\file gpio-c5socarm.c
\brief GPIOs for Altera Cyclone-V ARM
The file implements the GPIOs on Altera Cyclone-V ARM core used by
openPOWERLINK demo applications.
\ingroup module_app_common
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2015, Kalycito Infotech Private Limited
Copyright (c) 2016, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <alt_generalpurpose_io.h>
#include <oplk/oplk.h>
#include "gpio.h"
#include <system.h>
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P R I V A T E D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#define LED_OUTPUT_DELAY_US 500000 // 500ms
#define HPS_LED_ALL_BIT_MASK 0x0000F000
#define HPS_LED_ALL_TURN_ON 0x00000000
#define HPS_LED_ALL_TURN_OFF 0x0000F000
#define HPS_LED_0_TURN_ON 0x00007000 // GPIO[44] (HPS_LED_0) --> Error Led
#define HPS_LED_1_TURN_ON 0x0000B000 // GPIO[43] (HPS_LED_1) --> Status Led
#define HPS_LED_2_TURN_ON 0x0000D000 // GPIO[42] (HPS_LED_2)
#define HPS_LED_3_TURN_ON 0x0000E000 // GPIO[41] (HPS_LED_3)
#define HPS_LED_0_TURN_OFF 0x00008000
#define HPS_LED_1_TURN_OFF 0x00004000
#define HPS_LED_2_TURN_OFF 0x00002000
#define HPS_LED_3_TURN_OFF 0x00001000
#define HPS_PB_INT_ALL_BIT_MASK 0x01E00000 // Interrupt bits for GPIO2
#define HPS_PB_0_ASSERT 0x01C00000 // GPIO[8] (HPS_PB_0)
#define HPS_PB_1_ASSERT 0x01A00000 // GPIO[9] (HPS_PB_1)
#define HPS_PB_2_ASSERT 0x01600000 // GPIO[10](HPS_PB_2)
#define HPS_PB_3_ASSERT 0x00E00000 // GPIO[11](HPS_PB_3)
#define HPS_PB_ALL_BIT_MASK 0x01E00000
#define HPS_PB_0_BIT_MASK 0x01000000 // GPIO[8] (HPS_PB_0)
#define HPS_PB_1_BIT_MASK 0x00800000 // GPIO[9] (HPS_PB_1)
#define HPS_PB_2_BIT_MASK 0x00400000 // GPIO[10](HPS_PB_2)
#define HPS_PB_3_BIT_MASK 0x00200000 // GPIO[11](HPS_PB_3)
#define HPS_DIPSW_ALL_BIT_MASK 0x001E0000
#define HPS_DIPSW_NET_VAL(portVal) ((portVal >> 17) & 0xF)
#define HPS_DIPSW_0_BIT_MASK 0x00100000 // GPIO[4] (HPS_DIPSW_0)
#define HPS_DIPSW_1_BIT_MASK 0x00080000 // GPIO[5] (HPS_DIPSW_1)
#define HPS_DIPSW_2_BIT_MASK 0x00040000 // GPIO[6](HPS_DIPSW_2)
#define HPS_DIPSW_3_BIT_MASK 0x00020000 // GPIO[7](HPS_DIPSW_3)
#define FPGA_PB_ALL_BIT_MASK 0x00000003
#define FPGA_PB_1_BIT_MASK 0x00000002
#define FPGA_PB_0_BIT_MASK 0x00000001
#define FPGA_DIPSW_ALL_BIT_MASK 0x0000000F
#define FPGA_DIPSW_0_BIT_MASK 0x00000001
#define FPGA_DIPSW_1_BIT_MASK 0x00000002
#define FPGA_DIPSW_3_BIT_MASK 0x00000001
#define FPGA_DIPSW_4_BIT_MASK 0x00000002
#define FPGA_DIPSW_NET_VAL(portVal) (portVal & FPGA_DIPSW_ALL_BIT_MASK)
// Determine size of an array
#define ARRAY_COUNT(array) (sizeof(array) / sizeof(array[0]))
//------------------------------------------------------------------------------
// local types
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// local vars
//------------------------------------------------------------------------------
ALT_GPIO_CONFIG_RECORD_t cfgHpsGPI[] =
{
{ ALT_HLGPI_4, ALT_GPIO_PIN_INPUT, 0, 0, 0, 0 }, // HPS_DIPSW_0
{ ALT_HLGPI_5, ALT_GPIO_PIN_INPUT, 0, 0, 0, 0 }, // HPS_DIPSW_1
{ ALT_HLGPI_6, ALT_GPIO_PIN_INPUT, 0, 0, 0, 0 }, // HPS_DIPSW_2
{ ALT_HLGPI_7, ALT_GPIO_PIN_INPUT, 0, 0, 0, 0 }, // HPS_DIPSW_3
{ ALT_HLGPI_8, ALT_GPIO_PIN_INPUT, 0, 0, 0, 0 }, // HPS_PB_0
{ ALT_HLGPI_9, ALT_GPIO_PIN_INPUT, 0, 0, 0, 0 }, // HPS_PB_1
{ ALT_HLGPI_10, ALT_GPIO_PIN_INPUT, 0, 0, 0, 0 }, // HPS_PB_2
{ ALT_HLGPI_11, ALT_GPIO_PIN_INPUT, 0, 0, 0, 0 } // HPS_PB_3
};
ALT_GPIO_CONFIG_RECORD_t cfgHpsGPO[] =
{
{ ALT_GPIO_1BIT_44, ALT_GPIO_PIN_OUTPUT, 0, 0, 0, ALT_GPIO_PIN_DATAZERO }, // HPS_LED_0
{ ALT_GPIO_1BIT_43, ALT_GPIO_PIN_OUTPUT, 0, 0, 0, ALT_GPIO_PIN_DATAZERO }, // HPS_LED_1
{ ALT_GPIO_1BIT_42, ALT_GPIO_PIN_OUTPUT, 0, 0, 0, ALT_GPIO_PIN_DATAZERO }, // HPS_LED_2
{ ALT_GPIO_1BIT_41, ALT_GPIO_PIN_OUTPUT, 0, 0, 0, ALT_GPIO_PIN_DATAZERO } // HPS_LED_3
};
//------------------------------------------------------------------------------
// local function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P U B L I C F U N C T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Initialize GPIO module
The function initializes the GPIO module before being used.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void gpio_init(void)
{
ALT_STATUS_CODE halRet = ALT_E_SUCCESS;
/* Initialize HPS GPIO */
// Initialize GPIO module
halRet = alt_gpio_init();
if (halRet != ALT_E_SUCCESS)
goto Exit;
halRet = alt_gpio_group_config(cfgHpsGPO, ARRAY_COUNT(cfgHpsGPO)); // Setup GPIO LED
if (halRet != ALT_E_SUCCESS)
goto Exit;
halRet = alt_gpio_port_data_write(ALT_GPIO_PORTB,
HPS_LED_ALL_BIT_MASK,
HPS_LED_ALL_TURN_OFF); // clear the Leds
if (halRet != ALT_E_SUCCESS)
goto Exit;
halRet = alt_gpio_group_config(cfgHpsGPI, ARRAY_COUNT(cfgHpsGPI)); // Setup GPIO PUSHBUTTON
if (halRet != ALT_E_SUCCESS)
goto Exit;
halRet = alt_gpio_port_int_disable(ALT_GPIO_PORTC, HPS_PB_INT_ALL_BIT_MASK); // Enable GPIO interrupts
if (halRet != ALT_E_SUCCESS)
goto Exit;
/* Initialize FPGA GPIO */
// will be initialized in target initialization
// Clear the dip switch and push button interrupt status registers
#if defined(HOST_0_BUTTON_PIO_BASE)
IOWR_ALTERA_AVALON_PIO_IRQ_MASK(HOST_0_BUTTON_PIO_BASE, 0x0);
IOWR_ALTERA_AVALON_PIO_EDGE_CAP(HOST_0_BUTTON_PIO_BASE, FPGA_PB_ALL_BIT_MASK);
#endif
#if defined(HOST_0_DIPSW_PIO_BASE)
IOWR_ALTERA_AVALON_PIO_IRQ_MASK(HOST_0_DIPSW_PIO_BASE, 0x0);
IOWR_ALTERA_AVALON_PIO_EDGE_CAP(HOST_0_DIPSW_PIO_BASE, FPGA_DIPSW_ALL_BIT_MASK);
#endif
Exit:
return;
}
//------------------------------------------------------------------------------
/**
\brief Shutdown GPIO module
The function shuts down the GPIO module.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void gpio_exit(void)
{
/* Uninitialize HPS GPIO */
alt_gpio_uninit();
/* Uninitialize FPGA GPIO */
// will be handled by target module
#if defined(HOST_0_BUTTON_PIO_BASE)
IOWR_ALTERA_AVALON_PIO_IRQ_MASK(HOST_0_BUTTON_PIO_BASE, 0x0);
IOWR_ALTERA_AVALON_PIO_EDGE_CAP(HOST_0_BUTTON_PIO_BASE, FPGA_PB_ALL_BIT_MASK);
#endif
#if defined(HOST_0_DIPSW_PIO_BASE)
IOWR_ALTERA_AVALON_PIO_IRQ_MASK(HOST_0_DIPSW_PIO_BASE, 0x0);
IOWR_ALTERA_AVALON_PIO_EDGE_CAP(HOST_0_DIPSW_PIO_BASE, FPGA_DIPSW_ALL_BIT_MASK);
#endif
}
//------------------------------------------------------------------------------
/**
\brief Gets the node switch value
The function returns the node ID set by the node switches.
\return Returns the set node ID
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
UINT8 gpio_getNodeid(void)
{
UINT8 nodeId;
UINT32 hpsSwStatus = 0;
UINT32 fpgaSwStatus = 0;
hpsSwStatus = alt_gpio_port_data_read(ALT_GPIO_PORTC, HPS_DIPSW_ALL_BIT_MASK);
#if defined(HOST_0_DIPSW_PIO_BASE)
fpgaSwStatus = IORD_ALTERA_AVALON_PIO_DATA(HOST_0_DIPSW_PIO_BASE);
#endif
nodeId = (UINT8)((FPGA_DIPSW_NET_VAL(fpgaSwStatus) << HOST_0_DIPSW_PIO_DATA_WIDTH) | HPS_DIPSW_NET_VAL(hpsSwStatus));
return nodeId;
}
//------------------------------------------------------------------------------
/**
\brief Gets the application input
The function returns application inputs.
\return Returns the application inputs.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
UINT32 gpio_getAppInput(void)
{
UINT32 input;
#if defined(HOST_0_BUTTON_PIO_BASE)
input = (UINT32)IORD_ALTERA_AVALON_PIO_EDGE_CAP(HOST_0_BUTTON_PIO_BASE);
IOWR_ALTERA_AVALON_PIO_EDGE_CAP(HOST_0_BUTTON_PIO_BASE, FPGA_PB_ALL_BIT_MASK);
#else
input = 0;
#endif
return input;
}
//------------------------------------------------------------------------------
/**
\brief Sets the application output
The function sets the application outputs.
\param[in] val_p Determines the value to be set to the output
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void gpio_setAppOutputs(UINT32 val_p)
{
ALT_STATUS_CODE halRet = ALT_E_SUCCESS;
halRet = alt_gpio_port_data_write(ALT_GPIO_PORTB, HPS_LED_ALL_BIT_MASK, ~val_p);
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
/// \}

View File

@ -0,0 +1,201 @@
/**
********************************************************************************
\file gpio-microblaze.c
\brief GPIOs for Xilinx microblaze
The file implements the GPIOs on Xilinx microblaze used by openPOWERLINK demo
applications.
\ingroup module_app_common
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <xparameters.h>
#include <xgpio_l.h>
#include <oplk/oplk.h>
#include "gpio.h"
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P R I V A T E D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#ifdef XPAR_NODE_SWITCHES_BASEADDR
#define NODE_SWITCH_BASE XPAR_NODE_SWITCHES_BASEADDR
#endif // XPAR_NODE_SWITCHES_BASEADDR
#ifdef XPAR_GPIO_INPUTS_BASEADDR
#define GPIO_INPUTS_BASE XPAR_GPIO_INPUTS_BASEADDR
#endif // XPAR_GPIO_INPUTS_BASEADDR
#ifdef XPAR_GPIO_OUTPUTS_BASEADDR
#define GPIO_OUTPUTS_BASE XPAR_GPIO_OUTPUTS_BASEADDR
#endif // XPAR_GPIO_OUTPUTS_BASEADDR
//------------------------------------------------------------------------------
// local types
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// local vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// local function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P U B L I C F U N C T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Initialize GPIO module
The function initializes the GPIO module.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void gpio_init(void)
{
}
//------------------------------------------------------------------------------
/**
\brief Shutdown GPIO module
The function shuts down the GPIO module.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void gpio_exit(void)
{
}
//------------------------------------------------------------------------------
/**
\brief Gets the node switch value
The function returns the node ID set by the node switches.
\return Returns the set node ID
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
UINT8 gpio_getNodeid(void)
{
UINT8 nodeid;
#if defined(NODE_SWITCH_BASE)
nodeid = XGpio_ReadReg(NODE_SWITCH_BASE, 0);
#else
nodeid = 0;
#endif
return nodeid;
}
//------------------------------------------------------------------------------
/**
\brief Gets the application input
The function returns application inputs.
\return Returns the application inputs.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
UINT32 gpio_getAppInput(void)
{
UINT32 input;
#if defined(GPIO_INPUTS_BASE)
input = XGpio_ReadReg(GPIO_INPUTS_BASE, 0);
#else
input = 0;
#endif
return input;
}
//------------------------------------------------------------------------------
/**
\brief Sets the application output
The function sets the application outputs.
\param[in] val_p Determines the value to be set to the output
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void gpio_setAppOutputs(UINT32 val_p)
{
#if defined(GPIO_OUTPUTS_BASE)
XGpio_WriteReg(GPIO_OUTPUTS_BASE, XGPIO_DATA_OFFSET, val_p);
#else
UNUSED_PARAMETER(val_p);
#endif
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
/// \}

View File

@ -0,0 +1,192 @@
/**
********************************************************************************
\file gpio-nios2.c
\brief GPIOs for Altera Nios II
The file implements the GPIOs on Altera Nios II used by openPOWERLINK demo
applications.
\ingroup module_app_common
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
Copyright (c) 2013, SYSTEC electronic GmbH
Copyright (c) 2013, Kalycito Infotech Private Ltd.All rights reserved.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <system.h>
#include <altera_avalon_pio_regs.h>
#include <oplk/oplk.h>
#include "gpio.h"
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// 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 //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Initialize GPIO module
The function initializes the GPIO module.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void gpio_init(void)
{
}
//------------------------------------------------------------------------------
/**
\brief Shutdown GPIO module
The function shuts down the GPIO module.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void gpio_exit(void)
{
}
//------------------------------------------------------------------------------
/**
\brief Gets the node switch value
The function returns the node ID set by the node switches.
\return Returns the set node ID
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
UINT8 gpio_getNodeid(void)
{
UINT8 nodeid;
#if defined(NODE_SWITCH_PIO_BASE)
nodeid = IORD_ALTERA_AVALON_PIO_DATA(NODE_SWITCH_PIO_BASE);
#else
nodeid = 0;
#endif
return nodeid;
}
//------------------------------------------------------------------------------
/**
\brief Gets the application input
The function returns application inputs.
\return Returns the application inputs.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
UINT32 gpio_getAppInput(void)
{
UINT32 input;
#if defined(APP_PIO_BASE)
input = IORD_ALTERA_AVALON_PIO_DATA(APP_PIO_BASE);
#else
input = 0;
#endif
return input;
}
//------------------------------------------------------------------------------
/**
\brief Sets the application output
The function sets the application outputs.
\param[in] val_p Determines the value to be set to the output
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void gpio_setAppOutputs(UINT32 val_p)
{
#if defined(APP_PIO_BASE)
IOWR_ALTERA_AVALON_PIO_DATA(APP_PIO_BASE, val_p);
#else
UNUSED_PARAMETER(val_p);
#endif
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
/// \}

View File

@ -0,0 +1,73 @@
/**
********************************************************************************
\file gpio.h
\brief Definitions for GPIOs
This header file provides the definitions for GPIOs used by the openPOWERLINK
examples.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
Copyright (c) 2013, SYSTEC electronic GmbH
Copyright (c) 2013, Kalycito Infotech Private Ltd.All rights reserved.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
#ifndef _INC_gpio_H_
#define _INC_gpio_H_
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <oplk/oplk.h>
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// typedef
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// function prototypes
//------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
void gpio_init(void);
void gpio_exit(void);
UINT8 gpio_getNodeid(void);
UINT32 gpio_getAppInput(void);
void gpio_setAppOutputs(UINT32 val_p);
#ifdef __cplusplus
}
#endif
#endif /* _INC_gpio_H_ */

View File

@ -0,0 +1,280 @@
/**
********************************************************************************
\file lcd.c
\brief Generic LCD interface
The generic LCD interface module enables to control any LCD.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
Copyright (c) 2013, SYSTEC electronic GmbH
Copyright (c) 2013, Kalycito Infotech Private Ltd.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <string.h>
#include <oplk/oplk.h>
#include "lcd.h"
#include "lcdl.h"
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P R I V A T E D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#define LCD_COLUMN 16 ///< Minimum line size needed
static const char aStrNmtState_l[10][LCD_COLUMN + 1] =
{
"INVALID ",
"OFF ",
"INITIALISATION ",
"NOT ACTIVE ",
"BASIC ETHERNET ",
"PRE_OP1 ",
"PRE_OP2 ",
"READY_TO_OP ",
"OPERATIONAL ",
"STOPPED "
};
//------------------------------------------------------------------------------
// local types
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// local vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// local function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P U B L I C F U N C T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Initialize the LCD
The function initializes the generic LCD instance.
*/
//------------------------------------------------------------------------------
void lcd_init(void)
{
// Initialize low-level module
lcdl_init();
}
//------------------------------------------------------------------------------
/**
\brief Shutdown the LCD
The function exits the generic LCD instance.
*/
//------------------------------------------------------------------------------
void lcd_exit(void)
{
// Shutdown low-level module
lcdl_exit();
}
//------------------------------------------------------------------------------
/**
\brief Clear the LCD
The function clears the display.
*/
//------------------------------------------------------------------------------
void lcd_clear(void)
{
lcdl_clear();
}
//------------------------------------------------------------------------------
/**
\brief Print text to LCD
The function prints the provided text to the specified line in the LCD.
\param[in] sText_p Text to be printed
\param[in] line_p Line to print the text in
*/
//------------------------------------------------------------------------------
void lcd_printText(const char* sText_p,
UINT line_p)
{
if (lcdl_changeToLine(line_p) != 0)
return;
lcdl_printText(sText_p);
}
//------------------------------------------------------------------------------
/**
\brief Print NMT state to LCD
The function prints the NMT state to the second line of the display.
\param[in] nmtState_p NMT state to be written
*/
//------------------------------------------------------------------------------
void lcd_printNmtState(tNmtState nmtState_p)
{
if (lcdl_changeToLine(2) != 0)
return;
switch (nmtState_p)
{
case kNmtGsOff:
lcdl_printText(aStrNmtState_l[1]);
break;
case kNmtGsInitialising:
case kNmtGsResetApplication:
case kNmtGsResetCommunication:
case kNmtGsResetConfiguration:
lcdl_printText(aStrNmtState_l[2]);
break;
case kNmtCsNotActive:
case kNmtMsNotActive:
lcdl_printText(aStrNmtState_l[3]);
break;
case kNmtCsBasicEthernet:
case kNmtMsBasicEthernet:
lcdl_printText(aStrNmtState_l[4]);
break;
case kNmtCsPreOperational1:
case kNmtMsPreOperational1:
lcdl_printText(aStrNmtState_l[5]);
break;
case kNmtCsPreOperational2:
case kNmtMsPreOperational2:
lcdl_printText(aStrNmtState_l[6]);
break;
case kNmtCsReadyToOperate:
case kNmtMsReadyToOperate:
lcdl_printText(aStrNmtState_l[7]);
break;
case kNmtCsOperational:
case kNmtMsOperational:
lcdl_printText(aStrNmtState_l[8]);
break;
case kNmtCsStopped:
lcdl_printText(aStrNmtState_l[9]);
break;
default:
lcdl_printText(aStrNmtState_l[0]);
break;
}
}
//------------------------------------------------------------------------------
/**
\brief Print node ID to LCD
The function prints the provided node ID to the first line of the display.
In addition to the printed node ID 'MN' (=0xF0) or 'CN' is added.
\param[in] nodeId_p node ID to be written
*/
//------------------------------------------------------------------------------
void lcd_printNodeId(UINT8 nodeId_p)
{
char textNodeID[LCD_COLUMN+1];
sprintf(textNodeID,
"NodeID=0x%02X (%s)",
nodeId_p,
(nodeId_p == C_ADR_MN_DEF_NODE_ID) ? "MN" : "CN");
if (lcdl_changeToLine(1) != 0)
return;
lcdl_printText(textNodeID);
}
//------------------------------------------------------------------------------
/**
\brief Print error code to LCD
The function prints the provided error code to the second line of the display.
\param[in] error_p error code
*/
//------------------------------------------------------------------------------
void lcd_printError(tOplkError error_p)
{
char textError[LCD_COLUMN+1];
sprintf(textError, "ERROR=0x%04X", error_p);
if (lcdl_changeToLine(2) != 0)
return;
lcdl_printText(textError);
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
/// \}

View File

@ -0,0 +1,76 @@
/**
********************************************************************************
\file lcd.h
\brief Generic LCD interface
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
Copyright (c) 2013, SYSTEC electronic GmbH
Copyright (c) 2013, Kalycito Infotech Private Ltd.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
#ifndef _INC_lcd_H_
#define _INC_lcd_H_
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <oplk/oplk.h>
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// typedef
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// function prototypes
//------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
void lcd_init(void);
void lcd_exit(void);
void lcd_clear(void);
void lcd_printText(const char* sText_p,
UINT line_p);
void lcd_printNmtState(tNmtState nmtState_p);
void lcd_printNodeId(UINT8 nodeId_p);
void lcd_printError(tOplkError error_p);
#ifdef __cplusplus
}
#endif
#endif /* _INC_lcd_H_ */

View File

@ -0,0 +1,216 @@
/**
********************************************************************************
\file lcdl-16207.c
\brief Low-level LCD functions for Altera Avalon LCD IP-Core with HD44780
This implementation uses the Altera Avalon LCD 16207 IP-Core to handle the
display controller HD44780 - available e.g. on the Terasic DE2-115 board.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
Copyright (c) 2013, SYSTEC electronic GmbH
Copyright (c) 2013, Kalycito Infotech Private Ltd.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <unistd.h> // for usleep()
#include <string.h>
#include <system.h>
#include <altera_avalon_lcd_16207_regs.h>
#include "lcdl.h"
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#if !defined(LCD_BASE)
#error "Rename the LCD component in QSYS/SOPC to 'lcd'!"
#endif
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P R I V A T E D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#define LCDL_COLUMN 16 ///< Column count
#define LCDL_LINE 2 ///< Line count
#define LCDL_WRCMD(data) IOWR_ALTERA_AVALON_LCD_16207_COMMAND(LCD_BASE, data)
#define LCDL_RDCMD() IORD_ALTERA_AVALON_LCD_16207_STATUS(LCD_BASE)
#define LCDL_WRDATA(data) IOWR_ALTERA_AVALON_LCD_16207_DATA(LCD_BASE, data)
#define LCDL_RDDATA() IORD_ALTERA_AVALON_LCD_16207_DATA(LCD_BASE)
//------------------------------------------------------------------------------
// local types
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// local vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// local function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P U B L I C F U N C T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Initialize the low-level LCD module
This function writes a sequence of initialization parameters to the LCD.
*/
//------------------------------------------------------------------------------
void lcdl_init(void)
{
LCDL_WRCMD(0x38);
usleep(2000);
LCDL_WRCMD(0x0C);
usleep(2000);
LCDL_WRCMD(0x01);
usleep(2000);
LCDL_WRCMD(0x06);
usleep(2000);
LCDL_WRCMD(0x80);
usleep(2000);
}
//------------------------------------------------------------------------------
/**
\brief Shutdown the low-level LCD module
This function exits the LCD instance.
*/
//------------------------------------------------------------------------------
void lcdl_exit(void)
{
}
//------------------------------------------------------------------------------
/**
\brief Clear the LCD
This function clears all lines of the display.
*/
//------------------------------------------------------------------------------
void lcdl_clear(void)
{
LCDL_WRCMD(0x01);
usleep(2000);
}
//------------------------------------------------------------------------------
/**
\brief Change to specified line
Changes to specified line of the LCD
\param[in] line_p Specifies the line
\return The function returns 0 if the line is changed successfully,
otherwise -1.
*/
//------------------------------------------------------------------------------
int lcdl_changeToLine(unsigned int line_p)
{
if (line_p > LCDL_LINE)
return -1;
switch (line_p)
{
case 1:
LCDL_WRCMD(0x80);
break;
case 2:
LCDL_WRCMD(0xC0);
break;
default:
break;
}
usleep(2000);
return 0;
}
//------------------------------------------------------------------------------
/**
\brief Print text to the LCD
Writes text to the LCD currently selected.
\param[in] sText_p The text to print
*/
//------------------------------------------------------------------------------
void lcdl_printText(const char* sText_p)
{
int i;
int length = strlen(sText_p);
// Longer text is cut due to column limitation!
for (i = 0; i < LCDL_COLUMN; i++)
{
// Write blank if provided text is shorter than column count.
if (i < length)
LCDL_WRDATA(sText_p[i]);
else
LCDL_WRDATA(' ');
usleep(2000);
}
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
/// \}

View File

@ -0,0 +1,409 @@
/**
********************************************************************************
\file lcd-c5socarm.c
\brief LCD functions for Altera Cyclone-V HPS LCD
This implementation uses the Altera Cyclone-V HPS LCD available on
Altera Cyclone-V development board(D) for handling LCD module.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
Copyright (c) 2013, SYSTEC electronic GmbH
Copyright (c) 2015, Kalycito Infotech Private Ltd.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <inttypes.h>
#include <alt_cache.h>
#include <alt_interrupt.h>
#include <alt_i2c.h>
#include <alt_globaltmr.h>
#include <alt_timers.h>
#include <socal/hps.h>
#include <socal/socal.h>
#include <system.h>
#include <sleep.h>
#include <trace/trace.h>
#include "lcdl.h"
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P R I V A T E D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//TODO Replace the I2C address from system.h
#define LCD_I2C_ADDRESS (0x50 >> 1) // I2C address of LCD module
#define LCD_I2C_SPEED 40000 // I2C bus speed for accessing LCD module
#define LCD_ESCAPE_CHAR 0xfe // Escape character used to prefix commands
#define LCD_POS_1ST_LINE 0x00 // LCD cursor position for 1st line
#define LCD_POS_2ND_LINE 0x40 // LCD cursor position for 2nd line
#define LCD_PRINT_DELAY_US 500 // Delay in us after printing text on LCD
#define LCDL_COLUMN 16 // Maximum Column length
//------------------------------------------------------------------------------
// local types
//------------------------------------------------------------------------------
// Commands supported by the LCD display
typedef enum
{
kLcdCmdDisplayOn = 0,
kLcdCmdDisplayOff,
kLcdCmdSetCursor,
kLcdCmdCursorHome,
kLcdCmdUnderlineCursorOn,
kLcdCmdUnderlineCursorOff,
kLcdCmdMoveCursorLeftOnePlace,
kLcdCmdMoveCursorRightOnePlace,
kLcdCmdBlinkingCursorOn,
kLcdCmdBlinkingCursorOff,
kLcdCmdBackspace,
kLcdCmdClearScreen,
kLcdCmdSetContrast,
kLcdCmdSetBacklightBrightness,
kLcdCmdLoadCustomCharacter,
kLcdCmdMoveDisplayOnePlaceToTheLeft,
kLcdCmdMoveDisplayOnePlaceToTheRight,
kLcdCmdChangeRS232BaudRate,
kLcdCmdChangeI2CAddress,
kLcdCmdDisplayFirmwareVersionNumber,
kLcdCmdDisplayRS232BaudRate,
kLcdCmdDisplayI2CAddress,
} tLcdCmd;
// Command description
typedef struct
{
uint8_t command;
uint8_t padding;
uint16_t executionDuration;
} tLcdCmdDesc;
//------------------------------------------------------------------------------
// local vars
//------------------------------------------------------------------------------
ALT_I2C_DEV_t* deviceHandle_l;
// Descriptions for all supported commands
static tLcdCmdDesc lcdCommands_l[] =
{
{0x41, 0, 100}, // LCD_COMMAND_DISPLAY_ON,
{0x42, 0, 100}, // LCD_COMMAND_DISPLAY_OFF,
{0x45, 1, 100}, // LCD_COMMAND_SET_CURSOR,
{0x46, 0, 1500}, // LCD_COMMAND_CURSOR_HOME,
{0x47, 0, 1500}, // LCD_COMMAND_UNDERLINE_CURSOR_ON,
{0x48, 0, 1500}, // LCD_COMMAND_UNDERLINE_CURSOR_OFF,
{0x49, 0, 100}, // LCD_COMMAND_MOVE_CURSOR_LEFT_ONE_PLACE,
{0x4A, 0, 100}, // LCD_COMMAND_MOVE_CURSOR_RIGHT_ONE_PLACE,
{0x4B, 0, 100}, // LCD_COMMAND_BLINKING_CURSOR_ON,
{0x4C, 0, 100}, // LCD_COMMAND_BLINKING_CURSOR_OFF,
{0x4E, 0, 100}, // LCD_COMMAND_BACKSPACE,
{0x51, 0, 1500}, // LCD_COMMAND_CLEAR_SCREEN,
{0x52, 1, 500}, // LCD_COMMAND_SET_CONTRAST,
{0x53, 1, 100}, // LCD_COMMAND_SET_BACKLIGHT_BRIGHTNESS,
{0x54, 9, 200}, // LCD_COMMAND_LOAD_CUSTOM_CHARACTER,
{0x55, 0, 100}, // LCD_COMMAND_MOVE_DISPLAY_ONE_PLACE_TO_THE_LEFT,
{0x56, 0, 100}, // LCD_COMMAND_MOVE_DISPLAY_ONE_PLACE_TO_THE_RIGHT,
{0x61, 1, 3000}, // LCD_COMMAND_CHANGE_RS_232_BAUD_RATE,
{0x62, 1, 3000}, // LCD_COMMAND_CHANGE_I2C_ADDRESS,
{0x70, 0, 4000}, // LCD_COMMAND_DISPLAY_FIRMWARE_VERSION_NUMBER,
{0x71, 0, 10000}, // LCD_COMMAND_DISPLAY_RS_232_BAUD_RATE,
{0x72, 0, 4000}, // LCD_COMMAND_DISPLAY_I2C_ADDRESS,
};
//------------------------------------------------------------------------------
// local function prototypes
//------------------------------------------------------------------------------
static inline ALT_STATUS_CODE sendLcdCommand(ALT_I2C_DEV_t* deviceHdl_p,
tLcdCmd command_p,
const uint8_t* pArg_p);
//============================================================================//
// P U B L I C F U N C T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Initialize the LCD
This function writes a sequence of initialization parameters to the LCD.
*/
//------------------------------------------------------------------------------
void lcdl_init(void)
{
int ret = 0;
ALT_I2C_MASTER_CONFIG_t cfg;
uint32_t speed;
// Init I2C module
if (alt_i2c_init(ALT_I2C_I2C0, deviceHandle_l) != ALT_E_SUCCESS)
{
ret = -1;
goto Exit;
}
if (alt_i2c_enable(deviceHandle_l) != ALT_E_SUCCESS) // Enable I2C module
{
ret = -1;
goto Exit;
}
if (alt_i2c_master_config_get(deviceHandle_l, &cfg) != ALT_E_SUCCESS) // Configure I2C module
{
ret = -1;
goto Exit;
}
if (alt_i2c_master_config_speed_get(deviceHandle_l, &cfg, (uint32_t*)&speed) != ALT_E_SUCCESS)
{
ret = -1;
goto Exit;
}
TRACE("LCD INFO: Current I2C speed = %d Hz.\n", (int)speed);
if (alt_i2c_master_config_speed_set(deviceHandle_l, &cfg, LCD_I2C_SPEED) != ALT_E_SUCCESS)
{
ret = -1;
goto Exit;
}
if (alt_i2c_master_config_speed_get(deviceHandle_l, &cfg, (uint32_t*)&speed) != ALT_E_SUCCESS)
{
ret = -1;
goto Exit;
}
else
{
TRACE("LCD INFO: New I2C speed = %d Hz.\n", (int)speed);
cfg.addr_mode = ALT_I2C_ADDR_MODE_7_BIT;
cfg.restart_enable = ALT_E_TRUE;
if (alt_i2c_master_config_set(deviceHandle_l, &cfg) != ALT_E_SUCCESS)
{
ret = -1;
goto Exit;
}
if (alt_i2c_sda_hold_time_set(deviceHandle_l, 8) != ALT_E_SUCCESS)
{
ret = -1;
goto Exit;
}
if (alt_i2c_master_target_set(deviceHandle_l, LCD_I2C_ADDRESS) != ALT_E_SUCCESS) // Set target display I2C address
{
ret = -1;
goto Exit;
}
if (sendLcdCommand(deviceHandle_l, kLcdCmdDisplayOn, NULL) != ALT_E_SUCCESS) // Turn display on
{
ret = -1;
goto Exit;
}
if (sendLcdCommand(deviceHandle_l, kLcdCmdBlinkingCursorOn, NULL) != ALT_E_SUCCESS) // Turn cursor on
{
ret = -1;
goto Exit;
}
else
ret = 0;
}
Exit:
if (ret != 0)
{
TRACE("LCD ERR: Initialization failed!!\n");
}
}
//------------------------------------------------------------------------------
/**
\brief Exit the LCD instance
This function exits the LCD instance.
*/
//------------------------------------------------------------------------------
void lcdl_exit(void)
{
lcdl_clear();
sendLcdCommand(deviceHandle_l, kLcdCmdDisplayOff, NULL);
sendLcdCommand(deviceHandle_l, kLcdCmdBlinkingCursorOff, NULL);
alt_i2c_disable(deviceHandle_l);
alt_i2c_uninit(deviceHandle_l);
}
//------------------------------------------------------------------------------
/**
\brief Clear the LCD
This function clears all lines of the display.
*/
//------------------------------------------------------------------------------
void lcdl_clear(void)
{
// Clear screen
if (sendLcdCommand(deviceHandle_l, kLcdCmdClearScreen, NULL) != ALT_E_SUCCESS)
{
TRACE("LCD ERR: Failed to clear screen\n");
}
}
//------------------------------------------------------------------------------
/**
\brief Change to specified line
Changes to specified line of the LCD.
\param[in] line_p Specifies the line
\return The function returns 0 if the line is changed successfully, -1 otherwise.
*/
//------------------------------------------------------------------------------
int lcdl_changeToLine(unsigned int line_p)
{
uint8_t param;
if (line_p < 2)
param = LCD_POS_1ST_LINE;
else
param = LCD_POS_2ND_LINE;
if (sendLcdCommand(deviceHandle_l, kLcdCmdSetCursor, &param) != ALT_E_SUCCESS)
return -1;
else
return 0;
}
//------------------------------------------------------------------------------
/**
\brief Print text to the LCD
Writes text to the LCD currently selected.
\param[in] sText_p The text to print
*/
//------------------------------------------------------------------------------
void lcdl_printText(const char* sText_p)
{
ALT_STATUS_CODE halRet = ALT_E_SUCCESS;
size_t txtLen = strlen(sText_p);
const char padTxt = ' ';
for (size_t i = 0; i < LCDL_COLUMN; i++)
{
if (i < txtLen)
halRet = alt_i2c_master_transmit(deviceHandle_l,
&sText_p[i],
1,
ALT_E_FALSE,
ALT_E_TRUE);
else
halRet = alt_i2c_master_transmit(deviceHandle_l,
&padTxt,
1,
ALT_E_FALSE,
ALT_E_TRUE);
if (halRet != ALT_E_SUCCESS)
break;
}
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
//------------------------------------------------------------------------------
/**
\brief Send command to LCD display
The function sends a I2C command to the LCD module.
\param[in,out] deviceHdl_p I2C device
\param[in] command_p Opcode of command to be sent
\param[in] pArg_p Command parameters or NULL for no parameters
\return Returns an ALT_STATUS_CODE error code.
*/
//------------------------------------------------------------------------------
static inline ALT_STATUS_CODE sendLcdCommand(ALT_I2C_DEV_t* deviceHdl_p,
tLcdCmd command_p,
const uint8_t* pArg_p)
{
ALT_STATUS_CODE halRet = ALT_E_SUCCESS;
tLcdCmdDesc lcdCommandDesc = lcdCommands_l[(int)command_p];
uint8_t data[10];
uint8_t dataLen = 0;
data[dataLen++] = LCD_ESCAPE_CHAR;
data[dataLen++] = lcdCommandDesc.command;
for (uint8_t i = 0; i < lcdCommandDesc.padding; i++)
data[dataLen++] = pArg_p[i];
halRet = alt_i2c_master_transmit(deviceHdl_p,
data,
dataLen,
ALT_E_FALSE,
ALT_E_TRUE);
return halRet;
}
/// \}

View File

@ -0,0 +1,157 @@
/**
********************************************************************************
\file lcdl-null.c
\brief Low-level LCD null implementation
This implementation shall be used for platforms without an LCD.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
Copyright (c) 2013, SYSTEC electronic GmbH
Copyright (c) 2013, Kalycito Infotech Private Ltd.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include "lcdl.h"
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// 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 //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Initialize the low-level LCD module
This function is a stub function to initialize the low-level LCD module.
*/
//------------------------------------------------------------------------------
void lcdl_init(void)
{
}
//------------------------------------------------------------------------------
/**
\brief Shutdown the low-level LCD module
This function is a stub function to shutdown the low-level LCD module.
*/
//------------------------------------------------------------------------------
void lcdl_exit(void)
{
}
//------------------------------------------------------------------------------
/**
\brief Clear the LCD
This function is a stub function to clear all lines of the display.
*/
//------------------------------------------------------------------------------
void lcdl_clear(void)
{
}
//------------------------------------------------------------------------------
/**
\brief Change to specified line
This function is a stub function to change to a specified line of the LCD.
\param[in] line_p Specifies the line
\return The function always returns 0 to signal a successful change of line.
*/
//------------------------------------------------------------------------------
int lcdl_changeToLine(unsigned int line_p)
{
return 0;
}
//------------------------------------------------------------------------------
/**
\brief Print text to the LCD
This function is a stub function to write text to the currently selected LCD.
\param[in] sText_p The text to print
*/
//------------------------------------------------------------------------------
void lcdl_printText(const char* sText_p)
{
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
/// \}

View File

@ -0,0 +1,71 @@
/**
********************************************************************************
\file lcd-l.h
\brief Low-level interface for LCD
This is the low-level interface definition for specific LCDs.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
Copyright (c) 2013, SYSTEC electronic GmbH
Copyright (c) 2013, Kalycito Infotech Private Ltd.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
#ifndef _INC_lcdl_H_
#define _INC_lcdl_H_
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// typedef
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// function prototypes
//------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
void lcdl_init(void);
void lcdl_exit(void);
void lcdl_clear(void);
int lcdl_changeToLine(unsigned int line_p);
void lcdl_printText(const char* pText_p);
#ifdef __cplusplus
}
#endif
#endif /* _INC_lcdl_H_ */

View File

@ -0,0 +1,160 @@
/**
********************************************************************************
\file netselect.c
\brief Implementation of the network interface selection functions.
This header file provides the implementation for the network interface selection
functions used by the openPOWERLINK examples.
\ingroup module_app_common
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2017, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <oplk/oplk.h>
#include "netselect.h"
#include <stdio.h>
#include <string.h>
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P R I V A T E D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#define MAX_INTERFACES 10 // Define the max. number of interfaces shown to the user
//------------------------------------------------------------------------------
// local types
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// local vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// local function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P U B L I C F U N C T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Select network interface
With this function the network interface to be used for openPOWERLINK is selected
from a list of devices.
\param[out] pDevName_p Pointer to store the device name which
should be used.
\param[in] maxLen_p Max length of the string to store the device
name.
\return The function returns 0 if a device could be selected, otherwise -1.
*/
//------------------------------------------------------------------------------
int netselect_selectNetworkInterface(char* pDevName_p, size_t maxLen_p)
{
tNetIfId aInterfaces[MAX_INTERFACES];
size_t noInterfaces = sizeof(aInterfaces) / sizeof(aInterfaces[0]);
size_t i = 0;
unsigned int num;
if (oplk_enumerateNetworkInterfaces(aInterfaces, &noInterfaces) == kErrorOk)
{
printf("--------------------------------------------------\n");
printf("List of Ethernet cards found in this system:\n");
printf("--------------------------------------------------\n");
for (i = 0; i < noInterfaces; i++)
{
// Print adapters
printf("%u. ", (unsigned int)i + 1);
printf("%s\n %s\n", aInterfaces[i].aDeviceDescription, aInterfaces[i].aDeviceName);
}
}
else
return -1;
printf("--------------------------------------------------\n");
printf("Select the interface to be used for POWERLINK (1-%u):", (unsigned int)i);
#ifdef __XIUOS__
printf("1\n");
num = 1;
#else
if (scanf("%u", &num) == EOF)
{
return -1;
}
#endif
printf("--------------------------------------------------\n");
if ((num < 1) || (num > i))
{
printf("\nInterface number out of range.\n");
return -1;
}
// Return the selected interface name
strncpy(pDevName_p, aInterfaces[num - 1].aDeviceName, maxLen_p);
return 0;
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
/// \}

View File

@ -0,0 +1,66 @@
/**
********************************************************************************
\file netselect.h
\brief Definitions for network interface selection functions.
This header file provides the definitions for the network interface selection
functions used by the openPOWERLINK examples.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2017, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
#ifndef _INC_netselect_H_
#define _INC_netselect_H_
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// typedef
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// function prototypes
//------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
int netselect_selectNetworkInterface(char* pDevName_p, size_t maxLen_p);
#ifdef __cplusplus
}
#endif
#endif /* _INC_netselect_H_ */

View File

@ -0,0 +1,332 @@
/**
********************************************************************************
\file obdcreate/obdcreate.c
\brief Object dictionary creation
This file contains the OD data tables and the OD data structure initialization
function.
The OD data structure initialization is a very tricky part of the openPOWERLINK
stack. To create the different tables and code parts a set of macros defined in
obdmacro.h is used. These macros are redefined depending on some other
"type definition" macros. To create the different tables the specific
"type definition" macro will be set, the file objdict.h is included and therefore
the specified data structures are created. Afterwards the "type definition"
macro is unset, the next one is set and objdict.h is included again to generate
the next table.
\ingroup module_obd
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
Copyright (c) 2013, SYSTEC electronic GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include "obdcreate.h"
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
// Definitions according to the stack configuration (needed for the OD)
#define OBD_MAX_STRING_SIZE 32 // used for objects 0x1008/0x1009/0x100A
#define PLK_PRODUCT_NAME "OPLK"
#define PLK_PRODUCT_VERSION PLK_DEFINED_STRING_VERSION
// generate NMT_FeatureFlags_U32 depending on configuration values
// Set to true if this node is able to communicate synchronously
#if defined(CONFIG_INCLUDE_PDO)
#define CONFIG_FF_ISOCHR (NMT_FEATUREFLAGS_ISOCHR)
#else
#define CONFIG_FF_ISOCHR 0
#endif
// Set to true SDO via UDP is implemented
#if defined(CONFIG_INCLUDE_SDO_UDP)
#define CONFIG_FF_SDO_UDP (NMT_FEATUREFLAGS_SDO_UDP)
#else
#define CONFIG_FF_SDO_UDP 0
#endif
// Set to true SDO via ASnd is implemented
#if defined(CONFIG_INCLUDE_SDO_ASND)
#define CONFIG_FF_SDO_ASND (NMT_FEATUREFLAGS_SDO_ASND)
#else
#define CONFIG_FF_SDO_ASND 0
#endif
// Set to true if SDO/PDO is used (not implemented in the stack)
#if 0
#define CONFIG_FF_SDO_PDO (NMT_FEATUREFLAGS_SDO_PDO)
#else
#define CONFIG_FF_SDO_PDO 0
#endif
// Set to true if NMT Info Services are used (not implemented in the stack)
#if 0
#define CONFIG_FF_NMT_INFO (NMT_FEATUREFLAGS_NMT_INFO)
#else
#define CONFIG_FF_NMT_INFO 0
#endif
// Set to true if NMT Extended Commands are supported (always implemented in the stack)
#define CONFIG_FF_NMT_EXT (NMT_FEATUREFLAGS_NMT_EXT)
// Set to true if dynamic mapping is used (by default always true)
#if defined(CONFIG_INCLUDE_PDO)
#define CONFIG_FF_PDO_DYN (NMT_FEATUREFLAGS_PDO_DYN)
#else
#define CONFIG_FF_PDO_DYN 0
#endif
// Set to true if NMT Services via UDP are used (not implemented in the stack)
#if 0
#define CONFIG_FF_NMT_UDP (NMT_FEATUREFLAGS_NMT_UDP)
#else
#define CONFIG_FF_NMT_UDP 0
#endif
// Set to true if Configuration Manager is implemented on the MN
#if defined(CONFIG_INCLUDE_CFM)
#define CONFIG_FF_CFM (NMT_FEATUREFLAGS_CFM)
#else
#define CONFIG_FF_CFM 0
#endif
// Multiplexing CN is implemented (always implemented in the stack)
#define CONFIG_FF_MUX_CN (NMT_FEATUREFLAGS_MUX_CN)
// Set to true if Node ID setup by SW is used
#if 0
#define CONFIG_FF_NODEID_SW (NMT_FEATUREFLAGS_NODEID_SW)
#else
#define CONFIG_FF_NODEID_SW 0
#endif
// Set to true if Basic Ethernet mode is supported on an MN
#if 0
#define CONFIG_FF_BASIC_ETH_MN (NMT_FEATUREFLAGS_BASIC_ETH_MN)
#else
#define CONFIG_FF_BASIC_ETH_MN 0
#endif
// Set to true if Routing Type 1 is supported
#if 0
#define CONFIG_FF_RT1 (NMT_FEATUREFLAGS_RT1)
#else
#define CONFIG_FF_RT1 0
#endif
// Set to true if Routing Type 2 is supported
#if 0
#define CONFIG_FF_RT2 (NMT_FEATUREFLAGS_RT2)
#else
#define CONFIG_FF_RT2 0
#endif
// Set to true if SDO Read/Write All By Index is used (not implemented in the stack)
#if 0
#define CONFIG_FF_SDO_RW_ALL (NMT_FEATUREFLAGS_SDO_RW_ALL)
#else
#define CONFIG_FF_SDO_RW_ALL 0
#endif
// Set to true if SDO Read/Write Multiple Parameter By Index is used
#if defined(CONFIG_INCLUDE_SDO_RW_MULTIPLE)
#define CONFIG_FF_SDO_RW_MULTIPLE (NMT_FEATUREFLAGS_SDO_RW_MULTIPLE)
#else
#define CONFIG_FF_SDO_RW_MULTIPLE 0
#endif
// Set to true if Multiple ASnd (DS302-B) is implemented
#if defined(CONFIG_INCLUDE_MASND)
#define CONFIG_FF_MASND (NMT_FEATUREFLAGS_MASND)
#else
#define CONFIG_FF_MASND 0
#endif
// Set to true if Ring Redundancy Manager (DS302-A) is used (not implemented in the stack)
#if 0
#define CONFIG_FF_RR_MN (NMT_FEATUREFLAGS_RR_MN)
#else
#define CONFIG_FF_RR_MN 0
#endif
// Set to true if PResChaining on the CN (DS302-C) is used
#if defined(CONFIG_DLL_PRES_CHAINING_CN)
#define CONFIG_FF_PRC (NMT_FEATUREFLAGS_PRC)
#else
#define CONFIG_FF_PRC 0
#endif
// Set to true if Multiple PReq/PRes (DS302-D) is used (not implemented in the stack)
#if 0
#define CONFIG_FF_MULTI_PREQ_PRES (NMT_FEATUREFLAGS_MULTI_PREQ_PRES)
#else
#define CONFIG_FF_MULTI_PREQ_PRES 0
#endif
// Set to true if Dynamic Node Allocation (DS302-E) is used (not implemented in the stack)
#if 0
#define CONFIG_FF_DNA (NMT_FEATUREFLAGS_DNA)
#else
#define CONFIG_FF_DNA 0
#endif
// Set to true if a modular device (DS302-F) is created
#if defined(CONFIG_INCLUDE_MODULAR_DEVICE)
#define CONFIG_FF_MODULAR_DEVICE (NMT_FEATUREFLAGS_MODULAR_DEVICE)
#else
#define CONFIG_FF_MODULAR_DEVICE 0
#endif
#define PLK_DEF_FEATURE_FLAGS (CONFIG_FF_ISOCHR | \
CONFIG_FF_SDO_UDP | \
CONFIG_FF_SDO_ASND | \
CONFIG_FF_SDO_PDO | \
CONFIG_FF_NMT_INFO | \
CONFIG_FF_NMT_EXT | \
CONFIG_FF_PDO_DYN | \
CONFIG_FF_NMT_UDP | \
CONFIG_FF_CFM | \
CONFIG_FF_MUX_CN | \
CONFIG_FF_NODEID_SW | \
CONFIG_FF_BASIC_ETH_MN | \
CONFIG_FF_RT1 | \
CONFIG_FF_RT2 | \
CONFIG_FF_SDO_RW_ALL | \
CONFIG_FF_SDO_RW_MULTIPLE | \
CONFIG_FF_MASND | \
CONFIG_FF_RR_MN | \
CONFIG_FF_PRC | \
CONFIG_FF_MULTI_PREQ_PRES | \
CONFIG_FF_DNA | \
CONFIG_FF_MODULAR_DEVICE)
// macros to help building OD
// 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.
// For compilers not supporting a comma after last struct value, a dummy subindex
// has to be added.
#if ((DEV_SYSTEM & _DEV_COMMA_EXT_) != 0)
#define OBD_END_SUBINDEX()
#define OBD_MAX_ARRAY_SUBENTRIES 2
#else
#define OBD_END_SUBINDEX() {0, 0, 0, NULL, NULL}
#define OBD_MAX_ARRAY_SUBENTRIES 3
#endif
//------------------------------------------------------------------------------
// global variables
//------------------------------------------------------------------------------
#if !defined(DOXYGEN_PARSER) // skip section for doxygen
// creation of data in ROM memory
#define OBD_CREATE_ROM_DATA
#include "objdict.h"
#undef OBD_CREATE_ROM_DATA
// creation of data in RAM memory
#define OBD_CREATE_RAM_DATA
#include "objdict.h"
#undef OBD_CREATE_RAM_DATA
// creation of subindex tables in ROM and RAM
#define OBD_CREATE_SUBINDEX_TAB
#include "objdict.h"
#undef OBD_CREATE_SUBINDEX_TAB
// creation of index tables for generic, manufacturer and device part
#define OBD_CREATE_INDEX_TAB
#include "objdict.h"
#undef OBD_CREATE_INDEX_TAB
#endif
//------------------------------------------------------------------------------
/**
\brief Initialize OD data structures
The function initializes the object dictionary data structures.
\param[out] pInitParam_p Pointer to OD initialization parameters.
\return The function returns a tOplkError error code.
\ingroup module_obd
*/
//------------------------------------------------------------------------------
tOplkError obdcreate_initObd(tObdInitParam* pInitParam_p)
{
// Doxygen is confused by the inclusion of objdict.h in this function, therefore
// we exclude the function body from parsing by doxygen!
#if !defined(DOXYGEN_PARSER)
tObdInitParam* pInitParam = pInitParam_p; // pInitParam is required by obdmacro.h
// 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 to NULL)
memset(pInitParam, 0, sizeof(tObdInitParam));
#define OBD_CREATE_INIT_FUNCTION
{
// inserts code to init pointer to index tables
#include "objdict.h"
}
#undef OBD_CREATE_INIT_FUNCTION
#if (defined(OBD_USER_OD) && (OBD_USER_OD != FALSE))
{
// at the beginning no user OD is defined
pInitParam->pUserPart = NULL;
}
#endif
}
#define OBD_CREATE_INIT_SUBINDEX
{
// inserts code to copy subindex tables
#include "objdict.h"
}
#undef OBD_CREATE_INIT_SUBINDEX
#endif // !defined(DOXYGEN_PARSER)
return kErrorOk;
}

View File

@ -0,0 +1,68 @@
/**
********************************************************************************
\file obdcreate/obdcreate.h
\brief Object dictionary creation
This file contains the definitions for the creation of a static object
dictionary.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
Copyright (c) 2013, SYSTEC electronic GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
#ifndef _INC_obdcreate_obdcreate_H_
#define _INC_obdcreate_obdcreate_H_
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <oplk/oplk.h>
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// typedef
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// function prototypes
//------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
tOplkError obdcreate_initObd(tObdInitParam* pInitParam_p);
#ifdef __cplusplus
}
#endif
#endif /* _INC_obdcreate_obdcreate_H_ */

View File

@ -0,0 +1,645 @@
/**
********************************************************************************
\file obdcreate/obdmacro.h
\brief Macros for OD creation
This file contains the macros for the creation of the OD data structure tables and
initialization code. The macros will be used in the OD creation module
obdcreate.c. The object dictionaries in the directory objdicts are defined by
these macros.
For further information on a POWERLINK object dictionary (OD) refer to
\ref sect_powerlink_od
### Access Rights
Combinations of \ref sect_obdAccessRights "access rights" are possible. Some of
these access rights are automatically set by the macros. Which objects contain
which access rights depends on the applied device profile or on the application.
Macro | Automatically assigned rights
--------------------------------|------------------------------
OBD_SUBINDEX_RAM_VAR | None
OBD_SUBINDEX_RAM_VAR_RG | kObdAccRange
OBD_SUBINDEX_RAM_VSTRING | None
OBD_SUBINDEX_RAM_OSTRING | None
OBD_SUBINDEX_RAM_DOMAIN | kObdAccVar
OBD_SUBINDEX_RAM_USERDEF | kObdAccVar
OBD_SUBINDEX_RAM_USERDEF_RG | kObdAccVar \| kObdAccRange
For readable and writable objects (kObdAccRead and kObdAccWrite) there is always
a value available in ROM, which contains the default value, as well as a current
value in RAM. The default value is copied to the current value in the NMT states
kNmtGsResetApplication or kNmtGsResetCommunication and on the command to restore
the default parameters (object 0x1011, NMT_RestoreDefParam_REC). The current value
can be written and read for both SDO accesses or from the application.
Read-only objects created with macro OBD_SUBINDEX_RAM_... but without kEplObdAccWrite
cannot be written per SDO. However, the application can modify its object data by
calling the function oplk_writeLocalObject(). Therefore, a value is created in
ROM as well as in RAM.
\ingroup module_obd
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
Copyright (c) 2013, SYSTEC electronic GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
// This header file must be included multiple times, therefore no single
// inclusion macro is used!
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#if defined(OBD_DEFINE_MACRO)
#if defined(OBD_CREATE_ROM_DATA)
//------------------------------------------------------------------------------
// Macros for generating the ROM tables of the OD are used now
//------------------------------------------------------------------------------
// generic macros
#define OBD_BEGIN() static const UINT32 obd_OBK_g = 0x0000;
#define OBD_END()
// partition macros
#define OBD_BEGIN_PART_GENERIC()
#define OBD_BEGIN_PART_MANUFACTURER()
#define OBD_BEGIN_PART_DEVICE()
#define OBD_END_PART()
// index macros
#define OBD_BEGIN_INDEX_RAM(ind, cnt, evnt)
#define OBD_END_INDEX(ind)
#define OBD_RAM_INDEX_RAM_ARRAY(ind, cnt, evnt, typ, acc, dtyp, name, def) static const tObdUnsigned8 xDef##ind##_0x00_g = (cnt); \
static const dtyp xDef##ind##_0x01_g = (def);
#define OBD_RAM_INDEX_RAM_ARRAY_ALT(ind, cnt, evnt, typ, acc, dtyp, name, def) static const tObdUnsigned8 xDef##ind##_0x00_g = (cnt); \
static const dtyp xDef##ind##_0x01_g = (def);
#define OBD_RAM_INDEX_RAM_VARARRAY(ind, cnt, evnt, typ, acc, dtyp, name, def) static const tObdUnsigned8 xDef##ind##_0x00_g = (cnt); \
static const dtyp xDef##ind##_0x01_g = (def);
#define OBD_RAM_INDEX_RAM_VARARRAY_NOINIT(ind, cnt, evnt, typ, acc, dtyp, name) static const tObdUnsigned8 xDef##ind##_0x00_g = (cnt);
#define OBD_RAM_INDEX_RAM_PDO_MAPPING(ind, cnt, evnt, acc, name, def) static const tObdUnsigned8 xDef##ind##_0x00_g = 0; \
static const tObdUnsigned64 xDef##ind##_0x01_g = (def);
// subindex macros
#define OBD_SUBINDEX_RAM_VAR(ind, sub, typ, acc, dtyp, name, val) static const dtyp xDef##ind##_##sub##_g = val;
#define OBD_SUBINDEX_RAM_VAR_RG(ind, sub, typ, acc, dtyp, name, val, low, high) static const dtyp xDef##ind##_##sub##_g[3] = {val, low, high};
#define OBD_SUBINDEX_RAM_VAR_NOINIT(ind, sub, typ, acc, dtyp, name)
#define OBD_SUBINDEX_RAM_VSTRING(ind, sub, acc, name, size, val) static char szCur##ind##_##sub##_g[size + 1]; \
static const tObdVStringDef xDef##ind##_##sub##_g = {size, val, szCur##ind##_##sub##_g};
#define OBD_SUBINDEX_RAM_OSTRING(ind, sub, acc, name, size) static BYTE bCur##ind##_##sub##_g[size]; \
static const tObdOStringDef xDef##ind##_##sub##_g = {size, ((BYTE*)""), bCur##ind##_##sub##_g};
#define OBD_SUBINDEX_RAM_DOMAIN(ind, sub, acc, name)
#define OBD_SUBINDEX_RAM_USERDEF(ind, sub, typ, acc, dtyp, name, val) static const dtyp xDef##ind##_##sub##_g = val;
#define OBD_SUBINDEX_RAM_USERDEF_RG(ind, sub, typ, acc, dtyp, name, val, low, high) static const dtyp xDef##ind##_##sub##_g[3] = {val, low, high};
#define OBD_SUBINDEX_RAM_USERDEF_NOINIT(ind, sub, typ, acc, dtyp, name)
#elif defined(OBD_CREATE_RAM_DATA)
//------------------------------------------------------------------------------
// Macros for generating the RAM tables of the OD are used now
//------------------------------------------------------------------------------
// generic macros
#define OBD_BEGIN()
#define OBD_END()
// partition macros
#define OBD_BEGIN_PART_GENERIC()
#define OBD_BEGIN_PART_MANUFACTURER()
#define OBD_BEGIN_PART_DEVICE()
#define OBD_END_PART()
// index macros
#define OBD_BEGIN_INDEX_RAM(ind, cnt, evnt)
#define OBD_END_INDEX(ind)
#define OBD_RAM_INDEX_RAM_ARRAY(ind, cnt, evnt, typ, acc, dtyp, name, def) static dtyp axCur##ind##_g[cnt];
#define OBD_RAM_INDEX_RAM_ARRAY_ALT(ind, cnt, evnt, typ, acc, dtyp, name, def) static tObdUnsigned8 xCur##ind##_0x00_g; \
static dtyp axCur##ind##_g[cnt];
#define OBD_RAM_INDEX_RAM_VARARRAY(ind, cnt, evnt, typ, acc, dtyp, name, def) static tObdVarEntry aVarEntry##ind##_g[cnt];
#define OBD_RAM_INDEX_RAM_VARARRAY_NOINIT(ind, cnt, evnt, typ, acc, dtyp, name) static tObdVarEntry aVarEntry##ind##_g[cnt];
#define OBD_RAM_INDEX_RAM_PDO_MAPPING(ind, cnt, evnt, acc, name, def) static tObdUnsigned8 xCur##ind##_0x00_g; \
static tObdUnsigned64 axCur##ind##_g[cnt];
// subindex macros
#define OBD_SUBINDEX_RAM_VAR(ind, sub, typ, acc, dtyp, name, val) static dtyp xCur##ind##_##sub##_g;
#define OBD_SUBINDEX_RAM_VAR_RG(ind, sub, typ, acc, dtyp, name, val, low, high) static dtyp xCur##ind##_##sub##_g;
#define OBD_SUBINDEX_RAM_VSTRING(ind, sub, acc, name, size, val) static tObdVString xCur##ind##_##sub##_g;
#define OBD_SUBINDEX_RAM_OSTRING(ind, sub, acc, name, size) static tObdOString xCur##ind##_##sub##_g;
#define OBD_SUBINDEX_RAM_VAR_NOINIT(ind, sub, typ, acc, dtyp, name) static dtyp xCur##ind##_##sub##_g;
#define OBD_SUBINDEX_RAM_DOMAIN(ind, sub, acc, name) static tObdVarEntry VarEntry##ind##_##sub##_g;
#define OBD_SUBINDEX_RAM_USERDEF(ind, sub, typ, acc, dtyp, name, val) static tObdVarEntry VarEntry##ind##_##sub##_g;
#define OBD_SUBINDEX_RAM_USERDEF_RG(ind, sub, typ, acc, dtyp, name, val, low, high) static tObdVarEntry VarEntry##ind##_##sub##_g;
#define OBD_SUBINDEX_RAM_USERDEF_NOINIT(ind, sub, typ, acc, dtyp, name) static tObdVarEntry VarEntry##ind##_##sub##_g;
#elif defined(OBD_CREATE_SUBINDEX_TAB)
//------------------------------------------------------------------------------
// Macros for generating the sub-index tables of the OD are used now
//------------------------------------------------------------------------------
// generic macros
#define OBD_BEGIN()
#define OBD_END()
// partition macros
#define OBD_BEGIN_PART_GENERIC()
#define OBD_BEGIN_PART_MANUFACTURER()
#define OBD_BEGIN_PART_DEVICE()
#define OBD_END_PART()
// index macros
#define OBD_BEGIN_INDEX_RAM(ind, cnt, evnt) static tObdSubEntry aObdSubEntry##ind##Ram_g[cnt]= {
#define OBD_END_INDEX(ind) OBD_END_SUBINDEX()};
#define OBD_RAM_INDEX_RAM_ARRAY(ind, cnt, evnt, typ, acc, dtyp, name, def) static tObdSubEntry aObdSubEntry##ind##Ram_g[]= { \
{0, kObdTypeUInt8, kObdAccCR, &xDef##ind##_0x00_g, NULL}, \
{1, typ, (acc) | kObdAccArray, &xDef##ind##_0x01_g, &axCur##ind##_g[0]}, \
OBD_END_SUBINDEX()};
#define OBD_RAM_INDEX_RAM_ARRAY_ALT(ind, cnt, evnt, typ, acc, dtyp, name, def) static tObdSubEntry aObdSubEntry##ind##Ram_g[]= { \
{0, kObdTypeUInt8, (acc), &xDef##ind##_0x00_g, &xCur##ind##_0x00_g}, \
{1, typ, (acc) | kObdAccArray, &xDef##ind##_0x01_g, &axCur##ind##_g[0]}, \
OBD_END_SUBINDEX()};
#define OBD_RAM_INDEX_RAM_VARARRAY(ind, cnt, evnt, typ, acc, dtyp, name, def) static tObdSubEntry aObdSubEntry##ind##Ram_g[]= { \
{0, kObdTypeUInt8, kObdAccCR, &xDef##ind##_0x00_g, NULL}, \
{1, typ, (acc) | kObdAccArray | kObdAccVar, &xDef##ind##_0x01_g, &aVarEntry##ind##_g[0]}, \
OBD_END_SUBINDEX()};
#define OBD_RAM_INDEX_RAM_VARARRAY_NOINIT(ind, cnt, evnt, typ, acc, dtyp, name) static tObdSubEntry aObdSubEntry##ind##Ram_g[]= { \
{0, kObdTypeUInt8, kObdAccCR, &xDef##ind##_0x00_g, NULL}, \
{1, typ, (acc) | kObdAccArray | kObdAccVar, NULL, &aVarEntry##ind##_g[0]}, \
OBD_END_SUBINDEX()};
#define OBD_RAM_INDEX_RAM_PDO_MAPPING(ind, cnt, evnt, acc, name, def) static tObdSubEntry aObdSubEntry##ind##Ram_g[]= { \
{0, kObdTypeUInt8, (acc), &xDef##ind##_0x00_g, &xCur##ind##_0x00_g}, \
{1, kObdTypeUInt64, (acc) | kObdAccArray, &xDef##ind##_0x01_g, &axCur##ind##_g[0]}, \
OBD_END_SUBINDEX()};
// subindex macros
#define OBD_SUBINDEX_RAM_VAR(ind, sub, typ, acc, dtyp, name, val) {sub, typ, (acc), &xDef##ind##_##sub##_g, &xCur##ind##_##sub##_g},
#define OBD_SUBINDEX_RAM_VAR_RG(ind, sub, typ, acc, dtyp, name, val, low, high) {sub, typ, (acc) | kObdAccRange, &xDef##ind##_##sub##_g[0], &xCur##ind##_##sub##_g},
#define OBD_SUBINDEX_RAM_VAR_NOINIT(ind, sub, typ, acc, dtyp, name) {sub, typ, (acc), NULL, &xCur##ind##_##sub##_g},
#define OBD_SUBINDEX_RAM_VSTRING(ind, sub, acc, name, size, val) {sub, kObdTypeVString, (acc)/* | kObdAccVar*/, &xDef##ind##_##sub##_g, &xCur##ind##_##sub##_g},
#define OBD_SUBINDEX_RAM_OSTRING(ind, sub, acc, name, size) {sub, kObdTypeOString, (acc)/* | kObdAccVar*/, &xDef##ind##_##sub##_g, &xCur##ind##_##sub##_g},
#define OBD_SUBINDEX_RAM_DOMAIN(ind, sub, acc, name) {sub, kObdTypeDomain, (acc) | kObdAccVar, NULL, &VarEntry##ind##_##sub##_g},
#define OBD_SUBINDEX_RAM_USERDEF(ind, sub, typ, acc, dtyp, name, val) {sub, typ, (acc) | kObdAccVar, &xDef##ind##_##sub##_g, &VarEntry##ind##_##sub##_g},
#define OBD_SUBINDEX_RAM_USERDEF_RG(ind, sub, typ, acc, dtyp, name, val, low, high) {sub, typ, (acc) | kObdAccVar | kObdAccRange, &xDef##ind##_##sub##_g[0], &VarEntry##ind##_##sub##_g},
#define OBD_SUBINDEX_RAM_USERDEF_NOINIT(ind, sub, typ, acc, dtyp, name) {sub, typ, (acc) | kObdAccVar, NULL, &VarEntry##ind##_##sub##_g},
#elif defined(OBD_CREATE_INDEX_TAB)
//------------------------------------------------------------------------------
// Macros for generating the index tables of the OD are used now
//------------------------------------------------------------------------------
// generic macros
#define OBD_BEGIN()
#define OBD_END()
// partition macros
#define OBD_BEGIN_PART_GENERIC() static tObdEntry aObdTabGeneric_g[] = {
#define OBD_BEGIN_PART_MANUFACTURER() static tObdEntry aObdTabManufacturer_g[] = {
#define OBD_BEGIN_PART_DEVICE() static tObdEntry aObdTabDevice_g[] = {
#define OBD_END_PART() {OBD_TABLE_INDEX_END, (tObdSubEntry*)(void*)&obd_OBK_g, 0, FALSE}};
// index macros
#define OBD_BEGIN_INDEX_RAM(ind, cnt, evnt) {ind, (tObdSubEntry*)&aObdSubEntry##ind##Ram_g[0], cnt, evnt},
#define OBD_END_INDEX(ind)
#define OBD_RAM_INDEX_RAM_ARRAY(ind, cnt, evnt, typ, acc, dtyp, name, def) {ind, (tObdSubEntry*)&aObdSubEntry##ind##Ram_g[0], (cnt)+1, evnt},
#define OBD_RAM_INDEX_RAM_ARRAY_ALT(ind, cnt, evnt, typ, acc, dtyp, name, def) {ind, (tObdSubEntry*)&aObdSubEntry##ind##Ram_g[0], (cnt)+1, evnt},
#define OBD_RAM_INDEX_RAM_VARARRAY(ind, cnt, evnt, typ, acc, dtyp, name, def) {ind, (tObdSubEntry*)&aObdSubEntry##ind##Ram_g[0], (cnt)+1, evnt},
#define OBD_RAM_INDEX_RAM_VARARRAY_NOINIT(ind, cnt, evnt, typ, acc, dtyp, name) {ind, (tObdSubEntry*)&aObdSubEntry##ind##Ram_g[0], (cnt)+1, evnt},
#define OBD_RAM_INDEX_RAM_PDO_MAPPING(ind, cnt, evnt, acc, name, def) {ind, (tObdSubEntry*)&aObdSubEntry##ind##Ram_g[0], (cnt)+1, evnt},
// subindex macros
#define OBD_SUBINDEX_RAM_VAR(ind, sub, typ, acc, dtyp, name, val)
#define OBD_SUBINDEX_RAM_VAR_RG(ind, sub, typ, acc, dtyp, name, val, low, high)
#define OBD_SUBINDEX_RAM_VSTRING(ind, sub, acc, name, size, val)
#define OBD_SUBINDEX_RAM_OSTRING(ind, sub, acc, name, size)
#define OBD_SUBINDEX_RAM_VAR_NOINIT(ind, sub, typ, acc, dtyp, name)
#define OBD_SUBINDEX_RAM_DOMAIN(ind, sub, acc, name)
#define OBD_SUBINDEX_RAM_USERDEF(ind, sub, typ, acc, dtyp, name, val)
#define OBD_SUBINDEX_RAM_USERDEF_RG(ind, sub, typ, acc, dtyp, name, val, low, high)
#define OBD_SUBINDEX_RAM_USERDEF_NOINIT(ind, sub, typ, acc, dtyp, name)
#elif defined(OBD_CREATE_INIT_FUNCTION)
//------------------------------------------------------------------------------
// Macros for generating the initialization functions are used now
//------------------------------------------------------------------------------
// generic macros
#define OBD_BEGIN()
#define OBD_END()
// partition macros
#define OBD_BEGIN_PART_GENERIC() pInitParam->pGenericPart = (tObdEntry*)&aObdTabGeneric_g[0];
#define OBD_BEGIN_PART_MANUFACTURER() pInitParam->pManufacturerPart = (tObdEntry*)&aObdTabManufacturer_g[0];
#define OBD_BEGIN_PART_DEVICE() pInitParam->pDevicePart = (tObdEntry*)&aObdTabDevice_g[0];
#define OBD_END_PART()
// index macros
#define OBD_BEGIN_INDEX_RAM(ind, cnt, evnt)
#define OBD_END_INDEX(ind)
#define OBD_RAM_INDEX_RAM_ARRAY(ind, cnt, evnt, typ, acc, dtyp, name, def)
#define OBD_RAM_INDEX_RAM_ARRAY_ALT(ind, cnt, evnt, typ, acc, dtyp, name, def)
#define OBD_RAM_INDEX_RAM_VARARRAY(ind, cnt, evnt, typ, acc, dtyp, name, def)
#define OBD_RAM_INDEX_RAM_VARARRAY_NOINIT(ind, cnt, evnt, typ, acc, dtyp, name)
#define OBD_RAM_INDEX_RAM_PDO_MAPPING(ind, cnt, evnt, acc, name, def)
// subindex macros
#define OBD_SUBINDEX_RAM_VAR(ind, sub, typ, acc, dtyp, name, val)
#define OBD_SUBINDEX_RAM_VAR_RG(ind, sub, typ, acc, dtyp, name, val, low, high)
#define OBD_SUBINDEX_RAM_VSTRING(ind, sub, acc, name, size, val)
#define OBD_SUBINDEX_RAM_OSTRING(ind, sub, acc, name, size)
#define OBD_SUBINDEX_RAM_VAR_NOINIT(ind, sub, typ, acc, dtyp, name)
#define OBD_SUBINDEX_RAM_DOMAIN(ind, sub, acc, name)
#define OBD_SUBINDEX_RAM_USERDEF(ind, sub, typ, acc, dtyp, name, val)
#define OBD_SUBINDEX_RAM_USERDEF_RG(ind, sub, typ, acc, dtyp, name, val, low, high)
#define OBD_SUBINDEX_RAM_USERDEF_NOINIT(ind, sub, typ, acc, dtyp, name)
#else
//------------------------------------------------------------------------------
// Nothing specified macros are empty
//------------------------------------------------------------------------------
///\{
/**
********************************************************************************
\name OD Section Limiters
The Object Dictionary is always introduced with the macro OBD_BEGIN.
OBD_END ends the definition of the Object Dictionary. No other macros can be
used for the Object Dictionary outside of the boundary set by OBD_BEGIN and
OBD_END.
*/
#define OBD_BEGIN() ///< Begin of an OD definition section
#define OBD_END() ///< End of an OD definition section
///\}
///\{
/**
********************************************************************************
\name OD Partition Limiters
These macros are always positioned between the macros OBD_BEGIN and OBD_END and
introduce a partition of the Object Dictionary. The "GENERIC" range is always
utilized for the index range 0x1000 to 0x1FFF, the "MANUFACTURER" section
is used for 0x2000 to 0x5FFF and the "DEVICE" section for index range 0x6000 to
0x9FFF. Each of these macros must be used a single time (and only a single time!)
within an Object Dictionary. The applicable range or partial section is always
closed with the macro OBD_END_PART.
*/
#define OBD_BEGIN_PART_GENERIC() ///< Begin of generic partition
#define OBD_BEGIN_PART_MANUFACTURER() ///< Begin of manufacturer partition
#define OBD_BEGIN_PART_DEVICE() ///< Begin of device partition
#define OBD_END_PART() ///< End of partition
///\}
///\{
/**
********************************************************************************
\name OD Index Definitions
These macros are found within a partition of the Object Dictionary. They are
located within the range between the macros OBD_BEGIN_PART_... and OBD_END_PART.
They must be ordered with ascending object index. These macros define an index
entry in the Object Dictionary. An index entry is therefore always introduced
with the macro OBD_BEGIN_INDEX_... and ended with OBD_END_INDEX. The suffix
..._RAM indicates that the sub index table is located in RAM.
*/
/**
\brief Begin of index entry
\param ind Object index of the entry to be defined
\param cnt Number of sub-indices within this index entry
\param evnt Flag indicating that an object access shall trigger
a user event. If this flag is set to TRUE, a user event
is created that allows the user to react on the object access.
The trigger is always called if an object has been read
or written. It doesnt matter if the access comes from the
application or via SDO.
*/
#define OBD_BEGIN_INDEX_RAM(ind, cnt, evnt)
/**
\brief Begin of array index entry
This macro simplifies the definition of arrays. It can replace the OBD_BEGIN_INDEX_...,
OBD_END_INDEX and OBD_SUBINDEX_... macros. The macro reduces the allocation of
const memory, because of less sub-index table entries. The drawback is that it
needs a little more RAM.
\param ind Object index of the entry to be defined
\param cnt Number of sub-indices within this index entry
\param evnt Flag for enabling the user event for this index entry
\param typ Coded Object type (see \ref tObdType)
\param acc Access rights for object (see \ref sect_obdAccessRights "access rights")
\param dtyp C Data type definition used for this object
\param name Name of object
\param def Default value of object
*/
#define OBD_RAM_INDEX_RAM_ARRAY(ind, cnt, evnt, typ, acc, dtyp, name, def)
/**
\brief Begin of array index entry with writable subindex 0
This macro simplifies the definition of arrays. It can replace the OBD_BEGIN_INDEX_...,
OBD_END_INDEX and OBD_SUBINDEX_... macros. The macro reduces the allocation of
const memory, because of less sub-index table entries. The drawback is that it
needs a little more RAM. For objects created with this macro the array size could
be modified (sub-index 0 is writable).
\param ind Object index of the entry to be defined
\param cnt Number of sub-indices whithin this index entry
\param evnt Flag for enabling the user event for this index entry
\param typ Coded Object type (see \ref tObdType)
\param acc Access rights for object (see \ref sect_obdAccessRights "access rights")
\param dtyp C Data type definition used for this object
\param name Name of object
\param def Default value of object
*/
#define OBD_RAM_INDEX_RAM_ARRAY_ALT(ind, cnt, evnt, typ, acc, dtyp, name, def)
/**
\brief Begin of var-array index entry
Same as \ref OBD_RAM_INDEX_RAM_ARRAY but it contains a tVarEntry information structure
like it was defined by the \ref OBD_SUBINDEX_RAM_DOMAIN macro so it must be linked to
a variable by oplk_linkObject().
\param ind Object index of the entry to be defined
\param cnt Number of sub-indices whithin this index entry
\param evnt Flag for enabling the user event for this index entry.
\param typ Coded Object type (see \ref tObdType)
\param acc Access rights for object (see \ref sect_obdAccessRights "access rights")
\param dtyp C Data type definition used for this object
\param name Name of object
\param def Default value of object
*/
#define OBD_RAM_INDEX_RAM_VARARRAY(ind, cnt, evnt, typ, acc, dtyp, name, def)
/**
\brief Begin of var-array index entry without initialization
Same as \ref OBD_RAM_INDEX_RAM_VARARRAY but it isn't initialized with a default
value.
\param ind Object index of the entry to be defined
\param cnt Number of sub-indices whithin this index entry
\param evnt Flag for enabling the user event for this index entry
\param typ Coded Object type (see \ref tObdType)
\param acc Access rights for object (see \ref sect_obdAccessRights "access rights")
\param dtyp C Data type definition used for this object
\param name Name of object
*/
#define OBD_RAM_INDEX_RAM_VARARRAY_NOINIT(ind, cnt, evnt, typ, acc, dtyp, name)
/**
\brief Begin of PDO mapped variable
This macro generates an entry for a PDO mapping object.
\param ind Object index of the entry to be defined
\param cnt Number of sub-indices whithin this index entry
\param evnt Flag for enabling the user event for this index entry
\param acc Access rights for object (see \ref sect_obdAccessRights "access rights")
\param name Name of object
\param def Default value of object
*/
#define OBD_RAM_INDEX_RAM_PDO_MAPPING(ind, cnt, evnt, acc, name, def)
#define OBD_END_INDEX(ind) ///< End of index entry
///\}
///\{
/**
********************************************************************************
\name OD Sub-index Entry Definitions
The sub-indexes are now defined within an index entry. They are always located
within the range between the macros OBD_BEGIN_INDEX_... and OBD_END_INDEX and
must be ordered with ascending sub-index. Since there are various object types
and therefore various data types that have to be created, there are different
macros as well.
The macros ..._DOMAIN, ..._USERDEF and ..._USERDEF_RG define a variable
information structure of type tVarEntry in the RAM along with the sub-index entry.
This structure contains the data length and a pointer to the data. Upon initialization
of the openPOWERLINK stack with the function oplk_create() all variable information is
deleted. The application has to link these objects to its own variables by calling
the function oplk_linkObject().
*/
/**
\brief Definition of a variable
This macro defines an object for variables that have a defined data length, which
is determined by the object type (e.g. UNSIGNED8, UNSIGNED16, INTEGER8, etc.).
These objects cannot be mapped to a PDO!
\param ind Object index of the entry to be defined
\param sub Sub-index of the entry to be defined
\param typ Coded Object type (see \ref tObdType)
\param acc Access rights for object (see \ref sect_obdAccessRights "access rights")
\param dtyp C Data type definition used for this object
\param name Name of object
\param val Default value of this sub-index entry
*/
#define OBD_SUBINDEX_RAM_VAR(ind, sub, typ, acc, dtyp, name, val)
/**
\brief Definition of a variable with range check
Same as \ref OBD_SUBINDEX_RAM_VAR but with a range check for minimum and
maximum values. If CONFIG_OBD_CHECK_OBJECT_RANGE is set to TRUE, the openPOWERLINK
stack automatically checks the value range before an object is written to
(from the application or per SDO).
\param ind Object index of the entry to be defined
\param sub Sub-index of the entry to be defined
\param typ Coded Object type (see \ref tObdType)
\param acc Access rights for object (see \ref sect_obdAccessRights "access rights")
\param dtyp C Data type definition used for this object
\param name Name of object
\param val Default value of this sub-index entry
\param low Lower limit of valid range
\param high Higher limit of valid range
*/
#define OBD_SUBINDEX_RAM_VAR_RG(ind, sub, typ, acc, dtyp, name, val, low, high)
/**
\brief Definition of a VSTRING variable
This macro defines an object for variables of type VSTRING.
\param ind Object index of the entry to be defined
\param sub Sub-index of the entry to be defined
\param acc Access rights for object (see \ref sect_obdAccessRights "access rights")
\param name Name of object
\param size Maximum length of the string in RAM (incl. \0 termination)
\param val Default value of this sub-index entry
*/
#define OBD_SUBINDEX_RAM_VSTRING(ind, sub, acc, name, size, val)
/**
\brief Definition of an OSTRING variable
This macro defines an object for variables of type OSTRING.
\param ind Object index of the entry to be defined
\param sub Sub-index of the entry to be defined
\param acc Access rights for object (see \ref sect_obdAccessRights "access rights")
\param name Name of object
\param size Maximum length of the string in RAM (incl. \0 termination)
*/
#define OBD_SUBINDEX_RAM_OSTRING(ind, sub, acc, name, size)
/**
Definition of a variable which isn't initialized
The suffix ..._NOINIT defines objects which have no default value. That means the
openPOWERLINK stack does not initialize those variables with a default value on
NMT reset events. It is the responsibility of the application to initialize those
objects.
\param ind Object index of the entry to be defined
\param sub Sub-index of the entry to be defined
\param typ Coded Object type (see \ref tObdType)
\param acc Access rights for object (see \ref sect_obdAccessRights "access rights")
\param dtyp C Data type definition used for this object
\param name Name of object
*/
#define OBD_SUBINDEX_RAM_VAR_NOINIT(ind, sub, typ, acc, dtyp, name)
/**
\brief Definition of a DOMAIN variable
This macro defines an object for variables of type DOMAIN.
\param ind Object index of the entry to be defined
\param sub Sub-index of the entry to be defined
\param acc Access rights for object (see \ref sect_obdAccessRights "access rights")
\param name Name of object
*/
#define OBD_SUBINDEX_RAM_DOMAIN(ind, sub, acc, name)
/**
\brief Definition of a variable with user-specific type
Objects, which the user wants to manage in his application, can be created with
this _USERDEF macro. Only these objects can be mapped to a PDO as process variables.
\param ind Object index of the entry to be defined
\param sub Sub-index of the entry to be defined
\param typ Coded Object type (see \ref tObdType)
\param acc Access rights for object (see \ref sect_obdAccessRights "access rights")
\param dtyp C Data type definition used for this object
\param name Name of object
\param val Default value of this sub-index entry
*/
#define OBD_SUBINDEX_RAM_USERDEF(ind, sub, typ, acc, dtyp, name, val)
/**
\brief Definition of a variable with user-specific type and range check
Same as \ref OBD_SUBINDEX_RAM_USERDEF but with a range check for minimum and
maximum values. If CONFIG_OBD_CHECK_OBJECT_RANGE is set to TRUE, the openPOWERLINK
stack automatically checks the value range before an object is written to
(from the application or per SDO).
\param ind Object index of the entry to be defined
\param sub Sub-index of the entry to be defined
\param typ Coded Object type (see \ref tObdType)
\param acc Access rights for object (see \ref sect_obdAccessRights "access rights")
\param dtyp C Data type definition used for this object
\param name Name of object
\param val Default value of this sub-index entry
\param low Lower limit of valid range
\param high Higher limit of valid range
*/
#define OBD_SUBINDEX_RAM_USERDEF_RG(ind, sub, typ, acc, dtyp, name, val, low, high)
/**
\brief Definition of a variable with user-specific type that isn't initialized
The suffix ..._NOINIT defines objects which have no default value. That means the
openPOWERLINK stack does not initialize those variables with a default value on
NMT reset events. It is the responsibility of the application to initialize those
objects.
\param ind Object index of the entry to be defined
\param sub Sub-index of the entry to be defined
\param typ Coded Object type (see \ref tObdType)
\param acc Access rights for object (see \ref sect_obdAccessRights "access rights")
\param dtyp C Data type definition used for this object
\param name Name of object
*/
#define OBD_SUBINDEX_RAM_USERDEF_NOINIT(ind, sub, typ, acc, dtyp, name)
///\}
#endif
#elif defined(OBD_UNDEFINE_MACRO)
//------------------------------------------------------------------------------
// Undefine the macros now
//------------------------------------------------------------------------------
// generic macros
#undef OBD_BEGIN
#undef OBD_END
// partition macros
#undef OBD_BEGIN_PART_GENERIC
#undef OBD_BEGIN_PART_MANUFACTURER
#undef OBD_BEGIN_PART_DEVICE
#undef OBD_END_PART
// index macros
#undef OBD_BEGIN_INDEX_RAM
#undef OBD_END_INDEX
#undef OBD_RAM_INDEX_RAM_ARRAY
#undef OBD_RAM_INDEX_RAM_ARRAY_ALT
#undef OBD_RAM_INDEX_RAM_VARARRAY
#undef OBD_RAM_INDEX_RAM_VARARRAY_NOINIT
#undef OBD_RAM_INDEX_RAM_PDO_MAPPING
// subindex macros
#undef OBD_SUBINDEX_RAM_VAR
#undef OBD_SUBINDEX_RAM_VAR_RG
#undef OBD_SUBINDEX_RAM_VSTRING
#undef OBD_SUBINDEX_RAM_OSTRING
#undef OBD_SUBINDEX_RAM_VAR_NOINIT
#undef OBD_SUBINDEX_RAM_DOMAIN
#undef OBD_SUBINDEX_RAM_USERDEF
#undef OBD_SUBINDEX_RAM_USERDEF_RG
#undef OBD_SUBINDEX_RAM_USERDEF_NOINIT
#else
#error "Please define the type of initialization before including this file!"
#endif

View File

@ -0,0 +1,477 @@
/**
********************************************************************************
\file system-c5socarm.c
\brief System specific functions for Altera Cyclone-V ARM
The file implements the system specific functions for ARM on Altera Cyclone-V
used by the openPOWERLINK demo applications.
\ingroup module_app_common
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
Copyright (c) 2015, Kalycito Infotech Private Ltd.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <sys/unistd.h>
#include <alt_timers.h>
#include <alt_globaltmr.h>
#include <alt_interrupt.h>
#include <alt_cache.h>
#include <alt_fpga_manager.h>
#include <alt_bridge_manager.h>
#include <alt_address_space.h>
#include <alt_mpu_registers.h>
#include <alt_clock_manager.h>
#include <system.h>
#include <oplk/oplk.h>
#include <trace/trace.h>
#include <system/system.h>
#include <sleep.h>
#if defined(CONFIG_USE_SYNCTHREAD)
#error "Sync thread is not supported on this target!"
#endif
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// 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 int initializeFpga(void);
static int initializeTimer(void);
static int cleanupTimer(void);
#if defined(CONFIG_BOOT_FROM_SD)
static int initializeDriver(void);
#endif
//============================================================================//
// P U B L I C F U N C T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Initialize system
The function initializes important stuff on the system for openPOWERLINK to
work correctly.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
int system_init(void)
{
tOplkError oplkRet = kErrorOk;
if (initializeTimer() != 0)
{
TRACE("General purpose timer module initialization failed!!\n");
oplkRet = kErrorGeneralError;
goto Exit;
}
// Initialize the HPS to FPGA bridges alone and not initializeFpga()
if (alt_bridge_init(ALT_BRIDGE_LWH2F, NULL, NULL) != ALT_E_SUCCESS)
{
oplkRet = kErrorGeneralError;
TRACE("LWH2F initialization failed!!\n");
goto Exit;
}
if (alt_bridge_init(ALT_BRIDGE_H2F, NULL, NULL) != ALT_E_SUCCESS)
{
oplkRet = kErrorGeneralError;
TRACE("H2F initialization failed!!\n");
goto Exit;
}
#if defined(CONFIG_BOOT_FROM_SD)
// Initialize the driver processor
if (initializeDriver() != 0)
{
TRACE("Initializing the driver failed!!\n");
return -1;
}
#endif
Exit:
return oplkRet;
}
//------------------------------------------------------------------------------
/**
\brief Shutdown system
The function shuts-down the system.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_exit(void)
{
alt_bridge_uninit(ALT_BRIDGE_H2F, NULL, NULL);
alt_bridge_uninit(ALT_BRIDGE_LWH2F, NULL, NULL);
cleanupTimer();
}
//------------------------------------------------------------------------------
/**
\brief Return true if a termination signal has been received
The function can be used by the application to react on termination request.
On cyclone V ARM, this function only implemented as a stub.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
BOOL system_getTermSignalState(void)
{
return FALSE;
}
//------------------------------------------------------------------------------
/**
\brief Sleep for the specified number of milliseconds
The function makes the calling thread sleep until the number of specified
milliseconds have elapsed.
\param[in] milliSeconds_p Number of milliseconds to sleep
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_msleep(unsigned int milliSeconds_p)
{
msleep(milliSeconds_p);
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
//------------------------------------------------------------------------------
/**
\brief Initialize the FPGA from the hard processor system
The function initializes the FPGA, manager interface, data bridges and
configures the FPGA for operation.
\return The function returns an integer.
\retval 0 Success
\retval -1 Failure
*/
//------------------------------------------------------------------------------
static int initializeFpga(void)
{
int ret = 0;
ALT_STATUS_CODE halRet = ALT_E_SUCCESS;
/* initialize the FPGA control */
if (alt_fpga_init() != ALT_E_SUCCESS) // initialize the FPGA manager
{
TRACE("FPGA interface initialization failed!!\n");
ret = -1;
goto Exit;
}
if (alt_fpga_state_get() == ALT_FPGA_STATE_POWER_OFF) // check the FPGA state
{
TRACE("FPGA is powered off!!\n");
ret = -1;
goto Exit;
}
if (!alt_fpga_control_is_enabled()) // check if CPU has the control of the FPGA control block
{
// if not acquire control
halRet = alt_fpga_control_enable();
}
if (halRet != ALT_E_SUCCESS)
{
TRACE("FPGA interface control could not be acquired\n");
ret = -1;
goto Exit;
}
/* Program FPGA here if required */
/* Enable the HPS-FPGA bridge */
if (alt_bridge_init(ALT_BRIDGE_F2H, NULL, NULL) != ALT_E_SUCCESS)
{
TRACE("F2H initialization failed!!\n");
ret = -1;
goto Exit;
}
if (alt_bridge_init(ALT_BRIDGE_H2F, NULL, NULL) != ALT_E_SUCCESS)
{
TRACE("H2F initialization failed!!\n");
ret = -1;
goto Exit;
}
if (alt_bridge_init(ALT_BRIDGE_LWH2F, NULL, NULL) != ALT_E_SUCCESS)
{
TRACE("LWH2F initialization failed!!\n");
ret = -1;
goto Exit;
}
if (alt_addr_space_remap(ALT_ADDR_SPACE_MPU_ZERO_AT_BOOTROM,
ALT_ADDR_SPACE_NONMPU_ZERO_AT_OCRAM,
ALT_ADDR_SPACE_H2F_ACCESSIBLE,
ALT_ADDR_SPACE_LWH2F_ACCESSIBLE) != ALT_E_SUCCESS)
{
TRACE("FPGA address space remapping failed!!\n");
ret = -1;
goto Exit;
}
Exit:
return ret;
}
#if defined(CONFIG_BOOT_FROM_SD)
//------------------------------------------------------------------------------
/**
\brief Initialize the openPOWERLINK driver from the hard processor system
The function resets the driver processor, copies the driver binary to the
processor's memory and releases the processor out of reset.
\return The function returns an integer.
\retval 0 Success
\retval -1 Failure
*/
//------------------------------------------------------------------------------
static int initializeDriver(void)
{
ALT_STATUS_CODE halRet = ALT_E_SUCCESS;
/* Symbol name for the driver binary file contents linked in. */
extern char _binary_drv_daemon_bin_start;
extern char _binary_drv_daemon_bin_end;
/* Use the above symbols to extract the driver binary information */
const char* driverBinary = &_binary_drv_daemon_bin_start;
const UINT32 driverBinarySize = &_binary_drv_daemon_bin_end - &_binary_drv_daemon_bin_start;
char* driverExecutableStartAddress = (char*)DDR3_EMIF_0_BASE;
// Trace the driver image information.
TRACE("INFO: driver Image binary at %p.\n", driverBinary);
TRACE("INFO: driver Image size is %u bytes.\n", driverBinarySize);
TRACE("INFO: driver Executable start is %p\n", driverExecutableStartAddress);
// Reset the driver processor
halRet = alt_fpga_gpo_write(0x00000001, 0x00000000);
if (halRet != ALT_E_SUCCESS)
return -1;
while (alt_fpga_gpi_read(0x00000001) == 0);
// Copy the driver image
memcpy(driverExecutableStartAddress, driverBinary, driverBinarySize);
// Release the driver processor from reset
halRet = alt_fpga_gpo_write(0x00000001, 0x00000001);
if (halRet != ALT_E_SUCCESS)
return -1;
while (alt_fpga_gpi_read(0x00000001) != 0);
return 0;
}
#endif
//------------------------------------------------------------------------------
/**
\brief Initialize the timer module
The function initializes the global timer and configures it to be used as
the user stack generic timer.
\return The function returns an integer.
\retval 0 Success
\retval -1 Failure
*/
//------------------------------------------------------------------------------
static int initializeTimer(void)
{
int ret = 0;
ALT_STATUS_CODE halRet = ALT_E_SUCCESS;
// initialize timer, only the 64 bit global timer is used
halRet = alt_globaltmr_init();
if (halRet != ALT_E_SUCCESS)
{
TRACE("General purpose timer module initialization failed!!\n");
ret = -1;
goto Exit;
}
// set the comparator value to the maximum global timer value even though we do not use it
// the 'alt_gpt_curtime_millisecs_get()' api uses this to determine current time
if ((alt_globaltmr_autoinc_set(1) != ALT_E_SUCCESS) ||
(alt_globaltmr_comp_set64(GLOBALTMR_MAX) != ALT_E_SUCCESS))
{
TRACE("Auto increment mode could not be enabled for this timer!\n");
}
// Check if the timer is already running
halRet = alt_gpt_tmr_is_running(ALT_GPT_CPU_GLOBAL_TMR);
if (halRet == ALT_E_FALSE)
{
TRACE("Timer has to be started!\n");
// timer is not running, so try to start it
halRet = alt_globaltmr_start();
}
else
{
if (halRet == ALT_E_BAD_ARG)
{
// this timer instance does not exist
ret = -1;
goto Exit;
}
else // if (retStatus == ALT_E_TRUE)
{
// timer is already running. try to reset it
// retStatus = alt_gpt_tmr_reset(ALT_GPT_CPU_GLOBAL_TMR);
// Do not do it as its not needed and we would require to set its mode
// configuration again if we did
}
}
// check if any of the previous 2 timer operation failed, it can not be
// a bad instance as that is covered
if (halRet != ALT_E_SUCCESS)
{
TRACE("Timer initialization failed!!\n");
ret = -1;
goto Exit;
}
TRACE("Timer Comparator Mode: %u, value: %lu",
alt_globaltmr_is_comp_mode(),
alt_globaltmr_comp_get64() - 1);
TRACE("Timer Auto increment mode: %u, value: %u\n",
alt_globaltmr_is_autoinc_mode(),
alt_globaltmr_autoinc_get());
// stop the comparison function for this timer
if ((alt_globaltmr_autoinc_mode_stop() != ALT_E_SUCCESS) ||
(alt_globaltmr_comp_mode_start() != ALT_E_SUCCESS))
{
TRACE("Timer mode could not be set\n");
ret = -1;
goto Exit;
}
TRACE("Timer Comparator Mode: %u, value: %lu",
alt_globaltmr_is_comp_mode(),
alt_globaltmr_comp_get64() - 1);
TRACE("Timer Auto increment mode: %u, value: %u\n",
alt_globaltmr_is_autoinc_mode(),
alt_globaltmr_autoinc_get());
// disable comparator interrupts from this timer
if ((alt_globaltmr_int_disable() != ALT_E_SUCCESS) ||
(alt_globaltmr_int_clear_pending() != ALT_E_SUCCESS))
{
TRACE("Timer IRQ could not be disabled\n");
ret = -1;
goto Exit;
}
Exit:
return ret;
}
//------------------------------------------------------------------------------
/**
\brief Uninitialize the timer module
The function uninitializes the global timer.
\return The function returns an integer.
\retval 0 Success
\retval -1 Failure
*/
//------------------------------------------------------------------------------
static int cleanupTimer(void)
{
int ret = 0;
ALT_STATUS_CODE halRet = ALT_E_SUCCESS;
halRet = alt_globaltmr_stop();
if (halRet == ALT_E_SUCCESS)
halRet = alt_globaltmr_uninit();
if (halRet != ALT_E_SUCCESS)
ret = -1;
return ret;
}
/// \}

View File

@ -0,0 +1,447 @@
/**
********************************************************************************
\file system-linux.c
\brief System specific functions for Linux
The file implements the system specific functions for Linux used by the
openPOWERLINK demo applications.
\ingroup module_app_common
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
Copyright (c) 2013, SYSTEC electronic GmbH
Copyright (c) 2013, Kalycito Infotech Private Ltd.All rights reserved.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <pthread.h>
#include <signal.h>
#include <sys/time.h>
#include <trace/trace.h>
#include "system.h"
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#define SET_CPU_AFFINITY
#define MAIN_THREAD_PRIORITY 20
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P R I V A T E D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// local types
//------------------------------------------------------------------------------
#if defined(CONFIG_USE_SYNCTHREAD)
typedef struct
{
tSyncCb pfnSyncCb;
BOOL fTerminate;
} tSyncThreadInstance;
#endif
typedef struct
{
tFirmwareManagerThreadCb pfnFwmCb;
BOOL fTerminate;
unsigned int interval;
} tFwmThreadInstance;
//------------------------------------------------------------------------------
// local vars
//------------------------------------------------------------------------------
static BOOL fTermSignalReceived_l = FALSE;
#if defined(CONFIG_USE_SYNCTHREAD)
static pthread_t syncThreadId_l;
static tSyncThreadInstance syncThreadInstance_l;
#endif
static tFwmThreadInstance fwmThreadInstance_l;
//------------------------------------------------------------------------------
// local function prototypes
//------------------------------------------------------------------------------
static void handleTermSignal(int signum);
#if defined(CONFIG_USE_SYNCTHREAD)
static void* powerlinkSyncThread(void* arg);
#endif
static void* firmwareManagerThread(void* arg);
//============================================================================//
// P U B L I C F U N C T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Initialize system
The function initializes important stuff on the system for openPOWERLINK to
work correctly.
\return The function returns 0 if the initialization has been successful,
otherwise -1.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
int system_init(void)
{
struct sched_param schedParam;
struct sigaction new_action;
/* adjust process priority */
if (nice(-20) == -1) // push nice level in case we have no RTPreempt
{
TRACE("%s() couldn't set nice value! (%s)\n",
__func__,
strerror(errno));
}
schedParam.sched_priority = MAIN_THREAD_PRIORITY;
if (pthread_setschedparam(pthread_self(), SCHED_RR, &schedParam) != 0)
{
TRACE("%s() couldn't set thread scheduling parameters! %d\n",
__func__,
schedParam.sched_priority);
}
// Register termination handler for signals with termination semantics
new_action.sa_handler = handleTermSignal;
sigemptyset(&new_action.sa_mask);
new_action.sa_flags = 0;
sigaction(SIGINT, &new_action, NULL); // Sent via CTRL-C
sigaction(SIGTERM, &new_action, NULL); // Generic signal used to cause program termination.
sigaction(SIGQUIT, &new_action, NULL); // Terminate because of abnormal condition
#if defined(SET_CPU_AFFINITY)
{
/* binds all openPOWERLINK threads to the second CPU core */
cpu_set_t affinity;
CPU_ZERO(&affinity);
CPU_SET(1, &affinity);
sched_setaffinity(0, sizeof(cpu_set_t), &affinity);
}
#endif
return 0;
}
//------------------------------------------------------------------------------
/**
\brief Shutdown system
The function shuts down the system.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_exit(void)
{
}
//------------------------------------------------------------------------------
/**
\brief Determines whether a termination signal has been received
The function can be used by the application to react on termination request.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
BOOL system_getTermSignalState(void)
{
return fTermSignalReceived_l;
}
//------------------------------------------------------------------------------
/**
\brief Sleep for the specified number of milliseconds
The function makes the calling thread sleep until the number of specified
milliseconds has elapsed.
\param[in] milliSeconds_p Number of milliseconds to sleep
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_msleep(unsigned int milliSeconds_p)
{
struct timeval timeout;
fd_set readFds;
int maxFd;
int selectRetVal;
unsigned int seconds;
unsigned int microSeconds;
// initialize file descriptor set
maxFd = 0 + 1;
FD_ZERO(&readFds);
// Calculate timeout values
seconds = milliSeconds_p / 1000;
microSeconds = (milliSeconds_p - (seconds * 1000)) * 1000;
// initialize timeout value
timeout.tv_sec = seconds;
timeout.tv_usec = microSeconds;
selectRetVal = select(maxFd, &readFds, NULL, NULL, &timeout);
switch (selectRetVal)
{
case 0: // select timeout occurred, no packet received
break;
case -1: // select error occurred
break;
default: // packet available for receive
break;
}
}
#if defined(CONFIG_USE_SYNCTHREAD)
//------------------------------------------------------------------------------
/**
\brief Start synchronous data thread
The function starts the thread used for synchronous data handling.
\param[in] pfnSync_p Pointer to sync callback function
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_startSyncThread(tSyncCb pfnSync_p)
{
int ret;
syncThreadInstance_l.pfnSyncCb = pfnSync_p;
syncThreadInstance_l.fTerminate = FALSE;
// create sync thread
ret = pthread_create(&syncThreadId_l,
NULL,
&powerlinkSyncThread,
&syncThreadInstance_l);
if (ret != 0)
{
fprintf(stderr, "pthread_create() failed with \"%d\"\n", ret);
return;
}
#if (defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 12))
pthread_setname_np(syncThreadId_l, "oplkdemo-sync");
#endif
}
//------------------------------------------------------------------------------
/**
\brief Stop synchronous data thread
The function stops the thread used for synchronous data handling.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_stopSyncThread(void)
{
syncThreadInstance_l.fTerminate = TRUE;
}
#endif
//------------------------------------------------------------------------------
/**
\brief Start firmware manager thread
The function starts the thread used by the firmware manager.
\param[in] pfnFwmThreadCb_p Pointer to firmware manager callback
\param[in] intervalSec_p Thread execution interval in seconds
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_startFirmwareManagerThread(tFirmwareManagerThreadCb pfnFwmThreadCb_p,
unsigned int intervalSec_p)
{
int ret;
pthread_t thread;
struct sched_param schedParam;
fwmThreadInstance_l.fTerminate = FALSE;
fwmThreadInstance_l.pfnFwmCb = pfnFwmThreadCb_p;
fwmThreadInstance_l.interval = intervalSec_p;
ret = pthread_create(&thread, NULL, firmwareManagerThread, &fwmThreadInstance_l);
if (ret != 0)
{
fprintf(stderr, "%s() pthread_create() failed with \"%d\"\n",
__func__,
ret);
return;
}
schedParam.sched_priority = 0;
if (pthread_setschedparam(thread, SCHED_IDLE, &schedParam) != 0)
{
TRACE("%s() couldn't set thread scheduling parameters! %d\n",
__func__,
schedParam.sched_priority);
}
#if (defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 12))
pthread_setname_np(thread, "oplkdemo-fwm");
#endif
}
//------------------------------------------------------------------------------
/**
\brief Stop firmware manager thread
The function stops the thread used by the firmware manager.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_stopFirmwareManagerThread(void)
{
fwmThreadInstance_l.fTerminate = TRUE;
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
//------------------------------------------------------------------------------
/**
\brief Handle termination requests
This functions can be used to react on signals with termination semantics,
and remembers in a flag that the user or the system asked the program to shut down.
The application can than check this flag.
\param[in] signum Received signal.
*/
//------------------------------------------------------------------------------
static void handleTermSignal(int signum)
{
switch (signum)
{
case SIGINT: // Signals with termination semantics
case SIGTERM: // trigger a flag change
case SIGQUIT:
fTermSignalReceived_l = TRUE;
break;
default: // All other signals are ignored by this handler
break;
}
}
#if defined(CONFIG_USE_SYNCTHREAD)
//------------------------------------------------------------------------------
/**
\brief Synchronous application thread
This function implements the synchronous application thread.
\param[in,out] arg Needed for thread interface not used
*/
//------------------------------------------------------------------------------
static void* powerlinkSyncThread(void* arg)
{
tSyncThreadInstance* pSyncThreadInstance = (tSyncThreadInstance*)arg;
printf("Synchronous data thread is starting...\n");
while (!pSyncThreadInstance->fTerminate)
{
pSyncThreadInstance->pfnSyncCb();
}
printf("Synchronous data thread is terminating...\n");
return NULL;
}
#endif
//------------------------------------------------------------------------------
/**
\brief Firmware manager thread
This function implements the firmware manager thread.
\param[in,out] arg Needed for thread interface not used
*/
//------------------------------------------------------------------------------
static void* firmwareManagerThread(void* arg)
{
tFwmThreadInstance* pInstance = (tFwmThreadInstance*)arg;
while (!pInstance->fTerminate)
{
pInstance->pfnFwmCb();
sleep(pInstance->interval);
}
return NULL;
}
/// \}

View File

@ -0,0 +1,162 @@
/**
********************************************************************************
\file system-microblaze.c
\brief System specific functions for Microblaze
The file implements the system specific functions for Microblaze used by the
openPOWERLINK demo applications.
\ingroup module_app_common
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <usleep.h>
#include "system.h"
#if defined(CONFIG_USE_SYNCTHREAD)
#error "Sync thread is not supported on this target!"
#endif
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#define TGTCONIO_MS_IN_US(x) (x * 1000U)
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// 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 //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Initialize system
The function initializes important stuff on the system for openPOWERLINK to
work correctly.
\return The function returns 0 if the initialization has been successful,
otherwise -1.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
int system_init(void)
{
return 0;
}
//------------------------------------------------------------------------------
/**
\brief Shutdown system
The function shuts down the system.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_exit(void)
{
}
/**
\brief Determines whether a termination signal has been received
The function can be used by the application to react on termination request.
On Microblaze, this function is only implemented as a stub.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
BOOL system_getTermSignalState(void)
{
return FALSE;
}
//------------------------------------------------------------------------------
/**
\brief Sleep for the specified number of milliseconds
The function makes the calling thread sleep until the number of specified
milliseconds have elapsed.
\param[in] milliSeconds_p Number of milliseconds to sleep
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_msleep(unsigned int milliSeconds_p)
{
usleep(TGTCONIO_MS_IN_US(milliSeconds_p));
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
/// \}

View File

@ -0,0 +1,165 @@
/**
********************************************************************************
\file system-nios.c
\brief System specific functions for Nios2
The file implements the system specific functions for Nios2 used by the
openPOWERLINK demo applications.
\ingroup module_app_common
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <unistd.h>
#include <sys/alt_irq.h>
#include <sys/alt_alarm.h>
#include "system.h"
#if defined(CONFIG_USE_SYNCTHREAD)
#error "Sync thread is not supported on this target!"
#endif
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#define TGTCONIO_MS_IN_US(x) (x * 1000U)
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// 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 //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Initialize system
The function initializes important stuff on the system for openPOWERLINK to
work correctly.
\return The function returns 0 if the initialization has been successful,
otherwise -1.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
int system_init(void)
{
return 0;
}
//------------------------------------------------------------------------------
/**
\brief Shutdown system
The function shuts down the system.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_exit(void)
{
}
/**
\brief Determines whether a termination signal has been received
The function can be used by the application to react on termination request.
On Nios2, this function is only implemented as a stub.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
BOOL system_getTermSignalState(void)
{
return FALSE;
}
//------------------------------------------------------------------------------
/**
\brief Sleep for the specified number of milliseconds
The function makes the calling thread sleep until the number of specified
milliseconds have elapsed.
\param[in] milliSeconds_p Number of milliseconds to sleep
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_msleep(unsigned int milliSeconds_p)
{
usleep(TGTCONIO_MS_IN_US(milliSeconds_p));
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
/// \}

View File

@ -0,0 +1,362 @@
/**
********************************************************************************
\file system-windows.c
\brief System specific functions for Windows
The file implements the system specific functions for Windows used by the
openPOWERLINK demo applications.
\ingroup module_app_common
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
Copyright (c) 2013, SYSTEC electronic GmbH
Copyright (c) 2017, Kalycito Infotech Private Limited
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#define _WIN32_WINNT 0x0600 // Windows version must be at least Windows Vista
#define WIN32_LEAN_AND_MEAN // Do not use extended Win32 API functions
#include <Windows.h>
#include "system.h"
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P R I V A T E D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// local types
//------------------------------------------------------------------------------
#if defined(CONFIG_USE_SYNCTHREAD)
/**
\brief Local instance for synchronization thread
This structure contains local variables used by the synchronization thread.
*/
typedef struct
{
HANDLE hSyncThreadHandle; ///< Synchronization thread handle
tSyncCb pfnSyncCb; ///< Pointer to synchronization callback routine
BOOL fThreadExit; ///< Flag to communicate with main thread
} tSyncThreadInstance;
#endif
/**
\brief Local instance for firmware manager thread
This structure contains local variables used by the firmware manager thread.
*/
typedef struct
{
HANDLE hThreadHandle; ///< Firmware manager thread handle
tFirmwareManagerThreadCb pfnFwmCb; ///< Pointer to firmware manager thread callback routine
BOOL fThreadExit; ///< Flag to communicate with main thread
unsigned int interval; ///< Firmware manager thread call interval
} tFirmwareManagerThreadInstance;
//------------------------------------------------------------------------------
// local vars
//------------------------------------------------------------------------------
#if defined(CONFIG_USE_SYNCTHREAD)
static tSyncThreadInstance syncThreadInstance_l;
#endif
static tFirmwareManagerThreadInstance fwmThreadInstance_l;
//------------------------------------------------------------------------------
// local function prototypes
//------------------------------------------------------------------------------
#if defined(CONFIG_USE_SYNCTHREAD)
static DWORD WINAPI syncThread(LPVOID pArg_p);
#endif
static DWORD WINAPI fwmThread(LPVOID pArg_p);
//============================================================================//
// P U B L I C F U N C T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Initialize system
The function initializes important stuff on the system for openPOWERLINK to
work correctly.
\return The function returns 0 if the initialization has been successful,
otherwise -1.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
int system_init(void)
{
// activate realtime priority class
SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS);
// lower the priority of this thread
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE);
#if defined(CONFIG_USE_SYNCTHREAD)
syncThreadInstance_l.fThreadExit = FALSE;
#endif
return 0;
}
//------------------------------------------------------------------------------
/**
\brief Shutdown system
The function shuts down the system.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_exit(void)
{
#if defined(CONFIG_USE_SYNCTHREAD)
CloseHandle(syncThreadInstance_l.hSyncThreadHandle);
#endif
}
/**
\brief Determines whether a termination signal has been received
The function can be used by the application to react on termination request.
On Windows, this function is only implemented as a stub.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
BOOL system_getTermSignalState(void)
{
return FALSE;
}
//------------------------------------------------------------------------------
/**
\brief Sleep for the specified number of milliseconds
The function makes the calling thread sleep until the number of specified
milliseconds have elapsed.
\param[in] milliSeconds_p Number of milliseconds to sleep
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_msleep(unsigned int milliSeconds_p)
{
Sleep(milliSeconds_p);
}
#if defined(CONFIG_USE_SYNCTHREAD)
//------------------------------------------------------------------------------
/**
\brief Start synchronous data thread
The function starts the thread used for synchronous data handling.
\param[in] pfnSync_p Pointer to sync callback function
\note Currently not implemented for Windows!
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_startSyncThread(tSyncCb pfnSync_p)
{
// Currently threads are not used on Windows
syncThreadInstance_l.pfnSyncCb = pfnSync_p;
syncThreadInstance_l.hSyncThreadHandle = CreateThread(NULL, // Default security attributes
0, // Use Default stack size
syncThread, // Thread routine
NULL, // Argument to the thread routine
0, // Use default creation flags
NULL // Returned thread Id
);
}
//------------------------------------------------------------------------------
/**
\brief Stop synchronous data thread
The function stops the thread used for synchronous data handling.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_stopSyncThread(void)
{
CancelIoEx(syncThreadInstance_l.hSyncThreadHandle, NULL);
// Signal to stop the thread and wait for the thread to terminate
syncThreadInstance_l.fThreadExit = TRUE;
WaitForSingleObject(syncThreadInstance_l.hSyncThreadHandle, 1000);
}
#endif
//------------------------------------------------------------------------------
/**
\brief Start firmware manager thread
The function starts the thread used by the firmware manager.
\param[in] pfnFwmThreadCb_p Pointer to firmware manager callback
\param[in] intervalSec_p Thread execution interval in seconds
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_startFirmwareManagerThread(tFirmwareManagerThreadCb pfnFwmThreadCb_p,
unsigned int intervalSec_p)
{
fwmThreadInstance_l.pfnFwmCb = pfnFwmThreadCb_p;
fwmThreadInstance_l.interval = intervalSec_p * 1000;
fwmThreadInstance_l.fThreadExit = FALSE;
fwmThreadInstance_l.hThreadHandle = CreateThread(NULL, // Default security attributes
0, // Use Default stack size
fwmThread, // Thread routine
NULL, // Argument to the thread routine
0, // Use default creation flags
NULL // Returned thread Id
);
}
//------------------------------------------------------------------------------
/**
\brief Stop firmware manager thread
The function stops the thread used by the firmware manager.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_stopFirmwareManagerThread(void)
{
//TODO: Call CancelIoEx with thread handle as soon as XP support is dropped
// Signal to stop the thread and wait for the thread to terminate
fwmThreadInstance_l.fThreadExit = TRUE;
WaitForSingleObject(fwmThreadInstance_l.hThreadHandle, 1000);
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
#if defined(CONFIG_USE_SYNCTHREAD)
//------------------------------------------------------------------------------
/**
\brief Synchronous application thread
This function implements the synchronous application thread.
\param[in,out] pArg_p Thread parameter. Not used!
\return The function returns the thread exit code.
*/
//------------------------------------------------------------------------------
static DWORD WINAPI syncThread(LPVOID pArg_p)
{
tOplkError ret;
UNUSED_PARAMETER(pArg_p);
while (!syncThreadInstance_l.fThreadExit)
{
if (syncThreadInstance_l.pfnSyncCb)
{
ret = syncThreadInstance_l.pfnSyncCb();
if (ret != kErrorOk)
break;
}
else
break;
}
printf("Exiting sync thread\n");
return 0;
}
#endif
//------------------------------------------------------------------------------
/**
\brief Firmware manager thread
This function implements the firmware manager thread.
\param[in,out] pArg_p Thread parameter. Not used!
\return The function returns the thread exit code.
*/
//------------------------------------------------------------------------------
static DWORD WINAPI fwmThread(LPVOID pArg_p)
{
UNUSED_PARAMETER(pArg_p);
while (!fwmThreadInstance_l.fThreadExit)
{
fwmThreadInstance_l.pfnFwmCb();
Sleep(fwmThreadInstance_l.interval);
}
return 0;
}
/// \}

View File

@ -0,0 +1,366 @@
/**
********************************************************************************
\file system-xiuos.c
\brief System specific functions for XiUOS
The file implements the system specific functions for XiUOS used by the
openPOWERLINK demo applications.
\ingroup module_app_common
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2020, AIIT XUOS Lab
Copyright (c) 2016, B&R Industrial Automation GmbH
Copyright (c) 2013, SYSTEC electronic GmbH
Copyright (c) 2013, Kalycito Infotech Private Ltd.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <pthread.h>
#include <signal.h>
#include <sys/time.h>
#include <trace/trace.h>
#include "system.h"
#include <xizi.h>
//============================================================================//
// G L O B A L D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
#define SET_CPU_AFFINITY
#define MAIN_THREAD_PRIORITY 20
//------------------------------------------------------------------------------
// module global vars
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// global function prototypes
//------------------------------------------------------------------------------
//============================================================================//
// P R I V A T E D E F I N I T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// local types
//------------------------------------------------------------------------------
#if defined(CONFIG_USE_SYNCTHREAD)
typedef struct
{
tSyncCb pfnSyncCb;
BOOL fTerminate;
} tSyncThreadInstance;
#endif
typedef struct
{
tFirmwareManagerThreadCb pfnFwmCb;
BOOL fTerminate;
unsigned int interval;
} tFwmThreadInstance;
//------------------------------------------------------------------------------
// local vars
//------------------------------------------------------------------------------
static BOOL fTermSignalReceived_l = FALSE;
#if defined(CONFIG_USE_SYNCTHREAD)
static pthread_t syncThreadId_l;
static tSyncThreadInstance syncThreadInstance_l;
#endif
static tFwmThreadInstance fwmThreadInstance_l;
//------------------------------------------------------------------------------
// local function prototypes
//------------------------------------------------------------------------------
#if defined(CONFIG_USE_SYNCTHREAD)
static void* powerlinkSyncThread(void* arg);
#endif
static void* firmwareManagerThread(void* arg);
//============================================================================//
// P U B L I C F U N C T I O N S //
//============================================================================//
//------------------------------------------------------------------------------
/**
\brief Initialize system
The function initializes important stuff on the system for openPOWERLINK to
work correctly.
\return The function returns 0 if the initialization has been successful,
otherwise -1.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
int system_init(void)
{
struct sched_param schedParam;
schedParam.sched_priority = MAIN_THREAD_PRIORITY;
if (pthread_setschedparam(pthread_self(), SCHED_RR, &schedParam) != 0)
{
TRACE("%s() couldn't set thread scheduling parameters! %d\n",
__func__,
schedParam.sched_priority);
}
return 0;
}
//------------------------------------------------------------------------------
/**
\brief Shutdown system
The function shuts down the system.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_exit(void)
{
}
//------------------------------------------------------------------------------
/**
\brief Determines whether a termination signal has been received
The function can be used by the application to react on termination request.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
BOOL system_getTermSignalState(void)
{
return fTermSignalReceived_l;
}
//------------------------------------------------------------------------------
/**
\brief Sleep for the specified number of milliseconds
The function makes the calling thread sleep until the number of specified
milliseconds has elapsed.
\param[in] milliSeconds_p Number of milliseconds to sleep
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_msleep(unsigned int milliSeconds_p)
{
MdelayKTask(milliSeconds_p);
}
#if defined(CONFIG_USE_SYNCTHREAD)
//------------------------------------------------------------------------------
/**
\brief Start synchronous data thread
The function starts the thread used for synchronous data handling.
\param[in] pfnSync_p Pointer to sync callback function
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_startSyncThread(tSyncCb pfnSync_p)
{
int ret;
syncThreadInstance_l.pfnSyncCb = pfnSync_p;
syncThreadInstance_l.fTerminate = FALSE;
// create sync thread
ret = pthread_create(&syncThreadId_l,
NULL,
&powerlinkSyncThread,
&syncThreadInstance_l);
if (ret != 0)
{
fprintf(stderr, "pthread_create() failed with \"%d\"\n", ret);
return;
}
#if (defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 12))
pthread_setname_np(syncThreadId_l, "oplkdemo-sync");
#endif
}
//------------------------------------------------------------------------------
/**
\brief Stop synchronous data thread
The function stops the thread used for synchronous data handling.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_stopSyncThread(void)
{
syncThreadInstance_l.fTerminate = TRUE;
}
#endif
//------------------------------------------------------------------------------
/**
\brief Start firmware manager thread
The function starts the thread used by the firmware manager.
\param[in] pfnFwmThreadCb_p Pointer to firmware manager callback
\param[in] intervalSec_p Thread execution interval in seconds
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_startFirmwareManagerThread(tFirmwareManagerThreadCb pfnFwmThreadCb_p,
unsigned int intervalSec_p)
{
int ret;
pthread_t thread;
struct sched_param schedParam;
fwmThreadInstance_l.fTerminate = FALSE;
fwmThreadInstance_l.pfnFwmCb = pfnFwmThreadCb_p;
fwmThreadInstance_l.interval = intervalSec_p;
ret = pthread_create(&thread, NULL, firmwareManagerThread, &fwmThreadInstance_l);
if (ret != 0)
{
fprintf(stderr, "%s() pthread_create() failed with \"%d\"\n",
__func__,
ret);
return;
}
schedParam.sched_priority = 0;
if (pthread_setschedparam(thread, SCHED_IDLE, &schedParam) != 0)
{
TRACE("%s() couldn't set thread scheduling parameters! %d\n",
__func__,
schedParam.sched_priority);
}
#if (defined(__GLIBC__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 12))
pthread_setname_np(thread, "oplkdemo-fwm");
#endif
}
//------------------------------------------------------------------------------
/**
\brief Stop firmware manager thread
The function stops the thread used by the firmware manager.
\ingroup module_app_common
*/
//------------------------------------------------------------------------------
void system_stopFirmwareManagerThread(void)
{
fwmThreadInstance_l.fTerminate = TRUE;
}
//============================================================================//
// P R I V A T E F U N C T I O N S //
//============================================================================//
/// \name Private Functions
/// \{
//------------------------------------------------------------------------------
#if defined(CONFIG_USE_SYNCTHREAD)
//------------------------------------------------------------------------------
/**
\brief Synchronous application thread
This function implements the synchronous application thread.
\param[in,out] arg Needed for thread interface not used
*/
//------------------------------------------------------------------------------
static void* powerlinkSyncThread(void* arg)
{
tSyncThreadInstance* pSyncThreadInstance = (tSyncThreadInstance*)arg;
printf("Synchronous data thread is starting...\n");
while (!pSyncThreadInstance->fTerminate)
{
pSyncThreadInstance->pfnSyncCb();
}
printf("Synchronous data thread is terminating...\n");
return NULL;
}
#endif
//------------------------------------------------------------------------------
/**
\brief Firmware manager thread
This function implements the firmware manager thread.
\param[in,out] arg Needed for thread interface not used
*/
//------------------------------------------------------------------------------
static void* firmwareManagerThread(void* arg)
{
tFwmThreadInstance* pInstance = (tFwmThreadInstance*)arg;
while (!pInstance->fTerminate)
{
pInstance->pfnFwmCb();
MdelayKTask(pInstance->interval * 1000);
}
return NULL;
}
/// \}

View File

@ -0,0 +1,83 @@
/**
********************************************************************************
\file system.h
\brief Definitions for system specific functions
This header file provides the definitions for the system specific functions used
by the openPOWERLINK examples.
*******************************************************************************/
/*------------------------------------------------------------------------------
Copyright (c) 2016, B&R Industrial Automation GmbH
Copyright (c) 2013, SYSTEC electronic GmbH
Copyright (c) 2013, Kalycito Infotech Private Ltd.All rights reserved.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
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 COPYRIGHT HOLDERS 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.
------------------------------------------------------------------------------*/
#ifndef _INC_system_H_
#define _INC_system_H_
//------------------------------------------------------------------------------
// includes
//------------------------------------------------------------------------------
#include <oplk/oplk.h>
//------------------------------------------------------------------------------
// const defines
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// typedef
//------------------------------------------------------------------------------
typedef tOplkError (*tFirmwareManagerThreadCb)(void);
//------------------------------------------------------------------------------
// function prototypes
//------------------------------------------------------------------------------
#ifdef __cplusplus
extern "C"
{
#endif
int system_init(void);
void system_exit(void);
BOOL system_getTermSignalState();
void system_msleep(unsigned int milliSeconds_p);
#if defined(CONFIG_USE_SYNCTHREAD)
void system_startSyncThread(tSyncCb pfnSync_p);
void system_stopSyncThread(void);
#endif
void system_startFirmwareManagerThread(tFirmwareManagerThreadCb pfnFwmThreadCb_p,
unsigned int intervalSec_p);
void system_stopFirmwareManagerThread(void);
#ifdef __cplusplus
}
#endif
#endif /* _INC_system_H_ */

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