dev: Сборка под Sitara

This commit is contained in:
Vadim Sychev 2022-12-08 16:18:07 +03:00
parent f6bbef1af9
commit 7d65fcf69f
20 changed files with 447 additions and 105 deletions

4
.gitmodules vendored Normal file
View File

@ -0,0 +1,4 @@
[submodule "sitara_depot"]
path = sitara_depot
url = http://server_gorbunov:3000/SmartForce4.0/sitara_depot.git
branch = master

View File

@ -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

BIN
libs/lib/arm_a15/libosal.a Normal file

Binary file not shown.

BIN
libs/lib/arm_a15/libosald.a Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -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"
}
}

View File

@ -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
$<BUILD_INTERFACE:${OSAL_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
@ -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)

View File

@ -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
$<$<CONFIG:Coverage>:--coverage>
)
target_include_directories(osal PUBLIC
target_include_directories(${LIB_NAME} PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/linux>
)
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)

View File

@ -40,9 +40,6 @@ doc/_copied
*.x86_64
*.hex
# Editor files
.vscode/
# Sampleapp dummy LED files
pnet_led*.txt

View File

@ -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"
}
}

View File

@ -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
$<BUILD_INTERFACE:${PROFINET_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${PROFINET_BINARY_DIR}/include>
@ -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)

View File

@ -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
$<$<BOOL:${PNET_OPTION_SNMP}>: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
$<$<CONFIG:Coverage>:--coverage>
)
target_link_libraries(profinet
target_link_libraries(${LIB_NAME}
PUBLIC
$<$<BOOL:${PNET_OPTION_SNMP}>:NetSNMP::NetSNMPAgent>
$<$<BOOL:${PNET_OPTION_SNMP}>:NetSNMP::NetSNMP>
@ -62,35 +62,35 @@ target_link_libraries(profinet
$<$<CONFIG:Coverage>:--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()

View File

@ -16,7 +16,7 @@
# NOTE: add headers to make them show up in an IDE
# NOTE: Use full path for the <$<BOOL:${PNET_OPTION_SNMP}> 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

1
sitara_depot Submodule

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

78
src/.vscode/settings.json vendored Executable file
View File

@ -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"
}
}

View File

@ -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
)

View File

@ -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

View File

@ -663,9 +663,12 @@ int Profinet::getOutputCyclicData(uint32_t module_id,
uint32_t submodule_id,
std::vector<uint8_t>& 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<uint8_t>& 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<uint8_t>& 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);

View File

@ -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));
}