Closed iglesiasmarianod closed 4 years ago
That's great! Will it still work if xcsoar is restarted while variod is running though?
That's part of what's missing. Let me think how to handle reconnects and test some more. Right now it does not connect again if you restart xcsoar. If the send fails Variod waits for a reconnection. In case the socket is destroyed I would clean everything up, try to re create socket and reconnect there.
Ready, closed old socket and recreated one on send failure. Now Variod reconnects to xcsoar.
This part is broken:
if ((read_size = recv(xcsoar_sock, client_message, 2000, 0 )) > 0 ) {
// we got some message
// terminate received buffer
client_message[read_size] = '\0';
ddebug_print("Message from XCSoar: %s\n",client_message);
// parse message from XCSoar
parse_NMEA_command(client_message);
}
Compare what is reported form the ""Message from XCSoar: " and compare this with the reports from parse_NMEA_command(). If XCSoar throws several commands in a short time variod runs into Segmentation Fault (maybe the reason the socket closes?).
Same issue around parse_NMEA_sensor(client_message, &sensors);
I've addressed the above in https://github.com/Openvario/variod/pull/4
I did not look into the parsers yet, I just looked into the connection problem. The socket was closed and opened by design. This is the way it was written. If you look at the code you'll see two nested whiles, the outermost, the infinite loop, creates and closes the xcsoar socket all the time. Create a socket, transmit a message, check incoming messages, close socket and then repeat. I'll have a look at the parsers to see if I can help.
Comments reviewed in the code.
Found out that Variod creates and detroys the socket in each turn of the while loop. Just as a quick test, moved out of the While loop the XCSoar socket creation and commented out the closing of that socket. Just create a socket once and send/receive any amount of messages, Whith this mod XCSoar responded quickly to vario changes and accepts STF and Vario mode commands instantly. Debug button stopped flickering too. Did not see the xcsoar log but seems the problem with these delays lays there. This still needs work, how to deal with disconnects etc.. Please, test it if you have spare time and comment.