-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
hari
committed
Jul 22, 2023
0 parents
commit ec86686
Showing
111 changed files
with
24,772 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
cmake_minimum_required(VERSION 3.9) | ||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules") | ||
project(soem | ||
DESCRIPTION "Simple Open EtherCAT Master" | ||
VERSION 1.4.0 | ||
LANGUAGES C | ||
) | ||
|
||
if(NOT CMAKE_C_STANDARD) | ||
set(CMAKE_C_STANDARD 99) | ||
endif() | ||
|
||
if(NOT CMAKE_CXX_STANDARD) | ||
set(CMAKE_CXX_STANDARD 17) | ||
endif() | ||
|
||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-Wall -Wextra -Wpedantic) | ||
endif() | ||
|
||
# find dependencies | ||
find_package(ament_cmake REQUIRED) | ||
|
||
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) | ||
# Default to installing in SOEM source directory | ||
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_LIST_DIR}/install) | ||
endif() | ||
|
||
set(SOEM_INCLUDE_INSTALL_DIR include) | ||
set(SOEM_LIB_INSTALL_DIR lib) | ||
|
||
if(WIN32) | ||
set(OS "win32") | ||
include_directories(oshw/win32/wpcap/Include) | ||
if(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
link_directories(${CMAKE_CURRENT_LIST_DIR}/oshw/win32/wpcap/Lib/x64) | ||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) | ||
link_directories(${CMAKE_CURRENT_LIST_DIR}/oshw/win32/wpcap/Lib) | ||
endif() | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_SECURE_NO_WARNINGS") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX") | ||
set(OS_LIBS wpcap.lib Packet.lib Ws2_32.lib Winmm.lib) | ||
elseif(UNIX AND NOT APPLE) | ||
set(OS "linux") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror") | ||
set(OS_LIBS pthread rt) | ||
elseif(APPLE) | ||
# This must come *before* linux or MacOSX will identify as Unix. | ||
set(OS "macosx") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror") | ||
set(OS_LIBS pthread pcap) | ||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "rt-kernel") | ||
set(OS "rtk") | ||
message(STATUS "ARCH is ${ARCH}") | ||
message(STATUS "BSP is ${BSP}") | ||
include_directories(oshw/${OS}/${ARCH}) | ||
file(GLOB OSHW_EXTRA_SOURCES oshw/${OS}/${ARCH}/*.c) | ||
set(OSHW_SOURCES "${OS_HW_SOURCES} ${OSHW_ARCHSOURCES}") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-but-set-variable") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format") | ||
set(OS_LIBS "-Wl,--start-group -l${BSP} -l${ARCH} -lkern -ldev -lsio -lblock -lfs -lusb -llwip -leth -li2c -lrtc -lcan -lnand -lspi -lnor -lpwm -ladc -ltrace -lc -lm -Wl,--end-group") | ||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "rtems") | ||
message(STATUS "Building for RTEMS") | ||
set(OS "rtems") | ||
set(SOEM_LIB_INSTALL_DIR ${LIB_DIR}) | ||
set(BUILD_TESTS FALSE) | ||
endif() | ||
|
||
message(STATUS "OS is ${OS}") | ||
|
||
file(GLOB SOEM_SOURCES soem/*.c) | ||
file(GLOB OSAL_SOURCES osal/${OS}/*.c) | ||
file(GLOB OSHW_SOURCES oshw/${OS}/*.c) | ||
|
||
file(GLOB SOEM_HEADERS soem/*.h) | ||
file(GLOB OSAL_HEADERS osal/osal.h osal/${OS}/*.h) | ||
file(GLOB OSHW_HEADERS oshw/${OS}/*.h) | ||
|
||
add_library(soem SHARED | ||
${SOEM_SOURCES} | ||
${OSAL_SOURCES} | ||
${OSHW_SOURCES} | ||
${OSHW_EXTRA_SOURCES} | ||
) | ||
|
||
target_link_libraries(soem ${OS_LIBS}) | ||
|
||
target_include_directories(soem PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/soem> | ||
$<INSTALL_INTERFACE:include> | ||
) | ||
|
||
target_include_directories(soem PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/osal> | ||
$<INSTALL_INTERFACE:include> | ||
) | ||
|
||
target_include_directories(soem PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/osal/${OS}> | ||
$<INSTALL_INTERFACE:include> | ||
) | ||
|
||
|
||
target_include_directories(soem PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/oshw/${OS}> | ||
$<INSTALL_INTERFACE:include> | ||
) | ||
|
||
message(STATUS "LIB_DIR: ${SOEM_LIB_INSTALL_DIR}") | ||
|
||
# Export to lower stream files | ||
ament_export_targets(soem_EXPORT HAS_LIBRARY_TARGET) | ||
|
||
# Registering headers | ||
install(FILES | ||
${SOEM_HEADERS} | ||
${OSAL_HEADERS} | ||
${OSHW_HEADERS} | ||
DESTINATION ${SOEM_INCLUDE_INSTALL_DIR} | ||
) | ||
|
||
install(TARGETS soem | ||
EXPORT soem_EXPORT | ||
LIBRARY DESTINATION ${SOEM_LIB_INSTALL_DIR} | ||
ARCHIVE DESTINATION ${SOEM_LIB_INSTALL_DIR} | ||
RUNTIME DESTINATION bin | ||
INCLUDES DESTINATION ${SOEM_INCLUDE_INSTALL_DIR} | ||
) | ||
|
||
ament_package() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
Simple Open EtherCAT Master Library | ||
|
||
Copyright (C) 2005-2017 Speciaal Machinefabriek Ketels v.o.f. | ||
Copyright (C) 2005-2017 Arthur Ketels | ||
Copyright (C) 2008-2009 TU/e Technische Universiteit Eindhoven | ||
Copyright (C) 2009-2017 rt-labs AB, Sweden | ||
|
||
SOEM is free software; you can redistribute it and/or modify it under the terms | ||
of the GNU General Public License version 2 as published by the Free Software | ||
Foundation. | ||
|
||
SOEM is distributed in the hope that it will be useful, but WITHOUT ANY | ||
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
|
||
As a special exception, if other files instantiate templates or use macros or | ||
inline functions from this file, or you compile this file and link it with other | ||
works to produce a work based on this file, this file does not by itself cause | ||
the resulting work to be covered by the GNU General Public License. However the | ||
source code for this file must still be made available in accordance with | ||
section (3) of the GNU General Public License. | ||
|
||
This exception does not invalidate any other reasons why a work based on this | ||
file might be covered by the GNU General Public License. | ||
|
||
The EtherCAT Technology, the trade name and logo "EtherCAT" are the intellectual | ||
property of, and protected by Beckhoff Automation GmbH. You can use SOEM for the | ||
sole purpose of creating, using and/or selling or otherwise distributing an | ||
EtherCAT network master provided that an EtherCAT Master License is obtained | ||
from Beckhoff Automation GmbH. | ||
|
||
In case you did not receive a copy of the EtherCAT Master License along with | ||
SOEM write to Beckhoff Automation GmbH, Eiserstrasse 5, D-33415 Verl, Germany | ||
(www.beckhoff.com). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# ROS2-SOEM | ||
![Static Badge](https://img.shields.io/badge/license-GPLv2-red) | ||
![Static Badge](https://img.shields.io/badge/Test_on_-ros2_humble_in_Ubuntu22.04-blue) | ||
|
||
|
||
This package is down-stream of SOEM project, you can view the origin project [HERE](https://github.com/OpenEtherCATsociety/SOEM). This project have removed all the examples, if you want to build the example program, please download the up-stream package. | ||
|
||
## Install | ||
ROS2-SOEM is a ros2 package, to install and use it in your project, please running the following steps in your terminal: | ||
|
||
```bash | ||
$ cd ${your_worksapce_path}/src | ||
$ git clone https://github.com/UoN-Hari/ROS2-SOEM soem | ||
$ cd .. | ||
$ colcon build | ||
``` | ||
|
||
## Usage | ||
To use SOEM in your project, please add following lines in your `package.xml`, | ||
|
||
```XML | ||
<build_depend>soem</build_depend> | ||
<exec_depend>soem</exec_depend> | ||
``` | ||
|
||
And in your `CMakeLists.txt`, add the corressponding dependency, | ||
|
||
```cmake | ||
# Add soem package here | ||
find_package(soem REQUIRED) | ||
# No need to derive | ||
include_directories( | ||
include | ||
) | ||
# Your executable generation command, no need to derive | ||
add_executable(${executable_name} SOURCES) | ||
# Add soem package here | ||
ament_target_dependencies(${executable_name} | ||
soem ... | ||
) | ||
# No need to derive | ||
install(TARGETS ${executable_name} | ||
DESTINATION lib/${PROJECT_NAME} | ||
) | ||
``` | ||
|
||
## TODO | ||
* Multi-platform test | ||
* Build binary package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
message("rt-kernel-C.cmake") | ||
|
||
# Determine toolchain | ||
include(CMakeForceCompiler) | ||
|
||
if(${ARCH} MATCHES "kinetis") | ||
cmake_force_c_compiler(arm-eabi-gcc GNU) | ||
cmake_force_cxx_compiler(arm-eabi-g++ GNU) | ||
elseif(${ARCH} MATCHES "bfin") | ||
cmake_force_c_compiler(bfin-elf-gcc GNU) | ||
cmake_force_cxx_compiler(bfin-elf-g++ GNU) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
set(MACHINE "-mcpu=bf537") | ||
set(LDFLAGS "-T${RT_KERNEL_PATH}/bsp/${BSP}/${BSP}.ld") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
message("rt-kernel-gcc-kinetis.cmake") | ||
|
||
#SET_PROPERTY(GLOBAL PROPERTY ARCH kinetis) | ||
#SET_PROPERTY(GLOBAL PROPERTY BSP twrk60) | ||
|
||
set(MACHINE "-mfpu=vfp -mcpu=cortex-m3 -mthumb") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
message("rt-kernel-gcc.cmake") | ||
|
||
set(CMAKE_C_OUTPUT_EXTENSION .o) | ||
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) | ||
|
||
set(CFLAGS "${CFLAGS} -Wall -Wextra -Wno-unused-parameter -Werror") | ||
set(CFLAGS "${CFLAGS} -fomit-frame-pointer -fno-strict-aliasing -fshort-wchar") | ||
#set(CFLAGS" ${CFLAGS} -B$(GCC_PATH)/libexec/gcc") | ||
|
||
set(CXXFLAGS "${CXXFLAGS} -fno-rtti -fno-exceptions") | ||
|
||
set(LDFLAGS "${LDFLAGS} -nostartfiles") | ||
|
||
set(CMAKE_C_FLAGS "${CFLAGS} ${MACHINE}" CACHE STRING "") | ||
set(CMAKE_EXE_LINKER_FLAGS "${MACHINE} ${LDFLAGS}" CACHE STRING "") | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
if(__RTK_CMAKE_INCLUDED) | ||
return() | ||
endif() | ||
set(__RTK_CMAKE_INCLUDED TRUE) | ||
message("rt-kernel.cmake") | ||
|
||
include_directories( | ||
${RT_KERNEL_PATH}/include | ||
${RT_KERNEL_PATH}/include/kern | ||
${RT_KERNEL_PATH}/kern | ||
${RT_KERNEL_PATH}/include/drivers | ||
${RT_KERNEL_PATH}/include/arch/${ARCH} | ||
${RT_KERNEL_PATH}/bsp/${BSP}/include | ||
${RT_KERNEL_PATH}/lwip/src/include | ||
${RT_KERNEL_PATH}/lwip/src/include/ipv4 | ||
) | ||
|
||
link_directories( | ||
${RT_KERNEL_PATH}/lib/${ARCH} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
message("rtems.cmake") | ||
|
||
set(ARCH ${HOST}) | ||
set(BSP ${RTEMS_BSP}) | ||
|
||
set(CMAKE_C_COMPILER_FORCED true) | ||
set(CMAKE_CXX_COMPILER_FORCED true) | ||
set(CMAKE_C_COMPILER ${RTEMS_TOOLS_PATH}/bin/${ARCH}-gcc) | ||
set(CMAKE_CXX_COMPILER ${RTEMS_TOOLS_PATH}/bin/${ARCH}-g++) | ||
|
||
set(SOEM_INCLUDE_INSTALL_DIR ${INCLUDE_DIR}/soem) | ||
set(SOEM_LIB_INSTALL_DIR ${LIB_DIR}) | ||
|
||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${HOST_C_FLAGS}") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${HOST_CXX_FLAGS}") | ||
|
||
if(NOT ${HOST_LIBS} STREQUAL "") | ||
set(OS_LIBS "rtemscpu bsd ${HOST_LIBS}") | ||
else() | ||
set(OS_LIBS "-lrtemscpu -lbsd") | ||
endif() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
message("rt-kernel-kinetis.cmake") | ||
|
||
set(CMAKE_SYSTEM_NAME rt-kernel) | ||
set(CMAKE_SYSTEM_VERSION 1) | ||
set(CMAKE_SYSTEM_PROCESSOR bfin) | ||
|
||
set(ARCH bfin CACHE STRING "Architecture") | ||
set(BSP stamp537 CACHE STRING "Board") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
message("rt-kernel-kinetis.cmake") | ||
|
||
set(CMAKE_SYSTEM_NAME rt-kernel) | ||
set(CMAKE_SYSTEM_VERSION 1) | ||
set(CMAKE_SYSTEM_PROCESSOR kinetis) | ||
|
||
set(ARCH kinetis CACHE STRING "Architecture") | ||
set(BSP twrk60 CACHE STRING "Board") |
Oops, something went wrong.