How to receive serial strings in Simulink
27 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to read a stream of strings from serial input (COM Port) and then display the strings. The issue I am having is that the strings are of variable length and Simulink only seems to be able to read a string if I specify its length in the data size field. What I'd really like is a method to specify the max length and use the CR/LF as the termination mechanism. I tried every combination of the serial read block and cannot get it to work.
The model is similar to this:
In the above example, if I set the Data size to [1 1], then I only get the last character received.
I read thru the documentation multiple times for serial receive and was not able to understand what the Data size really means. Also, Row major and Column major are not defined very well. Two of built in examples are Matlab only. The simulink example is not found (2022a + I have the Instrument Toolbox installed).
Any help would be appreciated...
0 comentarios
Respuestas (1)
Pratyush Swain
el 10 de Sept. de 2023
Editada: Pratyush Swain
el 10 de Sept. de 2023
Hi Rick,
I understand that you want to receive strings of variable length through serial receive block, but block parameters are not dynamic and cannot change as per the input values.
Also here is some information regarding ‘Data Size’ and ‘Input Format’ (Row Major / Col major) parameters.
1- The data size parameter is specified by multidimensional numeric array in the format [a b] which implies an array with dimensions a x b. For example - data size parameter [1 18] implies a character row vector of size 18.
2- The input format is specified by values - ('Row major' or 'Column major'). 'Column major' means the elements in a column are read consecutively while 'Row major' implies elements are in row are read consecutively.
Hope the above information helps.
0 comentarios
Ver también
Categorías
Más información sobre Event Functions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!