We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am having troubles receiving messages with the oscP5 library. from the Java example, I got this setup in python
from oscP5 import *
from netP5 import *
print
def setup():
size(400, 400)
background(0)
port1 = 12000
oscP5 = OscP5(this, port1)
loc = NetAddress('127.0.0.1', 12000)
def draw():pass
def oscEvent(OscMessage):
msg = OscMessage
print "### received an osc message."
print " addrpattern: %s " % msg.addrPattern()
print " typetag:%s " % msg.typetag()
While sending messages works fine, for some reason this doesn't. I think there is something wrong with the way I assign the value in the oscEvent function. Any idea? Thanks
Answers
FYI this is the Java sketch where I got the oscEvent function
Go here: https://github.com/jdf/Processing.py-Bugs/issues/157
And demand the same fix done for serialEvent() to oscEvent() callback too. >-)
Will do! Thanks.
hi, I am not too familiar with the python mode but give the following a go. I have tested this with oscP5 version 0.9.9 and 2.0.4, sending and receiving worked fine.
giving the following a try with oscP5 2.0.4 also worked, in the code below a listener is directly assigned to a function (oscEvent)
Also make sure that the udp port must be closed when exiting the sketch, so that it is not blocked when re-running the sketch. This is taken care of calling
osc.dispose()
from inside thestop()
functionNote: an earlier version of the examples above used
m.getArguments()
which is only implemented for 2.0.4 but not 0.9.9 which caused the examples not to run under 0.9.9. this has been highlighted in the discussion below.m.getArguments()
was then replaced bym.arguments()
.Thank you so much! I was really struggling here. FYI: The first solution works great while the second does not let me assign oscEvent as an argument to addListener.
One last question: how do I get the oscEvent function in the Listen class to return the value received (first example)? I tried to return it with the addrPattern method but, while printing works, I can't get it to be assigned to a sketch variable...
I have made adjustments to my previous post, have a look. the code snippets now also show how to transfer and store an osc argument inside a global variable (here
col
).@sojamo, strangely your 1st example doesn't trigger the oscEvent() for me. It only sends. :(
Also I've tweaked it a little but no success.
For me it seems I'm forced to await for the actual oscEvent() fix. ~:>
works for me on osx and processing 3.0.2, your example also works fine.
Win 7, 64-bit P5 v3.0.2 and Osc v0.9.9. :-<
If I close all the PDEs (or kill all "java.exe" processes, keeping "javaw.exe" though) and re-run it and paste the code, at the 1st run I've got this after keyPressed():
On subsequent re-runs the sketch executes. But no oscEvent() triggers at all! :-&
If I comment out
#gray = m.getArguments()[0]
, the oscEvent() trigger is called back successfully! @-)col = m.getArguments()[0]
, I've ended up incurring in error! No idea why you were immune to it though. 8-}print 'Sending gray color message:', msg.arguments()[0]
http://www.Sojamo.de/libraries/oscp5/reference/oscP5/OscMessage.html#arguments()
P.S.: Once any error occurs in the OscEventListener, I've gotta close all PDEs or kill all "java.exe". Otherwise Python mode doesn't see any further editing made to the class! :(|)
I was running into the same problem of GoToLoop, now fixed. Thank you all for taking care of this issue!!
hi, sorry, my bad. when editing and updating my post from above, I did check the example only against oscP5 2.0.4 and later not 0.9.9 which is the version currently available from the library manager.
getArguments()
is only implemented with 2.0.4 and not 0.9.9.arguments()
is available with both versions. I have made updates to my previous post to make the examples work for both versions, I have left a remark that mentions the change fromgetArguments()
toarguments()
.great