diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..129c0dd --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "sitara_depot"] + path = sitara_depot + url = http://server_gorbunov:3000/SmartForce4.0/sitara_depot.git + branch = master diff --git a/libs/include/pnet_version.h b/libs/include/pnet_version.h index e796480..bf55875 100644 --- a/libs/include/pnet_version.h +++ b/libs/include/pnet_version.h @@ -16,7 +16,7 @@ #ifndef PNET_VERSION_H #define PNET_VERSION_H -/* #undef PROFINET_GIT_REVISION */ +#define PROFINET_GIT_REVISION "f6bbef1-dirty" #if !defined(PNET_VERSION_BUILD) && defined(PROFINET_GIT_REVISION) #define PNET_VERSION_BUILD PROFINET_GIT_REVISION diff --git a/libs/lib/arm_a15/libosal.a b/libs/lib/arm_a15/libosal.a new file mode 100644 index 0000000..cc3a971 Binary files /dev/null and b/libs/lib/arm_a15/libosal.a differ diff --git a/libs/lib/arm_a15/libosald.a b/libs/lib/arm_a15/libosald.a new file mode 100644 index 0000000..177c224 Binary files /dev/null and b/libs/lib/arm_a15/libosald.a differ diff --git a/libs/lib/arm_a15/libprofinet.a b/libs/lib/arm_a15/libprofinet.a new file mode 100644 index 0000000..8afca5a Binary files /dev/null and b/libs/lib/arm_a15/libprofinet.a differ diff --git a/libs/lib/arm_a15/libprofinetd.a b/libs/lib/arm_a15/libprofinetd.a new file mode 100644 index 0000000..44d882c Binary files /dev/null and b/libs/lib/arm_a15/libprofinetd.a differ diff --git a/profinet_stack/osal/.vscode/settings.json b/profinet_stack/osal/.vscode/settings.json new file mode 100644 index 0000000..3e57f48 --- /dev/null +++ b/profinet_stack/osal/.vscode/settings.json @@ -0,0 +1,73 @@ +{ + "cmake.configureArgs": [ + "-DSITARA=ON", + "-DCMAKE_TOOLCHAIN_FILE=${workspaceFolder}/../../sitara_depot/compile/toolchain.cmake" + ], + "files.associations": { + "typeinfo": "c", + "cctype": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "*.tcc": "cpp", + "cstdint": "cpp", + "deque": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "optional": "cpp", + "random": "cpp", + "string": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "fstream": "cpp", + "initializer_list": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "new": "cpp", + "ostream": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "cinttypes": "cpp", + "cstring": "cpp", + "thread": "cpp", + "ctime": "cpp", + "chrono": "cpp", + "condition_variable": "cpp", + "map": "cpp", + "ratio": "cpp", + "mutex": "cpp", + "any": "cpp", + "codecvt": "cpp", + "forward_list": "cpp", + "list": "cpp", + "iomanip": "cpp", + "valarray": "cpp", + "bitset": "cpp", + "complex": "cpp", + "set": "cpp", + "typeindex": "cpp", + "variant": "cpp", + "cfenv": "cpp" + } +} \ No newline at end of file diff --git a/profinet_stack/osal/CMakeLists.txt b/profinet_stack/osal/CMakeLists.txt index f0d6857..0aac537 100644 --- a/profinet_stack/osal/CMakeLists.txt +++ b/profinet_stack/osal/CMakeLists.txt @@ -51,32 +51,62 @@ configure_file ( version.h.in ${OSAL_BINARY_DIR}/src/version.h ) +#------------------------------------------------------------------------ +# +set(INSTALL_PATH ${CMAKE_SOURCE_DIR}/../../libs) +# +set(INSTALL_PATH_LIB ${INSTALL_PATH}/lib) + +if(SITARA) + message("-- Building for cortex-a15 (Sitara)") + set(SITARA_DEPOT ${CMAKE_SOURCE_DIR}/../../sitara_depot) + + set(INSTALL_PATH_LIB ${INSTALL_PATH_LIB}/arm_a15) + + include(${SITARA_DEPOT}/compile/sitara_compile_flags.cmake) + +else() +set(INSTALL_PATH_LIB ${INSTALL_PATH_LIB}/x86_64) + message("-- Building for x86") +endif() +# h- +set(INSTALL_PATH_INC ${INSTALL_PATH}/include) + +#------------------------------------------------------------------------ # Add platform-dependent targets early, so they can be configured by # platform -add_library(osal "") + +# +set(LIB_NAME osal) +# d: osald +if (CMAKE_BUILD_TYPE STREQUAL Debug) + set(LIB_NAME ${LIB_NAME}d) +endif() + +add_library(${LIB_NAME} "") # Use position independent code if platform supports shared libraries get_property(SUPPORTS_SHARED GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS) if (SUPPORTS_SHARED) - set_property(TARGET osal PROPERTY POSITION_INDEPENDENT_CODE ON) + set_property(TARGET ${LIB_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON) endif() -if (CMAKE_PROJECT_NAME STREQUAL OSAL AND BUILD_TESTING) - add_executable(osal_test "") -endif() +#if (CMAKE_PROJECT_NAME STREQUAL OSAL AND BUILD_TESTING) +# add_executable(osal_test "") +#endif() # Platform configuration include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/${CMAKE_SYSTEM_NAME}.cmake) -set_target_properties (osal +set_target_properties (${LIB_NAME} PROPERTIES C_STANDARD 99 ) -target_compile_features(osal PUBLIC c_std_99) +target_compile_features(${LIB_NAME} PUBLIC c_std_99) -target_include_directories(osal +target_include_directories(${LIB_NAME} PUBLIC $ $ @@ -86,8 +116,9 @@ target_include_directories(osal ) install( - TARGETS osal + TARGETS ${LIB_NAME} EXPORT OsalTargets + DESTINATION ${INSTALL_PATH_LIB} ) install( @@ -112,14 +143,14 @@ install(FILES install(FILES include/osal.h include/osal_log.h - DESTINATION include + DESTINATION ${INSTALL_PATH_INC} ) -if (CMAKE_PROJECT_NAME STREQUAL OSAL AND BUILD_TESTING) - add_subdirectory (test) - include(AddGoogleTest) - add_gtest(osal_test) -endif() +#if (CMAKE_PROJECT_NAME STREQUAL OSAL AND BUILD_TESTING) +# add_subdirectory (test) +# include(AddGoogleTest) +# add_gtest(osal_test) +#endif() # Doxygen configuration cmake_policy(SET CMP0057 NEW) diff --git a/profinet_stack/osal/cmake/Linux.cmake b/profinet_stack/osal/cmake/Linux.cmake index 311e96d..adcb5a1 100644 --- a/profinet_stack/osal/cmake/Linux.cmake +++ b/profinet_stack/osal/cmake/Linux.cmake @@ -19,12 +19,12 @@ option (USE_SCHED_FIFO "Use SCHED_FIFO policy. May require extra privileges to run" OFF) -target_sources(osal PRIVATE +target_sources(${LIB_NAME} PRIVATE src/linux/osal.c src/linux/osal_log.c ) -target_compile_options(osal +target_compile_options(${LIB_NAME} PRIVATE -Wall -Wextra @@ -35,11 +35,11 @@ target_compile_options(osal $<$:--coverage> ) -target_include_directories(osal PUBLIC +target_include_directories(${LIB_NAME} PUBLIC $ ) -target_link_libraries(osal PUBLIC +target_link_libraries(${LIB_NAME} PUBLIC Threads::Threads rt INTERFACE @@ -49,7 +49,7 @@ target_link_libraries(osal PUBLIC install(FILES src/linux/sys/osal_cc.h src/linux/sys/osal_sys.h - DESTINATION include/sys + DESTINATION ${INSTALL_PATH_INC}/sys ) if (BUILD_TESTING) diff --git a/profinet_stack/p-net/.gitignore b/profinet_stack/p-net/.gitignore index f783b9b..2deb620 100644 --- a/profinet_stack/p-net/.gitignore +++ b/profinet_stack/p-net/.gitignore @@ -40,9 +40,6 @@ doc/_copied *.x86_64 *.hex -# Editor files -.vscode/ - # Sampleapp dummy LED files pnet_led*.txt diff --git a/profinet_stack/p-net/.vscode/settings.json b/profinet_stack/p-net/.vscode/settings.json new file mode 100644 index 0000000..3e57f48 --- /dev/null +++ b/profinet_stack/p-net/.vscode/settings.json @@ -0,0 +1,73 @@ +{ + "cmake.configureArgs": [ + "-DSITARA=ON", + "-DCMAKE_TOOLCHAIN_FILE=${workspaceFolder}/../../sitara_depot/compile/toolchain.cmake" + ], + "files.associations": { + "typeinfo": "c", + "cctype": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "*.tcc": "cpp", + "cstdint": "cpp", + "deque": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "optional": "cpp", + "random": "cpp", + "string": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "fstream": "cpp", + "initializer_list": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "new": "cpp", + "ostream": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "cinttypes": "cpp", + "cstring": "cpp", + "thread": "cpp", + "ctime": "cpp", + "chrono": "cpp", + "condition_variable": "cpp", + "map": "cpp", + "ratio": "cpp", + "mutex": "cpp", + "any": "cpp", + "codecvt": "cpp", + "forward_list": "cpp", + "list": "cpp", + "iomanip": "cpp", + "valarray": "cpp", + "bitset": "cpp", + "complex": "cpp", + "set": "cpp", + "typeindex": "cpp", + "variant": "cpp", + "cfenv": "cpp" + } +} \ No newline at end of file diff --git a/profinet_stack/p-net/CMakeLists.txt b/profinet_stack/p-net/CMakeLists.txt index 27b53a9..47d4500 100644 --- a/profinet_stack/p-net/CMakeLists.txt +++ b/profinet_stack/p-net/CMakeLists.txt @@ -43,7 +43,7 @@ if (CMAKE_PROJECT_NAME STREQUAL PROFINET) message(STATUS "Building for ${CMAKE_SYSTEM_NAME}") endif() -include(AddOsal) +#include(AddOsal) include(GenerateExportHeader) include(CMakeDependentOption) include(GetGitRevision) @@ -165,35 +165,75 @@ configure_file ( ${PROFINET_BINARY_DIR}/include/pnet_options.h ) +#------------------------------------------------------------------------ +# +set(INSTALL_PATH ${CMAKE_SOURCE_DIR}/../../libs) +# +set(INSTALL_PATH_LIB ${INSTALL_PATH}/lib) + +if(SITARA) + message("-- Building for cortex-a15 (Sitara)") + set(SITARA_DEPOT ${CMAKE_SOURCE_DIR}/../../sitara_depot) + + set(INSTALL_PATH_LIB ${INSTALL_PATH_LIB}/arm_a15) + + include(${SITARA_DEPOT}/compile/sitara_compile_flags.cmake) + +else() +set(INSTALL_PATH_LIB ${INSTALL_PATH_LIB}/x86_64) + message("-- Building for x86") +endif() +# h- +set(INSTALL_PATH_INC ${INSTALL_PATH}/include) + +set(OSAL_NAME osal) + +if (CMAKE_BUILD_TYPE STREQUAL Debug) + set(OSAL_NAME ${OSAL_NAME}d) +endif() + +#------------------------------------------------------------------------ + + # Add platform-dependent targets early, so they can be configured by # platform -add_library(profinet "") -add_executable(pn_dev "") + +# +set(LIB_NAME profinet) +# d: osald +if (CMAKE_BUILD_TYPE STREQUAL Debug) + set(LIB_NAME ${LIB_NAME}d) +endif() + +add_library(${LIB_NAME} "") + +#add_library(profinet "") +#add_executable(pn_dev "") if (PNET_OPTION_DRIVER_ENABLE) include(${CMAKE_CURRENT_SOURCE_DIR}/src/drivers/drivers.cmake) endif () -if (CMAKE_PROJECT_NAME STREQUAL PROFINET AND BUILD_TESTING) - add_executable(pf_test "") -endif() +#if (CMAKE_PROJECT_NAME STREQUAL PROFINET AND BUILD_TESTING) +# add_executable(pf_test "") +#endif() # Platform configuration include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/${CMAKE_SYSTEM_NAME}.cmake) -generate_export_header(profinet +generate_export_header(${LIB_NAME} BASE_NAME pnet EXPORT_FILE_NAME ${PROFINET_BINARY_DIR}/include/pnet_export.h ) -set_target_properties (profinet pn_dev +set_target_properties (${LIB_NAME} PROPERTIES C_STANDARD 11 ) -target_compile_features(profinet PUBLIC c_std_99) +target_compile_features(${LIB_NAME} PUBLIC c_std_99) -target_include_directories(profinet +target_include_directories(${LIB_NAME} PUBLIC $ $ @@ -203,14 +243,19 @@ target_include_directories(profinet src src/common src/device + ${INSTALL_PATH_INC} + ${INSTALL_PATH_INC}/sys + ${INSTALL_PATH_INC}/x86_64 ) -target_link_libraries(profinet PUBLIC osal) +target_link_directories(${LIB_NAME} PRIVATE ${INSTALL_PATH_LIB}) + +target_link_libraries(${LIB_NAME} PUBLIC ${OSAL_NAME}) install ( - TARGETS profinet + TARGETS ${LIB_NAME} EXPORT ProfinetConfig - DESTINATION lib + DESTINATION ${INSTALL_PATH_LIB} ) install( @@ -223,17 +268,17 @@ install (FILES ${PROFINET_BINARY_DIR}/include/pnet_export.h ${PROFINET_BINARY_DIR}/include/pnet_options.h ${PROFINET_BINARY_DIR}/include/pnet_version.h - DESTINATION include + DESTINATION ${INSTALL_PATH_INC} ) add_subdirectory (src) -add_subdirectory (samples/pn_dev) +#add_subdirectory (samples/pn_dev) -if (CMAKE_PROJECT_NAME STREQUAL PROFINET AND BUILD_TESTING) - add_subdirectory (test) - include(AddGoogleTest) - add_gtest(pf_test) -endif() +#if (CMAKE_PROJECT_NAME STREQUAL PROFINET AND BUILD_TESTING) +# add_subdirectory (test) +# include(AddGoogleTest) +# add_gtest(pf_test) +#endif() # Doxygen configuration cmake_policy(SET CMP0057 NEW) diff --git a/profinet_stack/p-net/cmake/Linux.cmake b/profinet_stack/p-net/cmake/Linux.cmake index df29df1..763ad30 100644 --- a/profinet_stack/p-net/cmake/Linux.cmake +++ b/profinet_stack/p-net/cmake/Linux.cmake @@ -18,12 +18,12 @@ if (PNET_OPTION_SNMP) find_package(NetSNMPAgent REQUIRED) endif() -target_include_directories(profinet +target_include_directories(${LIB_NAME} PRIVATE src/ports/linux ) -target_sources(profinet +target_sources(${LIB_NAME} PRIVATE src/ports/linux/pnal.c src/ports/linux/pnal_eth.c @@ -43,7 +43,7 @@ target_sources(profinet $<$:src/ports/linux/mib/lldpXPnoRemTable.c> ) -target_compile_options(profinet +target_compile_options(${LIB_NAME} PRIVATE -Wall -Wextra @@ -54,7 +54,7 @@ target_compile_options(profinet $<$:--coverage> ) -target_link_libraries(profinet +target_link_libraries(${LIB_NAME} PUBLIC $<$:NetSNMP::NetSNMPAgent> $<$:NetSNMP::NetSNMP> @@ -62,35 +62,35 @@ target_link_libraries(profinet $<$:--coverage> ) -target_include_directories(pn_dev - PRIVATE - samples/pn_dev - src/ports/linux - ) +#target_include_directories(pn_dev +# PRIVATE +# samples/pn_dev +# src/ports/linux +# ) -target_sources(pn_dev - PRIVATE - samples/pn_dev/sampleapp_common.c - samples/pn_dev/app_utils.c - samples/pn_dev/app_log.c - samples/pn_dev/app_gsdml.c - samples/pn_dev/app_data.c - src/ports/linux/sampleapp_main.c - ) +#target_sources(pn_dev +# PRIVATE +# samples/pn_dev/sampleapp_common.c +# samples/pn_dev/app_utils.c +# samples/pn_dev/app_log.c +# samples/pn_dev/app_gsdml.c +# samples/pn_dev/app_data.c +# src/ports/linux/sampleapp_main.c +# ) -target_compile_options(pn_dev - PRIVATE - -Wall - -Wextra - -Wno-unused-parameter - -ffunction-sections - -fdata-sections - ) +#target_compile_options(pn_dev +# PRIVATE +# -Wall +# -Wextra +# -Wno-unused-parameter +# -ffunction-sections +# -fdata-sections +# ) -target_link_options(pn_dev - PRIVATE - -Wl,--gc-sections -) +#target_link_options(pn_dev +# PRIVATE +# -Wl,--gc-sections +#) install (FILES src/ports/linux/pnal_config.h @@ -105,10 +105,10 @@ file(COPY ${PROFINET_BINARY_DIR}/ ) -if (BUILD_TESTING) - set(GOOGLE_TEST_INDIVIDUAL TRUE) - target_include_directories(pf_test - PRIVATE - src/ports/linux - ) -endif() +#if (BUILD_TESTING) +# set(GOOGLE_TEST_INDIVIDUAL TRUE) +# target_include_directories(pf_test +# PRIVATE +# src/ports/linux +# ) +#endif() diff --git a/profinet_stack/p-net/src/CMakeLists.txt b/profinet_stack/p-net/src/CMakeLists.txt index 1d4639e..de7fc33 100644 --- a/profinet_stack/p-net/src/CMakeLists.txt +++ b/profinet_stack/p-net/src/CMakeLists.txt @@ -16,7 +16,7 @@ # NOTE: add headers to make them show up in an IDE # NOTE: Use full path for the <$ expression # to work with certain cmake versions -target_sources (profinet PRIVATE +target_sources (${LIB_NAME} PRIVATE ${PROFINET_SOURCE_DIR}/include/pnet_api.h pf_includes.h pf_types.h diff --git a/sitara_depot b/sitara_depot new file mode 160000 index 0000000..f647bff --- /dev/null +++ b/sitara_depot @@ -0,0 +1 @@ +Subproject commit f647bffdb723629a289befbefa3a564de4bb2cfa diff --git a/src/.vscode/settings.json b/src/.vscode/settings.json new file mode 100755 index 0000000..520c0f6 --- /dev/null +++ b/src/.vscode/settings.json @@ -0,0 +1,78 @@ +{ + "cmake.configureArgs": [ + "-DSITARA=ON", + "-DCMAKE_TOOLCHAIN_FILE=${workspaceFolder}/../sitara_depot/compile/toolchain.cmake", + ], + "files.associations": { + "string_view": "cpp", + "cctype": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "any": "cpp", + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "*.tcc": "cpp", + "bitset": "cpp", + "chrono": "cpp", + "codecvt": "cpp", + "compare": "cpp", + "complex": "cpp", + "concepts": "cpp", + "condition_variable": "cpp", + "cstdint": "cpp", + "deque": "cpp", + "forward_list": "cpp", + "list": "cpp", + "map": "cpp", + "set": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "optional": "cpp", + "random": "cpp", + "ratio": "cpp", + "string": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "fstream": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "mutex": "cpp", + "new": "cpp", + "numbers": "cpp", + "ostream": "cpp", + "ranges": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "stop_token": "cpp", + "streambuf": "cpp", + "thread": "cpp", + "cinttypes": "cpp", + "typeindex": "cpp", + "typeinfo": "cpp", + "valarray": "cpp", + "variant": "cpp", + "semaphore": "cpp" + } +} \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e07fbc0..043b808 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,8 +1,9 @@ cmake_minimum_required (VERSION 3.0) -project (PN_DEV_TEST VERSION 0.0.1) +project (PROFINET_IO_DEV VERSION 0.0.1) + +set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD 20) set(LIBS_INSTALL_PATH ../libs) set(PNET_PATH ../profinet_stack/p-net) set(TARGET_NAME profinet_io_dev) @@ -19,19 +20,12 @@ include (./user_data/user_data.cmake) set(SRC_FILES ${SRC_FILES} ./app.cpp) -# Копирование заглушки скрипта установки параметров сети. -# Если не копировать, то в недрах pnet после fork вызовется exit и -# вызовутся деструкторы объектов, что может привести к непредвиденным последствиям. -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/set_network_parameters - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +set(SITARA_DEPOT ${CMAKE_SOURCE_DIR}/../sitara_depot) -#Копирование файла конфигурации -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/program_configure.json - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +include(${SITARA_DEPOT}/compile/sitara_compile_flags.cmake) -#Копирование тестового файла конфигурации устройства Profinet -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/profinet_device_configure.json - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +# убирает предупреждения nlohman json о GCC7.1 +add_compile_options(-Wno-psabi) #Если не собирается с ошибкой линкера undefined reference pthread, то добавить флаг линкера: #add_link_options(-lrt) @@ -43,12 +37,43 @@ target_include_directories(${TARGET_NAME} PRIVATE ${LIBS_INSTALL_PATH}/include ${LIBS_INSTALL_PATH}/include/sys ${LIBS_INSTALL_PATH}/include/x86_64 - ) -target_link_directories(${TARGET_NAME} PUBLIC ${LIBS_INSTALL_PATH}/lib/x86_64) +if (CMAKE_BUILD_TYPE STREQUAL Debug) + set(LIB_LIST profinetd osald ${Boost_LIBRARIES}) +elseif(CMAKE_BUILD_TYPE STREQUAL Release) + set(LIB_LIST profinet osal ${Boost_LIBRARIES}) +endif() + +# убирает предупреждения nlohman json о GCC7.1 +add_compile_options(-Wno-psabi) + +set(LIB_ARCH_DIR x86_64) + +if(SITARA) + set(LIB_ARCH_DIR arm_a15) +endif() + +target_link_directories(${TARGET_NAME} PUBLIC ${LIBS_INSTALL_PATH}/lib/${LIB_ARCH_DIR}) #Если не собирается с ошибкой линкера undefined reference pthread, то после ${Boost_LIBRARIES} добавить pthread или -lpthread: #target_link_libraries (${TARGET_NAME} PUBLIC profinet osal ${Boost_LIBRARIES} pthread) -target_link_libraries (${TARGET_NAME} PUBLIC profinetd osald ${Boost_LIBRARIES}) +target_link_libraries (${TARGET_NAME} PUBLIC ${LIB_LIST} pthread c rt) + +install( + TARGETS ${TARGET_NAME} + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin +) + +install(FILES + # Копирование заглушки скрипта установки параметров сети. + # Если не копировать, то в недрах pnet после fork вызовется exit и + # вызовутся деструкторы объектов, что может привести к непредвиденным последствиям. + ${CMAKE_CURRENT_SOURCE_DIR}/set_network_parameters + #Копирование файла конфигурации + ${CMAKE_CURRENT_SOURCE_DIR}/program_configure.json + #Копирование тестового файла конфигурации устройства Profinet + ${CMAKE_CURRENT_SOURCE_DIR}/profinet_device_configure.json + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin +) \ No newline at end of file diff --git a/src/interprocess/pipes/profinet_pipes.cpp b/src/interprocess/pipes/profinet_pipes.cpp index 770455b..727d26e 100644 --- a/src/interprocess/pipes/profinet_pipes.cpp +++ b/src/interprocess/pipes/profinet_pipes.cpp @@ -48,7 +48,7 @@ void ProfinetPipes::listen_pipe(ProfinetIface * p_profinet, UserDataMap * p_User //std::cout << "Request: " << request_str << std::endl; if (json_rpc_handler(request_str, answer_str, p_profinet, p_UserDataMap)) { - //std::cout << "Answer: " << answer_str << std::endl; + //std::cout << "Answer: " << answer_str << std::endl; *p_output_stream_ << answer_str << std::endl; } else diff --git a/src/profinet/profinet.cpp b/src/profinet/profinet.cpp index 6395992..e663f04 100644 --- a/src/profinet/profinet.cpp +++ b/src/profinet/profinet.cpp @@ -663,9 +663,12 @@ int Profinet::getOutputCyclicData(uint32_t module_id, uint32_t submodule_id, std::vector& data) { - if (!m_modules.contains(module_id)) + if (m_modules.find(module_id) == m_modules.end()) return ErrorCode::ERR_MODULE_DOES_NOT_EXIST; + /*if (!m_modules.contains(module_id)) + return ErrorCode::ERR_MODULE_DOES_NOT_EXIST;*/ + auto submodule = m_modules[module_id]->getSubmodulePtr(submodule_id); if (submodule == nullptr) @@ -680,8 +683,10 @@ int Profinet::putInputCyclicData(uint32_t module_id, uint32_t submodule_id, std::vector& data) { - if (!m_modules.contains(module_id)) + if (m_modules.find(module_id) == m_modules.end()) return ErrorCode::ERR_MODULE_DOES_NOT_EXIST; + /*if (!m_modules.contains(module_id)) + return ErrorCode::ERR_MODULE_DOES_NOT_EXIST;*/ auto submodule = m_modules[module_id]->getSubmodulePtr(submodule_id); @@ -703,8 +708,11 @@ int Profinet::getSubmoduleParam(uint32_t module_id, uint32_t param_id, std::vector& data) { - if (!m_modules.contains(module_id)) + if (m_modules.find(module_id) == m_modules.end()) return ErrorCode::ERR_MODULE_DOES_NOT_EXIST; + + /*if (!m_modules.contains(module_id)) + return ErrorCode::ERR_MODULE_DOES_NOT_EXIST;*/ auto submodule = m_modules[module_id]->getSubmodulePtr(submodule_id); @@ -738,8 +746,10 @@ Profinet::~Profinet() int Profinet::getSubmoduleCyclicInpDataLen(uint32_t module_id, uint32_t submodule_id) const { - if (!m_modules.contains(module_id)) + if (m_modules.find(module_id) == m_modules.end()) return ErrorCode::ERR_MODULE_DOES_NOT_EXIST; + /*if (!m_modules.contains(module_id)) + return ErrorCode::ERR_MODULE_DOES_NOT_EXIST;*/ auto submodule = m_modules.at(module_id)->getSubmodulePtr(submodule_id); @@ -751,8 +761,10 @@ int Profinet::getSubmoduleCyclicInpDataLen(uint32_t module_id, uint32_t submodul int Profinet::getSubmoduleCyclicOutDataLen(uint32_t module_id, uint32_t submodule_id) const { - if (!m_modules.contains(module_id)) + if (m_modules.find(module_id) == m_modules.end()) return ErrorCode::ERR_MODULE_DOES_NOT_EXIST; + /*if (!m_modules.contains(module_id)) + return ErrorCode::ERR_MODULE_DOES_NOT_EXIST;*/ auto submodule = m_modules.at(module_id)->getSubmodulePtr(submodule_id); diff --git a/src/user_data/user_data.cpp b/src/user_data/user_data.cpp index d8cd7d9..812a050 100644 --- a/src/user_data/user_data.cpp +++ b/src/user_data/user_data.cpp @@ -299,8 +299,11 @@ SubmoduleUserData& UserData_getSubmod(uint32_t mod_id, uint32_t submod_id, UserD int UserData::getDataSize(const std::string& type_name) { - if (!data_corr.contains(type_name)) + if (data_corr.find(type_name) == data_corr.end()) return 0; + + /*if (!data_corr.contains(type_name)) + return 0;*/ return data_size.at(data_corr.at(type_name)); }