g0b1vetx-board/Board/network/proto.h
2023-11-30 08:10:01 +08:00

65 lines
986 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef _PROTO_H
#define _PROTO_H
#include <stdint.h>
// 上行统一使用M1模式无确认
// 下行统一使用M2模式一次确认
#define _651_STX 2
#define _651_ETX 3
#define _651_ETB 23
#pragma pack (1)
typedef struct _651_U_Header_t
{
uint16_t Head;
uint8_t CentAddr;
uint8_t DeviAddr[5];
uint16_t Pass;
uint8_t FuncCode;
uint16_t TypeLength;
uint8_t Stx;
} _651_U_Header_t;
typedef struct _651_D_Header_t
{
uint16_t Head;
uint8_t DeviAddr[5];
uint8_t CentAddr;
uint16_t Pass;
uint8_t FuncCode;
uint16_t Type: 4;
uint16_t Length: 12;
uint8_t Stx;
} _651_D_Header_t;
#pragma pack ()
// 打包数据帧
int PacketHeader (uint8_t func, char * data, int length, char * txbuff);
// 均匀时段报
int PakcetTimerUp (int k, char * tx_data);
// 闸门状态自报 闸门开度发生变化时上报
int PacketSluiceUp (int k, char * tx_data);
// 接受到提闸数据时应答的ACK
int PacketSluiceAck (char* tx_data);
int PacketAnsAck (char * tx_data);
int PacketUpRegist (char * tx_data);
#endif