필터 지우기
필터 지우기

SIMULINK: send string via Stream Output

조회 수: 5 (최근 30일)
John
John 2014년 8월 13일
댓글: John 2014년 8월 15일
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.

채택된 답변

Jan Houska
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 CenterFile Exchange에서 String에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by