Programmatically change UDP Packet Output IP: Desktop Real-Time

2 visualizaciones (últimos 30 días)
Spencer Chen
Spencer Chen el 30 de Abr. de 2020
Comentada: Manuel K el 4 de Ag. de 2020
Hi,
I have a Simulink desktop real-time model that has a Packet Output set up to do UDP. I want to be able to set it up so it is sending to the correct IP in the InitFcn, rather than hard-coding the IP from the Simulink UI. Does anyone know if it is possible to do that?
I tried a couple approaches:
  1. Try accessing with get_param(), but eally cannot find the right model path.
  2. Try setting CLIENT_IP = '127.0.0.1' in the base workspace and fill in the IP field with CLIENT_IP instead of the actual IP address. At compile, I get error that this cannot be resolved.
Matlab R2018b, Windows 10.
Blessings,
Spencer
  4 comentarios
Spencer Chen
Spencer Chen el 30 de Jul. de 2020
Editada: Spencer Chen el 30 de Jul. de 2020
I'm adopting a Variant solution with a small set of hardcoded IPs as a workaround.
Manuel K
Manuel K el 4 de Ag. de 2020
I'm sorry, I totally missed what block you are using.
Netherless I played a bit and saw the following line:
DrvOptions: '[0 50021 49 50 55 46 48 46 48 46 49 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]'
The elements after your port address "50021" are the decimal-representation for the ASCII-characters of your IP-adress.
49 50 55 46 48 46 48 46 49
translates to
127.0.0.1
With the following command I could change the IP-adress accordingly.
set_param(gcb,'DrvOptions','[0 50021 49 50 55 46 48 46 48 46 49 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]')
So you just have to convert your IP-adress to the right representation and insert it in this array.
I hope this addresses your issue better.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Troubleshooting in Simulink Desktop Real-Time en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by