| 1 |
This document describes how to invoke FlightGear's generic IO subsystem. |
| 2 |
|
| 3 |
FlightGear has a fairly flexible generic IO subsystem that allows you |
| 4 |
to "speak" any supported protocol over any supported medium. The IO |
| 5 |
options are configured at runtime via command line options. You can |
| 6 |
specify multiple entries if you like, one per command line option. |
| 7 |
|
| 8 |
|
| 9 |
The general form of the command line option is as follows: |
| 10 |
|
| 11 |
--protocol=medium,direction,hz,medium_options,... |
| 12 |
|
| 13 |
protocol = { native, nmea, garmin, fgfs, rul, pve, ray, etc. } |
| 14 |
medium = { serial, socket, file, etc. } |
| 15 |
direction = { in, out, bi, broadcast} |
| 16 |
hz = number of times to process channel per second (floating |
| 17 |
point values are ok. |
| 18 |
|
| 19 |
|
| 20 |
Generic Communication: |
| 21 |
|
| 22 |
--generic=params |
| 23 |
|
| 24 |
With this option it is possible to output a pre-configured |
| 25 |
ASCII string or binary sequence using a predefined separator. |
| 26 |
The configuration is defined in an XML file located in the |
| 27 |
Protocol directory of the base package. |
| 28 |
|
| 29 |
params can be: |
| 30 |
serial port communication: serial,dir,hz,device,baud,protocol |
| 31 |
socket communication: socket,dir,hz,machine,port,style,protocol |
| 32 |
i/o to a file: file,dir,hz,filename,protocol |
| 33 |
|
| 34 |
See README.protocol for how to define a generic protocol. |
| 35 |
|
| 36 |
|
| 37 |
Serial Port Communication: |
| 38 |
|
| 39 |
--nmea=serial,dir,hz,device,baud |
| 40 |
|
| 41 |
device = OS device name of serial line to be open()'ed |
| 42 |
baud = {300, 1200, 2400, ..., 230400} |
| 43 |
|
| 44 |
example to pretend we are a real gps and output to a moving map application: |
| 45 |
|
| 46 |
--nmea=serial,out,0.5,COM1,4800 |
| 47 |
|
| 48 |
Note that for unix variants you might use a device name like "/dev/ttyS0" |
| 49 |
|
| 50 |
|
| 51 |
Socket Communication: |
| 52 |
|
| 53 |
A number of protocols can communicate over the various networks connected |
| 54 |
to a single machine to implement a distributed simulation. |
| 55 |
|
| 56 |
Example protocols include {generic, native-ctrls, native-fdm, native, etc} |
| 57 |
|
| 58 |
--<protocol>=socket,dir,hz,address,port,style,other-paramaters |
| 59 |
|
| 60 |
method = "socket" sends or receives data through either a connected socket, or an unconnected broadcast socket. |
| 61 |
dir = "in" for a server, "out" for a client, "broadcast" to do a network broadcast as a client. |
| 62 |
hz = network operations per second. Floating point values are OK. |
| 63 |
address = machine name, ip address, or broadcast address if client, |
| 64 |
(may leave empty if server) |
| 65 |
port = port, leave empty to let system choose |
| 66 |
style = "tcp" or "udp". Broadcasts are always "udp". |
| 67 |
other-parameters = other paramters required by the specific protocol. |
| 68 |
|
| 69 |
example 1: to slave one copy of fgfs to another machine named "fgfs2". |
| 70 |
|
| 71 |
fgfs1: --native=socket,out,30,fgfs2,5500,udp |
| 72 |
fgfs2: --native=socket,in,30,,5500,udp --fdm=external |
| 73 |
|
| 74 |
This instructs the first copy of fgfs to send UDP packets in the |
| 75 |
native format to a machine called fgfs2 on port 5500. |
| 76 |
|
| 77 |
The second copy of fgfs will accept UDP packets (from anywhere) on |
| 78 |
port 5500. Note the additional --fdm=external option. This tells |
| 79 |
the second copy of fgfs to not run the normal flight model, but |
| 80 |
instead set the FDM values based on an external source (the |
| 81 |
network in this case.) |
| 82 |
|
| 83 |
If a second slave (fgfs3) exists use: |
| 84 |
|
| 85 |
fgfs1: --native=socket,out,30,fgfs2,5500,udp |
| 86 |
fgfs1: --native=socket,out,30,fgfs3,5500,udp |
| 87 |
fgfs2: --native=socket,in,30,,5500,udp –fdm=external |
| 88 |
fgfs3: --native=socket,in,30,,5500,udp –fdm=external |
| 89 |
|
| 90 |
or more simply just broadcast so both fgfs2 and fgfs3 receive the same packet: |
| 91 |
|
| 92 |
fgfs1: --native=socket,broadcast,30,192.168.0.255,5500,udp |
| 93 |
fgfs2: --native=socket,in,30,,5500,udp –fdm=external |
| 94 |
fgfs3: --native=socket,in,30,,5500,udp –fdm=external |
| 95 |
|
| 96 |
Example 2. send data to one or more ForeFlight EFBs (or other EFBs that use the ForeFlight protocol) |
| 97 |
on wireless network 192.168.20.0/24 |
| 98 |
|
| 99 |
--generic=socket,broadcast,1,192.168.20.255,49002,udp,foreflight-xgps |
| 100 |
|
| 101 |
This instructs fgfs to broadcast a packet defined by the protocol description |
| 102 |
foreflight-xgps.xml in the system's Protocol directory once a second to the |
| 103 |
network 192.168.20.0 as defined by ForeFlight for use with their EFB. |
| 104 |
|
| 105 |
File I/O: |
| 106 |
|
| 107 |
--garmin=file,dir,hz,filename |
| 108 |
|
| 109 |
filename = file system file name |
| 110 |
|
| 111 |
example to record a flight path at 10 hz: |
| 112 |
|
| 113 |
--native=file,out,10,flight1.fgfs |
| 114 |
|
| 115 |
example to replay your flight |
| 116 |
|
| 117 |
--native=file,in,10,flight1.fgfs --fdm=external |
| 118 |
|
| 119 |
You can make the replay from a file loop back to the beginning |
| 120 |
when it reaches the end of the file with the "repeat" flag: |
| 121 |
|
| 122 |
--generic=file,in,20,flight.out,playback,repeat |
| 123 |
|
| 124 |
With a numeric argument, FlightGear will exit after that number of repeats. |
| 125 |
--generic=file,in,20,flight.out,playback,repeat,5 |
| 126 |
|
| 127 |
|
| 128 |
Moving Map Example: |
| 129 |
|
| 130 |
Per Liedman has developed a moving map program called Atlas |
| 131 |
(atlas.sourceforge.net) The initial inspiration and much code came |
| 132 |
from Alexei Novikov. |
| 133 |
|
| 134 |
The moving map supports NMEA format input either via network or |
| 135 |
via serial port. Either way will work, but this example |
| 136 |
demonstrates the use of a socket connection. |
| 137 |
|
| 138 |
Start up fgfs with: |
| 139 |
|
| 140 |
fgfs --nmea=socket,out,0.5,atas-host-name,5500,udp |
| 141 |
|
| 142 |
Start up the Atlas program with: |
| 143 |
|
| 144 |
Atlas --udp=5500 --fgroot=path-to-fg-root --glutfonts |
| 145 |
|
| 146 |
Once both programs are running, the Atlas program should display |
| 147 |
your current location. Atlas is a really nifty program with many |
| 148 |
neat options such as the ability to generate and use background |
| 149 |
bitmaps that show the terrain, cities, lakes, oceans, rivers, etc. |
| 150 |
|
| 151 |
|
| 152 |
HTTP Server Example |
| 153 |
|
| 154 |
You can now interact with a running copy of FlightGear using your |
| 155 |
web browser. You can view all the key internal variables and even |
| 156 |
change the ones that are writable. If you have support in your |
| 157 |
favorite [scripting] language for interacting with an http server, |
| 158 |
you should be able to use this as a mechanism to interface your |
| 159 |
script with FlightGear. |
| 160 |
|
| 161 |
Start up fgfs with the --httpd=<port#> option: |
| 162 |
|
| 163 |
For example: |
| 164 |
|
| 165 |
fgfs --httpd=5500 |
| 166 |
|
| 167 |
Now point your web browser to: |
| 168 |
|
| 169 |
http://host.domain.name:5500/ |
| 170 |
|
| 171 |
When a value is displayed, you can click on it to bring up a form |
| 172 |
to assign it a new value. |
| 173 |
|
| 174 |
|
| 175 |
ACMS flight data recorder playback |
| 176 |
|
| 177 |
fgfs --fdm=acms --generic=file,in,1,<path_to_replay_file>,acms |
| 178 |
|