emsApplication/applications/ems_datahubs/frame_define.h

49 lines
982 B
C
Raw Normal View History

2024-09-03 16:27:43 +08:00
#pragma once
#pragma pack(1)
#include "kdefine.h"
NAMESPACE_BEGIN(HJ)
2024-09-04 16:24:53 +08:00
typedef enum tagErrorCode : unsigned char
2024-09-03 16:27:43 +08:00
{
2024-09-04 16:24:53 +08:00
ERR_OK = 0X00,
ERR_INVALID_LEN = 0X01,
ERR_INVALID_UTF8 = 0X02,
ERR_INVALID_BUF_LEN = 0X03,
ERR_UNKOWN = 0XFF
}ErrorCode;
typedef enum tagFrameType : unsigned char
{
Frame_Request = 0x00, //<2F><><EFBFBD><EFBFBD>֡
Frame_Response = 0x01, //<2F><><EFBFBD><EFBFBD>֡
Frame_DeviceData_Request = 0x02, //<2F><><EFBFBD>Բɼ<D4B2><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><E6B5BD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>
2024-09-03 16:27:43 +08:00
}FrameType;
2024-09-04 16:24:53 +08:00
typedef struct tagFrameTail
{
unsigned char frame_delimiter[4] = { 0xEE,0xFF,0xEE,0xFF };
}FrameTail;
2024-09-03 16:27:43 +08:00
typedef struct tagFrame
{
FrameType frame_type; //֡<><D6A1><EFBFBD><EFBFBD>
unsigned int frame_len; //֡<><D6A1><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
2024-09-04 16:24:53 +08:00
unsigned char frame_content[1]; //֡<><D6A1><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>ʵ<EFBFBD><CAB5>ӦΪjson<6F>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>json<6F><6E><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD>
tagFrame()
{
frame_type = Frame_Response;
frame_len = 1;
frame_content[0] = ERR_OK;
}
void setErrorFrame(ErrorCode err = ERR_OK)
{
frame_len = 1;
frame_content[0] = err;
}
2024-09-03 16:27:43 +08:00
}MessageFrame;
NAMESPACE_END(HJ)
#pragma pack()