attwad / python-osc

Open Sound Control server and client in pure python
The Unlicense
517 stars 108 forks source link

Cant get Basic Server Demo to work with TouchOSC #131

Open HarlekinSimplex opened 3 years ago

HarlekinSimplex commented 3 years ago

Hi,

I just used the following sample code to test the server with my TouchOSC Surface:

from pythonosc.dispatcher import Dispatcher
from pythonosc.osc_server import BlockingOSCUDPServer

def print_handler(address, *args):
    print(f"{address}: {args}")

def default_handler(address, *args):
    print(f"DEFAULT {address}: {args}")

dispatcher = Dispatcher()
dispatcher.map("/scene/*", print_handler)
dispatcher.set_default_handler(default_handler)

ip = "127.0.0.1"
port = 8006

server = BlockingOSCUDPServer((ip, port), dispatcher)
server.serve_forever()  # Blocks forever

TouchOSC sends to port 8006 and receives on port 9006. Sending messages to TouchOSC works nicely but the server does not give any output. Regardless what I set as the address used by the dispatcher. Neither the function to handle the set mapping nor the default handler seem to be called.

PyCharm gives two warnings for the disptcher calls: Expected type 'FunctionType', got '(address: Any, args: Tuple[Any, ...]) -> None' instead May that be a hint what is wrong?

Im running that code on Windows10 Pro using PyCharm. What am I doing wrong here?

Cheers Harlekin

HarlekinSimplex commented 3 years ago

Just changed ip address from 127.0.0.1 to my real address 192.168.2.100 and it started working... Wiered.

However the 'FunctionType' Warnings are still there... Any idea how to hint PyCharm properly here?

Cheers Harlekin

jpc0 commented 2 years ago

See my comment https://github.com/attwad/python-osc/issues/144#issuecomment-1021223208