lgUAHee
Electrical
- Aug 17, 2005
- 1
Have an issue connecting an Ultra-wideband radio which broadcasts position tables to 3 other similar radios, using UDP. Aside from this, basically all I am trying to do is create a socket on my local host (PC) with a port of 19842, bind to it, then connect this socket to the radio's ip address and port (19843). The radio creates a UDP socket and binds it to this port (19843). The PC's UDP socket is used to send/receive UDP commands to the radio's port ID 19843. I have functional code using the free pnet function, but I am looking to replace this with the Instrument Control Toolbox. My code in pnet:
% Create and bind to the socket
% If the socket is already created then close it first
if exist('sock')
pnet(sock,'close');
end
%creates the socket and binds it to port 19842
sock = pnet('udpsocket', 19842);
%connects radio_ip_addr and port 19843 to the above socket
pnet(sock,'udpconnect',radio_ip_addr,19843);
There is other code as well (this is actually in a gui). We have a function behind a gui button for connection (where we specify the radio_ip_addr value and send a connect command via socket). This code works with pnet, but not very efficiently. This is why we are looking for an alternative. Using the ICT I was thinking something like this:
if exist('sock')
pnet(sock,'close');
end
sock = udp('radio_ip_addr', 'RemotePort', 19843, LocalPort',19842);
fopen(sock);
simple as that (or so I thought). Matlab kicks me an error message stating that the network address is already in use. Please help me if you can. Thanks
Also, for a little info on the pnet commands used, see --
Also, to see a full version of the GUI code, see the pdf attachment
% Create and bind to the socket
% If the socket is already created then close it first
if exist('sock')
pnet(sock,'close');
end
%creates the socket and binds it to port 19842
sock = pnet('udpsocket', 19842);
%connects radio_ip_addr and port 19843 to the above socket
pnet(sock,'udpconnect',radio_ip_addr,19843);
There is other code as well (this is actually in a gui). We have a function behind a gui button for connection (where we specify the radio_ip_addr value and send a connect command via socket). This code works with pnet, but not very efficiently. This is why we are looking for an alternative. Using the ICT I was thinking something like this:
if exist('sock')
pnet(sock,'close');
end
sock = udp('radio_ip_addr', 'RemotePort', 19843, LocalPort',19842);
fopen(sock);
simple as that (or so I thought). Matlab kicks me an error message stating that the network address is already in use. Please help me if you can. Thanks
Also, for a little info on the pnet commands used, see --
Also, to see a full version of the GUI code, see the pdf attachment