diff --git a/APP_Framework/Framework/connection/industrial_ethernet/Kconfig b/APP_Framework/Framework/connection/industrial_ethernet/Kconfig index 0826acf22..f5f858f84 100644 --- a/APP_Framework/Framework/connection/industrial_ethernet/Kconfig +++ b/APP_Framework/Framework/connection/industrial_ethernet/Kconfig @@ -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 diff --git a/APP_Framework/Framework/connection/industrial_ethernet/Makefile b/APP_Framework/Framework/connection/industrial_ethernet/Makefile index 2bdec6d77..85d8055c2 100644 --- a/APP_Framework/Framework/connection/industrial_ethernet/Makefile +++ b/APP_Framework/Framework/connection/industrial_ethernet/Makefile @@ -1,3 +1,5 @@ +include $(KERNEL_ROOT)/.config + all: COMPILER CUR_DIR := $(shell pwd) @@ -5,19 +7,48 @@ 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)&: - cd $(LIBOPLK_BUILD_DIR) && \ - rm -rf CMakeFiles proj cmake_install.cmake CMakeCache.txt Makefile && \ - cmake -DCMAKE_TOOLCHAIN_FILE=$(OPLK_TOOLCHAIN) ../.. && \ - cmake --build . --target install + $(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): + $(call oplk_build,$(OPLK_DEMO_MN_CONSOLE_BUILD_DIR)) + +.PHONY: $(OPLK_DEMO_CN_CONSOLE) +$(OPLK_DEMO_CN_CONSOLE): + $(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 := $(LIBOPLKMN) $(LIBOPLKCN) +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 diff --git a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/common/cmake/configure-xiuos.cmake b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/common/cmake/configure-xiuos.cmake new file mode 100644 index 000000000..0d3f1d593 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/common/cmake/configure-xiuos.cmake @@ -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") + + + diff --git a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/common/cmake/findoplklib.cmake b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/common/cmake/findoplklib.cmake index 242ba9931..ce2f2ed78 100644 --- a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/common/cmake/findoplklib.cmake +++ b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/common/cmake/findoplklib.cmake @@ -56,6 +56,9 @@ MACRO(FIND_OPLK_LIBRARY OPLK_NODE_TYPE) 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}) diff --git a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/common/cmake/options.cmake b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/common/cmake/options.cmake index 24d9b58f7..35c1a691f 100644 --- a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/common/cmake/options.cmake +++ b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/common/cmake/options.cmake @@ -4,6 +4,7 @@ # # 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 @@ -95,6 +96,8 @@ 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") diff --git a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/common/src/system/system-xiuos.c b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/common/src/system/system-xiuos.c new file mode 100644 index 000000000..9ca2e2cfe --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/common/src/system/system-xiuos.c @@ -0,0 +1,396 @@ +/** +******************************************************************************** +\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 +#include +#include +#include +#include +#include +#include +#include "system.h" + +#include + +//============================================================================// +// 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) +{ + 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 +/// \{ + +//------------------------------------------------------------------------------ + +#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(); + + DelayKTask(pInstance->interval * 1000); + } + + return NULL; +} + +/// \} diff --git a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_cn_console/CMakeLists.txt b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_cn_console/CMakeLists.txt index 4004957bb..78fa80481 100644 --- a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_cn_console/CMakeLists.txt +++ b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_cn_console/CMakeLists.txt @@ -112,6 +112,8 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") include(linux.cmake) ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Windows") include (windows.cmake) +ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "XiUOS") + include(xiuos.cmake) ELSE() MESSAGE(FATAL_ERROR "System ${CMAKE_SYSTEM_NAME} is not supported!") ENDIF() @@ -131,7 +133,11 @@ SOURCE_GROUP("Object Dictionary" FILES ################################################################################ # Set the executable -ADD_EXECUTABLE(demo_cn_console ${DEMO_SOURCES} ${DEMO_ARCH_SOURCES}) +IF(CMAKE_SYSTEM_NAME STREQUAL "XiUOS") + ADD_LIBRARY(demo_cn_console STATIC ${DEMO_SOURCES} ${DEMO_ARCH_SOURCES}) +ELSE() + ADD_EXECUTABLE(demo_cn_console ${DEMO_SOURCES} ${DEMO_ARCH_SOURCES}) +ENDIF() SET_PROPERTY(TARGET demo_cn_console PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUG;DEF_DEBUG_LVL=${CFG_DEBUG_LVL}) @@ -144,4 +150,4 @@ TARGET_LINK_LIBRARIES(demo_cn_console ${ARCH_LIBRARIES}) ################################################################################ # Installation rules -INSTALL(TARGETS demo_cn_console RUNTIME DESTINATION ${PROJECT_NAME}) +INSTALL(TARGETS demo_cn_console DESTINATION ${PROJECT_NAME}) diff --git a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_cn_console/build/xiuos/.gitignore b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_cn_console/build/xiuos/.gitignore new file mode 100644 index 000000000..1735fada1 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_cn_console/build/xiuos/.gitignore @@ -0,0 +1,4 @@ +* +.* +!.gitignore + diff --git a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_cn_console/src/main.c b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_cn_console/src/main.c index 881cb55fb..a7ca266d9 100644 --- a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_cn_console/src/main.c +++ b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_cn_console/src/main.c @@ -142,7 +142,11 @@ This is the main function of the openPOWERLINK console CN demo application. \ingroup module_demo_cn_console */ //------------------------------------------------------------------------------ +#ifdef __XIUOS__ +int OplkDemoCnConsole(int argc, char* argv[]) +#else int main(int argc, char* argv[]) +#endif { tOplkError ret = kErrorOk; tOptions opts; diff --git a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_cn_console/xiuos.cmake b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_cn_console/xiuos.cmake new file mode 100644 index 000000000..dfdaa5ebe --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_cn_console/xiuos.cmake @@ -0,0 +1,78 @@ +################################################################################ +# +# XiUOS definitions for console CN demo application +# +# Copyright (c) 2016, B&R Industrial Automation GmbH +# 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. +################################################################################ + +################################################################################ +# Set architecture specific definitions + +ADD_DEFINITIONS(-D__XIUOS__ -D_GNU_SOURCE -D_POSIX_C_SOURCE=200112L) +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -std=c99") + +################################################################################ +# Set architecture specific sources and include directories + +SET (DEMO_ARCH_SOURCES + ${COMMON_SOURCE_DIR}/system/system-xiuos.c + ${CONTRIB_SOURCE_DIR}/console/console-xiuos.c + ${CONTRIB_SOURCE_DIR}/trace/trace-printf.c + ) + +################################################################################ +# Set architecture specific libraries + +IF (NOT CFG_COMPILE_SHARED_LIBRARY) + SET(PCAP_CONFIG_OPTS --static) +ENDIF() + +IF (CFG_KERNEL_STACK_DIRECTLINK OR CFG_KERNEL_STACK_USERSPACE_DAEMON) + +FIND_PROGRAM(PCAP_CONFIG NAMES pcap-config PATHS) + +IF (PCAP_CONFIG) + MESSAGE (STATUS "Looking for pcap-config... ${PCAP_CONFIG}") + + EXECUTE_PROCESS (COMMAND ${PCAP_CONFIG} --libs ${PCAP_CONFIG_OPTS} + OUTPUT_VARIABLE PCAP_LDFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) + EXECUTE_PROCESS (COMMAND ${PCAP_CONFIG} --cflags ${PCAP_CONFIG_OPTS} + OUTPUT_VARIABLE PCAP_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) + + SET (ARCH_LIBRARIES ${ARCH_LIBRARIES} ${PCAP_LDFLAGS}) +ELSE (PCAP_CONFIG) + MESSAGE (STATUS "pcap-config not found, using defaults...") + SET (ARCH_LIBRARIES ${ARCH_LIBRARIES} pcap) +ENDIF (PCAP_CONFIG) + +ENDIF (CFG_KERNEL_STACK_DIRECTLINK OR CFG_KERNEL_STACK_USERSPACE_DAEMON) +SET (ARCH_LIBRARIES ${ARCH_LIBRARIES} pthread rt) + +################################################################################ +# Set architecture specific installation files + +INSTALL(PROGRAMS ${TOOLS_DIR}/linux/set_prio DESTINATION ${PROJECT_NAME}) diff --git a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_mn_console/CMakeLists.txt b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_mn_console/CMakeLists.txt index 1f8c83856..15ecd5d1e 100644 --- a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_mn_console/CMakeLists.txt +++ b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_mn_console/CMakeLists.txt @@ -4,6 +4,7 @@ # # Copyright (c) 2017, 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 @@ -126,6 +127,8 @@ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") include(linux.cmake) ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Windows") include (windows.cmake) +ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "XiUOS") + include(xiuos.cmake) ELSE() MESSAGE(FATAL_ERROR "System ${CMAKE_SYSTEM_NAME} is not supported!") ENDIF() @@ -146,7 +149,11 @@ SOURCE_GROUP("Object Dictionary" FILES ################################################################################ # Set the executable -ADD_EXECUTABLE(demo_mn_console ${DEMO_SOURCES} ${DEMO_ARCH_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/mnobd.cdc) +IF(CMAKE_SYSTEM_NAME STREQUAL "XiUOS") + ADD_LIBRARY(demo_mn_console ${DEMO_SOURCES} ${DEMO_ARCH_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/mnobd.cdc) +ELSE() + ADD_EXECUTABLE(demo_mn_console ${DEMO_SOURCES} ${DEMO_ARCH_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/mnobd.cdc) +ENDIF() SET_PROPERTY(TARGET demo_mn_console PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUG;DEF_DEBUG_LVL=${CFG_DEBUG_LVL}) @@ -164,5 +171,5 @@ TARGET_LINK_LIBRARIES(demo_mn_console ${ARCH_LIBRARIES}) ################################################################################ # Installation rules -INSTALL(TARGETS demo_mn_console RUNTIME DESTINATION ${PROJECT_NAME}) +INSTALL(TARGETS demo_mn_console DESTINATION ${PROJECT_NAME}) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mnobd.cdc DESTINATION ${PROJECT_NAME}) diff --git a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_mn_console/build/xiuos/.gitignore b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_mn_console/build/xiuos/.gitignore new file mode 100644 index 000000000..3aac69562 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_mn_console/build/xiuos/.gitignore @@ -0,0 +1,3 @@ +* +.* +!.gitignore diff --git a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_mn_console/src/main.c b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_mn_console/src/main.c index 89302cf6a..ff522965d 100644 --- a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_mn_console/src/main.c +++ b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_mn_console/src/main.c @@ -151,7 +151,11 @@ This is the main function of the openPOWERLINK console MN demo application. \ingroup module_demo_mn_console */ //------------------------------------------------------------------------------ +#ifdef __XIUOS__ +int OplkDemoMnConsole(int argc, char* argv[]) +#else int main(int argc, char* argv[]) +#endif { tOplkError ret = kErrorOk; tOptions opts; diff --git a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_mn_console/xiuos.cmake b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_mn_console/xiuos.cmake new file mode 100644 index 000000000..24f976eb8 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/apps/demo_mn_console/xiuos.cmake @@ -0,0 +1,78 @@ +################################################################################ +# +# XiUOS definitions for demo_mn_console application +# +# Copyright (c) 2017, B&R Industrial Automation GmbH +# 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. +################################################################################ + +################################################################################ +# Set architecture specific definitions + +ADD_DEFINITIONS(-D__XIUOS__ -D_GNU_SOURCE -D_POSIX_C_SOURCE=200112L) +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -std=c99") + +################################################################################ +# Set architecture specific sources and include directories + +SET (DEMO_ARCH_SOURCES + ${COMMON_SOURCE_DIR}/system/system-xiuos.c + ${CONTRIB_SOURCE_DIR}/console/console-xiuos.c + ${CONTRIB_SOURCE_DIR}/trace/trace-printf.c + ) + +################################################################################ +# Set architecture specific libraries + +IF (NOT CFG_COMPILE_SHARED_LIBRARY) + SET(PCAP_CONFIG_OPTS --static) +ENDIF() + +IF (CFG_KERNEL_STACK_DIRECTLINK OR CFG_KERNEL_STACK_USERSPACE_DAEMON) + +FIND_PROGRAM(PCAP_CONFIG NAMES pcap-config PATHS) + +IF (PCAP_CONFIG) + MESSAGE (STATUS "Looking for pcap-config... ${PCAP_CONFIG}") + + EXECUTE_PROCESS (COMMAND ${PCAP_CONFIG} --libs ${PCAP_CONFIG_OPTS} + OUTPUT_VARIABLE PCAP_LDFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) + EXECUTE_PROCESS (COMMAND ${PCAP_CONFIG} --cflags ${PCAP_CONFIG_OPTS} + OUTPUT_VARIABLE PCAP_CFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE) + + SET (ARCH_LIBRARIES ${ARCH_LIBRARIES} ${PCAP_LDFLAGS}) +ELSE (PCAP_CONFIG) + MESSAGE (STATUS "pcap-config not found, using defaults...") + SET (ARCH_LIBRARIES ${ARCH_LIBRARIES} pcap) +ENDIF (PCAP_CONFIG) + +ENDIF (CFG_KERNEL_STACK_DIRECTLINK OR CFG_KERNEL_STACK_USERSPACE_DAEMON) +SET (ARCH_LIBRARIES ${ARCH_LIBRARIES} pthread rt) + +################################################################################ +# Set architecture specific installation files + +INSTALL(PROGRAMS ${TOOLS_DIR}/linux/set_prio DESTINATION ${PROJECT_NAME}) diff --git a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/contrib/console/console-xiuos.c b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/contrib/console/console-xiuos.c new file mode 100644 index 000000000..f53b6d726 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/contrib/console/console-xiuos.c @@ -0,0 +1,82 @@ +/** +******************************************************************************** +\file console-xiuos.c + +\brief Console input/output implementation for XiUOS + +This file contains the console input/output implementation for XiUOS. + +\ingroup module_console +*******************************************************************************/ + +/*------------------------------------------------------------------------------ +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 +#include +#include + +//============================================================================// +// P U B L I C F U N C T I O N S // +//============================================================================// + +//------------------------------------------------------------------------------ +/** +\brief Get character from console + +This function reads a character from the console input. It uses the +termios library. + +\return The function returns the read character. + +\ingroup module_console +*/ +//------------------------------------------------------------------------------ +int console_getch(void) +{ + return getchar(); +} + +//------------------------------------------------------------------------------ +/** +\brief Detecting a keystroke + +The function checks the console for a keystroke. + +\return The function returns 0 if no key has been pressed or 1 if a key has + been pressed. + +\ingroup module_console +*/ +//------------------------------------------------------------------------------ +int console_kbhit(void) +{ + return 1; +} diff --git a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/stack/src/arch/xiuos/target-xiuos.c b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/stack/src/arch/xiuos/target-xiuos.c index e7f2a9c69..985f9b491 100644 --- a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/stack/src/arch/xiuos/target-xiuos.c +++ b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/stack/src/arch/xiuos/target-xiuos.c @@ -51,6 +51,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include #include //============================================================================// @@ -136,37 +137,7 @@ milliseconds has elapsed. //------------------------------------------------------------------------------ void target_msleep(UINT32 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; - } + DelayKTask(milliSeconds_p); } //------------------------------------------------------------------------------ diff --git a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/stack/src/kernel/edrv/edrv-xiuos.c b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/stack/src/kernel/edrv/edrv-xiuos.c index 748a21407..c3cd25a3e 100644 --- a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/stack/src/kernel/edrv/edrv-xiuos.c +++ b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/stack/src/kernel/edrv/edrv-xiuos.c @@ -229,7 +229,7 @@ tOplkError edrv_exit(void) edrvInstance_l.fStartCommunication = FALSE; // Wait to terminate thread safely - usleep(100000); + target_msleep(100); if (edrvInstance_l.fThreadIsExited) pthread_cancel(edrvInstance_l.hThread); diff --git a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/stack/src/kernel/timer/hrestimer-xiuos.c b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/stack/src/kernel/timer/hrestimer-xiuos.c index 1b692554a..9acbe3edf 100644 --- a/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/stack/src/kernel/timer/hrestimer-xiuos.c +++ b/APP_Framework/Framework/connection/industrial_ethernet/openPOWERLINK/stack/src/kernel/timer/hrestimer-xiuos.c @@ -461,7 +461,6 @@ flag m_fContinue is set the thread loops until the timer is deleted. //------------------------------------------------------------------------------ static void* timerThread(void* pArgument_p) { - int iRet; tHresTimerInfo* pTimerInfo; struct timespec startTime, timeout; ULONGLONG period; @@ -504,13 +503,7 @@ static void* timerThread(void* pArgument_p) do { /* sleep until timeout */ - iRet = usleep(period / 1000); - if (iRet < 0) - { - DEBUG_LVL_ERROR_TRACE("%s(): Error in clock_nanosleep!\n", - __func__); - /* todo how to signal that timeout wasn't correct? */ - } + target_msleep(period / 1000000); FTRACE_MARKER("HighReskTimer(%d) expired (%d ns)", (int)pArgument_p, period); diff --git a/APP_Framework/Framework/connection/industrial_ethernet/powerlink_demo.c b/APP_Framework/Framework/connection/industrial_ethernet/powerlink_demo.c new file mode 100644 index 000000000..a484b1a47 --- /dev/null +++ b/APP_Framework/Framework/connection/industrial_ethernet/powerlink_demo.c @@ -0,0 +1,28 @@ +#include +#include + +#ifdef POWERLINK_MN +extern int OplkDemoMnConsole(int argc, char *argv[]); + +SHELL_EXPORT_CMD( + SHELL_CMD_PERMISSION(0) | + SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | + SHELL_CMD_PARAM_NUM(0) | + SHELL_CMD_DISABLE_RETURN, + OplkDemoMnConsole, + OplkDemoMnConsole, + openPOWERLINK demo MN (console version)); +#endif + +#ifdef POWERLINK_CN +extern int OplkDemoCnConsole(int argc, char *argv[]); + +SHELL_EXPORT_CMD( + SHELL_CMD_PERMISSION(0) | + SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | + SHELL_CMD_PARAM_NUM(0) | + SHELL_CMD_DISABLE_RETURN, + OplkDemoCnConsole, + OplkDemoCnConsole, + openPOWERLINK demo CN (console version)); +#endif diff --git a/APP_Framework/Framework/transform_layer/xizi/user_api/posix_support/include/pthread.h b/APP_Framework/Framework/transform_layer/xizi/user_api/posix_support/include/pthread.h index 19ea1de46..fd108553c 100644 --- a/APP_Framework/Framework/transform_layer/xizi/user_api/posix_support/include/pthread.h +++ b/APP_Framework/Framework/transform_layer/xizi/user_api/posix_support/include/pthread.h @@ -67,6 +67,7 @@ typedef int pid_t; #define SCHED_OTHER 0 #define SCHED_FIFO 1 #define SCHED_RR 2 +#define SCHED_IDLE 5 /* function in pthread.c */ int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)); diff --git a/APP_Framework/Framework/transform_layer/xizi/user_api/posix_support/pthread.c b/APP_Framework/Framework/transform_layer/xizi/user_api/posix_support/pthread.c index 7d1cef960..924b39179 100644 --- a/APP_Framework/Framework/transform_layer/xizi/user_api/posix_support/pthread.c +++ b/APP_Framework/Framework/transform_layer/xizi/user_api/posix_support/pthread.c @@ -67,6 +67,12 @@ pthread_t pthread_self(void){ return pthread; } +int pthread_setschedparam(pthread_t thread, int policy, + const struct sched_param *pParam) +{ + return 0; +} + int pthread_setschedprio(pthread_t thread, int prio) { //add syscall @@ -98,6 +104,11 @@ int pthread_setcanceltype(int type, int *oldtype) return -1; } +int pthread_join(pthread_t thread, void **retval) +{ + return -1; +} + int pthread_kill(pthread_t thread, int sig) { /* This api should not be used, and will not be supported */