Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

How to connect processing with gh using UDP or OSC?

$
0
0

Hi there, I am trying to receive some data from grasshopper, and I firstly use OCSP5 library, which allows sending message to gh but cannot receive. And I tried UDP class, but the processing keeps saying the library cannot be used... I was wondering is there a way to get the newer version of the UDP library, or is there a way to receiving data from grasshopper?

Thanks!

I am really try with a simple sketch.

import netP5.*;
import oscP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;

float mySum;

void setup()
{
  frameRate(25);
  oscP5 = new OscP5(this,12000);
  myRemoteLocation = new NetAddress("10.10.15.157",12000);
  oscP5.addListener(myListener);
  mySum = 0;
}

void draw()
{
  background(0);
}

/* incoming osc message are forwarded to the oscEvent method. */
void oscEvent(OscMessage theOscMessage) {
  print ("oscEvent"+theOscMessage.addrPattern()+theOscMessage.arguments());
}

and when I send data from grasshopper, the console says NullPointerException, and print something in console like

java.lang.NullPointerException
    at oscP5.OscP5.callMethod(Unknown Source)
    at oscP5.OscP5.process(Unknown Source)
    at oscP5.OscNetManager.process(Unknown Source)
    at netP5.AbstractUdpServer.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:748)

I commented the initiation for Add listener, and it worked...sorry I've got this in console

oscEvent/GH/none[Ljava.lang.Object;@54f912f5

Thanks for your time!

==============================

update Now my new sketch, what troubles me now is that I don't want the java object, but a list of doubles. But I got Error in console

code:

import netP5.*;
import oscP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
OscMessage arrayMsg = new OscMessage("/array");

void setup()
{
  frameRate(25);
  oscP5 = new OscP5(this,12000);
  myRemoteLocation = new NetAddress("10.10.15.157",12000);
}

void draw()
{
  background(0);
}

void oscEvent(OscMessage theOscMessage) {
  println("Address pattern: "+theOscMessage.addrPattern());
  println ("Typetag: "+theOscMessage.typetag());
  println ("Arguments: "+theOscMessage.get(0).doubleValue());
}

and the console prints

Address pattern: /test01
Typetag: ssss
### [2018/5/31 15:22:4] ERROR @ OscP5 ERROR. an error occured while forwarding an OscMessage
 to a method in your program. please check your code for any 
possible errors that might occur in the method where incoming
 OscMessages are parsed e.g. check for casting errors, possible
 nullpointers, array overflows ... .
method in charge : oscEvent  java.lang.reflect.InvocationTargetException

Viewing all articles
Browse latest Browse all 2896

Trending Articles