Send String with SCI transmit
6 ビュー (過去 30 日間)
古いコメントを表示
Anyone here know how to send a string with the SCI Transmit block.
I tried creating an embedded matlab function that simply returns
y = uint8('fu');
but the SCI transmit block spits out an error message saying it only accepts scalars. Is there any way to send a vector? Only other option i have is to create a function that runs a for loop and transmits each character at a time but i don't want to do this if a tool for this already exist. The matlab embedded tools cost so much I can't believe they don't have a simple serial send command that can accept an array of numbers or characters.
0 件のコメント
採用された回答
Walter Roberson
2011 年 2 月 22 日
When you are in enough of a hurry that you can't afford to follow a lead from someone who is trying to help, then it is time to call Mathworks technical support. The people who answer questions here are volunteers, and most of them are not Mathworks staff. When you see someone's name here in a link, look right after the link: Mathworks staff have the little Mathworks icon -- but even those staff are volunteers.
------
In your hurry, you omitted to say what your device is. I researched all of the devices that are documented as supporting SCI. The links to their SCI Transmit blocks are:
All of the blocks explicitly state they support vectors of data, including vectors of uint8. There is, however, an important clue in the mpc555 description:
The Serial Transmit block transmits bytes via either of the MPC555 QSMCM submodules SCI1 or SCI2. You can use it either to transmit a fixed number of bytes, or, by enabling the second input, transmit a variable number of bytes each time this block is called. With SCI1, a hardware buffer is used that allows up to 16 bytes to be queued for transmission. With SCI2, the buffer allows only up to one byte to be queued each time the block is called. Once bytes are queued for transmit, they will be sent as fast as possible by the serial interface hardware with no further intervention required by the rest of the application.
Thus, if you happen to be using mpc555 and you are using it with two input ports, one of which is the number of bytes to transmit, then in that mode only one byte is accepted per trigger of the block, and so that one mode would complain if you tried to pass in a vector.
Corresponding two-input uses are not documented for the c28* series. I do not have the toolbox so I cannot experiment to see if the same construction applies.
There is also a relevant technical support note that is suggestive in the situation: 1-92LEMV . It presumes that vectors can be sent, but notes that in some circumstances you have to do klutzy things to build the vectors.
2 件のコメント
Walter Roberson
2011 年 2 月 22 日
Your problem description says that you are having difficulty getting the SCI Transmit blocks to accept vectors. Is that no longer the case -- did you solve that issue?
atoi within simulink is a different topic, and would likely be better off as a new Question. (No need to mention SCI in that question, just list your target chip and indicate that it does not support the ascii encode block.)
その他の回答 (4 件)
Walter Roberson
2011 年 2 月 21 日
2 件のコメント
Walter Roberson
2011 年 2 月 22 日
Guess you aren't interested in the solutions I researched, then, since I don't KNOW from personal experience that they will work.
Daniel
2011 年 2 月 22 日
1 件のコメント
Joris Lambrecht
2013 年 7 月 8 日
編集済み: Joris Lambrecht
2013 年 7 月 8 日
In many cases you can use the ASCII Encode block with C2000 devices (with minor modification). Locate the file "asciiencode.c" in "<MATLABROOT>\toolbox\rtw\targets\xpc\target\build\xpcblocks" and comment out the line as follows: //#include <windows.h>
参考
カテゴリ
Help Center および File Exchange で String についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!