lsforever 发表于 2018-1-2 17:04:29

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:44

图片不会传,上传一下我的代码吧,下面是我的.bat启动flight gear文件和generic协议:
D:
cd D:\Program Files\FlightGear 2017.1.1

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

lsforever 发表于 2018-1-2 17:08:46

和protocol_out.xml文件(已经放到/data/Protocol下)<?xml version="1.0"?>
<PropertyList>

<generic>

    <output>
      <binary_mode>true</binary_mode>

      
      <chunk>
      <name>latitude</name>
      <type>float</type>
      <node>/position/latitude-deg</node>
      </chunk>

      <chunk>
      <name>longitude</name>
      <type>float</type>
      <node>/position/longitude-deg</node>
      </chunk>

      <chunk>
      <name>altitude</name>
      <type>int</type>
      <node>/position/altitude-ft</node>
      </chunk>

      <chunk>
      <name>airspeed</name>
      <type>int</type>
      <node>/velocities/airspeed-kt</node>
      </chunk>

      <chunk>
      <name>roll</name>
      <type>float</type>
      <node>/orientation/roll-deg</node>
      </chunk>

      <chunk>
      <name>pitch</name>
      <type>float</type>
      <node>/orientation/pitch-deg</node>
      </chunk>

      <chunk>
      <name>heading</name>
      <type>float</type>
      <node>/orientation/heading-deg</node>
      </chunk>

    </output>

</generic>

</PropertyList>

gle 发表于 2018-2-1 12:19:23

参考下面的代码,对比一下。只不过是ASCII模式。你可以修改一下试试。也许是你的问题,也许是fg的问题。github.com/TimothyKwok/c172p-panel。发不了连接,自己找一下吧。
页: [1]
查看完整版本: FlightGear接口协议generic输出不了数据