I am trying to send datetimes to simulink via python. (I have to use simulink, not just MATLAB)
Here is my python program for a UDP server
import socket
from datetime import datetime
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(("127.0.0.1", 12345))
while True:
data, addr = sock.recvfrom(256)
print(data)
message = bytes(str(datetime.now()), encoding='utf-8')
sock.sendto(message, addr)
And here is my attempt at writing a receiver in Simulink
I have set the simulink model to run indefinitely but I get an error:
OSError: [Errno 48] Address already in use from python
Isn't it the point to use the same address to communicate? I understand the error is because it's between MATLAB and Python, so how do I get around it?