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
@@ -0,0 +1,39 @@
|
||||
#ifndef MODBUSTCPSLAVE_H
|
||||
#define MODBUSTCPSLAVE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifndef DATA_BUF_SIZE
|
||||
#define DATA_BUF_SIZE 2048
|
||||
#endif
|
||||
|
||||
// RTU接收状态结构体
|
||||
typedef struct {
|
||||
uint8_t buf[512];
|
||||
_Bool done;
|
||||
uint16_t size;
|
||||
} RtuRxST;
|
||||
|
||||
extern uint8_t loopback_tcps_modbus_rxbuf[1024];
|
||||
extern uint8_t loopback_tcps_modbus_txbuf[1024];
|
||||
|
||||
// Modbus TCP服务主函数
|
||||
int32_t loopback_tcps_modbus(uint8_t sn, uint16_t port);
|
||||
|
||||
// Modbus TCP转RTU转发主函数
|
||||
int32_t loopback_tcps_modbus_to485(uint8_t sn, uint8_t *buf, uint16_t port, uint16_t *timeout, RtuRxST *rtu_rx);
|
||||
|
||||
// 工具函数
|
||||
uint16_t tcp_to_rtu(uint8_t *tcp_buf, uint8_t *rtu_buf);
|
||||
uint16_t rtu_to_tcp(uint8_t *rtu_buf, uint8_t *tcp_buf, uint16_t rtu_len, uint8_t *rx_buf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user