Serial Port in RTWT (s-function)
2 次查看(过去 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!