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:
![Screenshot 2024-09-30 140043](https://private-user-images.githubusercontent.com/16569257/372192697-c151d545-84f1-4829-b35e-5109e2b46a71.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyMjk1OTcsIm5iZiI6MTczOTIyOTI5NywicGF0aCI6Ii8xNjU2OTI1Ny8zNzIxOTI2OTctYzE1MWQ1NDUtODRmMS00ODI5LWIzNWUtNTEwOWUyYjQ2YTcxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDIzMTQ1N1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWI5OTM1MjAxNmU1YmVmM2ZkODVhNWJlYzM2YTZiMzAwNjQyNDc4ZmMyZjIzZmI4NTJlMWRmZGU1Njc2YWNjYmEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.7cfP3K1P6dyuq0XgU1pJFVfiLZWHJsGbTnlrw175IkI)
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