Serial Port in RTWT (s-function)
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Kaustubha Govind
le 6 Août 2013
Martin: Please provide more information on what the exact problem is - how do the lines that you highlighted fail?
Réponses (4)
Kaustubha Govind
le 7 Août 2013
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 commentaires
Voir également
Catégories
En savoir plus sur Target Computer Setup dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!