To listen for UDP input, you would create a tag and have it process the results either as a string or as a byte array.
Here is a fairly basic panel that sends strings or bytes to itself.
<abs contexttype="opengear">
<table height="104" left="6" right="7" top="7">
<tr>
<button buttontype="push" colspan="1" fill="both" name="Send UDP String" rowspan="1" weightx="0.0" weighty="1.0" width="200">
<task tasktype="ogscript">ogscript.sendUDPString('localhost', 7890, 'This is a string');</task>
</button>
<button buttontype="push" colspan="1" fill="both" name="Send UDP Bytes" rowspan="1" weightx="0.0" weighty="1.0" width="200">
<task tasktype="ogscript">ogscript.sendUDPAsBytes('l-ottjpeltzer', 7890, '00 00 01 02 03 04 05 06');</task>
</button>
<label colspan="1" fill="both" id="output" rowspan="1" style="bg#dark;txt-align:center;bdr:etched;" weightx="1.0" weighty="1.0"/>
<listener buttontype="toggle" colspan="1" fill="both" id="UDP Listener" listenport="7890" maxlength="1024" name="Listen for UDP on port 7890" style="t:bg#DF0C0C;f:bg#panelbg;" udp="true" weightx="0.0" weighty="1.0">
<task tasktype="ogscript">if (event.getEventType() == 1)
{
var bytes = event.getBytes();
if (bytes != null && bytes.length > 0)
{
if (bytes[0] == 0)
{
var rxBytes = '';
for (var i = 0; i < bytes.length; i++)
{
rxBytes += bytes[i] + ' ';
}
ogscript.rename('output', 'Got Bytes: ' + rxBytes.trim());
}
else
{
ogscript.rename('output', 'Got String: ' + event.getBytesAsString());
}
}
}</task>
</listener>
</tr>
</table>
</abs>
#DashBoard