Are there any examples of using rosstalk.sendBytesWithResponse() ? I can get rosstalk.sendBytes() to work, but I need to get a response.
(Actually, even rosstalk.sendBytes() is a little weird in that the callback function is never called, but that’s a different issue…)
Hello Rich,
sorry for the delay. I’ve tested this with DashBoard 9.6.1 and seems to be working fine.
Here is a small example of a custom panel which communicates with a simple server I had running locally.
Each button would send a different integer value to the server.
You can see that the sendAsBytesWithResponse takes the provided value and a terminator; ‘0A’ in this case.
The server receives the integer value and then returns a series of bytes followed by a 0x0A.
DashBoard then invokes the callback function where result is the data received from the server.
function callback(success, sentData, result, exception)
{
var resultString = result.map(String);
ogscript.debug('Got success: ' + success + ', sentData: ' + sentData + ', result: ' + resultString + ', exception: ' + exception);
}
function sendInt(value)
{
rosstalk.sendAsBytesWithResponse('127.0.0.1', 4442, value, '0A', callback);
}
sendInt(0);
sendInt(1);
sendInt(2);
Hope this helps. Best regards,
Marc, I came across this post while trying to figure out some TCP connection functions.
The code you had included the localhost 127.0.0.1 ip address and you mentioned you had a simple server running locally. What did you mean you had a simple server running locally? Was there something running on an Ultitrouch panel or something along those lines? Is there a way to load files on to a local device to setup as a simple server?
Hi Seth,
You can set up a small server within a custom panel using the OGLML listener tag. It operates in two modes: listening for incoming connections (server mode) or establishing a connection (client mode). In both cases, the listener tag monitors incoming data from the remote system. I’ve included two panels in a zip file: one acts as a listener for incoming connections, while the other sends a message to it using the rosstalk.sendMessage command. You can also upload the panel to an Ultritouch device and run it directly from there.