Simulink Real-Time TCP Send variable size data input

1 次查看(过去 30 天)
I am trying to create a communication interface in simulink real-time where i have to send data of variable size (e.g. I have messages like start/stop which are just a header of constant size, but I also have messages with an attached payload of variable size). I cycle through the desired data using multiport-switch blocks which support inputs of variable size. The TCP Send block of the real-time toolbox however, does not support this. This seems counterintuitive, given as it also takes a length input specifying how long the data input is. Am I overlooking some configuration options in the block?
If not, what is the recommended way to send variable size data via TCP in simulink real-time? My current idea is to apply zero-padding to my data vectors to alter them to a constant size for all cases, while relying on the length input to convince the TCP send block to only send the data I want to send. Would this work? If not, what alternatives are there?
Any help would be greatly appreciated!

采纳的回答

Diego Kuratli
Diego Kuratli 2020-9-24
The approach you suggest is correct.
The Data vector should be defined with the expected maximum length. You can control the data that is effectively transmitted with the Length port.
Example: if you have a Data vector of size 100, but the Length port value is 70, only the first 70 elements of the vector are transmitted (the others are ignored)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Development Computer Setup 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by