mirror of
				https://gitee.com/jiuyilian/embedded-framework.git
				synced 2025-10-24 18:20:15 -04:00 
			
		
		
		
	Backup.
This commit is contained in:
		
							parent
							
								
									3cf1a1d8bd
								
							
						
					
					
						commit
						b11ebd8e4c
					
				
							
								
								
									
										7
									
								
								external/libhv/libhv-1.3.2/CMakeLists.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								external/libhv/libhv-1.3.2/CMakeLists.txt
									
									
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -231,8 +231,11 @@ endif()
 | 
			
		|||
 | 
			
		||||
list_source_directories(LIBHV_SRCS ${LIBHV_SRCDIRS})
 | 
			
		||||
 | 
			
		||||
file(INSTALL ${LIBHV_HEADERS} DESTINATION include/hv)
 | 
			
		||||
file(INSTALL ${LIBHV_HEADERS} DESTINATION ${PROJECT_SOURCE_DIR}/include/hv)
 | 
			
		||||
set(folder_path "${PROJECT_SOURCE_DIR}/include/hv") # added by xiao
 | 
			
		||||
if(NOT EXISTS ${folder_path})                       # added by xiao
 | 
			
		||||
    file(INSTALL ${LIBHV_HEADERS} DESTINATION include/hv)
 | 
			
		||||
    file(INSTALL ${LIBHV_HEADERS} DESTINATION ${PROJECT_SOURCE_DIR}/include/hv)
 | 
			
		||||
endif() # added by xiao
 | 
			
		||||
 | 
			
		||||
if(BUILD_SHARED)
 | 
			
		||||
    add_library(hv SHARED ${LIBHV_SRCS})
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,4 +14,5 @@ add_subdirectory(LedControl)
 | 
			
		|||
add_subdirectory(KeyControl)
 | 
			
		||||
add_subdirectory(MediaAdapter)
 | 
			
		||||
add_subdirectory(FxHttpServer)
 | 
			
		||||
add_subdirectory(Servers)
 | 
			
		||||
add_subdirectory(Servers)
 | 
			
		||||
add_subdirectory(TcpModule)
 | 
			
		||||
							
								
								
									
										51
									
								
								utils/TcpModule/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								utils/TcpModule/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,51 @@
 | 
			
		|||
include(${CMAKE_SOURCE_DIR_IPCSDK}/build/global_config.cmake)
 | 
			
		||||
set(EXECUTABLE_OUTPUT_PATH ${EXEC_OUTPUT_PATH})
 | 
			
		||||
set(LIBRARY_OUTPUT_PATH ${LIBS_OUTPUT_PATH})
 | 
			
		||||
 | 
			
		||||
include_directories(
 | 
			
		||||
    ./src
 | 
			
		||||
    ./include
 | 
			
		||||
    ${UTILS_SOURCE_PATH}/LinuxApi/include
 | 
			
		||||
    ${UTILS_SOURCE_PATH}/StatusCode/include
 | 
			
		||||
    ${UTILS_SOURCE_PATH}/Log/include
 | 
			
		||||
)
 | 
			
		||||
# link_directories(
 | 
			
		||||
#     ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs
 | 
			
		||||
# )
 | 
			
		||||
 | 
			
		||||
aux_source_directory(./src SRC_FILES)
 | 
			
		||||
 | 
			
		||||
set(TARGET_NAME TcpModule)
 | 
			
		||||
add_library(${TARGET_NAME} STATIC ${SRC_FILES})
 | 
			
		||||
target_link_libraries(${TARGET_NAME} LinuxApi StatusCode Log)
 | 
			
		||||
 | 
			
		||||
if ("${CLANG_TIDY_SUPPORT}" MATCHES "true")
 | 
			
		||||
add_custom_target(
 | 
			
		||||
    TcpModule_code_check
 | 
			
		||||
    COMMAND ${CLANG_TIDY_EXE}
 | 
			
		||||
    -checks='${CLANG_TIDY_CHECKS}'
 | 
			
		||||
    --header-filter=.*
 | 
			
		||||
    --system-headers=false
 | 
			
		||||
    ${SRC_FILES}
 | 
			
		||||
    ${CLANG_TIDY_CONFIG}
 | 
			
		||||
    -p ${PLATFORM_PATH}/cmake-shell
 | 
			
		||||
    WORKING_DIRECTORY ${UTILS_SOURCE_PATH}/TcpModule
 | 
			
		||||
)
 | 
			
		||||
file(GLOB_RECURSE HEADER_FILES *.h)
 | 
			
		||||
add_custom_target(
 | 
			
		||||
    TcpModule_code_format
 | 
			
		||||
    COMMAND ${CLANG_FORMAT_EXE}
 | 
			
		||||
    -style=file
 | 
			
		||||
    -i ${SRC_FILES} ${HEADER_FILES}
 | 
			
		||||
    WORKING_DIRECTORY ${UTILS_SOURCE_PATH}/TcpModule
 | 
			
		||||
)
 | 
			
		||||
add_custom_command(
 | 
			
		||||
    TARGET ${TARGET_NAME}
 | 
			
		||||
    PRE_BUILD
 | 
			
		||||
    COMMAND make TcpModule_code_check
 | 
			
		||||
    COMMAND make TcpModule_code_format
 | 
			
		||||
    WORKING_DIRECTORY ${PLATFORM_PATH}/cmake-shell/
 | 
			
		||||
)
 | 
			
		||||
endif()
 | 
			
		||||
 | 
			
		||||
define_file_name(${TARGET_NAME})
 | 
			
		||||
							
								
								
									
										36
									
								
								utils/TcpModule/include/TcpModule.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								utils/TcpModule/include/TcpModule.h
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,36 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2023 Fancy Code.
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
#ifndef TCP_MODULE_H
 | 
			
		||||
#define TCP_MODULE_H
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
typedef void (*TcpReadFunction)(void *, const int, void *);
 | 
			
		||||
typedef struct tcp_parm
 | 
			
		||||
{
 | 
			
		||||
    const char *mIp;
 | 
			
		||||
    const int mPort;
 | 
			
		||||
    const TcpReadFunction mReadFunc;
 | 
			
		||||
} TcpPram;
 | 
			
		||||
void *CreateTcpServer(const TcpPram param);
 | 
			
		||||
void FreeTcpServer(void *pointer);
 | 
			
		||||
int TcpServerWrite(void *object, void *buf, const int bufLenght);
 | 
			
		||||
void *CreateTcpClient(const TcpPram param);
 | 
			
		||||
void FreeTcpClient(void *pointer);
 | 
			
		||||
int TcpClientWrite(void *object, void *buf, const int bufLenght);
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
							
								
								
									
										17
									
								
								utils/TcpModule/src/TcpModule.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								utils/TcpModule/src/TcpModule.cpp
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,17 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2023 Fancy Code.
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
#include "TcpModule.h"
 | 
			
		||||
#include "TcpModuleImpl.h"
 | 
			
		||||
void *CreateTcpServer(const TcpPram param) { return NewTcpServer(param); }
 | 
			
		||||
							
								
								
									
										34
									
								
								utils/TcpModule/src/TcpModuleImpl.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								utils/TcpModule/src/TcpModuleImpl.cpp
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,34 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2023 Fancy Code.
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
#include "TcpModuleImpl.h"
 | 
			
		||||
#include "ILog.h"
 | 
			
		||||
#include <cstring>
 | 
			
		||||
static const char *TCP_MODULE_NAME = "tcp_module";
 | 
			
		||||
const char *GetTcpModuleName(void) { return TCP_MODULE_NAME; }
 | 
			
		||||
void *NewTcpModuleImpl(const TcpPram &tcpParam)
 | 
			
		||||
{
 | 
			
		||||
    if (nullptr == tcpParam.mIp) {
 | 
			
		||||
        LogError("Parament error, nullptr == tcpParam.mIp\n");
 | 
			
		||||
        return nullptr;
 | 
			
		||||
    }
 | 
			
		||||
    LogInfo("Create the tcp module object.\n");
 | 
			
		||||
    TcpServer *impl = (TcpServer *)malloc(sizeof(TcpServer));
 | 
			
		||||
    TcpServer tmp;
 | 
			
		||||
    memcpy((void *)impl, (void *)&tmp, sizeof(TcpServer));
 | 
			
		||||
    impl->mHeader.mCheckName = TCP_MODULE_NAME;
 | 
			
		||||
    impl->mTcpImpl = std::make_shared<TcpModuleImpl>(tcpParam);
 | 
			
		||||
    return (void *)(((char *)impl) + sizeof(TcpModuleHeader));
 | 
			
		||||
}
 | 
			
		||||
void *NewTcpServer(const TcpPram &tcpParam) { return nullptr; }
 | 
			
		||||
							
								
								
									
										52
									
								
								utils/TcpModule/src/TcpModuleImpl.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								utils/TcpModule/src/TcpModuleImpl.h
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,52 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright (c) 2023 Fancy Code.
 | 
			
		||||
 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 *
 | 
			
		||||
 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 *
 | 
			
		||||
 * Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
 * See the License for the specific language governing permissions and
 | 
			
		||||
 * limitations under the License.
 | 
			
		||||
 */
 | 
			
		||||
#ifndef TCP_MODULE_IMPL_H
 | 
			
		||||
#define TCP_MODULE_IMPL_H
 | 
			
		||||
#include "StatusCode.h"
 | 
			
		||||
#include "TcpModule.h"
 | 
			
		||||
#include <memory>
 | 
			
		||||
#define TCP_MODULE_INIT_NAME "UART"
 | 
			
		||||
typedef struct uart_device_header
 | 
			
		||||
{
 | 
			
		||||
    const char *mCheckName;
 | 
			
		||||
} TcpModuleHeader;
 | 
			
		||||
class TcpModuleImpl
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    TcpModuleImpl(const TcpPram &uatrInfo);
 | 
			
		||||
    virtual ~TcpModuleImpl() = default;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    const StatusCode SetConfig(void);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    const TcpPram mUatrInfo;
 | 
			
		||||
    int mFd;
 | 
			
		||||
};
 | 
			
		||||
// TODO: There may be a CPU byte alignment bug.
 | 
			
		||||
typedef struct tcp_server TcpServer;
 | 
			
		||||
typedef struct tcp_server
 | 
			
		||||
{
 | 
			
		||||
    TcpModuleHeader mHeader;
 | 
			
		||||
    std::shared_ptr<TcpModuleImpl> mTcpImpl;
 | 
			
		||||
} TcpServer;
 | 
			
		||||
void *NewTcpModuleImpl(const TcpPram &tcpParam);
 | 
			
		||||
void *NewTcpServer(const TcpPram &tcpParam);
 | 
			
		||||
static inline TcpServer *TcpModuleImplConvert(void *object)
 | 
			
		||||
{
 | 
			
		||||
    return ((TcpServer *)(((char *)object) - sizeof(TcpModuleHeader)));
 | 
			
		||||
}
 | 
			
		||||
const char *GetTcpModuleName(void);
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			@ -13,8 +13,6 @@ include_directories(
 | 
			
		|||
#     ${EXTERNAL_SOURCE_PATH}/libconfig/libconfig-1.7.3/lib/.libs
 | 
			
		||||
# )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
aux_source_directory(./src SRC_FILES)
 | 
			
		||||
 | 
			
		||||
set(TARGET_NAME UartDevice)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user