User Tools

Site Tools


python-osc-arduino

This is an old revision of the document!



Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /var/www/kucjica/emperors-wiki/inc/parser/handler.php on line 1458

Warning: Declaration of syntax_plugin_wrap_div::handle($match, $state, $pos, Doku_Handler &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /var/www/kucjica/emperors-wiki/lib/plugins/wrap/syntax/div.php on line 43

Warning: Declaration of syntax_plugin_wrap_div::render($mode, Doku_Renderer &$renderer, $indata) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /var/www/kucjica/emperors-wiki/lib/plugins/wrap/syntax/div.php on line 81

Warning: Declaration of syntax_plugin_wrap_closesection::handle($match, $state, $pos, Doku_Handler &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /var/www/kucjica/emperors-wiki/lib/plugins/wrap/syntax/closesection.php on line 23

Warning: Declaration of syntax_plugin_wrap_closesection::render($mode, Doku_Renderer &$renderer, $indata) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /var/www/kucjica/emperors-wiki/lib/plugins/wrap/syntax/closesection.php on line 29

Warning: Declaration of syntax_plugin_wrap_span::handle($match, $state, $pos, Doku_Handler &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /var/www/kucjica/emperors-wiki/lib/plugins/wrap/syntax/span.php on line 43

Warning: Declaration of syntax_plugin_wrap_span::render($mode, Doku_Renderer &$renderer, $indata) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /var/www/kucjica/emperors-wiki/lib/plugins/wrap/syntax/span.php on line 63

Warning: Declaration of syntax_plugin_gallery::handle($match, $state, $pos, &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /var/www/kucjica/emperors-wiki/lib/plugins/gallery/syntax.php on line 51

Warning: Declaration of syntax_plugin_gallery::render($mode, &$R, $data) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /var/www/kucjica/emperors-wiki/lib/plugins/gallery/syntax.php on line 147

Warning: Declaration of syntax_plugin_vshare::handle($match, $state, $pos, &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /var/www/kucjica/emperors-wiki/lib/plugins/vshare/syntax.php on line 47

Warning: Declaration of syntax_plugin_vshare::render($mode, &$R, $data) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /var/www/kucjica/emperors-wiki/lib/plugins/vshare/syntax.php on line 107

Warning: preg_match(): Compilation failed: invalid range in character class at offset 3444 in /var/www/kucjica/emperors-wiki/inc/parser/lexer.php on line 118
A PCRE internal error occured. This might be caused by a faulty plugin

====== Python code used to receive OSC transmission and communicate the results to Arduino ====== <code python> """ pythonic test on Arduino Yun """ import codecs, time from datetime import datetime import OSC, threading print "i am here" f_out = codecs.open("/mnt/sd/arduino/www/pajton.csv", "w", encoding="utf-8") currentTime = datetime.fromtimestamp(int(time.time())).strftime('%Y-%m-%d %H:%M: f_out.write('pisao'+str(currentTime)) # tupple with ip, port receive_address = '0.0.0.0', 50000 # OSC Server. there are three different types of server. s = OSC.OSCServer(receive_address) # basic # this registers a 'default' handler (for unmatched messages), # an /'error' handler, an '/info' handler. # And, if the client supports it, a '/subscribe' & '/unsubscribe' handler s.addDefaultHandlers() def all_handler(addr, tags, stuff, source): print "received new osc msg from %s" % OSC.getUrlStr(source) f_out.write(OSC.getUrlStr(source)+'; ') print "with addr : %s" % addr f_out.write(addr+'; ') print "typetags %s" % tags print "data %s" % stuff f_out.write(addr+'; ') f_out.write(str(stuff[0])+'; ') f_out.write(str(time.time())+'; ') f_out.write('\n') s.addMsgHandler("/conversation", all_handler) # adding our function s.addMsgHandler("/data", all_handler) s.addMsgHandler("/sms", all_handler) s.addMsgHandler("/signal", all_handler) # checking which handlers we have added print "Registered Callback-functions are :" for addr in s.getOSCAddressSpace(): print addr # Start OSCServer print "\nStarting OSCServer. Use ctrl-C to quit." st = threading.Thread(target = s.serve_forever) st.start() try: while 1: time.sleep(5) except KeyboardInterrupt: print "\nClosing OSCServer." s.close() print "Waiting for Server-thread to finish" st.join() ##!!! print "Done" f_out.close() </code>

python-osc-arduino.1401094861.txt.gz · Last modified: 2014/05/26 09:01 by zoza