emsApplication/applications/emsConfigurer/frame_define.h

55 lines
1.1 KiB
C
Raw Normal View History

#pragma once
#pragma pack(1)
#include "kdefine.h"
__NAMESPACE_BEGIN__(HJ)
#define FRAME_HEADER_LENGTH (5)
#define FRAME_TAILE_LENGTH (4)
typedef enum tagErrorCode : unsigned char
{
ERR_OK = 0X00,
ERR_INVALID_LEN = 0X01,
ERR_INVALID_UTF8 = 0X02,
ERR_INVALID_BUF_LEN = 0X03,
ERR_INVALID_JSON_FMT = 0X04,
ERR_INVALID_FSUCODE = 0X05,
ERR_UNKOWN = 0XFF
}ErrorCode;
typedef enum tagFrameType : unsigned char
{
Frame_Response = 0x00, //<2F><><EFBFBD><EFBFBD>֡
Frame_Request = 0x01, //<2F><><EFBFBD><EFBFBD>֡
Frame_Echo_Request = 0x02, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡
Frame_DeviceData_Request = 0x03, //<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>
}FrameType;
typedef struct tagFrameTail
{
unsigned char frame_delimiter[4] = { 0xEE,0xFF,0xEE,0xFF };
}FrameTail;
typedef struct tagFrame
{
FrameType frame_type; //֡<><D6A1><EFBFBD><EFBFBD>
unsigned int frame_len; //֡<><D6A1><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
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;
}
}MessageFrame;
__NAMESPACE_END__(HJ)
#pragma pack()