78 lines
1.3 KiB
C
78 lines
1.3 KiB
C
#ifndef prot_uc_h__
|
|
#define prot_uc_h__
|
|
|
|
#include "signal.h"
|
|
#include "bytearray.h"
|
|
#include "list.h"
|
|
#include "board.h"
|
|
#include "rtthread.h"
|
|
|
|
struct _protu_def;
|
|
typedef array_def *(*codec_fun_def)(struct _protu_def *p,array_def *data);
|
|
|
|
typedef struct{
|
|
const char *name;
|
|
codec_fun_def decode;
|
|
codec_fun_def encode;
|
|
}codec_item;
|
|
|
|
|
|
struct _protu_def{
|
|
uart_def *uart;
|
|
uint8_t *buff;
|
|
int buff_index;
|
|
int num_to_recv;
|
|
void *sem;
|
|
int run;
|
|
char *str_err;
|
|
uint16_t cmd_no;
|
|
uint8_t cmd;
|
|
int is_big_data;
|
|
codec_item *codec;
|
|
};
|
|
typedef struct _protu_def protu_def;
|
|
|
|
|
|
|
|
protu_def *protu_creat(uart_def *uart);
|
|
|
|
|
|
|
|
|
|
signal protu_recv_signal(void *obj,const char *codec_name,uint8_t cmd,array_def *data,char *err_str);
|
|
|
|
void protu_reply_call(protu_def *p,array_def *data);
|
|
void protu_send_call(protu_def *p,uint8_t cmd,array_def *data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define protuc_codec_export(name_,decode_,encode_) \
|
|
const static char __codec_##name_##_name[] SECTION(".rodata.codecstr") = #name_; \
|
|
RT_USED static codec_item _codec_##name_ SECTION("codecstruct")= \
|
|
{\
|
|
.name=__codec_##name_##_name,\
|
|
.decode=decode_,\
|
|
.encode=encode_,\
|
|
};
|
|
|
|
|
|
|
|
// 查找指定解码器
|
|
codec_item *protu_find_codec(const char *name);
|
|
// 返回正在使用的解码器
|
|
codec_item *protu_codec_inuse(protu_def *p);
|
|
void protu_codec_set(protu_def *p,codec_item *c);
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|