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

조회 수: 2 (최근 30일)
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 0.0.0.0 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?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2023년 3월 20일
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:

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Subsystems에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by