phase 2 serial

This commit is contained in:
flower_linux
2026-06-12 18:34:49 +08:00
parent 0cf0713dc5
commit 628ccf1409
78 changed files with 2571 additions and 345 deletions

View File

@@ -0,0 +1,51 @@
# Vendored libmodbus v3.1.10 static library for softbus_edge
set(_src_dir "${CMAKE_SOURCE_DIR}/third_party/libmodbus")
if(NOT EXISTS "${_src_dir}/src/modbus.c")
message(WARNING "Vendor libmodbus not found at ${_src_dir}")
return()
endif()
set(_gen_dir "${CMAKE_BINARY_DIR}/libmodbus_vendor")
file(MAKE_DIRECTORY "${_gen_dir}")
configure_file(
"${CMAKE_SOURCE_DIR}/cmake/libmodbus/config.h.linux"
"${_gen_dir}/config.h"
COPYONLY
)
configure_file(
"${CMAKE_SOURCE_DIR}/cmake/libmodbus/modbus-version.h"
"${_gen_dir}/modbus-version.h"
COPYONLY
)
add_library(modbus_vendor STATIC
"${_src_dir}/src/modbus.c"
"${_src_dir}/src/modbus-data.c"
"${_src_dir}/src/modbus-rtu.c"
"${_src_dir}/src/modbus-tcp.c"
)
set_target_properties(modbus_vendor PROPERTIES
C_STANDARD 99
POSITION_INDEPENDENT_CODE ON
)
target_include_directories(modbus_vendor
PUBLIC
"${_src_dir}/src"
"${_gen_dir}"
)
if(UNIX)
target_link_libraries(modbus_vendor PUBLIC pthread)
endif()
add_library(libmodbus_iface INTERFACE)
target_link_libraries(libmodbus_iface INTERFACE modbus_vendor)
target_include_directories(libmodbus_iface INTERFACE
"${_src_dir}/src"
"${_gen_dir}"
)
set(SOFTBUS_HAS_LIBMODBUS ON PARENT_SCOPE)
set(SOFTBUS_LIBMODBUS_VENDOR ON PARENT_SCOPE)
message(STATUS "libmodbus: using vendored build from third_party/libmodbus")

View File

@@ -0,0 +1,46 @@
/* Linux config.h for vendored libmodbus v3.1.10 */
#define HAVE_ARPA_INET_H 1
#define HAVE_DECL_TIOCSRS485 1
#define HAVE_DECL_TIOCM_RTS 1
#define HAVE_ERRNO_H 1
#define HAVE_FCNTL_H 1
#define HAVE_FORK 1
#define HAVE_GETADDRINFO 1
#define HAVE_GETTIMEOFDAY 1
#define HAVE_INTTYPES_H 1
#define HAVE_LIMITS_H 1
#define HAVE_LINUX_SERIAL_H 1
#define HAVE_MEMORY_H 1
#define HAVE_MEMSET 1
#define HAVE_NETDB_H 1
#define HAVE_NETINET_IN_H 1
#define HAVE_NETINET_TCP_H 1
#define HAVE_SELECT 1
#define HAVE_SOCKET 1
#define HAVE_STDINT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRERROR 1
#define HAVE_STRINGS_H 1
#define HAVE_STRING_H 1
#define HAVE_SYS_IOCTL_H 1
#define HAVE_SYS_SOCKET_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TIME_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_TERMIOS_H 1
#define HAVE_TIME_H 1
#define HAVE_UNISTD_H 1
#define HAVE_VFORK 1
#define HAVE_WORKING_FORK 1
#define HAVE_WORKING_VFORK 1
#define PACKAGE "libmodbus"
#define PACKAGE_BUGREPORT "https://github.com/stephane/libmodbus/issues"
#define PACKAGE_NAME "libmodbus"
#define PACKAGE_STRING "libmodbus 3.1.10"
#define PACKAGE_TARNAME "libmodbus"
#define PACKAGE_URL ""
#define PACKAGE_VERSION "3.1.10"
#define STDC_HEADERS 1
#define TIME_WITH_SYS_TIME 1
#define VERSION "3.1.10"

View File

@@ -0,0 +1,19 @@
#ifndef MODBUS_VERSION_H
#define MODBUS_VERSION_H
#define LIBMODBUS_VERSION_MAJOR (3)
#define LIBMODBUS_VERSION_MINOR (1)
#define LIBMODBUS_VERSION_MICRO (10)
#define LIBMODBUS_VERSION 3.1.10
#define LIBMODBUS_VERSION_STRING "3.1.10"
#define LIBMODBUS_VERSION_HEX \
((LIBMODBUS_VERSION_MAJOR << 16) | (LIBMODBUS_VERSION_MINOR << 8) | \
(LIBMODBUS_VERSION_MICRO << 0))
#define LIBMODBUS_VERSION_CHECK(major, minor, micro) \
(LIBMODBUS_VERSION_MAJOR > (major) || \
(LIBMODBUS_VERSION_MAJOR == (major) && LIBMODBUS_VERSION_MINOR > (minor)) || \
(LIBMODBUS_VERSION_MAJOR == (major) && LIBMODBUS_VERSION_MINOR == (minor) && \
LIBMODBUS_VERSION_MICRO >= (micro)))
#endif /* MODBUS_VERSION_H */