UDP Connection to Python Support #2028
banningjoe
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi all,
I'm hoping to setup a connection between bonsai and python where python connects to a camera and feeds an image via UDP to bonsai.
As a stepping stone to getting this setup I've been trying to just setup a python script + bonsai script where I send a series of integers using UDP. I'm struggling to do this and wondering if anyone has any pointers!
Here is my current python script:
from pythonosc import udp_client
from pythonosc import osc_message_builder
import random
import time
HOST = '127.0.0.1' # Change this to the server's IP address
PORT = 9001
client = udp_client.SimpleUDPClient(HOST, PORT)
while True:
random_integer = random.randint(0, 100)
# Send the integer as an OSC message
client.send_message("/random", random_integer)
print("Sent:", random_integer)
time.sleep(1) # Wait 1 second before sending the next integer
_____________________-
And here is an image of my bonsai scripts with the details on the parameters listed below:
test Node (CreateUDPClient):
Name: test
Port: 9002
RemoteHostName: 127.0.0.1
RemotePort:9001
Recieve Message Node:
Address: /random
Connection:test
TypeTag: i
This setup has not been working. While I've been able to setup two bonsai files that can communicate with one another via TCP, I've failed to setup a python script communicating via TCP/UDP with bonsai. I've playing with the settings and parameters quite a bit but I am not well versed in communication protocols.
I'm hoping to get some support to setup a simple data transfer of integers. Once I figure that out I feel reasonably confident I can handle the other data manipulations.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions