wkitty42 wrote in Sat Jan 05, 2019 2:24 pm:daweed wrote in Fri Jan 04, 2019 10: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.