Info

此问题已关闭。 请重新打开它进行编辑或回答。

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

1 次查看(过去 30 天)
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