Packet Input block Buffer for TCP/IP Communication
古いコメントを表示
Hi,
I am using the Packet Input block of the Simulink Desktop Real-Time [SLDRT] library for a Simulink model running in external mode. https://de.mathworks.com/help/sldrt/ref/packetinput.html
In my set up, I am receiving and sending serial binary messages via TCP/IP in a frquency of 500Hz. My problem is, that there are 5 initial messages of different length before the real communication starts and the messages become constant in terms of length.
With the usage of some enabled subsystems and multiple Packet Output blocks I was able to handle the sending of differen messages, but I don't know how to use the Packet Input block to receive messages of different lengths.
Functionality of the Package Input block
It offers a slot for the message length to be received which somehow looks like a buffer, but behaves a little strange.
In the picture below you see the result of the initial messages. I set the Packet Input block to 100 uint8 bytes. In black, there is message 1 (the oldest) in green there is message 2 and in blue is the latest message. I would have expected 115 Bytes in total, but the block simply filled the array and cut off as soon as it got 100 bytes.
For when I am setting the block to more bytes than it will receive, the array shows no bytes at all.
Conclusion: This block waits for a certain amount of bytes to be captured and stores them inside of an array. If the array is filled, it waits again for the same amount of bytes and overwrites the previous array then completely.
Question: is there some way to receive messages of different length when I know, that the first two bytes of each message determine the length of the message??
The messages I am going to receive have the following lengths in byte: 4,19,27,65,3 and then constantly 104 (atleast for now)

採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Target Computer Setup についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!