refactor: 整合SLMP到loopback,按照FINS架构重写,只保留ModbusTCP/SLMP/FINS三个功能
This commit is contained in:
1 parent
32f5ef9d3b
commit
8114a8c0b9
2 files changed
+313
-447
No files matched your search
+285
-432
File diff suppressed because it is too large.
Load diff
+28
-15
@@ -6,10 +6,10 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Loopback test debug message printout enable */
|
||||
//#define _LOOPBACK_DEBUG_
|
||||
//#define _LOOPBACK_DEBUG_S7_
|
||||
/* DATA_BUF_SIZE define for Loopback example */
|
||||
#ifndef DATA_BUF_SIZE
|
||||
#define DATA_BUF_SIZE 2048
|
||||
@@ -18,43 +18,56 @@ extern "C" {
|
||||
/************************/
|
||||
/* Select LOOPBACK_MODE */
|
||||
/************************/
|
||||
//#define _LOOPBACK_DEBUG_SLMP_
|
||||
#define LOOPBACK_MAIN_NOBLOCK 0
|
||||
#define LOOPBACK_MODE LOOPBACK_MAIN_NOBLOCK
|
||||
|
||||
// 全局共享变量
|
||||
extern uint16_t client_wait_timeout;
|
||||
extern uint16_t s7Timegap;
|
||||
|
||||
extern uint16_t comm_count;
|
||||
extern _Bool comm_flag;
|
||||
extern uint16_t slmpTimegap;
|
||||
extern uint16_t fins_timeout;
|
||||
void update_timeout_slmp();
|
||||
|
||||
// RTU接收状态结构体
|
||||
typedef struct {
|
||||
uint8_t buf[512];
|
||||
_Bool done;
|
||||
uint16_t size;
|
||||
} RtuRxST;
|
||||
|
||||
/* TCP server Loopback test example */
|
||||
int32_t loopback_tcps_modbus(uint8_t sn, uint16_t port);
|
||||
// SLMP状态枚举 (对外声明)
|
||||
typedef enum {
|
||||
SLMP_STATE_WRITE_RX_DONE,
|
||||
SLMP_STATE_READ_RX_DONE,
|
||||
SLMP_STATE_READY_SEND
|
||||
} SLMPSTATUS;
|
||||
|
||||
extern SLMPSTATUS slmp_master_status;
|
||||
extern uint8_t slmp_txbuf[1024];
|
||||
extern uint8_t slmp_rxbuf[1024];
|
||||
extern uint16_t slmp_read_addr;
|
||||
extern uint16_t slmp_read_size;
|
||||
extern uint16_t slmp_write_addr;
|
||||
extern uint16_t slmp_write_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);
|
||||
|
||||
/* TCP client Loopback test example */
|
||||
int32_t loopback_tcpc_s7(uint8_t sn, uint8_t *recvbuf, uint8_t *destip, uint16_t destport);
|
||||
|
||||
/* UDP Loopback test example */
|
||||
int32_t loopback_udps(uint8_t sn, uint8_t *buf, uint16_t port);
|
||||
|
||||
/* SLMP TCP 客户端 (三菱) */
|
||||
void update_timeout_slmp(void);
|
||||
int32_t loopback_tcpc_slmp(uint8_t sn, uint8_t *destip, uint16_t destport);
|
||||
|
||||
void update_timeout_fins();
|
||||
/* 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
|
||||
|
||||
Reference in new issue
Block a user