Files
checker_slave/source/task/prot_uc.h
2023-11-15 18:11:39 +08:00

81 lines
1.4 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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 sem_num;
uint32_t recv_tick;
int run;
char *str_err;
uint16_t cmd_no;
uint8_t cmd;
int is_big_data;
codec_item *codec;
int silent;// 此项为1不返回数据
};
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