Serial Port in RTWT (s-function)
3 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I'm searching for help. I'm working on a project at college in Germany. The project is to build a communication between an autonomous vehicle and a PC. The PC shall regulate the vehicle using SIMULINK. The radio communications happens via XBee-Modules.
The control is in Real Time Windows-Target.
And now to the problem: The Serial Port block in Simulink is not possible in RTWT. Is that right? So I thought, that I could write a s-function. But I have trouble with this. I'd never written a s-function before.
It would be nice, if anybody could help me. I have some code from German Forum, which I used. I'm using Windows 7x64 and MATLAB R2013a.
I compile the code with mex sfun_comport.c Then I built a model with an constant input, the s-function-block and a display. The problem are the lines with "!!" beginning. The command "ssSetPWorkValue" makes problems.
Is here anybody who can help me? I despair. When there gives a better way to communicate via serial port in rtwt, let me know. I am very grateful for any help and every tip.
Ps. sorry for my English.
Many thanks and many greetings
Martin
1 件のコメント
Kaustubha Govind
2013 年 8 月 6 日
Martin: Please provide more information on what the exact problem is - how do the lines that you highlighted fail?
回答 (4 件)
Kaustubha Govind
2013 年 8 月 7 日
Ah! I think it might be because you are not configuring the number of PWorks on the S-function as described here. Essentially, you need the following line in mdlInitializeSizes:
ssSetNumPWork(1);
Also, is there a reason you are overwriting the PWork value immediately after assigning it, or did you really mean to use two different PWorks?
ssSetPWorkValue(S, 0, &hCom);
ssSetPWorkValue(S, 0, &pcCommPort);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Target Computer Setup についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!