mdetools / mdetools18

0 stars 0 forks source link

No reply for second request on the same port #4

Open hamzabaccouri opened 6 years ago

hamzabaccouri commented 6 years ago

While trying to send 2 messages via TCP socket to a port (control/observation), I did not receive response from the simulator for the second message. For example, I send "ready" to port 9999 and after that I send "Leader,GPS()" to the same port, I didn't receive anything as supposed ( posx and posz). I tested the same to port 9998 and I faced the same problem. Even when I send the same message twice, I got no reply for the second request.

PasternakMichal commented 6 years ago

On port 9998, are you sending any other commands between your first and second "Rover,GPS()" message? you might have the same issue as in #2 . If this is the case, re-downloading from the main page should help!

hamzabaccouri commented 6 years ago

Thank you for your response, I think my problem is not with one specific message or port. In fact, once I send a request on a TCP socket to a particular port I got response. When I send the same messages or another message to the same port, I got no response. I tried to send different messages ("Rover,GPS()" and "Rover,getCompass()" and as I said no response received for the second one). Identically for port 9999 after sending "ready" leader start moving and sending "Leader,GPS()" got no response. Thanks again for your help. I hope I made the problem clear.

PasternakMichal commented 6 years ago

How much time are you waiting in between sending messages? In testing, messages that are sent ~20ms or less apart, will end up being received as a single line, and parts of it get ignored by the simulator, and UnityObserver. This could lead to what you are seeing, where the second message is ignored.

hamzabaccouri commented 6 years ago

Thanks again for your help. In fact in the program I developed , I open socket, send data , wait for response and then close it. and I reopen , send another messages .... Below you can find a portion of the code that send "ready" and "Leader,GPS()". Would you please support me to find the problem.

Leader.txt

PasternakMichal commented 6 years ago

The issue occurs when you close the socket and try to re-connect. Both the simulation and UnityObserver expect you to maintain the connection through-out the simulation, so they will stop replying once you close the socket (even if you try to reconnect).

Let me know if you are able to send/receive consecutive messages if you keep the socket open.

salman2135 commented 6 years ago

I am also encountering the same issue, though I have kept the socket open. Below is my code: rover.txt

PasternakMichal commented 6 years ago

@salman2135 Make sure that you are not waiting for a reply after sending commands which do not give a reply, otherwise your program will end up waiting for a reply which will never come. The Commands listed with "none" in the return column do not send any return over the socket (not even an empty string).

For example in your code after sending the setForwardPower:

char* control_string = "Rover,setForwardPower(5)";
socket_send(hSocketControl, control_string, strlen(control_string));

read_size = socket_receive(hSocketControl, server_reply, 200);
printf("Server Response for set Power: %s\n\n", server_reply);

That may, be causing your issue and would explain why your program would get stuck after the second message. Let me know if it helps!

salman2135 commented 6 years ago

thanks, it is solved now:)