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!