How can receive UDP data from Python UDP client in MatLab/Simulink support package for Raspberry Pi
Afficher commentaires plus anciens
Hi I programmed UDP client in python. This is the code.
import socket
import sys
# Create a UDP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
server_address = ('localhost', 10000)
x=0.4
message = str(x)
try:
# Send data
print >>sys.stderr, 'sending "%s"' % message
sent = sock.sendto(message, server_address)
# Receive response
print >>sys.stderr, 'waiting to receive'
data, server = sock.recvfrom(4096)
print >>sys.stderr, 'received "%s"' % data
finally:
print >>sys.stderr, 'closing socket'
sock.close()
Now I would like to receive that data in my MatLab/Simulink block. I have done some research, and what found is that Instrument Control Toolbox can be use UDP object to get the data. Or go to the File Exchange and grabbed the Simple UDP Communications App code. It is just one function, judp, that allows me to send and receive UDP packets.
Is this going to work with my python UDP client? Is there any other solution?
Thanks
Réponses (1)
Floris Jan Florijn
le 6 Juin 2018
2 votes
Did you managed to get this up and running?
I'm struggling with the same issue at the moment...
1 commentaire
Jeongmin Hong
le 4 Fév 2022
Did you solve the problem?
Catégories
En savoir plus sur Call Python from MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!