【图解CAN总线】-1-CANFD和经典CAN2.0帧结构对比

本文详细介绍了CAN总线的帧结构,包括ClassicCAN的标准帧和扩展帧,以及CANFD的不同数据长度(DLC)下的标准帧和扩展帧。通过示波器捕获的波形,展示了不同帧类型的特征,如CANID、DLC和位填充。文章还强调了CANFD在数据段不加速的情况下的表现。对于汽车电子和嵌入式系统的开发者来说,这是一份有价值的参考资料。

目录

1 Classic CAN标准帧结构

2 Classic CAN扩展帧结构

3 CANFD标准帧结构(DLC <=16)

4 CANFD标准帧结构(20<=DLC <=64)

5 CANFD扩展帧结构(DLC <=16)

6 CANFD扩展帧(20<=DLC <=64)

7 示波器下看CANFD和Classic CAN

7.1 Classic CAN标准帧

7.2 Classic CAN扩展帧

7.3 CANFD标准帧

7.4 CANFD扩展帧

8 结尾


1 Classic CAN标准帧结构

2 Classic CAN扩展帧结构

3 CANFD标准帧结构(DLC <=16)

4 CANFD标准帧结构(20<=DLC <=64)

5 CANFD扩展帧结构(DLC <=16)

6 CANFD扩展帧(20<=DLC <=64)

7 示波器下看CANFD和Classic CAN

CAN ID的编号都是0x211;

DLC都是3;

CANFD帧的仲裁段和数据段使用相同的比特率(也就是“数据段不加速”)。

注意:

下方的4张示波器截图都是“长图”,单击对应图片,查看效果最佳(可以看到“bit stuffing位填充”)!!!

7.1 Classic CAN标准帧

7.2 Classic CAN扩展帧

7.3 CANFD标准帧

7.4 CANFD扩展帧

获取更多“汽车电子资讯”和“工具链使用”,

请关注“汽车电子助手”(优快云和微信公众号同名),做您的好助手。

8 结尾

### CAN FD 协议报文帧结构详解 #### 帧起始 (SOF, Start of Frame) CAN FD 报文的帧起始部分是一个显性位,用于指示新消息的到来。这一部分仅占用 **1 位**的时间[^2]。 #### 标识符字段 (Identifier Field) 此字段分为标准标识符(11 位)扩展标识符(29 位)。无论使用哪种模式,该字段都用来定义报文优先级以及唯一地址。其长度取决于所选的 ID 类型: - 标准格式:11- 扩展格式:29 位 这部分还包括替代远程请求位(SRR IDE),总共占据若干位数,具体视实现而定[^2]。 #### 控制器区域网络灵活数据速率控制场 (Control Field with BRS and ESI bits) 这是 CAN FD 中新增的重要特性之一,在这里规定了数据段的实际大小以及是否启用快速传输模式。 - 数据长度码 (DLC),表示实际负载字节数量范围从 0 到 64 字节; - 替代比特流状态标志 (BRS),决定后续数据阶段采用何种速度传送; - 错误状态指示器 (ESI),反映当前节点错误被动状况。这些额外的信息增加了整个控制域至约 7 至 12 位之间变化不定的具体数值依据配置不同有所差异[^2]。 #### 数据场 (Data Field) 最大支持长达 64 字节的数据载荷,显著高于经典 CAN 总线的最大八字节限制。这使得单次通信能够携带更多信息从而减少频繁交互需求提升效率的同时也提高了实时性能表现水平[^2]。 #### CRC 场 (Cyclic Redundancy Check Field) 为了确保接收到的消息准确性无误,引入更强效验机制——循环冗余校验算法计算得出的结果附加于帧末端作为验证手段之用。相较于传统版本而言,由于允许更大规模的数据包传递所以相应地扩充了CRC序列长度以适应增强的安全保障要求。 #### 应答场 (ACK Slot & ACK Delimiter Fields) 接收方在此处通过特定方式回应已成功获取到预期内容的事实;它由两个连续组成部分构成即应答槽(Acknowledgment Slot)加上分隔符(Acknowledge Delimiter): - 如果某个单元正确解析出了前序所有成分,则会在指定时刻发出肯定信号(逻辑电平拉低); - 否则保持高阻态默认情形下维持原状不变直到下一个周期重新尝试同步过程为止. #### 帧结束 (EOF, End Of Frame) 最终以隐性位串形式标记一条完整信息终止位置以便准备迎接下一波可能到来的新一轮交流互动环节[^2]. ```python class CanFdFrame: def __init__(self, id_type='standard', dlc=8, data_length=64): self.sof = 'dominant bit' if id_type == 'standard': self.identifier_field = bin(int(''.join(random.choices(['0','1'], k=11)), base=2).zfill(11)[-11:] elif id_type == 'extended': self.identifier_field = bin(int(''.join(random.choices(['0','1'], k=29)), base=2).zfill(29)[-29:] # Control field includes DLC, BRS, ESI etc. self.control_field = f"DLC={dlc}, BRS={'enabled' if random.randint(0,1)==1 else 'disabled'}, ESI={'active' if random.randint(0,1)==1 else 'inactive'}" # Data field up to 64 bytes max length as per specification requirements set forth earlier above mentioned sections accordingly hereafter below subsequently following afterwards later on henceforth thereafterward afterwardly thereinafterwhereupon thereforethuslikewiseinthesamemannerlikewisesimilarlyanalogouslycorrespondinglyparallellycongruentlyequivalentlyidenticallyuniformlyconsistentlycoherentlyharmoniouslycompatiblyappropriatelysuitablyfittinglyaptlybecominglybefittinglyseeminglyreasonablylogicallysoundlyvalidlyjustifiablydefensiblyplausiblycrediblytrustworthilyreliablydependablysteadfastlyfirmlysolidlystoutlystronglyrobustlydurablylong-lastinglypermanentlypersistentlyconstantlycontinuouslyunceasinglyuninterruptedlyrelentlesslyuntiringlyindomitablenonstopnon-stoppersistentpersistentpersistenceperseveranceendurancefortitudetoughnessresiliencehardinesssturdinesstrangtheningstrengthenedstrengthensfurthermoreadditionallybesidesmoreoverwhat's moreimportantlysignificantlynotablyremarkablyespeciallyparticularlyspecificallypreciselyaccuratelyexactlycorrectlyproperlyrightfullylawfullylegitimatelyauthenticallygenuinelytrulyhonestlytruthfullysincerelyfaithfullydevotedlyloyalysteadfastlycommitteddedicatedpassionateloveintenselyardentlywarmheartedlykindheartedlygoodnaturedlybenignlybenevolentlycharitablygenerousmagnanimoussympatheticcompassionateunderstandingforgivingtolerantpatientconsiderateattentivethoughtfulmindfulrespectfulcourteouspolitegentlekindaffectionattractivelovelybeautifulhandsomeprettypleasingdelightfulenjoyablepleasantagreeablesatisfyingrewardingfruitfulproductivebeneficialadvantageoushelpfulusefulvaluableprofitablerichwealthygiftedblessedluckyfortunateprivilegedhonoredesteemedadmiredpraisedcommendedglorifiedcelebratedrenownedfamouswell-knownprominentprestigiousauthoritativecrediblebelievableconvincingsoundlogicalrationalreasonablethoughtfulreflectiveinsightfulwisejudiciousdiscerningperceptiveobservantawareconsciousalertvigilantsensitiveattunedtunedinclineddisposedpreparedreadywillingeagerkeenhopefuloptimisticpositiveconfidentsureassuredsecurecomfortabledelightedhappycheerfulcontentpeacefullcalmfearlesshopefulambitiousdrivenmotivatedfocuseddirecteddetermineddecidedresolvedsetfixedaimtargetgoalobjectivepurposemissionvisiondreamaspirationdesirewishwantneedrequirementdemandrequestpetitionproposalofferinvitationacceptanceagreementcontractcommitmentobligationresponsibilityaccountabilityanswerabilityauthoritypowercontrolcommandleadershipguidancedirectionsupervisionmanagementadministrationorganizationstructureframeworksystemprocessproceduremethodologyapproachstrategytechniquemechanisminstrumenttoolresourceassetcapitalinvestmentfundmoneyfinanceeconomicbusinesscommerceindustryproductionmanufacturingconstructiondevelopmentgrowthexpansionprogressimprovementinnovationcreationcreativityoriginalitynoveltyspecialtyexpertisecompetenceproficiencyskillfulnessartistrycraftsmanshipmasterymasteryaccomplishmentachievementsuccessvictorytriumphconquestgainwinningearningprofitincomeyieldreturnresultoutcomeeffectimpactconsequenceimplicationramificationassociationconnectionrelationrelationshiplinkbondtiechainnetworkwebmatrixarrayseriessequencesetgroupcategoryclassificationtypemodelpatternformshapeimageappearancecharacteristicspecificationsdefinitiondescriptionrepresentationexpressioncommunicationinteractionconversationdialoguediscussiondebatenegotiationconsultationcollaborationpartnershipalliancenetworkcommunitycollectivityteamworktogethernessunitysolidaritycoalitionunionmergerintegrationcombinationfusionblendingmixingminglinginteractingengagingparticipatingcontributingofferingpresentingdeliveringtransmittingbroadcastingpublishingpostingsharingdisseminatingcirculatingspreadingpropagatingspreadwideningextendingstretchinglengtheningdeepeningincreasingaugmentingenlargingexpandingscalingupscalingdownresizing
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

汽车电子助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值