SIMULINK: send string via Stream Output
5 次查看(过去 30 天)
显示 更早的评论
How are strings sent to serial devices in Simulink? If I have a string that's of length N, all ASCII characters, how can I specify that as a single input to a Stream Output block?
Right now I can't imagine that I'd have to explicitly list out all (say) 100 characters in the "Format String" line inside that block.
NOTE: This is in the case of Real-Time Windows Target, but i think should be the same for any Stream Output block from other libraries.
0 个评论
采纳的回答
Jan Houska
2014-8-15
Simulink does not have a signal of type "string". To work with strings, you must use their numeric (ASCII) encodings.
The Stream Output block is designed for sending numeric values formatted as ASCII, perhaps surrounded by additional characters. If you need to send, say "x=3.14" in one time step and "x=3.18" in the next time step, you would use this block.
With fixed-size messages that don't contain the input signal numeric value encoded as ASCII string, you may get better results using the Packet Output block. Please encode your messages into ASCII and then feed such encoded messages as numeric inputs into this block. To select different messages based on some input signal, it would be probably necessary to use some sort of look-up table that would translate the input signal into the encoded message.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 String 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!