Running a simulink model from python script using TCP/IP
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
import socket, struct
import matlab.engine
import os
eng = matlab.engine.start_matlab()
TCP_IP = 'localhost'
TCP_PORT = 30001
BUFFER_SIZE = 1024
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((TCP_IP, TCP_PORT))
print('Waiting for Simulink to start')
s.listen()
print("Waiting for connection")
-------------------------Stops at this point--------------------------------------------------------------
eng.sim('TCP')
conn, addr = s.accept()
print("Connection Accpeted")
print('Connection address: ', addr)
for i in range(51):
msg1 = struct.pack('>d', i)
conn.send(msg1)
print('sent data:', i)
data = conn.recv(BUFFER_SIZE)
print(data)
conn.close()
I am trying to run a simulink model which sends and receives data from python. The connection fails when I run the model through python scipt. Can anyone help me with the same.
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Call Python from MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!