Board index FlightGear Support Interfacing

FGFS Interface

Connecting two computers, using generic protocol, connecting with Matlab?

Re: FGFS Interface

Postby Hooray » Sat Jan 05, 2019 1:09 am

This may not be relevant at this point, so I would ignore this for now - but if you are already familiar with the property tree and generic protocols (xml), it should be easy to learn more about some of the other I/O options - even if just to see that there are more efficient ways to do I/O - for staters, you could also look at Torsten's mongoose/Phi code, which uses web sockets.

But again, that's best discussed on the devel list.

Assuming that you are currently using the generic protocol (?) you may still want to read more about other I/O options to learn what's possible, should performance ever become an issue

http://wiki.flightgear.org/Generic_protocol
http://wiki.flightgear.org/Telnet_usage
http://wiki.flightgear.org/Property_Tree/Web_Server
http://wiki.flightgear.org/Property_Tree/Sockets

But even if you are never going to touch any C++ code, you may still want to introduce your project via the newsletter/devel list - maybe someone shows up with a more efficient interfacing mechanism, there are meanwhile a number of home cockpit builders using FlightGear after all.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11292
Joined: Tue Mar 25, 2008 8:40 am

Re: FGFS Interface

Postby daweed » Sat Jan 05, 2019 10:45 am

FGFS Interface is using Generic Protocol and talk to FG throught network socket [ Client / Server system ], and i can't say that the props tree does not have any secret for me, but this where i read and store my informations.
Linux Mint 18.3
AMD FX 4300 Quad-Core Black Edition|20 Go RAMGeForce GTX 750 Ti
FG Interface
Lyon Saint Exupery Scenery
daweed
 
Posts: 272
Joined: Thu Dec 11, 2014 10:45 am
Location: LFKP LFLL
Callsign: daweed
OS: Windows 10 Familly

Re: FGFS Interface

Postby wkitty42 » Sat Jan 05, 2019 1:24 pm

daweed wrote in Fri Jan 04, 2019 9:35 pm:The interface is completely autonomous, based on a Raspberry and talk with the simulator through the network.

that is exactly what he is talking about... right now you're using telnet or http or something to talk to the sim, right? hooray is talking about taking one of those protocols and extending it (maybe with a new name?) to make it easier to handle all your switches on your device(s) so they can be better connected into the sim over the network... in other words, making your code connection easier to manage with all those switch properties...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 5018
Joined: Fri Feb 20, 2015 3:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 14.04.5

Re: FGFS Interface

Postby daweed » Sat Jan 05, 2019 4:55 pm

wkitty42 wrote in Sat Jan 05, 2019 1:24 pm:
daweed wrote in Fri Jan 04, 2019 9:35 pm:The interface is completely autonomous, based on a Raspberry and talk with the simulator through the network.

that is exactly what he is talking about... right now you're using telnet or http or something to talk to the sim, right? hooray is talking about taking one of those protocols and extending it (maybe with a new name?) to make it easier to handle all your switches on your device(s) so they can be better connected into the sim over the network... in other words, making your code connection easier to manage with all those switch properties...



Hello,

i probably don't use the good word, or are not able to correctly translate the things, but, no , i don't use any http or telnet connection.

I am using, Python stream socket on both side.

1°) i start a server on FGFS interface (RPI Side) which is waiting for Flightgear to connect [ here FG acting as client ] . This is the part that send data from FG (output generic protocol)

Python Code is as like

Code: Select all
Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Bind the socket to the port
server_address = (FGINTADDR, FGINTPORT)
print('starting up on {} port {}'.format(*server_address))
sock.bind(server_address)

# Listen for incoming connections
sock.listen(1)


2°) i Start a TCP client too on RPI that will be used to send data to Flightgear , again data structure are definie wiuth an XML file and using generic protocol, data are sent to FG ONLY if a data if something have been modify

Code: Select all
sockclient = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sockclient.connect((FGADDR, FGPORT))

....

all the process to manage data coming from the hardware, then a data "line" is created , regarding the data structure describe in the generic protocol xml file, for example , for the radio panel :

Code: Select all
########################################
# DATA MANAGEMENT
########################################

datastr = str(data_tree['cptpowersw'])
datastr = datastr + ':' + str(data_tree['sel_chan'])
datastr = datastr + ':' + str(data_tree['transfer_sw'])
datastr = datastr + ':' + str(data_tree['vhf1_stby'])
datastr = datastr + ':' + str(data_tree['vhf2_stby'])
datastr = datastr + ':' + str(data_tree['vhf3_stby'])

########################################
# DATA SENDING PROCESS
########################################
cypher = hashlib.md5(datastr.encode('utf-8')).digest()

if cypher != oldcypher:
    print("DATA : {} | PROPS : {}".format(datastr, props_tree))
    sockclient.send(bytes(datastr, 'utf-8'))
    sockclient.send(bytes("\n", 'utf8'))
    oldcypher = cypher


And FGFS is started with something like --generic=file,out,1,/tmp/data.xml,myproto , one for input, one for output [i don't have exact parameter near me, but could post later if needed ]

Maybe you are associating "telent connexion" to socket connection as what i am doing .... in this case, you are right.

As i said i don't have the require skill to create a new protocol binary, even extend an existing one , seems, for me. to be "a mountain" and fact is i don"t know from where to begin, i alredy read documentation on input / output, but don't find clear examples i could exploit.
Linux Mint 18.3
AMD FX 4300 Quad-Core Black Edition|20 Go RAMGeForce GTX 750 Ti
FG Interface
Lyon Saint Exupery Scenery
daweed
 
Posts: 272
Joined: Thu Dec 11, 2014 10:45 am
Location: LFKP LFLL
Callsign: daweed
OS: Windows 10 Familly

Re: FGFS Interface

Postby wkitty42 » Sat Jan 05, 2019 10:03 pm

daweed wrote in Sat Jan 05, 2019 4:55 pm:i probably don't use the good word, or are not able to correctly translate the things,

you're doing fine :)

daweed wrote in Sat Jan 05, 2019 4:55 pm:but, no , i don't use any http or telnet connection.

I am using, Python stream socket on both side.

about the same thing but ok... so you've already developed your protocol, then... that's what hooray was talking about doing with the extension so that your development of the protocol was easier as most of the work would already have been done... but you are using python and you're already further ahead in development than was thought :)
Last edited by wkitty42 on Mon Jan 07, 2019 6:15 pm, edited 1 time in total.
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 5018
Joined: Fri Feb 20, 2015 3:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 14.04.5

Re: FGFS Interface

Postby Hooray » Sun Jan 06, 2019 8:12 pm

yeah, absolutely correct.

Using the telnet (props) protocol from Python is fine for prototyping purposes.
However, if/when your project should outgrow the telnet/props I/O mechanism, you may want to consider using the web socket mechanism (based on Torsten's Phi/mongoose integration).

And if you should ever end up deciding that the websocket approach isn't sufficient, a dedicated (or customized) I/O protocol would seem like a good idea, especially if it's based on something ARINC related.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11292
Joined: Tue Mar 25, 2008 8:40 am

Re: FGFS Interface

Postby daweed » Sun Feb 24, 2019 9:02 pm

Somes new,

FCU Airbus , FG Interface powered

Image

Image

Image

Rotary encoder and Push / Pull are on the way, but it need to print some pieces

Image
Linux Mint 18.3
AMD FX 4300 Quad-Core Black Edition|20 Go RAMGeForce GTX 750 Ti
FG Interface
Lyon Saint Exupery Scenery
daweed
 
Posts: 272
Joined: Thu Dec 11, 2014 10:45 am
Location: LFKP LFLL
Callsign: daweed
OS: Windows 10 Familly

Previous

Return to Interfacing

Who is online

Users browsing this forum: No registered users and 1 guest