Difference between revisions of "Property Tree Servers"

From FlightGear wiki
Jump to: navigation, search
(Property Servers)
 
(Major copy editing; Rewriting smaller portions; +rel: Interfacing FlightGear, readme file)
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
==Web Server==
+
{{mergefrom|Property Tree/Web Server|Talk:Property Tree Servers#Merging Property Tree/Web Server into this article |date=September 2020}}
 +
{{PropertyTree}}
 +
FlightGear have a built in servers that you can connect to for view and interacting with the [[property tree]] through telnet or through HTTP using a web browser or HTTP requests.
  
To view the [[Property Tree]] with a web browser, start FlightGear with the following option:
+
== Web server ==
 +
To view the property tree with a web browser, start FlightGear with the following option:
  
 
  --httpd=5400
 
  --httpd=5400
  
where 5400 is the port number. You can pick any port number, but 5400 will probably work just fine.
+
Where <code>5400</code> is the port number. You can pick any port number, but <code>5400</code> will probably work just fine.
  
Now on the same machine, fire up a web browser and open up the following url:
+
Now on the same machine, fire up a web browser and open up the following URL:
  
 
[http://localhost:5400/ http://localhost:5400/]
 
[http://localhost:5400/ http://localhost:5400/]
  
Now you can browse the entire FG property tree "live" (you'll need to refresh the browser) and even change values if you like. You can configure autopilot modes and even set control inputs so you can literally fly the airplane from your web browser, although it's not the most convenient interface for doing that. ;-)
+
Now you can browse the entire FlightGear property tree "live" (you will need to refresh the browser). You can even change most values if you like. You can for example configure autopilot modes and even set control inputs so you can literally fly the airplane from your web browser, although it is not the most convenient interface for doing that. ;-)
 +
 
 +
== Telnet server ==
 +
{{main article|Telnet usage}}
 +
 
 +
FlightGear comes with a internal telnet server that can be used to read end set values within the property tree structure. The telnet server is activated with the <code>--telnet=''port''</code> [[Command line options|command line option]], where ''port'' is the number of the listening port that will be opened.
 +
 
 +
A connection to the server can be done using a telnet client or opening a simple socket from any program. Multiple connections (more below) are possible at the same time. Too start FlightGear and open the port <code>5401</code> as available telnet server use this command:
 +
 
 +
fgfs --telnet=5401
 +
 
 +
== Props server ==
 +
There is a similar interface minus the HTML wrappings that you can enable with the following option:
  
==Props Server==
 
There is a similar interface minus the html wrappings that you can enable with the following option:
 
 
  fgfs --props=5401
 
  fgfs --props=5401
Once you have a 'props' interface configured you can now  
+
 
 +
Once you have a "props" interface configured you can now
 +
 
 
  telnet localhost 5401
 
  telnet localhost 5401
and interact with the property system (again live) and set and examine values using a 'command line' style interface. This is covered more on the [[Telnet usage|Telnet]] page.
 
  
The cool thing is that you can easily write scripts to access this --props=<port#> interface.
+
and interact with the property system (again live) and set and examine values using a command line style interface. This is covered more on the [[Telnet usage|Telnet]] page.
  
Take a look at [http://cvs.flightgear.org/viewvc/source/scripts/perl/examples/ FlightGear/source/scripts/perl/examples].
+
== Writing properties ==
 +
The cool thing is that you can easily write scripts to access this <code>--props=''port''</code> interface.
  
Note that there is no requirement that you do this with perl. You could just as easily interact with FlightGear this way using perl, C, C++, java, python, probably even <ack> visual basic or anything else that can do tcpip network communication ... matlab? netcat?
+
Take a look at the following link for some example Perl scripts. {{flightgear source|path=scripts/perl/examples/}}
  
Also note that the downside to this interface is that you can't blast a lot of data across it. It's fine if you want to monitor location and speed every second or 1/4 second and occasionally set some values (such as dump in a new weather configuration, reset the aircraft location, or read a set of values, etc.)
+
Note that there is no requirement that you do this with Perl. 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 TCP/IP network communication ... Matlab? netcat?
  
But if you need to track 100 different variables at 60hz, this isn't the interface for you.
+
Also note that the downside to this interface is that you cant blast a lot of data across it. It is fine if you want to monitor location and speed every second or 1/4 second and occasionally set some values (such as dump in a new weather configuration, reset the aircraft location, or read a set of values, etc.)
  
==Multi Servers==
+
But if you need to track 100 different variables at 60 Hz, this is not the interface you are looking for.
 +
 
 +
== Multiple servers ==
 
Note that you can setup as many of these as you want ... for instance, just to be obscene you could do:
 
Note that you can setup as many of these 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
 
  fgfs --httpd=5400 --httpd=5401 --httpd=5402 --props=5403 --props=5404 --props=5405
  
 
Now there are 6 different network interfaces running that you can access from anywhere.
 
Now there are 6 different network interfaces running that you can access from anywhere.
 +
 +
== Related content ==
 +
=== Wiki articles ===
 +
* [[Interfacing FlightGear]]
 +
 +
=== Readme files ===
 +
* {{readme file|IO}}
 +
 +
[[Category:Property Tree]]

Latest revision as of 03:20, 8 September 2020

Mergefrom.gif
It has been suggested that Property Tree/Web Server be merged into this article or section. Discuss this merge. This has been proposed since September 2020.

FlightGear have a built in servers that you can connect to for view and interacting with the property tree through telnet or through HTTP using a web browser or HTTP requests.

Web server

To view the property tree with a web browser, start FlightGear with the following option:

--httpd=5400

Where 5400 is the port number. You can pick any port number, but 5400 will probably work just fine.

Now on the same machine, fire up a web browser and open up the following URL:

http://localhost:5400/

Now you can browse the entire FlightGear property tree "live" (you will need to refresh the browser). You can even change most values if you like. You can for example configure autopilot modes and even set control inputs so you can literally fly the airplane from your web browser, although it is not the most convenient interface for doing that. ;-)

Telnet server

1rightarrow.png See Telnet usage for the main article about this subject.

FlightGear comes with a internal telnet server that can be used to read end set values within the property tree structure. The telnet server is activated with the --telnet=port command line option, where port is the number of the listening port that will be opened.

A connection to the server can be done using a telnet client or opening a simple socket from any program. Multiple connections (more below) are possible at the same time. Too start FlightGear and open the port 5401 as available telnet server use this command:

fgfs --telnet=5401

Props server

There is a similar interface minus the HTML wrappings that you can enable with the following option:

fgfs --props=5401

Once you have a "props" interface configured you can now

telnet localhost 5401

and interact with the property system (again live) and set and examine values using a command line style interface. This is covered more on the Telnet page.

Writing properties

The cool thing is that you can easily write scripts to access this --props=port interface.

Take a look at the following link for some example Perl scripts. flightgear/flightgear/next/scripts/perl/examples/

Note that there is no requirement that you do this with Perl. 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 TCP/IP network communication ... Matlab? netcat?

Also note that the downside to this interface is that you cant blast a lot of data across it. It is fine if you want to monitor location and speed every second or 1/4 second and occasionally set some values (such as dump in a new weather configuration, reset the aircraft location, or read a set of values, etc.)

But if you need to track 100 different variables at 60 Hz, this is not the interface you are looking for.

Multiple servers

Note that you can setup as many of these 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 6 different network interfaces running that you can access from anywhere.

Related content

Wiki articles

Readme files