CANBeded——诊断自动生成代码

目录

一、如何自动生成代码

二、借鉴之处


 

一、如何自动生成代码

准备:
.gny——geny工程
.dbc——CAN 信号矩阵
.cdd——诊断文件
.cfg文件——工程文件宏定义

1.1 打开gny文件

ce4de1a14ecb4f079be4116892aa0aa9.png

1.2 导入dbc文件

f585643cf7b0414da0354904a0268a98.png

根据dbc文件更新can消息
channel0,configurable options,Acceptance Filter Configuration,optimize
Rx Signals编辑,Add需要接收的信号

1.3 导入cdd文件

3dc3c7b9a9b84deb84d2d808879076bf.png

1.4 导入cfg文件
在configurable options中选择user Config File,   设置生成代码路径

d4efa80b36da4ce3a579036ce5742051.png

1.5 生成代码

b92bf2d255254738ab95ebf604496ef5.png

 

二、借鉴之处

appdesc.c
desc.h 应用层定义
drv_par.h 物理驱动层
nmb_cfg.h 网络管理配置信息
tp_cfg.h   传输层参数配置信息
v_inc.h    定义文件版本
v_par.h    定义软件版本信息
ccl_cfg.h 定义外部接口

基本流程如下:

bc419fe5cd114d3d971ee6c15d3b5d0f.png

 


/*session id*/
typedef struct DescStateInfoTag
{
  DescStateGroup stateSession : 2;
  DescStateGroup stateGap_0 : 6;
} DescStateInfo;

/*service id*/
typedef vuint8  DescMsgItem;
DescMsgItem g_descSidMap[];

typedef struct
{
  DescBitType                reqHeadByteSpec   :8; /* Each bit represents sub-function/identifier - 0: identifier; 1: any subfunction */
#if defined(DESC_ENABLE_SUB_SVC_USAGE)
  DescBitType                reqHeadExLen      :4; /* Request HeadEx length up to 7 Byte  */
  DescBitType                resHeadExLen      :4; /* Response HeadEx length up to 7 Byte */
#endif
#if defined (DESC_ENABLE_ADDR_METHOD_CHECK)
  DescBitType             reqType           :2; /* 0x01: Phys 0x02: Func */
  DescBitType             resOnReq          :2; /* 0x01: Phys 0x02: Func */
#endif
  DescBitType             suppPosRes        :1; /* 0x00: No   0x01: Yes  */
  DescBitType             isReqHeadExtEchoed:1; /* 0x00: No   0x01: Yes  */
  DescBitType             hasSubFunction    :1; /* 0x00: No   0x01: Yes  */
#if (kDescNumSvcHeadConstGapBits > 0)
  DescBitType             svcHeadPlaceHolder:kDescNumSvcHeadConstGapBits; /* Gap holder  */
#endif
#if defined (DESC_ENABLE_AUTO_STATES)
# if defined (DESC_ENABLE_ALL_STATEGROUPS_SID_CHECK)
  DescStateInfo           checkState;
# else
#  if (kDescNumStateSession > 0)
  DescStateGroup          checkSessionState :kDescNumStateSession;/* State group Session on SId level */
#   if (kDescNumSvcHeadSessionGapBits > 0)
  DescBitType             sessionPlaceHolder:kDescNumSvcHeadSessionGapBits; /* Gap holder  */
#   endif
#  endif
# endif
#endif
#if defined (DESC_ENABLE_MIN_REQ_LEN_CHECK) && \
    defined (DESC_ENABLE_SUB_SVC_USAGE)
  vuint8                  minReqLength;
#endif
#if defined (DESC_ENABLE_MULTI_VARIANT)
  DescVariantMask         variantMask;
#endif
/* First item in Service Instance table */
  DescMemSvcInstIndex        svcInstFirstItem;
  DescMemSvcInstHeadExtIndex svcInstHeadExtFirstItem;
} DescSvcHead;
/* Table of service ID relevant information. */
V_MEMROM0 static V_MEMROM1 DescSvcHead V_MEMROM2 g_descSvcHead[kDescSvcHeadNumItems] = 
{
  { 0x01, 1, 1, 1, 1, 1, 0x00, { 0x03, 0x00 },  2,  0,  0 } /* $10 */, 
  { 0x01, 0, 0, 0, 1, 0, 0x00, { 0x03, 0x00 },  4,  2,  2 } /* $14 */, 
  { 0x01, 1, 1, 1, 1, 1, 0x00, { 0x03, 0x00 },  2,  3,  2 } /* $19 */, 
  { 0x01, 0, 0, 0, 1, 0, 0x00, { 0x03, 0x00 },  1,  9,  8 } /* $22 */, 
  { 0x01, 1, 1, 1, 1, 1, 0x00, { 0x02, 0x00 },  2, 10,  8 } /* $28 */, 
  { 0x07, 2, 2, 0, 1, 0, 0x00, { 0x03, 0x00 },  4, 12, 10 } /* $2E */, 
  { 0x01, 0, 0, 1, 1, 1, 0x00, { 0x03, 0x00 },  1, 22, 30 } /* $31 */, 
  { 0x01, 1, 1, 1, 1, 1, 0x00, { 0x03, 0x00 },  2, 23, 30 } /* $3E */, 

  { 0x00, 0, 0, 0, 1, 0, 0x00, { 0x03, 0x00 },  1, 24, 31 } /* $FF */
};

typedef struct
{
  DescMsgLen             reqLen;
#if defined (DESC_ENABLE_ADDR_METHOD_CHECK)
  DescMsgAddInfo         msgAddInfo;
#endif
#if defined (DESC_ENABLE_AUTO_STATES)
  DescStateInfo          checkState;
# if (kDescStateGroupNumTransition > 0)
  DescSetStateIndex      setStateIndex;
# endif
#endif /* DESC_ENABLE_AUTO_STATES */
#if defined (DESC_ENABLE_MULTI_VARIANT)
  DescVariantMask        variantMask;
#endif
#if defined (DESC_ENABLE_PREHANDLER_USAGE)
  DescPreHandlerIndex    preHandlerRef;
#endif
#if defined (DESC_ENABLE_POSTHANDLER_USAGE)
  DescPostHandlerIndex   postHandlerRef;
#endif
  DescMainHandler        mainHandler;
} DescSvcInst;

/* Table of sub-service protocol information. */
V_MEMROM0 static V_MEMROM1 DescMsgItem V_MEMROM2 g_descSvcInstHeadExt[kDescSvcInstHeadExtNumItems] = 
{
  0x01, 0x03 /* $10 */, 
  0x01, 0x02, 0x03, 0x04, 0x05, 0x0A /* $19 */, 
  0x00, 0x03 /* $28 */, 
  0x10, 0x41, 0x10, 0x42, 0x10, 0x43, 0x10, 0x44, 0x10, 0x66, 0x10, 0x67, 0x10, 0x68, 0x10, 0x69 /* $2E */, 
  0x10, 0x6A, 0x10, 0x6B /* $2E */, 
  0x00 /* $3E */
};


/* Table of all RIDs' */
V_MEMROM0 static V_MEMROM1 vuint16 V_MEMROM2 g_descRidLookUpTable[kDescNumRids] = 
{
  0x0201, 0x0202, 0x0203, 0x0204, 0x0205, 0x0221, 0x0225, 
  0x0226, 0x0227
};
/* Table of RIDs' sub-function to control type mapping. */
V_MEMROM0 static V_MEMROM1 vuint8 V_MEMROM2 g_descRidSubFuncToCtrlTypeMap[4] = 
{
  27, 
  0, 
  1, 
  2
};
/* Table of all RIDs' properties. */
V_MEMROM0 static V_MEMROM1 DescRidTinyInfo V_MEMROM2 g_descRIDInfo[kDescNumRids] = 
{
  { { 0x03, 0x00 }, { 0x01, 0x01, 0 } } /* $0202 */, 
};

typedef struct
{
  DescMsgLen           reqDataLen; /* contains the RID and the request parameters' length only*/
  DescRidTinyInfo      tinyInfo;
#if defined (DESC_ENABLE_RID_POSTHANDLER_USAGE)
  DescPostHandlerIndex postHandlerRef;
#endif
  DescMainHandler      mainHandler;
} DescRidInst;

 

 

 

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值