Board index FlightGear Support Interfacing

Problems using udp to send input to fg

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

Problems using udp to send input to fg

Postby RuiRui » Mon Feb 11, 2019 6:30 pm

Hello, although I read a lot of posts about how to use udp socket to send inputs to FG, but I still can not succeed. Could you please have a look?
I want to set 'throttle' as 0.9
This is the udp client codes:
Code (client.c): Select all
#include<stdio.h>
#include<winsock2.h>
#pragma comment(lib,"ws2_32.lib")
#pragma warning(disable:4996)
int main(int argc, char * argv[])
{
WSADATA data;
SOCKET socketfd;
struct sockaddr_in my_addr;
char buf[80]="0.9";


if (WSAStartup(MAKEWORD(2, 2), &data) != 0)
{
return 0;

}
socketfd = socket(AF_INET, SOCK_DGRAM, 0);
if (socketfd<0)
{
return 0;
}
my_addr.sin_family = AF_INET;
my_addr.sin_port = htons(8000);
my_addr.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
while (1)
{
int ret=sendto(socketfd, buf, strlen(buf), 0, (struct sockaddr *)&my_addr, sizeof(my_addr));
printf("ret is:\n%d\n", ret);
}
closesocket(socketfd);
WSACleanup();
return 0;
}


This is XML file(sendsocket):
Code (sensockt.xml): Select all
<?xml version="1.0"?>
<PropertyList>
<generic>
<input>
<line_separator>newline</line_separator>
<var_separator>,</var_separator>

<chunk>
<node>/controls/engines/engine/throttle</node>
<name>throttle</name>
<type>float</type>
<format>%f</format>
</chunk>

</input>
</generic>
</PropertyList>


I want to change throttle.

And I run FG first, used
fgfs--generic=socket,in,1,localhost,8000,udp,sendsocket
then run the client codes.

But I see the property browser in FG, there is no change. But socket send successfully.
Is there anybody know reasons?
RuiRui
 
Posts: 1
Joined: Mon Feb 11, 2019 6:20 pm

Return to Interfacing

Who is online

Users browsing this forum: No registered users and 0 guests