refactor: 分文件重构,新建protocols文件夹,三个协议分文件存放:modbustcpslave/finsudpmaster/slmptcpmaster,结构更清晰
This commit is contained in:
1 parent
99fa72eaa0
commit
e3519bf1f4
8 files changed
+852
-741
No files matched your search
+44
-67
@@ -1,67 +1,44 @@
|
||||
#ifndef _LOOPBACK_H_
|
||||
#define _LOOPBACK_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Loopback test debug message printout enable */
|
||||
//#define _LOOPBACK_DEBUG_
|
||||
/* DATA_BUF_SIZE define for Loopback example */
|
||||
#ifndef DATA_BUF_SIZE
|
||||
#define DATA_BUF_SIZE 2048
|
||||
#endif
|
||||
|
||||
/************************/
|
||||
/* Select LOOPBACK_MODE */
|
||||
/************************/
|
||||
#define LOOPBACK_MAIN_NOBLOCK 0
|
||||
#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK
|
||||
|
||||
// 全局共享变量
|
||||
extern uint16_t client_wait_timeout;
|
||||
extern uint16_t comm_count;
|
||||
extern uint16_t slmpTimegap;
|
||||
extern uint16_t fins_timeout;
|
||||
|
||||
// RTU接收状态结构体
|
||||
typedef struct {
|
||||
uint8_t buf[512];
|
||||
_Bool done;
|
||||
uint16_t size;
|
||||
} RtuRxST;
|
||||
|
||||
// SLMP全局变量 (和FINS相同风格)
|
||||
extern uint8_t slmp_txbuf[1024];
|
||||
extern uint8_t slmp_rxbuf[1024];
|
||||
extern uint16_t slmp_idx;
|
||||
extern uint16_t slmp_addr;
|
||||
extern uint16_t slmp_size;
|
||||
|
||||
/* Modbus TCP 服务 */
|
||||
int32_t loopback_tcps_modbus(uint8_t sn, uint16_t port);
|
||||
int32_t loopback_tcps_modbus_to485(uint8_t sn, uint8_t *buf, uint16_t port, uint16_t *timeout, RtuRxST *rtu_rx);
|
||||
|
||||
/* SLMP TCP 客户端 (三菱) */
|
||||
void update_timeout_slmp(void);
|
||||
int32_t loopback_tcpc_slmp(uint8_t sn, uint8_t *destip, uint16_t destport);
|
||||
|
||||
/* OMR FINS UDP 客户端 (欧姆龙) */
|
||||
void update_timeout_fins(void);
|
||||
int32_t loopback_udpc_omrfins(uint8_t sn, uint8_t *destip, uint16_t destport, uint16_t local_node);
|
||||
|
||||
/* 顶层统一入口 */
|
||||
void loopback_comm(uint8_t *ip, uint16_t port, uint8_t node);
|
||||
|
||||
/* 字节序转换工具函数 */
|
||||
void to_big_endian_16(uint16_t value, uint8_t *dest);
|
||||
void to_big_endian_24(uint32_t value, uint8_t *dest);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#ifndef _LOOPBACK_H_
|
||||
#define _LOOPBACK_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "protocols/modbustcpslave.h"
|
||||
#include "protocols/finsudpmaster.h"
|
||||
#include "protocols/slmptcpmaster.h"
|
||||
|
||||
/* Loopback test debug message printout enable */
|
||||
//#define _LOOPBACK_DEBUG_
|
||||
/* DATA_BUF_SIZE define for Loopback example */
|
||||
#ifndef DATA_BUF_SIZE
|
||||
#define DATA_BUF_SIZE 2048
|
||||
#endif
|
||||
|
||||
/************************/
|
||||
/* Select LOOPBACK_MODE */
|
||||
/************************/
|
||||
#define LOOPBACK_MAIN_NOBLOCK 0
|
||||
#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK
|
||||
|
||||
// 全局共享变量
|
||||
extern uint16_t client_wait_timeout;
|
||||
extern uint16_t comm_count;
|
||||
extern uint16_t slmpTimegap;
|
||||
extern uint16_t fins_timeout;
|
||||
|
||||
// 工具函数声明
|
||||
void to_big_endian_16(uint16_t value, uint8_t *dest);
|
||||
void to_big_endian_24(uint32_t value, uint8_t *dest);
|
||||
|
||||
// 顶层统一入口
|
||||
void loopback_comm(uint8_t *ip, uint16_t port, uint8_t node);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user