UDP block for simulink
22 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I am trying to use judp.m as a reference for building a simple udp receive block for simulink.
In simulink I am using matlab function block with the code below:
I am not very familiar with coder and would be thankful if I can get assistance in getting this block fixed.
Thanks
function mssg = judp(targetPort)
timeout = 5000;
packetLength = 10;
coder.extrinsic('java.io.*')
coder.extrinsic('java.net.InetAddress')
coder.extrinsic('java.net.DatagramSocket')
coder.extrinsic('java.net.DatagramPacket')
socket = java.net.DatagramSocket(targetPort)
socket.setSoTimeout(timeout)
socket.setReuseAddress(1);
packet = java.net.DatagramPacket(zeros(1,packetLength,'int8'),packetLength);
socket.receive(packet);
socket.close;
mssg = packet.getData;
mssg = mssg(1:packet.getLength);
inetAddress = packet.getAddress;
sourceHost = char(java.net.InetAddress.inetAddress.getHostAddress);
end
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Simulink Coder 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!