UDP writing/reading data?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I am currently working on such a system:
- Windows PC with MATLAB/Simulink;
- Real-Time Linux system, where the compiled model of Simulink is uploaded and running every time;
- 5DOF robotic arm.
Between Windows PC and RTL there is an Ethernet cable, which allows communication through UDP protocol.
I am able to read the data from the robot on the Windows PC, using the following settings:
rhost = '10.1.64.97'; %this is RTL IP address
rport = 26000; %this port is on RTL
localPort = 1597; %this port is on WIN
echoudp('on', rport);
u = udp(rhost, rport, 'LocalPort', 'localPort');
fopen(u)
A = fread(u, 19, 'double'); % this is because I have 152 bytes I have to read, so 19 * 8 = 152
But now I would like to write the data, from the Windows PC to the robot (or to the RTL system first), and I don't know which ports to use as remote or local, nor which IP address I should use as rhost. Since I will use the function fwrite, I am guessing it could be something like this:
rhost = '10.1.64.97'; %this is RTL IP address
rport = 4012; %this port is on RTL
localPort = 2103; %this port is on WIN
echoudp('on', rport);
u = udp(rhost, rport, 'LocalPort', 'localPort');
fopen(u)
Data = zeros(25,1); % I need to send 200 bytes; 25 * 8 = 200
fwrite(u, Data, 'double');
However, this doesn't work, because if I close the u object and try to read out the data, it won't match (I added some constants to check if they eventually become zero, as I would expect them to).
Do you have any suggestions, or perhaps maybe just a good explanation WHAT is the remote host/port and what is the local host/port in my case??
Thank you!!
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu State-Space Control Design and Estimation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!