大疆社区
标题:
达人们,LightBrige中的接口定义D-BUS是个什么接口?
[打印本页]
作者:
shifeller
时间:
2015-7-16
标题:
达人们,LightBrige中的接口定义D-BUS是个什么接口?
达人们,大家好!
最近在玩LightBrige,了解到其有一个D-BUS接口用来传输飞控信息,
,还有一个Gimbal port,在用户手册里定义了其功能,以及与云台对接的使用方法。但是,其接口是采用的什么协议呢?硬件接口规格是什么呢?
心中怀着工程师的执着,查询了一圈,还是没有搞明白这两个接口的定义。到底是什么呢?
有知道的达人们,说说看。
无标题.png
(25.67 KB, 下载次数: 21)
下载附件
保存到相册
2015-7-16 上传
作者:
community_user_
时间:
2015-7-16
就是变种的s.bus嘛~~ 多好理解
作者:
shifeller
时间:
2015-7-19
<div class="quote"><blockquote><font size="2"><a class="nopicture" rel="noopener" href="https://bbs.dji.com/forum.php?mod=redirect&goto=findpost&pid=197509&ptid=18066" target="_blank"><font color="#999999">borneol@21cn.co 发表于 2015-7-16 07:03</font></a></font>
就是变种的s.bus嘛~~ 多好理解</blockquote></div>s.bus又是什么接口?:)多谢
作者:
community_user_
时间:
2015-7-20
<div class="quote"><blockquote><font size="2"><a class="nopicture" rel="noopener" href="https://bbs.dji.com/forum.php?mod=redirect&goto=findpost&pid=201453&ptid=18066" target="_blank"><font color="#999999">shifeller 发表于 2015-7-19 22:03</font></a></font>
s.bus又是什么接口?:)多谢</blockquote></div> S-bus<font face="宋体">为</font>futaba<font face="宋体">使用的串行通信协议。实际上为串口通信。但是有几点需要注意:</font>
<div align="left">1. 在大端小端上,网上资料都说的不是很清楚;</div><div align="left">2. 跟TTL串口信号相比,S-bus的逻辑电平是反的,需用如下电路对电平反相,再借到串口接收的Rx管脚就可以了;</div><div align="left"><a class="nopicture" rel="noopener" href="http://upload.semidata.info/www.eefocus.com/blog/media/201405/322082.png" target="_blank"><img data-type="image" id="aimg_Uo7Bn" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="http://upload.semidata.info/www.eefocus.com/blog/media/201405/322082.png" data-src="http://upload.semidata.info/www.eefocus.com/blog/media/201405/322082.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" onerror="this.src='/static/image/common/state_empty_cover.png';this.setAttribute('data-type','default-image');"/></a></div><div align="left">一、协议说明:</div><div align="left">串口配置为波特率100kbps,8位数据,偶校验(even),2位停止位,无流控。</div><div align="left">链接<a rel="noopener" href="https://mbed.org/users/Digixx/notebook/futaba-s-bus-controlled-by-mbed/" target="_blank">https://mbed.org/users/Digixx/no ... controlled-by-mbed/</a>说明了S-bus帧格式。每帧25个字节,按照如下顺序排列:</div><div align="center"><font color="#222222"><font face="""><font style="font-size:10.5pt">[startbyte] [data1] [data2] .... [data22] [flags][endbyte]</font></font></font></div>
<div align="left"><font color="#222222"><font face="宋体"><font style="font-size:10.5pt">起始字节</font></font></font><font color="#222222"><font face="""><font style="font-size:10.5pt">startbyte = 11110000b (0xF0)</font></font></font><font color="#222222"><font face="宋体"><font style="font-size:10.5pt">,但实际上用</font></font></font><font color="#222222"><font face="""><font style="font-size:10.5pt">STM32</font></font></font><font color="#222222"><font face="宋体"><font style="font-size:10.5pt">(据说</font></font></font><font color="#222222"><font face="""><font style="font-size:10.5pt">ARM</font></font></font><font color="#222222"><font face="宋体"><font style="font-size:10.5pt">核)收到的是</font></font></font><font color="#222222"><font face="""><font style="font-size:10.5pt">0x0F</font></font></font><font color="#222222"><font face="宋体"><font style="font-size:10.5pt">。中间</font></font></font><font color="#222222"><font face="""><font style="font-size:10.5pt">22</font></font></font><font color="#222222"><font face="宋体"><font style="font-size:10.5pt">个字节就是</font></font></font><font color="#222222"><font face="""><font style="font-size:10.5pt">16</font></font></font><font color="#222222"><font face="宋体"><font style="font-size:10.5pt">个通道的数据了,为什么是</font></font></font><font color="#222222"><font face="""><font style="font-size:10.5pt">16</font></font></font><font color="#222222"><font face="宋体"><font style="font-size:10.5pt">个通道?因为</font></font></font><font color="#222222"><font face="""><font style="font-size:10.5pt">22x8=11x16</font></font></font><font color="#222222"><font face="宋体"><font style="font-size:10.5pt">,每个通道用</font></font></font><font color="#222222"><font face="""><font style="font-size:10.5pt">11bit</font></font></font><font color="#222222"><font face="宋体"><font style="font-size:10.5pt">表示,范围是</font></font></font><font color="#222222"><font face="""><font style="font-size:10.5pt">0-2047</font></font></font><font color="#222222"><font face="宋体"><font style="font-size:10.5pt">。不信看波形图:</font></font></font></div><div align="left"><font color="#222222"></font></div><div align="left"><a class="nopicture" rel="noopener" href="http://upload.semidata.info/www.eefocus.com/blog/media/201405/322083.png" target="_blank"><img data-type="image" id="aimg_QlL9M" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="http://upload.semidata.info/www.eefocus.com/blog/media/201405/322083.png" data-src="http://upload.semidata.info/www.eefocus.com/blog/media/201405/322083.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" onerror="this.src='/static/image/common/state_empty_cover.png';this.setAttribute('data-type','default-image');"/></a></div><div align="left"><font face="宋体">什么,还看不清?</font></div><div align="left"><a class="nopicture" rel="noopener" href="http://upload.semidata.info/www.eefocus.com/blog/media/201405/322084.png" target="_blank"><img data-type="image" id="aimg_v7fuo" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="http://upload.semidata.info/www.eefocus.com/blog/media/201405/322084.png" data-src="http://upload.semidata.info/www.eefocus.com/blog/media/201405/322084.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" onerror="this.src='/static/image/common/state_empty_cover.png';this.setAttribute('data-type','default-image');"/></a></div><div align="left">两帧之间的时间间隔4ms(高速模式),约7ms一帧。</div><div align="left"><a class="nopicture" rel="noopener" href="http://upload.semidata.info/www.eefocus.com/blog/media/201405/322085.png" target="_blank"><img data-type="image" id="aimg_DZT33" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="http://upload.semidata.info/www.eefocus.com/blog/media/201405/322085.png" data-src="http://upload.semidata.info/www.eefocus.com/blog/media/201405/322085.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" onerror="this.src='/static/image/common/state_empty_cover.png';this.setAttribute('data-type','default-image');"/></a></div><div align="left"><a class="nopicture" rel="noopener" href="http://upload.semidata.info/www.eefocus.com/blog/media/201405/322086.png" target="_blank"><img data-type="image" id="aimg_HR8ur" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="http://upload.semidata.info/www.eefocus.com/blog/media/201405/322086.png" data-src="http://upload.semidata.info/www.eefocus.com/blog/media/201405/322086.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" onerror="this.src='/static/image/common/state_empty_cover.png';this.setAttribute('data-type','default-image');"/></a></div><div align="left"><a class="nopicture" rel="noopener" href="http://upload.semidata.info/www.eefocus.com/blog/media/201405/322087.png" target="_blank"><img data-type="image" id="aimg_YDuAB" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="http://upload.semidata.info/www.eefocus.com/blog/media/201405/322087.png" data-src="http://upload.semidata.info/www.eefocus.com/blog/media/201405/322087.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" onerror="this.src='/static/image/common/state_empty_cover.png';this.setAttribute('data-type','default-image');"/></a></div><div align="left">基本而言,data1为ch1的低8位,data2的低3位为ch1的高三位,data2的高5位是ch2的低5位,data3的低6位是ch2的高6位,以此类推,如下图所示:</div><div align="left"><a class="nopicture" rel="noopener" href="http://upload.semidata.info/www.eefocus.com/blog/media/201405/322088.png" target="_blank"><img data-type="image" id="aimg_YujEx" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="http://upload.semidata.info/www.eefocus.com/blog/media/201405/322088.png" data-src="http://upload.semidata.info/www.eefocus.com/blog/media/201405/322088.png" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" onerror="this.src='/static/image/common/state_empty_cover.png';this.setAttribute('data-type','default-image');"/></a></div><div align="left">flags<font face="宋体">的结构如下所示:</font></div><div align="left"><font color="#222222"><font face="""><font style="font-size:10.5pt">flags</font></font></font><font color="#222222"><font face="宋体"><font style="font-size:10.5pt">:</font></font></font><font color="#222222"></font></div><div align="left"><font color="#222222"><font face="""><font style="font-size:10.5pt">bit7 = ch17 = digital channel (0x80)</font></font></font><font color="#222222"><font face="""><font style="font-size:10.5pt">
bit6 = ch18 = digital channel (0x40)
bit5 = Frame lost, equivalent red LED on receiver (0x20)
bit4 = failsafe activated (0x10)
bit3 = n/a
bit2 = n/a
bit1 = n/a
bit0 = n/a</font></font></font></div><div align="left"><font color="#222222"><font face="""><font style="font-size:10.5pt"> </font></font></font></div>
<div align="left"><font color="#222222"><font face="""><font style="font-size:10.5pt">endbyte</font></font></font><font color="#222222"><font face="宋体"><font style="font-size:10.5pt">为</font></font></font><font color="#222222"><font face="""><font style="font-size:10.5pt">0x00</font></font></font><font color="#222222"><font face="宋体"><font style="font-size:10.5pt">。</font></font></font></div><div align="left">一、程序实现:</div><div align="left">在STM32中的具体实现,除了如上述内容配置串口参数,还需要写好中断函数,写好解析函数。思路很简单,利用间隔时间来区分两帧,收到一帧数据后,做如下检查:</div><div align="left">1. 字节数够不够?</div><div align="left">2. 第一个字节是不是0x0f?</div><div align="left">3. 最后一个字节是不是0x00?</div><div align="left">4. 检查flag中的标志位</div><div align="left"><font face="宋体">举个中断函数栗子:</font></div><div align="left">void UART4_IRQHandler(void)</div><div align="left">{</div><div align="left"> static uint8_t byteCNT = 0;</div><div align="left"> </div><div align="left"> static uint32_t lastTime = 0;</div><div align="left"> uint32_t curTime;</div><div align="left"> uint32_t interval = 0;</div><div align="left"> </div><div align="left"> HAL_NVIC_ClearPendingIRQ(UART4_IRQn);</div><div align="left"> </div><div align="left"> //<font face="宋体">如果时间间隔大于</font>3<font face="宋体">毫秒,则认为是新的一帧</font></div><div align="left"> if(lastTime == 0)</div><div align="left"> {</div><div align="left"> curTime = HAL_GetTick();</div><div align="left"> lastTime = curTime;</div><div align="left"> }</div><div align="left"> else</div><div align="left"> {</div><div align="left"> curTime = HAL_GetTick();</div><div align="left"> interval = curTime - lastTime;</div><div align="left"> lastTime = curTime;</div><div align="left"> </div><div align="left"> if(interval >= 3)</div><div align="left"> {</div><div align="left"> if(byteCNT == 25 && uart4_cache1[0] == 0x0f && uart4_cache1[24] == 0x00)</div><div align="left"> {</div><div align="left"> rc_captured = 0;</div><div align="left"> memcpy(uart4_cache2, uart4_cache1, byteCNT);</div><div align="left"> rc_captured = 1;</div><div align="left"> }</div><div align="left"> byteCNT = 0;</div><div align="left"> }</div><div align="left"> }</div><div align="left"> </div><div align="left"> if(RESET != __HAL_UART_GET_FLAG(&huart4, UART_FLAG_ORE))</div><div align="left"> {</div><div align="left"> __HAL_UART_CLEAR_FLAG(&huart4, UART_FLAG_ORE);</div><div align="left"> uart4_cache1[byteCNT++] = huart4.Instance->DR;</div><div align="left"> }</div><div align="left"> </div><div align="left"> if(RESET != __HAL_UART_GET_FLAG(&huart4, UART_FLAG_RXNE))</div><div align="left"> {</div><div align="left"> uart4_cache1[byteCNT++] = huart4.Instance->DR;</div><div align="left"> }</div>
}
作者:
449114643@qq.co
时间:
2016-4-27
围观学习
作者:
autumu
时间:
2017-2-23
<div class="quote"><blockquote><a class="nopicture" rel="noopener" href="https://bbs.dji.com/forum.php?mod=redirect&goto=findpost&pid=201723&ptid=18066" target="_blank"><font color="#5c5c5c">borneol@21cn.co</font><font color="#5c5c5c">悟1</font><font color="#9d9d9d">2015-7-20 07:15</font></a>
S-bus为futaba使用的串行通信协议。实际上为串口通信。但是有几点需要注意:
1. 在大端小端上,网上资料都说的不是很清楚;2. 跟TTL串口信号相比,S-bus的逻辑电平是反的,需用如下电路对电平反相,再借到串口接收的Rx管脚就可以了;<a class="picture" rel="noopener" href="https://bbs.dji.com/forum.php?mod=redirect&goto=findpost&pid=201723&ptid=18066" target="_blank">[图片]</a>一、协议说明:串口配置为波特率100kbps,8位数据,偶校验(even),2位停止位,无流控。链接https://mbed.org/users/Digixx/notebook/futaba-s-bus-controlled-by-mbed/说明了S-bus帧格式。每帧25个字节,按照如下顺序排列:[startbyte] [data1] [data2] .... [data22] [flags][endbyte]
起始字节startbyte = 11110000b (0xF0),但实际上用STM32(据说ARM核)收到的是0x0F。中间22个字节就是16个通道的数据了,为什么是16个通道?因为22x8=11x16,每个通道用11bit表示,范围是0-2047。不信看波形图:<a class="picture" rel="noopener" href="https://bbs.dji.com/forum.php?mod=redirect&goto=findpost&pid=201723&ptid=18066" target="_blank">[图片]</a>什么,还看不清?<a class="picture" rel="noopener" href="https://bbs.dji.com/forum.php?mod=redirect&goto=findpost&pid=201723&ptid=18066" target="_blank">[图片]</a>两帧之间的时间间隔4ms(高速模式),约7ms一帧。<a class="picture" rel="noopener" href="https://bbs.dji.com/forum.php?mod=redirect&goto=findpost&pid=201723&ptid=18066" target="_blank">[图片]</a><a class="picture" rel="noopener" href="https://bbs.dji.com/forum.php?mod=redirect&goto=findpost&pid=201723&ptid=18066" target="_blank">[图片]</a><a class="picture" rel="noopener" href="https://bbs.dji.com/forum.php?mod=redirect&goto=findpost&pid=201723&ptid=18066" target="_blank">[图片]</a>基本而言,data1为ch1的低8位,data2的低3位为ch1的高三位,data2的高5位是ch2的低5位,data3的低6位是ch2的高6位,以此类推,如下图所示:<a class="picture" rel="noopener" href="https://bbs.dji.com/forum.php?mod=redirect&goto=findpost&pid=201723&ptid=18066" target="_blank">[图片]</a>flags的结构如下所示:flags:bit7 = ch17 = digital channel (0x80)
bit6 = ch18 = digital channel (0x40)
bit5 = Frame lost, equivalent red LED on receiver (0x20)
bit4 = failsafe activated (0x10)
bit3 = n/a
bit2 = n/a
bit1 = n/a
bit0 = n/a
endbyte为0x00。一、程序实现:在STM32中的具体实现,除了如上述内容配置串口参数,还需要写好中断函数,写好解析函数。思路很简单,利用间隔时间来区分两帧,收到一帧数据后,做如下检查:1. 字节数够不够?2. 第一个字节是不是0x0f?3. 最后一个字节是不是0x00?4. 检查flag中的标志位举个中断函数栗子:void UART4_IRQHandler(void){ static uint8_t byteCNT = 0; static uint32_t lastTime = 0; uint32_t curTime; uint32_t interval = 0; HAL_NVIC_ClearPendingIRQ(UART4_IRQn); //如果时间间隔大于3毫秒,则认为是新的一帧 if(lastTime == 0) { curTime = HAL_GetTick(); lastTime = curTime; } else { curTime = HAL_GetTick(); interval = curTime - lastTime; lastTime = curTime; if(interval >= 3) { if(byteCNT == 25 && uart4_cache1[0] == 0x0f && uart4_cache1[24] == 0x00) { rc_captured = 0; memcpy(uart4_cache2, uart4_cache1, byteCNT); rc_captured = 1; } byteCNT = 0; } } if(RESET != __HAL_UART_GET_FLAG(&huart4, UART_FLAG_ORE)) { __HAL_UART_CLEAR_FLAG(&huart4, UART_FLAG_ORE); uart4_cache1 = huart4.Instance->DR; } if(RESET != __HAL_UART_GET_FLAG(&huart4, UART_FLAG_RXNE)) { uart4_cache1 = huart4.Instance->DR; }
}</blockquote></div>请问您知道大疆的遥控接收机从D-BUS出来的消息的具体格式吗,就是应用层协议
欢迎光临 大疆社区 (https://bbs.dji.com/)
Powered by Discuz! X3.2