Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Can't get model in xPC Target to communicate with a computer running MATLAB via UDP

1 回表示 (過去 30 日間)
Hannes
Hannes 2013 年 3 月 29 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
In short, I can get two computers running MATLAB to talk to each other via UDP, and I've used UDP blocks in xPC Target to communicate with a C program on a separate program, but I can't send data back and forth between a target and a computer running a MATLAB script.
To debug this, I'm running a very simple model in xPC Target ( http://tinypic.com/r/11tpogo/6 ) that should just receive UDP numeric inputs, display them, and send some different ones back. On a separate computer (not the host, though I tried that too), I've opened a UDP port in MATLAB and am trying to send/receive data to/from the target.
Using http://www.mathworks.com/support/solutions/en/data/1-OUCYT/ as a reference, I successfully sent/received messages between two computers running MATLAB. I then tried to extend that to communicate with the model running on the target:
%%Define computer-specific variables
ipA = '192.168.3.1'; portA = 49154; %Computer running MATLAB
ipB = '192.168.3.250'; portB = 26401; %Target
%%Create UDP Object
udpA = udp(ipB,portB,'LocalPort',portA);
%%Connect to UDP Object
fopen(udpA)
%%Send Data
fprintf(udpA, 3);
%%Receive Data
fscan(udpA)
(And when I'm done with it, I close the connection:)
%%Exit and clear
fclose(udpA)
delete(udpA);
clear all
fscanf(udPA) just returns an empty character ('') and it's clear from the Target data logs (tg.OutputLog) that nothing is successfully received by the target. Any help/insight would be much appreciated.

回答 (0 件)

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by