I'm an old maxer and pretty new both to Rhino and GH.
I'm trying to send and receive UDP messages to and from GH. I've easily coded a udp sender but my receiver makes Rhino freeze. Luis Fraguada has done it using The Engine from the grasshopper-tools.
- How do I make another "thread" I could have a upd listener waiting for new incoming messages ? How do I avoid these freezes ?
I have the latest possible versions and I'm running on a Mac with Windows XP and WMware.
It will freeze no matter what refreshes the canvas. Check out the new timer component...does something similar to Giulio's "the engine." the idea is to do it asynchronously, having one thread waiting for the info. I've been too busy to jump on that at the moment, and actually, though some components (image) work asynch, I am not sure GH script nodes allow it... Perhaps David or Rajaa could answer that.
Hi Oliver, this simple UDP asynchronous listener should help you in this task. It is tested only with Processing (sorry, I don't have Max). It listens to the loopback address, but you can change this. In this case it does not freeze the sketch - it simply drops frames or re-releases old ones if the connection is too slow. It could be re-worked to be used in other scenarios, though.
It uses with the Timer from Grasshopper version GH 0.6.19. I am sending the Processing sketch as well, so you can test it (with Processing version 1.0.5 and Stephane Cousot's UDP library udp.zip from http://processing.org/reference/libraries/ ).
One small remark: this is a listener on the very basic UDP layer. You need to define the way you want your data to be subdivided (which bytes, small or big endian, strings, etc you want to use).
I hope this helps and please let me know more details if you need any further help.
Hi Giulio, It works perfectly!! Many thanks ! You saved me a lot of time... Really nice from you for sharing this stuff.
Here is a simple and obvious Max patch to send data to Grasshooper using udp.
Only "mxj net.udp.send" sends proper lists to Grasshooper. "udpsend" does not (small format problem).
Luis Fraguada
By the way, is your data feed continuous?
Aug 20, 2009
Giulio Piacentino
It uses with the Timer from Grasshopper version GH 0.6.19. I am sending the Processing sketch as well, so you can test it (with Processing version 1.0.5 and Stephane Cousot's UDP library udp.zip from http://processing.org/reference/libraries/ ).
One small remark: this is a listener on the very basic UDP layer. You need to define the way you want your data to be subdivided (which bytes, small or big endian, strings, etc you want to use).
I hope this helps and please let me know more details if you need any further help.
Aug 21, 2009
Olivier Pasquet
Here is a simple and obvious Max patch to send data to Grasshooper using udp.
Only "mxj net.udp.send" sends proper lists to Grasshooper. "udpsend" does not (small format problem).
Aug 22, 2009