我正在尝试通过OSC (Open Sound Control) protocol设置chuck和python之间的通信.在python方面,我们使用的是python-osc library,而chuck本身支持OSC协议.看来我们从python端发送的消息没有到达卡盘端.但是,所有其他组合,即python到python,chuck到chuck和chuck到python都可以正常工作.
我在Windows 7上运行python 3.4.4.
这里可能出什么问题了?
这是我用于测试的客户端/服务器实现的四个文件.
chuck_client.py:
OscSend xmit;
xmit.setHost("localhost", 5005);
<<<"Sending">>>;
xmit.startMsg("/debug");
chuck_server.py:
OscRecv orec;
5005 => orec.port;
orec.listen();
orec.event("/debug") @=> OscEvent e;
<<<"Waiting">>>;
e => now;
<<<"Received">>>;
python_client.py:
from pythonosc import osc_message_builder
from pythonosc import udp_client
client = udp_client.UDPClient('localhost', 5005)
msg = osc_message_builder.OscMessageBuilder(address="/debug")
msg = msg.build()
print('Sending')
client.send(msg)
python_server.py:
from pythonosc import dispatcher
from pythonosc import osc_server
dispatcher = dispatcher.Dispatcher()
dispatcher.map("/debug", lambda _: print('Received'))
print('Waiting')
server = osc_server.ThreadingOSCUDPServer(
('localhost', 5005), dispatcher)
print("Serving on {}".format(server.server_address))
server.serve_forever()
解决方法:
这似乎是python-osc 1.5中的错误.在1.6版中,提供的示例适用.参考:https://github.com/attwad/python-osc/issues/31