Hi fellow wiki editors!

To help newly registered users get more familiar with the wiki (and maybe older users too) there is now a {{Welcome to the wiki}} template. Have a look at it and feel free to add it to new users discussion pages (and perhaps your own).

I have tried to keep the template short, but meaningful. /Johan G

Changes

Jump to: navigation, search

Property Tree/Web Server

5 bytes removed, 18:14, 5 April 2015
no edit summary
{{PropertyTree}}
{{Note|This feature received significant updates in FlightGear 3.1+:
FlightGear has a few network access protocolsWhile working on the new radio/atis implementation, Torsten rediscovered the internal httpd (aka webserver) to browse the property tree. These are started as a [[Command Line Parameters|command line option]]It's much easier to have multiple browser windows open and point to various locations in the property tree than to reopen the internal property browser and navigate to the locations after each sim restart.
==Web Server== After a while, Torsten got disappointed by the functionality and the look&feel of the http property-browser, so he had a look at the code to see if it could be improved, he quickly realized, that the implementation was simple but not scalable, so he looked for something allready available on the GPL market.
To view the [[PropertyTree]] with And he found Mongoose as a web browserwell maintained, start feature rich and yet simple implementation of a web server and started to embedd that into FlightGear with the following option:.
What is ready so far and pushed to next is:* A single threaded httpd running in the main loop (should probably get its own thread soon)* Running as a replacement for the old httpd* Serving FGDATA/Docs as the document root* Serving the uri /props/ as a replacement for the old property browser (improved functionality, improved l&f, styling via css)* Serving the uri /run.cgi as a replacement for the old interface to run fg_commands* Serving the uri /json/ to return selected properties as JSON (read--only so far){{FGCquote |If your using fgrun, under Advanced (last tab)/ Network, check httpdand enter 5500. Then in a compatible browser use <code>http://localhost:5500/gui/</code> |{{cite web |url=http://forum.flightgear.org/viewtopic.php?p=237925#p237925 |title=<nowiki>Re: Heaven or Hell? Phi sneak preview.</nowiki> |author=<nowiki>wlbragg</nowiki> |date=5480<nowiki>Sun Apr 05</nowiki> }}}}}}
where 5480 is the port number[[FlightGear]] has a few network access protocols. You can pick any port number, but 5480 will probably work just fineThese are started via a [[Command Line Parameters|command line option]].
On the same machineAnd, fire up just for fun we have an embedded web server you can activate which exposes the internal property tree via a web browser style interface that you can browse (and open up edit) with any web browser. You can literally fly the following url:airplane remotely via your web browser. It's primarily there as an interactive remote debugging tool, but it could be used for many things.
[http://localhost:5480/ http://localhost:5480/]
You can now browse == Web Server ==To view the entire FG property tree "live" as the sim is running. You need to refresh the browser so see changes and you can even change values if you like. You could configure autopilot modes and even set control inputs so you can literally fly the airplane from your [[PropertyTree]] with a web browser, although it's maybe not start FlightGear with the most convenient interface for doing that. ;-)following option:
==Telnet Server==FlightGear has a telnet server that can be used to read and set values of the [[PropertyTree]]. The telnet server is activated with the ''' fgfs --telnethttpd=port''' [[Command_Line_Parameters|command line option]], where port is the number of the listening port that will be opened.5480
A connection to where 5480 is the server port number. You can be done using a [[Telnet usage|telnet client]] or opening a simple socket from pick any program. Multiple connections (more below) are possible at the same time. Too start FG and open the port 5401 as available telnet server use this command: fgfs --telnet=5401Using this server is covered in detail on the [[Telnet usage]] pagenumber, but 5480 will probably work just fine.
==Manipulate Properties==The cool thing is that you can easily write scripts to access On the --telnet=<port#> interface. //* psuedo code conn = telnet.connect(127.0.0.1same machine, 5480) gear_down = conn.get("/gear/state") if gear_down: conn.set("/gear/state", "fire up")a web browser and open up the following url:
Some links to source code example in various flavours:* Perl - [http://cvs.flightgear.orglocalhost:5480/viewvc/source/scripts/perl/examples/ /source/scripts/perl/examples].* Python - [http://cvs.flightgear.org/viewvc/source/scripts/python/ /source/scripts/python/]* Java - [httplocalhost://cvs.flightgear.org/viewvc/source/scripts/java/ source/scripts/java5480/] You could just as easily interact with a running FlightGear instance using perl, C, C++, java, python, probably even <ack> visual basic or anything else that can do tcpip network communication ... matlab? netcat? twisted?
Also note that You can now browse the downside to this interface entire FG property tree "live" as the sim is that running. You need to refresh the browser to see changes and you can't blast a lot of data across it. It's fine even change values if you want to monitor location like. You can configure autopilot modes and speed every second or 1/4 second and occasionally even set some values (such as dump in a new weather configuration, reset control inputs so you could literally fly the aircraft locationairplane from your web browser, or read a set of values, etcalthough it's maybe not the most convenient interface for doing that.;-)
But if Note that you need to track 100 different variables at 60hz, this isn't the interface for can setup as many of these as youwant . For that .. for instance, just to be obscene you need a [[PropertyTreecould do:Socket]].
==Multi Servers==Note that you can setup as many of these servers as you want, for instance, just to be obscene you could do: fgfs * --httpd=5400 * --httpd=5401 * --httpd=5402 * --props=5403 * --props=5404 * --props=5405
Now there are six you have 6 different network interfaces running that you can access from anywhere ;-) >> can I borrow your ipod please. why ?[Note: security issues if not used wisely.]
====Links====* httpd source - [http[Category://cvs.flightgear.org/viewvc/source/src/Network/httpd.cxx?view=markup source/src/Network/httpd.cxxProperty Tree]* telnet (props) source - [http://cvs.flightgear.org/viewvc/source/src/Network/props.cxx?view=markup source/src/Network/props.cxx]
18,174
edits

Navigation menu