重新构建的批检仪主板程序
This commit is contained in:
@@ -13,9 +13,16 @@ public:
|
||||
fullFrame = false;
|
||||
}
|
||||
virtual ~Codec() {}
|
||||
virtual myarray encode(int srcAddr, int dstAddr, int cmd, myarray data) = 0;
|
||||
virtual myarray decode(int &srcAddr, int &dstAddr, int &cmd, myarray data) = 0;
|
||||
virtual myarray decode(int &srcAddr, int &dstAddr, int &cmd)
|
||||
// 返回true,则是一个完整的帧
|
||||
// virtual bool packCheck(myarray data){return false;}
|
||||
// virtual bool recvByte(int byte){return false;}
|
||||
// virtual myarray encode(int srcAddr, int dstAddr, int cmd, myarray data){return myarray();}
|
||||
// virtual myarray decode(int &srcAddr, int &dstAddr, int &cmd, myarray data){return myarray();}
|
||||
virtual bool packCheck(myarray data)=0;
|
||||
virtual bool recvByte(int byte)=0;
|
||||
virtual myarray encode(int srcAddr, int dstAddr, int cmd, myarray data)=0;
|
||||
virtual myarray decode(int &srcAddr, int &dstAddr, int &cmd, myarray data)=0;
|
||||
myarray decode(int &srcAddr, int &dstAddr, int &cmd)
|
||||
{
|
||||
if (fullFrame == true)
|
||||
{
|
||||
@@ -24,11 +31,37 @@ public:
|
||||
}
|
||||
return myarray();
|
||||
}
|
||||
virtual bool recvByte(int byte) = 0;
|
||||
|
||||
protected:
|
||||
bool fullFrame;
|
||||
myarray data;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
Codec *codecFind(const char *name);
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct{
|
||||
const char *name;
|
||||
Codec *(*codec_get_fun)();
|
||||
}codec_def;
|
||||
|
||||
|
||||
#define codec_export(name_,fun_) \
|
||||
const static char __codec_##name_##_name[] __attribute__((section(".rodata.codecstr"))) = #name_; \
|
||||
__attribute__((used)) static codec_def _codec_##name_ __attribute__((section("codecdef")))={\
|
||||
.name=__codec_##name_##_name,\
|
||||
.codec_get_fun=fun_,\
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // CODEC_H
|
||||
|
Reference in New Issue
Block a user