attwad/python-osc

grouping in a list values received by dispatcher.map

abadpablo opened this issue · 0 comments

Hi all,
I'm sending values from a pointgrey camera via osc to python (from Bonsai), and I get the values but one per one.

I would like to store all the values coming via osc in an array or a list in order to make posterior operations. When I try to append the new values coming to an array, the array does not grow, it only keeps track of the last value that has arrived.

Do you have any suggestions? Here is the code.
Thanks in advance

import numpy as np
import argparse
from pythonosc import dispatcher
from pythonosc import osc_server
from pythonosc import udp_client

global sec = []

def print_number(unused_addr, args, number):
#print(volume)
global seconds
cycle1 = (number >> 12) & 0x1FFF
cycle2 = (number >> 25) & 0x7F
seconds = cycle2 + cycle1 / 8000.
print(seconds)
sec.append(seconds)

if name == "main":
parser = argparse.ArgumentParser()
parser.add_argument("--ip",
default="127.0.0.1", help="The ip to listen on")
parser.add_argument("--port",
type=int, default=9000, help="The port to listen on")
args = parser.parse_args()
print(args)

dispatcher = dispatcher.Dispatcher()
dispatcher.map("/number", print_number, "number")

server = osc_server.ThreadingOSCUDPServer(
(args.ip, args.port), dispatcher)
print("Serving on {}".format(server.server_address))
server.serve_forever()