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
답변 (0개)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!