Original Message:
Sent: 11-21-2023 10:40
From: James Peltzer
Subject: TCP communication
There is a DashBoard quirk where it has a different behavior with sendMessage vs. sendMessageWithResponse: when sendMessage is used, DashBoard will automatically append a carriage return and linefeed to the outgoing message (if one is not already present). When sendMessageWithResponse is used, the carriage return and linefeed are not automatic (you would need to send 'CHECK_STATUS\n' to add the linefeed). If your server is expecting the incoming message to be terminated this way, it would likely trigger a timeout on the response.
See this panel for an example:
<abs contexttype="opengear" gridsize="20" keepalive="true"> <meta> <listener autostart="true" delimitertype="newline" listenport="2468"> <task tasktype="ogscript">if (event.isMessageEvent()){ ogscript.debug(event.getBytesAsString()); this.writeString('DONE\n', false);}</task> </listener> </meta> <button buttontype="push" height="120" left="80" name="Send with Linefeed" top="120" width="240"> <task tasktype="ogscript">function callback(success, sentData, resultString, exception){ ogscript.debug("success: " + success); ogscript.debug("sentData: " + sentData); ogscript.debug("resultString: " + resultString); ogscript.debug("exception: " + exception);}rosstalk.sendMessageWithResponse('localhost', 2468, 'TESTING\n', '\n', callback);</task> </button> <button buttontype="push" height="120" left="340" name="Send without Linefeed" top="120" width="240"> <task tasktype="ogscript">function callback(success, sentData, resultString, exception){ ogscript.debug("success: " + success); ogscript.debug("sentData: " + sentData); ogscript.debug("resultString: " + resultString); ogscript.debug("exception: " + exception);}rosstalk.sendMessageWithResponse('localhost', 2468, 'TESTING', '\n', callback);</task> </button></abs>
------------------------------
James Peltzer
Ross Video
------------------------------
Original Message:
Sent: 11-20-2023 16:52
From: Sylvain Menet
Subject: TCP communication
Hi James,
I put a return carriage inside my message:
rosstalk.sendMessageWithResponse("127.0.0.1", 12345, "CHECK_STATUS", "\n", callback);
But now, have a got a timed out answer inside dashboard debugger.
I'm sure that the server send me a response with a return carriage. Can you know whats happen?
Thx a lot
------------------------------
Sylvain Menet
Technical Manager
Dreamwall
Original Message:
Sent: 11-20-2023 11:55
From: James Peltzer
Subject: TCP communication
Hi Sylvain
You need to specify a response terminator for the reply message. Since you are just using an empty string, the ogScript is not waiting for a response since it does not have anything to match on. If the response is terminated by a carriage return or line feed, you'll want to specify it in your call.
Cheers
James
------------------------------
James Peltzer
Ross Video