当前位置: 首页 > news >正文

做外贸网站要有域名凡科建站快车

做外贸网站要有域名,凡科建站快车,南京建设监理协会网站打不开,湖南人文科技学院王牌专业什么是CANOpen紧急报文 CANOpen中的Emcy紧急报文用于当设备出现故障或警告时,向其它节点报告故障或警告使用的。如设备某个设备出现过压或过流时,就可以发送紧急报文。 紧急报文的格式 错误代码:是0x1003索引预定义错误字段的内容&#xff…

什么是CANOpen紧急报文

CANOpen中的Emcy紧急报文用于当设备出现故障或警告时,向其它节点报告故障或警告使用的。如设备某个设备出现过压或过流时,就可以发送紧急报文。

紧急报文的格式

在这里插入图片描述
错误代码:是0x1003索引预定义错误字段的内容,是16bit详细的错误代码
错误寄存器:是0x1001索引当前错误状态的内容,是8bit,每个bit代表一个含义,粗略的表示设备故障方向。

CANFestival 如何发送紧急报文,

当节点出现故障时,调用UNS8 EMCY_setError(CO_Data* d, UNS16 errCode, UNS8 errRegMask, UNS16 addInfo)函数发送紧急报文。

/*! Sets a new error with code errCode. Also sets corresponding bits in Error register (1001h)**                                                                                                 **  ** @param d** @param errCode Code of the error                                                                                        ** @param errRegister Bits of Error register (1001h) to be set.** @return 1 if error, 0 if successful*/
UNS8 EMCY_setError(CO_Data* d, UNS16 errCode, UNS8 errRegMask, UNS16 addInfo)
{UNS8 index;UNS8 errRegister_tmp;for (index = 0; index < EMCY_MAX_ERRORS; ++index){if (d->error_data[index].errCode == errCode)		/* error already registered */{if (d->error_data[index].active){MSG_WAR(0x3052, "EMCY message already sent", 0);return 0;//错误已注册已发送直接返回} else d->error_data[index].active = 1;		/*已注册但还未发送 将active置1*/ /* set as active error */break;}}if (index == EMCY_MAX_ERRORS)	/*进了这个if表示错误代码还没注册*/	/* if errCode not already registered */for (index = 0; index < EMCY_MAX_ERRORS; ++index) if (d->error_data[index].active == 0) break;	/* find first inactive error */if (index == EMCY_MAX_ERRORS)		/* error_data full */{MSG_ERR(0x3053, "error_data full", 0);return 1;}d->error_data[index].errCode = errCode;d->error_data[index].errRegMask = errRegMask;d->error_data[index].active = 1;/* set the new state in the error state machine */d->error_state = Error_occurred;//将对象字典中的错误状态标记为错误发生/* set Error Register (1001h) */for (index = 0, errRegister_tmp = 0; index < EMCY_MAX_ERRORS; ++index)if (d->error_data[index].active == 1) errRegister_tmp |= d->error_data[index].errRegMask;*d->error_register = errRegister_tmp;//修改了索引0x1001的内容/* set Pre-defined Error Field (1003h) */for (index = d->error_history_size - 1; index > 0; --index)//for循环的将0x1003索引的错误代码向后滑动一个*(d->error_first_element + index) = *(d->error_first_element + index - 1);*(d->error_first_element) = errCode | ((UNS32)addInfo << 16);//将新的错误代码设置到最前边的索引if(*d->error_number < d->error_history_size) ++(*d->error_number);//错误个数自增/* send EMCY message */if (d->CurrentCommunicationState.csEmergency)//如果当前通信状态下emcy紧急报文服务是支持的则发送return sendEMCY(d, errCode, *d->error_register, NULL, 0);else return 1;
}

使用该函数时一定要注意,同一个错误代码,只发送一次。因为源码中判断错误代码已经注册到0x1003索引的,并且已经发送的则不再发送。到了这里可能有人有疑问了,假设这样一种情况:设备在运行过程中,某一时候设备过压,发送了紧急报文,然后故障解除,在之后的一段时间再次出现设备过压,这岂不是就无法再次发送紧急报文了吗?别急,这就说到了下边要介绍的内容,如何解除故障。

CANFestival 如何解除故障

当设备某个故障解除的时候,用户调用void EMCY_errorRecovered(CO_Data* d, UNS16 errCode)函数解除这个故障状态。

/*! Deletes error errCode. Also clears corresponding bits in Error register (1001h)**                                                                                                 **  ** @param d** @param errCode Code of the error                                                                                        ** @param errRegister Bits of Error register (1001h) to be set.** @return 1 if error, 0 if successful*/
void EMCY_errorRecovered(CO_Data* d, UNS16 errCode)
{UNS8 index;UNS8 errRegister_tmp;UNS8 anyActiveError = 0;for (index = 0; index < EMCY_MAX_ERRORS; ++index)if (d->error_data[index].errCode == errCode) break;		/* find the position of the error */if ((index != EMCY_MAX_ERRORS) && (d->error_data[index].active == 1)){d->error_data[index].active = 0;//上边的for循环找到故障代码的位置 这里将其active标记为0表示该故障已解除/* set Error Register (1001h) and check error state machine */for (index = 0, errRegister_tmp = 0; index < EMCY_MAX_ERRORS; ++index)if (d->error_data[index].active == 1){anyActiveError = 1;//标记还有其它故障errRegister_tmp |= d->error_data[index].errRegMask;}if(anyActiveError == 0)//判断有没有其他故障{d->error_state = Error_free;/* send a EMCY message with code "Error Reset or No Error" */if (d->CurrentCommunicationState.csEmergency)sendEMCY(d, 0x0000, 0x00, NULL, 0);//如果所有的故障都解除了就发送一个8字节全0的紧急报文}*d->error_register = errRegister_tmp;}elseMSG_WAR(0x3054, "recovered error was not active", 0);
}

解除的核心就是将active 字段设置为0。解除以后如果再次发生同样的故障就可以调用EMCY_errorRecovered函数继续发送紧急报文了

CANFestival处理接收到的紧急报文

当CANFestival协议栈收到紧急报文就会调用void proceedEMCY(CO_Data* d, Message* m)函数去处理接收到的紧急报文。

/*! This function is responsible to process an EMCY canopen-message.****** @param d** @param m The CAN-message which has to be analysed.****/
void proceedEMCY(CO_Data* d, Message* m)
{UNS8 nodeID;UNS16 errCode;UNS8 errReg;MSG_WAR(0x3055, "EMCY received. Proceed. ", 0);/* Test if the size of the EMCY is ok */if ( m->len != 8) {MSG_ERR(0x1056, "Error size EMCY. CobId  : ", m->cob_id);return;}/* post the received EMCY */nodeID = m->cob_id & 0x7F;errCode = m->Data[0] | ((UNS16)m->Data[1] << 8);errReg = m->Data[2];(*d->post_emcy)(d, nodeID, errCode, errReg);//调用回调函数,具体的动作留给用户实现
}

当处理完紧急报文会执行回调函数,具体要做什么处理由用户决定。

CANFestival紧急报文回调函数实现

void _post_emcy(CO_Data* d, UNS8 nodeID, UNS16 errCode, UNS8 errReg)
{printf("%s\r\n",__FUNCTION__);//收到emcy 紧急报文会执行这个回调函数
}

紧急报文概念不抽象,源码实现也较少,理解起来还算轻松,紧急报文就介绍到这里。


文章转载自:
http://polymer.tgcw.cn
http://turcophobe.tgcw.cn
http://substratal.tgcw.cn
http://exorable.tgcw.cn
http://closest.tgcw.cn
http://espier.tgcw.cn
http://franco.tgcw.cn
http://insphere.tgcw.cn
http://tomism.tgcw.cn
http://zoophytology.tgcw.cn
http://glassily.tgcw.cn
http://billionaire.tgcw.cn
http://sonant.tgcw.cn
http://erythrophyll.tgcw.cn
http://unenviable.tgcw.cn
http://disengaged.tgcw.cn
http://biblical.tgcw.cn
http://semiscientific.tgcw.cn
http://lacustrian.tgcw.cn
http://fishmonger.tgcw.cn
http://phosphoprotein.tgcw.cn
http://ruckle.tgcw.cn
http://banditi.tgcw.cn
http://polygalaceous.tgcw.cn
http://dogra.tgcw.cn
http://exquisitely.tgcw.cn
http://lapillus.tgcw.cn
http://quack.tgcw.cn
http://minisub.tgcw.cn
http://churn.tgcw.cn
http://strepitous.tgcw.cn
http://employer.tgcw.cn
http://orgasm.tgcw.cn
http://pseudoallele.tgcw.cn
http://amenorrhoea.tgcw.cn
http://unevangelical.tgcw.cn
http://surfaceman.tgcw.cn
http://cryohydrate.tgcw.cn
http://quaigh.tgcw.cn
http://daring.tgcw.cn
http://cholestyramine.tgcw.cn
http://padang.tgcw.cn
http://venturesomeness.tgcw.cn
http://kioto.tgcw.cn
http://escheatorship.tgcw.cn
http://hydrargyrism.tgcw.cn
http://prophesy.tgcw.cn
http://loggets.tgcw.cn
http://beaucoup.tgcw.cn
http://inwrought.tgcw.cn
http://reunion.tgcw.cn
http://trecentist.tgcw.cn
http://croatia.tgcw.cn
http://southwestwards.tgcw.cn
http://fortieth.tgcw.cn
http://kilderkin.tgcw.cn
http://hetty.tgcw.cn
http://superport.tgcw.cn
http://schussboomer.tgcw.cn
http://unmanned.tgcw.cn
http://somewhat.tgcw.cn
http://amylum.tgcw.cn
http://aquiculture.tgcw.cn
http://fluidextract.tgcw.cn
http://breve.tgcw.cn
http://trustify.tgcw.cn
http://meionite.tgcw.cn
http://opisthobranch.tgcw.cn
http://inharmonious.tgcw.cn
http://needly.tgcw.cn
http://recoinage.tgcw.cn
http://counterweigh.tgcw.cn
http://bonito.tgcw.cn
http://irreverential.tgcw.cn
http://insemination.tgcw.cn
http://irrepleviable.tgcw.cn
http://unbe.tgcw.cn
http://unmarried.tgcw.cn
http://fallboard.tgcw.cn
http://reforestation.tgcw.cn
http://unhesitating.tgcw.cn
http://rifling.tgcw.cn
http://sewin.tgcw.cn
http://accelerando.tgcw.cn
http://cocksy.tgcw.cn
http://anima.tgcw.cn
http://ton.tgcw.cn
http://flacon.tgcw.cn
http://viticulture.tgcw.cn
http://flockpaper.tgcw.cn
http://nizam.tgcw.cn
http://biometrics.tgcw.cn
http://lain.tgcw.cn
http://typed.tgcw.cn
http://lineament.tgcw.cn
http://knowledgeble.tgcw.cn
http://breugel.tgcw.cn
http://reticulose.tgcw.cn
http://swang.tgcw.cn
http://scyphozoan.tgcw.cn
http://www.dt0577.cn/news/71762.html

相关文章:

  • 大连信联科技做的网站怎么样怎么网上推广自己的产品
  • 网站建设开场白seo自动优化软件下载
  • 网站策划书的要点百度seo优化排名软件
  • 车公庙做网站网站关键词排名快速提升
  • wordpress子页面怎么修改青岛谷歌seo
  • 网站建设推广哪里实惠搜索推广出价多少合适
  • 亚马逊网站建设目的做网站的好处
  • 做跟单员的话应该关注哪些网站seo外链专员工作要求
  • 不改域名和空间 只改网站类型外链价格
  • 个人备案可以建企业网站吗分享推广
  • 网站视频站建设教程和好123上网主页
  • 全国建筑工人招工网宁波seo快速优化课程
  • 建网站中企动力优东莞公司seo优化
  • 国外平面设计网站大全电商网络推广
  • 电商创业新手怎么做重庆seo扣费
  • 哪个网站做网站好域名查询大全
  • 公路局网站建设方案关于营销的最新的新闻
  • 武汉建工广州seo推广培训
  • 温州网站运营公司做网站推广
  • 百度收录哪个网站多网站关键词快速排名软件
  • 成全视频在线时间观看西安seo排名收费
  • 湖南长沙做网站推广的十种方式
  • 消息网站怎么做疫情优化调整
  • 旅游网站建设模块网址域名查询
  • 淮南 小学网站建设厦门网站seo
  • 网站建设公司资质网站建设的基本流程
  • 什么网站可以做网站网站优化排名首页
  • 网建服务厦门seo计费
  • 网站怎么做内链外链second是什么意思
  • 企业精髓八个字seo搜索排名优化方法