예제 #1
0
def send_osc(ip = default_IP, port = default_PORT, loop = default_LOOP, command = []):
    """Function, send a list of OSC commands."""
    osc.init()
    bundle = osc.createBundle()
    for item in command:
        osc.appendToBundle(bundle, '/sl/%s/hit' % loop, ['%s' % item])
    osc.sendBundle(bundle, '%s' % ip, int(port))
예제 #2
0
 def sendevent(self, event, down):
     bundle=osc.createBundle()
     osc.appendToBundle(bundle, "/keylogger/window/"+str(event.Window)+"/key", [event.Key, down])
     osc.appendToBundle(bundle, "/keylogger/WindowName/"+str(event.WindowName)+"/key", [event.Key, down])
     osc.sendBundle(bundle, self.host, self.port)
     if(self.callback):
         self.callback(str(event.Window), str(event.Key))
예제 #3
0
def myTest():
    """ a simple function that creates the necesary sockets and enters an enless
        loop sending and receiving OSC
    """
    osc.init()
    
##    osc.createListener() # this defaults to port 9001 as well
    osc.listen('127.0.0.1', 9001)

    # bind addresses to functions -> printStuff() function will be triggered everytime a
    # "/test" labeled message arrives
    osc.bind(printStuff, "/test")

    import time # in this example we will have a small delay in the while loop

    print 'ready to receive and send osc messages ...'
    
    while 1:
##        osc.sendMsg("/test", [444], "127.0.0.1", 9000) # send normal msg to a specific ip and port
        osc.sendMsg("/test", [444]) # !! it sends by default to localhost ip "127.0.0.1" and port 9000 
        # create and send a bundle
        bundle = osc.createBundle()
        osc.appendToBundle(bundle, "/test/bndlprt1", [1, 2, 3]) # 1st message appent to bundle
        osc.appendToBundle(bundle, "/test/bndlprt2", [4, 5, 6]) # 2nd message appent to bundle
##        osc.sendBundle(bundle, "127.0.0.1", 9000) # send it to a specific ip and port

        osc.sendBundle(bundle) # !! it sends by default to localhost ip "127.0.0.1" and port 9000 
        #osc.getOSC(inSocket) # listen to incomming OSC in this socket
        time.sleep(0.5) # you don't need this, but otherwise we're sending as fast as possible.
        

    osc.dontListen() # finally close the connection bfore exiting or program
예제 #4
0
 def __init__(self):
     osc.init()
     bundle = osc.createBundle()
     self.set_laser(False)
     for servo in servos:
         servo['range'] = self._range(servo)
         osc.appendToBundle(
             bundle,
             "/digitalout/%i/speed" % servo['address'],
             [servo['speed']]
         )
     osc.sendBundle(bundle, BOARD_ADDRESS, BOARD_PORT)
예제 #5
0
    def update_servos(self, x, y):
        bundle = osc.createBundle()
        for servo in servos:
            p = x if servo['axis'] == 'x' else y
            osc.appendToBundle(
                bundle,
                "/servo/%i/position" % servo['address'],
                [servo['range'](1 - p if servo['direction'] else p)]
            )
        osc.sendBundle(bundle, BOARD_ADDRESS, BOARD_PORT)

        return {
            'x': x,
            'y': y,
        }
예제 #6
0
def myTest():
    """ a simple function that creates the necesary sockets and enters an enless
        loop sending and receiving OSC
    """
    osc.init()

    inSocket = osc.createListener('127.0.0.1',
                                  9001)  # in this case just using one socket
    ##    inSocket = osc.createListener() # this defaults to port 9001 as well

    # bind addresses to functions -> printStuff() function will be triggered everytime a
    # "/test" labeled message arrives
    osc.bind(printStuff, "/test")

    import time  # in this example we will have a small delay in the while loop

    print 'ready to receive and send osc messages ...'

    while 1:
        ##        osc.sendMsg("/test", [444], "127.0.0.1", 9000) # send normal msg to a specific ip and port
        osc.sendMsg("/test", [
            444
        ])  # !! it sends by default to localhost ip "127.0.0.1" and port 9000

        # create and send a bundle
        bundle = osc.createBundle()
        osc.appendToBundle(bundle, "/test/bndlprt1",
                           [1, 2, 3])  # 1st message appent to bundle
        osc.appendToBundle(bundle, "/test/bndlprt2",
                           [4, 5, 6])  # 2nd message appent to bundle
        ##        osc.sendBundle(bundle, "127.0.0.1", 9000) # send it to a specific ip and port

        osc.sendBundle(
            bundle
        )  # !! it sends by default to localhost ip "127.0.0.1" and port 9000

        osc.getOSC(inSocket)  # listen to incomming OSC in this socket

        time.sleep(
            0.5
        )  # you don't need this, but otherwise we're sending as fast as possible.
예제 #7
0
파일: luaexecute.py 프로젝트: dwiel/swarm
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import osc
import sys

osc.init()

#for line in sys.stdin :
lua = ""
print "enter command:"
while lua != "quit\n" and lua != "exit\n":
	line = sys.stdin.readline()
	lua += line
	if line == "" or line == "\n" :
		bundle = osc.createBundle()
		# osc.appendToBundle(bundle, "/lua/execute", 'groups["swarm1"].pos.z = -30')
		osc.appendToBundle(bundle, "/lua/execute", lua)
		osc.sendBundle(bundle, "localhost", 9001)
		print "sent:\n  >" + lua.replace('\n', '\n  >')
		print "------------"
		print "enter command:"
		lua = ""



예제 #8
0
import osc

osc.init()
    
# create and send a bundle
bundle = osc.createBundle()
osc.appendToBundle(bundle, "/test/bndlprt1", [1, 2.2, "333"])
osc.appendToBundle(bundle, "/test/bndlprt2", [4, 5.5, 6])
osc.sendBundle(bundle, "127.0.0.1", 9999)