FlightGear飞行模拟器

标题: FlightGear接口协议generic输出不了数据 [打印本页]

作者: lsforever    时间: 2018-1-2 17:04
标题: FlightGear接口协议generic输出不了数据
见标题,我想利用C#或C++编辑一个可以接收发送Flight Gear的窗口程序,使用udp的socket网络编程和flight gear的generic协议相结合。可是每次recvfrom的时候都返回值为-1,所以我用抓包工具抓取5500端口的数据流,显示抓取不到,不知道为什么,下面附上我的大概设置:C:\Users\Anthony\Desktop\TIM截图20180102165953.pngC:\Users\Anthony\Desktop\TIM图片20180102170110.pngC:\Users\Anthony\Desktop\TIM图片20180102170117.pngC:\Users\Anthony\Desktop\TIM图片20180102170123.png
作者: lsforever    时间: 2018-1-2 17:06
图片不会传,上传一下我的代码吧,下面是我的.bat启动flight gear文件和generic协议:
  1. D:
  2. cd D:\Program Files\FlightGear 2017.1.1

  3. SET FG_ROOT=D:\Program Files\FlightGear 2017.1.1\data
  4. .\\bin\fgfs --generic=socket,out,10,127.0.0.1,5500,udp,protocol_out
复制代码

作者: lsforever    时间: 2018-1-2 17:08
和protocol_out.xml文件(已经放到/data/Protocol下)
  1. <?xml version="1.0"?>
  2. <PropertyList>

  3.   <generic>

  4.     <output>
  5.       <binary_mode>true</binary_mode>

  6.       
  7.       <chunk>
  8.         <name>latitude</name>
  9.         <type>float</type>
  10.         <node>/position/latitude-deg</node>
  11.       </chunk>

  12.       <chunk>
  13.         <name>longitude</name>
  14.         <type>float</type>
  15.         <node>/position/longitude-deg</node>
  16.       </chunk>

  17.       <chunk>
  18.         <name>altitude</name>
  19.         <type>int</type>
  20.         <node>/position/altitude-ft</node>
  21.       </chunk>

  22.       <chunk>
  23.         <name>airspeed</name>
  24.         <type>int</type>
  25.         <node>/velocities/airspeed-kt</node>
  26.       </chunk>

  27.       <chunk>
  28.         <name>roll</name>
  29.         <type>float</type>
  30.         <node>/orientation/roll-deg</node>
  31.       </chunk>

  32.       <chunk>
  33.         <name>pitch</name>
  34.         <type>float</type>
  35.         <node>/orientation/pitch-deg</node>
  36.       </chunk>

  37.       <chunk>
  38.         <name>heading</name>
  39.         <type>float</type>
  40.         <node>/orientation/heading-deg</node>
  41.       </chunk>

  42.     </output>

  43.   </generic>

  44. </PropertyList>
复制代码

作者: gle    时间: 2018-2-1 12:19
参考下面的代码,对比一下。只不过是ASCII模式。你可以修改一下试试。也许是你的问题,也许是fg的问题。github.com/TimothyKwok/c172p-panel。发不了连接,自己找一下吧。




欢迎光临 FlightGear飞行模拟器 (https://flightgear.org.cn/) Powered by Discuz! X3.2