所有协议解析完成
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* ParserPack.h
|
||||
*
|
||||
* Created on: Jun 24, 2020
|
||||
* Author: matth
|
||||
*/
|
||||
|
||||
#ifndef MATT_PARSEPACK_H_
|
||||
#define MATT_PARSEPACK_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef PARSER_BUFF_LEN
|
||||
#define PARSER_BUFF_LEN (512)
|
||||
#endif
|
||||
|
||||
#ifndef PACKER_BUFF_LEN
|
||||
#define PACKER_BUFF_LEN (512+6)
|
||||
#endif
|
||||
|
||||
typedef struct{
|
||||
int stage;
|
||||
uint16_t idx;
|
||||
uint16_t len;
|
||||
uint8_t seq;
|
||||
uint16_t id;
|
||||
uint16_t crc16;
|
||||
uint32_t crc_err_cnt;
|
||||
uint32_t head_err_cnt;
|
||||
uint8_t buff[PARSER_BUFF_LEN];
|
||||
} Parser_t;
|
||||
|
||||
typedef struct{
|
||||
uint8_t seq;
|
||||
uint8_t buff[PARSER_BUFF_LEN];
|
||||
} Packer_t;
|
||||
|
||||
void Parser_init(Parser_t *parser);
|
||||
void Packer_init(Packer_t *pack);
|
||||
|
||||
int Parser_char(Parser_t *parser, uint8_t c);
|
||||
size_t Packer_pack(Packer_t *pack, uint8_t id, uint8_t pkg[], uint16_t len);
|
||||
|
||||
typedef struct{
|
||||
int stage;
|
||||
uint8_t idx;
|
||||
uint8_t len;
|
||||
uint16_t id;
|
||||
uint8_t sum;
|
||||
uint8_t buff[255];
|
||||
} Parser2_t;
|
||||
|
||||
typedef struct{
|
||||
uint8_t buff[260];
|
||||
} Packer2_t;
|
||||
|
||||
void Parser2_init(Parser2_t *parser);
|
||||
void Packer2_init(Packer2_t *pack);
|
||||
|
||||
int Parser2_char(Parser2_t *parser, uint8_t c);
|
||||
size_t Packer2_pack(Packer2_t *pack, uint8_t id, uint8_t pkg[], uint8_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MATT_PARSEPACK_H_ */
|
||||
Reference in New Issue
Block a user