28 lines
583 B
Python
28 lines
583 B
Python
import socket
|
|
import struct
|
|
from oscpy import *
|
|
|
|
UDP_IP = "172.18.0.1"
|
|
UDP_PORT = 7000
|
|
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
sock.bind((UDP_IP, UDP_PORT))
|
|
|
|
|
|
while True:
|
|
data, addr = sock.recvfrom(10*1024)
|
|
n = get_string_size(data)
|
|
[tag] = struct.unpack(f'{n}s', data[:n])
|
|
if "#bundle" in tag.decode():
|
|
b = Bundle(data)
|
|
print("Bundle:")
|
|
for msg in b.msgs:
|
|
print(" -", msg)
|
|
else:
|
|
msg = Message(data)
|
|
if msg.address == "/time":
|
|
msg.args[0] = float(msg.args[0])
|
|
print(msg)
|
|
|
|
|