Page 1 of 1

OSC Protocol via UDPSend,x,xxx question

PostPosted: Fri Apr 21, 2017 8:38 pm
by chrisr
All, hope you are well.

And thanks for any insight on this question. I've read through the forum, and specifically didnt find anything that answered what I was looking for. I am using OSC to control a 3rd party application successfully via the OSC output node. So the straight forward command structure works great. For example : /layer1/clip1/opacity/values , which has a floating value or ,f . I am wondering how does one produce a string that says I'm an OSC transmission. I've tried the obvious UDPSend,1,/layer1/clip1/opacity/values, but where I am obviously failing is this string needs to be defined, as well as the floating value needs to be defined. Understanding that OSC commands are sent in multiples of 32 bits 4, 8 bit bytes. When I try to use UDPSend its not doing the back end work that the node is doing. My question is, if I wanted to format a string command after the UDPSend. What would it look like? Below is a successful string out of TouchOSC:
https://hexler.net/software/touchosc
, this has a floating value you see at the bottom.

Image

So basically just curious if anyone has successfully sent OSC with a UDPSend command. I've read through http://opensoundcontrol.org/spec-1_0 website. Its has provided useful information but I'm still struggling.

Have a great weekend everyone.

Re: OSC Protocol via UDPSend,x,xxx question

PostPosted: Tue Apr 25, 2017 5:25 pm
by schoissi
hi Chris,
this is just a guess as i currently can't test it...

i would try to route touch osc into widget designer and read out how the command looks like arriving in WD, via UDP in connection.
probably TouchOSC is converting it automatically as needed, maybe into HEX or something?

i think if you want to send a string, you need to put it into "quotes".
not sure if that is succesfull via udp... (without converting it to HEX or similar...).

best,
Roman

edit:
have a project in summer where i will do somehow the same,
converting enocoder/sensor values to osc...
:-)

Re: OSC Protocol via UDPSend,x,xxx question

PostPosted: Wed Apr 26, 2017 2:26 pm
by chrisr
Roman,
Yes, I have done that. What I believe to be the case for me, is that the packets are arranged in 4 8 byte segments, if you string doesn't add to 4 8 or 32 etc. then you need to add NULL bytes. Which I can not seem to figure out how to do. The null bytes coming in on the TCP IP Test window look like squares. I think this is one of the main issues I'm having is figuring out how to write in NULL bytes in Widget Designer.

Re: OSC Protocol via UDPSend,x,xxx question

PostPosted: Thu Apr 27, 2017 6:42 am
by schoissi
did you try adding \x00 ?
for the nulls...

it would be awesome if you could post an example if it works.

Re: OSC Protocol via UDPSend,x,xxx question

PostPosted: Thu Apr 27, 2017 4:08 pm
by chrisr
When I figure it out, I'll post the string.

Re: OSC Protocol via UDPSend,x,xxx question

PostPosted: Thu Apr 27, 2017 11:01 pm
by Dennis Kuypers
Hello,

I was thinking about having the ability to send binary data in a very flexible manner. Maybe we could port python's struct.pack syntax to Widget Designer: https://docs.python.org/3.6/library/struct.html
What do you think?

Regards
Dennis

Re: OSC Protocol via UDPSend,x,xxx question

PostPosted: Fri Apr 28, 2017 6:36 am
by schoissi
sure :D

(following your link, i have currently no clue what this all means...) :D

do you maybe know a basic introduction resource to all of those serial connection things?

i've started playing around with arduino and stuff,
have a midi and dmx shield,
would be great to connect those things with widget designer for future application options...

on another project,
i'm trying to readout nrpn values coming from a bcr2000 with an arduino midi shield,
to control things from another 3rd party application (bmd...)

figuring out osc is on my summer project plan...

i found the hint about \x00 when searching trough the christie spyder remote control specifications (for other stuff...)

thx,
Roman

Re: OSC Protocol via UDPSend,x,xxx question

PostPosted: Fri Apr 28, 2017 10:45 am
by Dennis Kuypers
Hello,

The idea of struct.pack is to build packages of binary data. Well lets start with why we would need this in the first place...

You can represent numbers using different amounts of bytes, like one byte can handle the values from 0-255. If you take the first bit in the byte as the sign, you can do -128 to 127. So values may be signed or unsigned.
Then you can use more than one byte, like, if you use two, you have a "short". So the value of a short is = FIRST_BYTE * 256 + SECOND_BYTE; but wait. Why not FIRST_BYTE + SECOND_BYTE * 256. Either representation is valid, but when talking over the network the systems should agree on one system. Which byte has the greatest impact on the value? If the most significant byte (MSB) comes first, this is called big-endian, the other one is little-endian. In networking it is common to use the network byte order, which is big-endian. Then we have the various sizes with 1, 2, 4, 8 or even more bytes. Those are only the basic number formats. There are also floating point representations and we have other data like text that we might want to send.

Python's struct.pack is a handy tool to define the structure and then convert between the binary format and python's internal formats.

In the following example taken from the Pandoras Box SDK on github you can see the struct.pack in action. The format string tell us that we want "!BlhlB"

Code: Select all
 # + protocol version (byte, currently 1)
        # + domain id (integer)
        # + message size (short)
        # + connection id (int, user definable, defaults to 0)
        # + protocol flag (byte, 0 for TCP)
header = struct.pack("!BlhlB", 1, self.domain, len(data), 0, 0)

https://github.com/PandorasBoxSDK/pbaut ... o.py#L3698

Regards
Dennis

Re: OSC Protocol via UDPSend,x,xxx question

PostPosted: Tue May 16, 2017 8:28 pm
by chrisr
Dennis, Awesome. And I like Roman, this is above me. Though after reading through your examples and reading the information on the Python site, I do sort of understand where you are going. Also I'm enlisting a friend of mine that will better help me understand. Thanks for the help.

I hate to ask, but Is this doable in WD Ver6? If so this is kind of old news :) Or is 6 much like 4.7 in this matter?

Have a great week Dennis and Roman!!