Hi I am trying to comunicate pd with data coming from pachube (www.pachube.com) using a python script. The script ask for data from pachube web and convert the data to OSC protocol. Then the OSC mesagge is sent to pd. Pd recibe the OSC mesagge but something is wrong when unpack and route the data. Data can not get in a number box object, this error mesagge is diplayed in console: error: gatom: no method for '1'
The python script
# to receive data import urllib2 # to send on with OpenSoundControl, OSC from simpleOSC import * import time
initOSCClient('127.0.0.1', 57110) while 1: data=urllib2.urlopen(' http://api.pachube.com/v2/feeds/2791.csv?key=hereyourcode') for l in data: d = l.strip().split(",", 2) print d sendOSCMsg('/test/num',d[0]) sendOSCMsg('/test/val',d[2]) time.sleep(5) # wait here some secs
the patch
#N canvas 599 0 450 476 10; #X declare -lib mrpeach; #X obj -217 25 import mrpeach; #X obj -220 112 unpackOSC; #X floatatom -219 277 5 0 0 0 - - -; #X obj -214 148 routeOSC /test; #X obj -191 348 print; #X floatatom -150 281 5 0 0 0 - - -; #X obj -219 66 udpreceive 57110; #X floatatom -92 290 5 0 0 0 - - -; #X obj -204 205 routeOSC /val /num; #X connect 1 0 3 0; #X connect 3 0 8 0; #X connect 6 0 1 0; #X connect 8 0 2 0; #X connect 8 1 5 0; #X connect 8 1 4 0; #X connect 8 2 7 0;
any idea?
thanks
Hi Fernando
I wasn't able to successfully run your python script, because I have no access to the URL you posted: urllib2.HTTPError: HTTP Error 401: Unauthorized
However, the description of the problem you have did ring a bell. I remember that once someone had a similar problem. OSC allows to transport different data types and a '1' can be sent as a string, an int or a float. Ints and floats are converted by [unpackOSC] to Pd's floating point number format and strings are converted to Pd's symbols. I guess what you have here might be a symbolic '1' instead of a numeric one.
The real fix would be to make sure that numeric values are really sent as numeric values. That doesn't help if you don't have any control over the sender. I haven't found yet a nice solution in Pd to convert symbolic numbers into real floats. You could send all your data over a [netsend]-[netclient] connection, because then the data is transformed to FUDI messages and back to Pd messages and thus loses any information about whether a certain element was numeric or symbolic.
Roman
On Sun, 2010-12-05 at 22:26 -0300, FernandoG wrote:
Hi I am trying to comunicate pd with data coming from pachube (www.pachube.com) using a python script. The script ask for data from pachube web and convert the data to OSC protocol. Then the OSC mesagge is sent to pd. Pd recibe the OSC mesagge but something is wrong when unpack and route the data. Data can not get in a number box object, this error mesagge is diplayed in console: error: gatom: no method for '1'
The python script
# to receive data import urllib2 # to send on with OpenSoundControl, OSC from simpleOSC import * import time
initOSCClient('127.0.0.1', 57110) while 1:
data=urllib2.urlopen('http://api.pachube.com/v2/feeds/2791.csv?key=hereyourcode') for l in data: d = l.strip().split(",", 2) print d sendOSCMsg('/test/num',d[0])
sendOSCMsg('/test/val',d[2]) time.sleep(5) # wait here some secsthe patch
#N canvas 599 0 450 476 10; #X declare -lib mrpeach; #X obj -217 25 import mrpeach; #X obj -220 112 unpackOSC; #X floatatom -219 277 5 0 0 0 - - -; #X obj -214 148 routeOSC /test; #X obj -191 348 print; #X floatatom -150 281 5 0 0 0 - - -; #X obj -219 66 udpreceive 57110; #X floatatom -92 290 5 0 0 0 - - -; #X obj -204 205 routeOSC /val /num; #X connect 1 0 3 0; #X connect 3 0 8 0; #X connect 6 0 1 0; #X connect 8 0 2 0; #X connect 8 1 5 0; #X connect 8 1 4 0; #X connect 8 2 7 0;
any idea?
thanks _______________________________________________ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
On 6 Dec 2010, at 01:26, FernandoG dataferx@gmail.com wrote:
Hi I am trying to comunicate pd with data coming from pachube (www.pachube.com) using a python script. The script ask for data from pachube web and convert the data to OSC protocol. Then the OSC mesagge is sent to pd. Pd recibe the OSC mesagge but something is wrong when unpack and route the data.
It looks like someone is solving the same problem in Max. Maybe worth a look...
http://www.frankmacdonald.co.uk/digital-economy-news/parsing-pachube-xml-dat...
Jamie
Data can not get in a number box object, this error mesagge is diplayed in console: error: gatom: no method for '1'
The python script
# to receive data import urllib2 # to send on with OpenSoundControl, OSC from simpleOSC import * import time
initOSCClient('127.0.0.1', 57110) while 1: data=urllib2.urlopen('http://api.pachube.com/v2/feeds/2791.csv?key=hereyourcode') for l in data: d = l.strip().split(",", 2) print d sendOSCMsg('/test/num',d[0])
sendOSCMsg('/test/val',d[2]) time.sleep(5) # wait here some secsthe patch
#N canvas 599 0 450 476 10; #X declare -lib mrpeach; #X obj -217 25 import mrpeach; #X obj -220 112 unpackOSC; #X floatatom -219 277 5 0 0 0 - - -; #X obj -214 148 routeOSC /test; #X obj -191 348 print; #X floatatom -150 281 5 0 0 0 - - -; #X obj -219 66 udpreceive 57110; #X floatatom -92 290 5 0 0 0 - - -; #X obj -204 205 routeOSC /val /num; #X connect 1 0 3 0; #X connect 3 0 8 0; #X connect 6 0 1 0; #X connect 8 0 2 0; #X connect 8 1 5 0; #X connect 8 1 4 0; #X connect 8 2 7 0;
any idea?
thanks _______________________________________________ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
hello,
can you try to change this line: sendOSCMsg('/test/num',d[0])
with this: m = '[',d[0],']' sendOSCMsg('/test/num',m)
I can not test right now with your script and simpleOSC API, but I got this error long ago when working on pd2blender project, the simpleOSC API has changed since I've used it, maybe it's worth to try.
----- "Jamie Bullock" jamie@postlude.co.uk a écrit :
On 6 Dec 2010, at 01:26, FernandoG < dataferx@gmail.com > wrote:
Hi I am trying to comunicate pd with data coming from pachube ( www.pachube.com ) using a python script. The script ask for data from pachube web and convert the data to OSC protocol. Then the OSC mesagge is sent to pd. Pd recibe the OSC mesagge but something is wrong when unpack and route the data.
It looks like someone is solving the same problem in Max. Maybe worth a look...
http://www.frankmacdonald.co.uk/digital-economy-news/parsing-pachube-xml-dat...
Jamie
Data can not get in a number box object, this error mesagge is diplayed in console: error: gatom: no method for '1'
The python script
# to receive data import urllib2 # to send on with OpenSoundControl, OSC from simpleOSC import * import time
initOSCClient('127.0.0.1', 57110) while 1: data=urllib2.urlopen(' http://api.pachube.com/v2/feeds/2791.csv?key=hereyourcode ') for l in data: d = l.strip().split(",", 2) print d sendOSCMsg('/test/num',d[0]) sendOSCMsg('/test/val',d[2]) time.sleep(5) # wait here some secs
the patch
#N canvas 599 0 450 476 10; #X declare -lib mrpeach; #X obj -217 25 import mrpeach; #X obj -220 112 unpackOSC; #X floatatom -219 277 5 0 0 0 - - -; #X obj -214 148 routeOSC /test; #X obj -191 348 print; #X floatatom -150 281 5 0 0 0 - - -; #X obj -219 66 udpreceive 57110; #X floatatom -92 290 5 0 0 0 - - -; #X obj -204 205 routeOSC /val /num; #X connect 1 0 3 0; #X connect 3 0 8 0; #X connect 6 0 1 0; #X connect 8 0 2 0; #X connect 8 1 5 0; #X connect 8 1 4 0; #X connect 8 2 7 0;
any idea?
thanks
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
On Sun, Dec 5, 2010 at 8:26 PM, FernandoG dataferx@gmail.com wrote:
Data can not get in a number box object, this error mesagge is diplayed in console: error: gatom: no method for '1'
I don't know simpleOSC but this code/description looks like your '1', by the time it is received by Pd is untyped(?), and there fore numberbox does not know how to deal with it. Did you try [print]? You may want to pass that output through [sprintf %i] or something similar (perhaps just [trigger float] will do?) to 'cast' it into proper datatype. I don't have pd handy to test but this should set you on the right track.
./MiS
wow... looks like a lot of platforms are supported. http://community.pachube.com/software_hardware
maybe a native pd external or pyext external would be nice....
anyway... i would like to know if you get this working..,
thanks! mark
On Sat, Dec 11, 2010 at 3:26 PM, Michal Seta mis@artengine.ca wrote:
On Sun, Dec 5, 2010 at 8:26 PM, FernandoG dataferx@gmail.com wrote:
Data can not get in a number box object, this error mesagge is diplayed in console: error: gatom: no method for '1'
I don't know simpleOSC but this code/description looks like your '1', by the time it is received by Pd is untyped(?), and there fore numberbox does not know how to deal with it. Did you try [print]? You may want to pass that output through [sprintf %i] or something similar (perhaps just [trigger float] will do?) to 'cast' it into proper datatype. I don't have pd handy to test but this should set you on the right track.
./MiS
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Thanks guys for yours coments
There was a problem with the datatype (thanks roman and michal), python script received and sent the data like simbols. To solve the issue i cast this data to floats in python and now pd patch its working. I think my solution is really unpolite(sorry iam not a programer) but i can get the data in to pd numbers boxes. The script is adapted to the specific data feed, and this data is a vector with tree elements ( ['0', '2010-12-11T22:11:34.480041Z', '7.6']). First I delate second elemnt(2010-12-11T22:11:34.480041Z) because i dont know how to cast it and i dont need the date. There is the python code:
# to receive data import urllib2 # to send on with OpenSoundControl, OSC from simpleOSC import * import time
initOSCClient('127.0.0.1', 57110) while 1: data=urllib2.urlopen(' http://api.pachube.com/v2/feeds/2791.csv?key=hereyourownkey') # this data feed has tree diferents values for l in data: d = l.strip().split(",", 2) del d[1] #this is because this variable was the date and i dont know how to cast it var = map(lambda x: float(x), d) print var sendOSCMsg('/test/num',var) # del var[0] sendOSCMsg('/test/val',var) time.sleep(5) # wait here some secs
the pd patch
#N canvas 822 23 450 476 10; #X declare -lib mrpeach; #X obj -103 27 import mrpeach; #X obj -106 114 unpackOSC; #X floatatom -105 279 0 0 0 0 - - -; #X obj -100 150 routeOSC /test; #X floatatom -36 283 5 0 0 0 - - -; #X obj -105 68 udpreceive 57110; #X floatatom 22 292 5 0 0 0 - - -; #X obj -55 205 routeOSC /val /num; #X obj -98 321 osc~ 440; #X obj -85 371 dac~; #X connect 1 0 3 0; #X connect 2 0 8 0; #X connect 3 0 7 0; #X connect 5 0 1 0; #X connect 7 0 2 0; #X connect 7 1 4 0; #X connect 7 2 6 0; #X connect 8 0 9 0; #X connect 8 0 9 1;
2010/12/11 mark edward grimm mgrimm@syr.edu
wow... looks like a lot of platforms are supported. http://community.pachube.com/software_hardware
maybe a native pd external or pyext external would be nice....
anyway... i would like to know if you get this working..,
thanks! mark
On Sat, Dec 11, 2010 at 3:26 PM, Michal Seta mis@artengine.ca wrote:
On Sun, Dec 5, 2010 at 8:26 PM, FernandoG dataferx@gmail.com wrote:
Data can not get in a number box object, this error mesagge is diplayed
in
console: error: gatom: no method for '1'
I don't know simpleOSC but this code/description looks like your '1', by the time it is received by Pd is untyped(?), and there fore numberbox does not know how to deal with it. Did you try [print]? You may want to pass that output through [sprintf %i] or something similar (perhaps just [trigger float] will do?) to 'cast' it into proper datatype. I don't have pd handy to test but this should set you on the right track.
./MiS
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management ->
http://lists.puredata.info/listinfo/pd-list
-- ____________________ mark edward grimm | m.f.a IT macintosh engineer | adjunct syracuse u. | vpa foundations | timearts mgrimm@syr.edu | 315.378.2136 _________________________________
On Sat, 11 Dec 2010, FernandoG wrote:
script is adapted to the specific data feed, and this data is a vector with tree elements ( ['0', '2010-12-11T22:11:34.480041Z', '7.6']). First I delate second elemnt(2010-12-11T22:11:34.480041Z) because i dont know how to cast it and i dont need the date. There is the python code:
What I recommend for dates in Pd, is to put it as a triplet of integers (represented as floats). First put the date as a standard unix number, adjusted in the timezone you choose to use. Then separate it in three parts : $3 is for microseconds, from 0 to 999999 ; $2 is for seconds in a day, using % 86400; $1 is for the day number, using / 86400 ; for example, your above date is :
1292105494.480041 in epoch format $3 = 480041 1292105494 is rounded downwards, in whole seconds $2 = 1292105494 % 86400 = 79894 $1 = 1292105494 / 86400 = 14954
I don't know any Python. I just know that it's quite similar to Ruby, and in Ruby, when I print Time.new.to_f, I get a double (float64) that says something like 1292105494.480041, so, I suppose you can find a way to get the same.
The above triplet of numbers is output by the middle outlet of my external named [unix_time] :
http://gridflow.ca/help/unix_time-help.html
| Mathieu Bouchard ---- tél: +1.514.383.3801 ---- Villeray, Montréal, QC