Hi Jeff
I believe we've posted this as the example panel before. it has an <api/> tag called "OSC Message Builder" with some pre-made functions for sending as int or float. String would be another possible data type but I do not have an example on-hand for that.
<abs contexttype="opengear" style="">
<meta>
<params>
<param access="1" maxlength="0" name="Host" oid="Host" type="STRING" value="localhost" widget="text"/>
<param access="1" constraint="0.0;65535.0;0.0;65535.0;1" constrainttype="INT_STEP_RANGE" name="Port" oid="Port" precision="0" type="INT32" value="1234" widget="spinner"/>
<param access="1" maxlength="0" name="Message" oid="Message" type="STRING" value="/playbackcontroller/paused " widget="text"/>
<param access="1" constrainttype="INT_NULL" name="Value" oid="Value" precision="0" type="INT32" value="0" widget="default"/>
</params>
<api id="OSC Message Builder" immediate="true">function createOSCMessage(cmd, val, isFloat)
{
var messageBuilder = ogscript.createMessageBuilder();
var len = cmd.length+1;
var pad = (4 - len%4)%4;
var cmdLen = len+pad; // must be integer multiple of 4
//ogscript.debug ("length: " + len + " pad: " + pad + " = " + cmdLen);
messageBuilder.writeString(cmd);
// put null terminator at end of command string
messageBuilder.writeChar(0); // null terminator
// pad end of command string with nulls
for (var i=0; i<pad; ++i)
{
messageBuilder.writeChar(0);
}
// set the 4 bytes that identify the format
messageBuilder.writeChar(',');
if (isFloat)
{
messageBuilder.writeChar('f');
}
else
{
messageBuilder.writeChar('i');
}
messageBuilder.writeChar(0);
messageBuilder.writeChar(0);
// tack on the value
if (isFloat)
{
messageBuilder.writeFloat(val);
}
else
{
messageBuilder.writeInt(val);
}
return messageBuilder.toByteArray();
}
function sendOSCMessageInt(ip, port, cmd, val)
{
ogscript.sendUDPBytes(ip, port, createOSCMessage(cmd, val, false));
}
function sendOSCMessageFloat(ip, port, cmd, val)
{
ogscript.sendUDPBytes(ip, port, createOSCMessage(cmd, val, true));
}</api>
<listener autostart="true" listenport="1234" maxlength="1024" udp="true">
<task tasktype="ogscript">if (event.isMessageEvent())
{
var bytes = event.getBytes();
/*
writes the command
writes the null terminator
pads with nulls to reach multiple of 4
writes the comma
writes f or i
writes 2 nulls
writes the value
*/
var parser = ogscript.createMessageParser(bytes);
var i = 0;
while (i < bytes.length)
{
/*
writes the command
writes the null terminator
pads with nulls to reach multiple of 4
*/
var cmd = "";
while (i < bytes.length)
{
var b = parser.readByte(); //reading the next byte
i++;
if (b != 0)
{
cmd += String.fromCharCode(b); //getting the character from the byte
}
else
{
while (i % 4 != 0) //skipping until we have the command divisible by 4 (weirdness of OSC)
{
b = parser.readByte();
i++;
}
break;
}
}
//writes the comma
var nextChar = String.fromCharCode(parser.readByte());
i++;
if (nextChar != ',')
{
return; //We don't have a valid message
}
//check for float or int (f or i)
nextChar = String.fromCharCode(parser.readByte()).toLowerCase();
i++;
if (nextChar != 'f' && nextChar != 'i')
{
ogscript.debug("RETURNING EARLY: " + nextChar);
return; //We don't have a valid message
}
//writes 2 nulls (more OSC weirdness)
parser.skipBytes(2);
i+=2;
var value = 0;
if (nextChar == 'i')
{
value = parser.readInt();
i+=4;
}
else if (nextChar == 'f')
{
value = parser.readFloat();
i+=4;
}
ogscript.debug(cmd + "\nVALUE: " + value + " " + i + " " + bytes.length);
if (cmd == 'THAT THING I WANT')
{
//DO THE THING I WANT TO DO
}
}
}</task>
</listener>
</meta>
<table height="367" left="21" top="19" width="493">
<tr>
<label colspan="2" fill="both" insets="2,2,2,2" name="Send OSC Command" rowspan="1" style="txt-align:center;bg#dark;size:Bigger;font:bold;" weightx="1.0" weighty="1.0"/>
</tr>
<tr>
<label colspan="1" fill="both" insets="2,2,2,2" name="Host: " rowspan="1" style="txt-align:east;" weighty="1.0"/>
<param colspan="1" expand="true" fill="both" insets="2,2,2,2" oid="Host" rowspan="1" weightx="1.0" weighty="1.0"/>
</tr>
<tr>
<label colspan="1" fill="both" insets="2,2,2,2" name="Port: " rowspan="1" style="txt-align:east;" weighty="1.0"/>
<param anchor="west" colspan="1" expand="true" fill="vertical" insets="2,2,2,2" oid="Port" rowspan="1" weightx="1.0" weighty="1.0"/>
</tr>
<tr>
<label colspan="1" fill="both" insets="2,2,2,2" name="Message: " rowspan="1" style="txt-align:east;" weighty="1.0"/>
<param colspan="1" expand="true" fill="both" insets="2,2,2,2" oid="Message" rowspan="1" weightx="1.0" weighty="1.0"/>
</tr>
<tr>
<label colspan="1" fill="both" insets="2,2,2,2" name="Value: " rowspan="1" style="txt-align:east;" weighty="1.0"/>
<param anchor="west" colspan="1" expand="true" fill="vertical" insets="2,2,2,2" oid="Value" rowspan="1" weighty="1.0"/>
</tr>
<tr>
<button buttontype="push" colspan="2" fill="both" insets="2,2,2,2" name="Go! (Float)" rowspan="1" weightx="1.0" weighty="1.0">
<task tasktype="ogscript">/*! block id=1005,1001,1002,1003,1004 !*/
sendOSCMessageFloat(params.getValue('Host', 0), params.getValue('Port', 0), params.getValue('Message', 0), params.getValue('Value', 0))
/*!!
<block id="1005" type="function_sendOSCMessageFloat" x="283" y="10" w="243" ip="ID:1001" port="ID:1002" cmd="ID:1003" val="ID:1004" />
<block id="1001" type="param_Host (Host)[0]" x="10" y="10" w="243" SET="" />
<block id="1002" type="param_Port (Port)[0]" x="10" y="72" w="243" SET="" />
<block id="1003" type="param_Message (Message)[0]" x="10" y="134" w="243" SET="" />
<block id="1004" type="param_Value (Value)[0]" x="10" y="196" w="243" SET="" />
!!*/
/*!!<checksum>37e85f509c16c798f6976597013f4ce2</checksum>!!*/</task>
</button>
</tr>
<tr>
<button buttontype="push" colspan="2" fill="both" insets="2,2,2,2" name="Go! (Int)" rowspan="1" weightx="1.0" weighty="1.0">
<task tasktype="ogscript">/*! block id=1006,1001,1002,1003,1004 !*/
sendOSCMessageInt(params.getValue('Host', 0), params.getValue('Port', 0), params.getValue('Message', 0), params.getValue('Value', 0))
/*!!
<block id="1006" type="function_sendOSCMessageInt" x="283" y="10" w="243" ip="ID:1001" port="ID:1002" cmd="ID:1003" val="ID:1004" />
<block id="1001" type="param_Host (Host)[0]" x="10" y="10" w="243" SET="" />
<block id="1002" type="param_Port (Port)[0]" x="10" y="72" w="243" SET="" />
<block id="1003" type="param_Message (Message)[0]" x="10" y="134" w="243" SET="" />
<block id="1004" type="param_Value (Value)[0]" x="10" y="196" w="243" SET="" />
!!*/
/*!!<checksum>7ad40349f4a60fbeaab59c3f232b9b10</checksum>!!*/</task>
</button>
</tr>
</table>
</abs>
------------------------------
James Peltzer
Ross Video
------------------------------
Original Message:
Sent: 02-07-2024 12:35
From: Jeff Bins
Subject: Dashboard OSC Commands to High End Systems Hog4
James,
Do you have a link for that example panel? I am tinkering with some OSC commands and trying to control a Yamaha DM3.
------------------------------
Jeff Bins
AV Production Supervisor
PMI ENTERTAINMENT - RESCH CENTER
Green Bay United States
Original Message:
Sent: 09-12-2019 13:30
From: James Peltzer
Subject: Dashboard OSC Commands to High End Systems Hog4
Hi Jeff
We have an example panel that can send OSC integer or float messages - is this what you've already played with?
#DashBoard