Simulink - TCP/IP Receive with variable Data Size
21 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
In Simulink (2016a) I'm using TCP/IP Receive block (from Instrument Control Toolbox) to receive some a ASCII string from remote server, every 0.5 seconds. The bytes are passing through fine and Server-Simulink Client are chatting with no problem.
However, every time remote server sends string, it's of different length and with that the received stream doesn't have fixed byte length. For example, this is what server sends at different timestamps:
0.5 seconds: "value=1.345" (size = 11 bytes)
1.0 seconds: "value=10.345" (size = 12 bytes)
1.5 seconds: "value=-105.345" (size = 14 bytes)
.
.
.
The problem is that in TCP/IP Receive block you have to specify Data Size as constant and so if I specify it to be let's say 1 byte I won't get all bytes of string on block's Data port but rather byte-per-byte, which is not good since I need to parse entire string, and if I specify the Data size to some big number let's say 50 (my strings are never longer than 20 bytes) the TCP/IP receive block waits for the buffer to fill with 50 bytes, before it releases the bytes to Data port and that's also not good since than my string sentences can get cut off in the middle.
The similar implementation works OK in MATLAB, where I use:
tcpip(ip, port, 'InputBufferSize', 50)
and that's it, whether the buffer gets filled with 50 bytes or less I can read the entire string.
Is there a way to achieve similar behavior in Simulink's TCP/IP Receive?
2 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Development Computer Setup finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!