Azzera filtri
Azzera filtri

Can I use multiple "UDP Receive" blocks with masked subsystem variables?

1 visualizzazione (ultimi 30 giorni)
I want to include multiple copies of the same subsystem in my Simulink model, each with a "UDP Receive" block and a "UDP Send" block that are set with their own unique IP:port combination. I set the IP:port combination programmatically using mask variables whose values are sent from the mask to each of the UDP blocks' parameters. This way, I can import as many of the subsystem as I want into the model and then my script iteratively assigns the mask variables to different values - "localPort" for ports and "localAddr" for IP addresses. However, when I try building this model with multiple subsystems, I get the following error:
Two UDP receive blocks cannot share the same ip:port combination.
IP address is assumed equal to any other unicast IP address.
When I set these in my script, the IP:port combinations are different, so why is Simulink telling me that they are the same?

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 20 Mar 2023
Using mask variables to assign IP Addresses and Port Numbers to the "UDP Receive" and "UDP Send" blocks is currently unsupported and we hope to adjust this in a future release
In each of the copies of the masked subsystem, the "UDP Receive" blocks are using the same mask workspace variables for "localPort" and "localAddr". When the "UDP Receive" block in a given subsystem, let's call it "Subsystem 1", executes its internal callback function to validate the model, it identifies its own IP Address and Port Number from the aforementioned variables then checks the IP Address and Port Number of the other "UDP Receive" Blocks that are located in the other subsystems as a part of the validation process. Because these blocks also use the same mask workspace variables "localPort" and "localAddr", and this code execution is still processing inside "Subsystem 1", these variables evaluate to their values in the "Subsystem 1" workspace rather than their own workspaces. Because of this behavior, the variables in the UDP blocks in the other subsystems are seen to be the same as those in "Subsystem 1", and thus the error is thrown. This is an edge case that the UDP Receive block has not accounted for.
As a workaround, you can still use the mask variables "localPort" and "localAddr" but assign them as block parameters directly using mask callback functions. The data will be stored in the mask workspace instead. This way, the values corresponding to the mask workspace variables are directly assigned as block parameters to the "UDP Receive" and "UDP Send" blocks inside a given masked subsystem. 
See the screenshot attached on what this might look like:

Più risposte (0)


Scopri di più su Subsystems in Help Center e File Exchange


Non è stata ancora inserito alcun tag.

Community Treasure Hunt

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

Start Hunting!

Translated by