From da63bec5941e2131b2cb07cbc7fbf0fe01a9261a Mon Sep 17 00:00:00 2001 From: Vadim Sychev Date: Fri, 9 Dec 2022 12:54:37 +0300 Subject: [PATCH] =?UTF-8?q?dev:=20=D0=A1=D0=B1=D0=BE=D1=80=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20Linux=20Sitara?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- profinet_test/sample_app_echo/CMakeLists.txt | 35 ++++++++++++++----- .../sample_app_echo_config.json | 4 +-- src/CMakeLists.txt | 18 +++++----- src/app.cpp | 2 +- src/program_configure.json | 6 ++-- 5 files changed, 41 insertions(+), 24 deletions(-) diff --git a/profinet_test/sample_app_echo/CMakeLists.txt b/profinet_test/sample_app_echo/CMakeLists.txt index 4490493..f608754 100644 --- a/profinet_test/sample_app_echo/CMakeLists.txt +++ b/profinet_test/sample_app_echo/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required (VERSION 3.0) project (PN_ECHO_TEST VERSION 0.0.1) -set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD 17) + +set(TARGET_NAME pn_echo_test) set(INC_DIRS ${INC_DIRS} ../../src/profinet) set(INC_DIRS ${INC_DIRS} ../../src/nlohmann_json) @@ -19,8 +21,15 @@ set(SRC_FILES ${SRC_FILES} ./CreatePipes.cpp) set(SRC_FILES ${SRC_FILES} ../../src/file_api/file_api.cpp) set(SRC_FILES ${SRC_FILES} ./main.cpp) -set(Boost_USE_STATIC_LIBS ON) -set(Boost_USE_STATIC_RUNTIME ON) +set(SITARA_DEPOT ${CMAKE_SOURCE_DIR}/../../sitara_depot) + +include(${SITARA_DEPOT}/compile/sitara_compile_flags.cmake) + +# nlohman json GCC7.1 +add_compile_options(-Wno-psabi) + +#set(Boost_USE_STATIC_LIBS ON) +#set(Boost_USE_STATIC_RUNTIME ON) find_package(Boost 1.74.0) if(Boost_FOUND) @@ -32,13 +41,21 @@ endif() message("Boost dir: " ${Boost_INCLUDE_DIRS}) message("Boost libs:" ${Boost_LIBRARIES}) -#Копирование тестового файла конфигурации устройства Profinet -file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/sample_app_echo_config.json - DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +add_executable(${TARGET_NAME} ./main.cpp ${SRC_FILES}) -add_executable(pn_echo_test ./main.cpp ${SRC_FILES}) - -target_include_directories(pn_echo_test PRIVATE +target_include_directories(${TARGET_NAME} PRIVATE ./ ${INC_DIRS} ) + +target_link_libraries (${TARGET_NAME} PUBLIC ${Boost_LIBRARIES} pthread c rt) + +install( + TARGETS ${TARGET_NAME} + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin +) + +install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/sample_app_echo_config.json + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin +) diff --git a/profinet_test/sample_app_echo/sample_app_echo_config.json b/profinet_test/sample_app_echo/sample_app_echo_config.json index ffd3aa1..4a02510 100644 --- a/profinet_test/sample_app_echo/sample_app_echo_config.json +++ b/profinet_test/sample_app_echo/sample_app_echo_config.json @@ -1,7 +1,7 @@ { "app_settings": { - "app_out_pipe_name": "/home/svad/Projects/profinet_io_dev/profinet_io_dev_inp", - "app_inp_pipe_name": "/home/svad/Projects/profinet_io_dev/profinet_io_dev_out" + "app_out_pipe_name": "/home/root/pnet/profinet_io_dev_inp", + "app_inp_pipe_name": "/home/root/pnet/profinet_io_dev_out" } } \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 043b808..778453e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -24,10 +24,10 @@ set(SITARA_DEPOT ${CMAKE_SOURCE_DIR}/../sitara_depot) include(${SITARA_DEPOT}/compile/sitara_compile_flags.cmake) -# убирает предупреждения nlohman json о GCC7.1 +# nlohman json GCC7.1 add_compile_options(-Wno-psabi) -#Если не собирается с ошибкой линкера undefined reference pthread, то добавить флаг линкера: +# undefined reference pthread, : #add_link_options(-lrt) add_executable(${TARGET_NAME} ./main.cpp ${SRC_FILES}) @@ -45,7 +45,7 @@ elseif(CMAKE_BUILD_TYPE STREQUAL Release) set(LIB_LIST profinet osal ${Boost_LIBRARIES}) endif() -# убирает предупреждения nlohman json о GCC7.1 +# nlohman json GCC7.1 add_compile_options(-Wno-psabi) set(LIB_ARCH_DIR x86_64) @@ -56,7 +56,7 @@ endif() target_link_directories(${TARGET_NAME} PUBLIC ${LIBS_INSTALL_PATH}/lib/${LIB_ARCH_DIR}) -#Если не собирается с ошибкой линкера undefined reference pthread, то после ${Boost_LIBRARIES} добавить pthread или -lpthread: +# undefined reference pthread, ${Boost_LIBRARIES} pthread -lpthread: #target_link_libraries (${TARGET_NAME} PUBLIC profinet osal ${Boost_LIBRARIES} pthread) target_link_libraries (${TARGET_NAME} PUBLIC ${LIB_LIST} pthread c rt) @@ -67,13 +67,13 @@ install( ) install(FILES - # Копирование заглушки скрипта установки параметров сети. - # Если не копировать, то в недрах pnet после fork вызовется exit и - # вызовутся деструкторы объектов, что может привести к непредвиденным последствиям. + # . + # , pnet fork exit + # , . ${CMAKE_CURRENT_SOURCE_DIR}/set_network_parameters - #Копирование файла конфигурации + # ${CMAKE_CURRENT_SOURCE_DIR}/program_configure.json - #Копирование тестового файла конфигурации устройства Profinet + # 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/app.cpp b/src/app.cpp index 1adde01..258a6f7 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -8,7 +8,7 @@ bool App::Init(std::string profinet_config_file) ProfinetPipesSettings profinet_pipe_settings; /// Читаем настройки из файла - if (!programconf_getProfinetSettings("program_configure.json", profinet_settings, profinet_pipe_settings)) + if (!programconf_getProfinetSettings(profinet_config_file, profinet_settings, profinet_pipe_settings)) { return false; } diff --git a/src/program_configure.json b/src/program_configure.json index 3fda0c1..91a4cc2 100644 --- a/src/program_configure.json +++ b/src/program_configure.json @@ -3,10 +3,10 @@ { "ticks_us": 1000, "cyclic_ms": 100, - "eth_dev_name": "enp6s1", + "eth_dev_name": "eth0", "profinet_device_config": "profinet_device_configure.json", "enable_pipes": true, - "out_pipe_name": "/home/svad/Projects/profinet_io_dev/profinet_io_dev_out", - "inp_pipe_name": "/home/svad/Projects/profinet_io_dev/profinet_io_dev_inp" + "out_pipe_name": "/home/root/pnet/profinet_io_dev_out", + "inp_pipe_name": "/home/root/pnet/profinet_io_dev_inp" } } \ No newline at end of file