更新 common.h
This commit is contained in:
23
common.h
23
common.h
@@ -3,15 +3,20 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define DATA_LEN 512
|
||||
#define TYPE_DATA 1
|
||||
#define TYPE_ACK 2
|
||||
#define TYPE_DATA 0
|
||||
#define TYPE_ACK 1
|
||||
|
||||
typedef struct {
|
||||
uint8_t type; // DATA or ACK
|
||||
uint8_t seq; // 序号 0 / 1
|
||||
uint16_t length; // 数据长度
|
||||
char data[DATA_LEN];
|
||||
} packet_t;
|
||||
#define PORT 9000
|
||||
#define BUF_SIZE 1024
|
||||
#define TIMEOUT_SEC 2
|
||||
|
||||
/* 应用层协议数据包 */
|
||||
#pragma pack(push, 1)
|
||||
struct packet {
|
||||
uint8_t seq; // 停等协议序号:0 / 1
|
||||
uint8_t type; // 0=DATA, 1=ACK
|
||||
char payload[BUF_SIZE - 2];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user