串口ok
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* ParserPack.h
|
||||
*
|
||||
* Created on: Jun 24, 2020
|
||||
* Author: matth
|
||||
*/
|
||||
|
||||
#ifndef MATT_PARSEPACK_H_
|
||||
#define MATT_PARSEPACK_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#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_cal;
|
||||
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);
|
||||
|
||||
|
||||
#endif /* MATT_PARSEPACK_H_ */
|
||||
Reference in New Issue
Block a user