From 8754ab61d345038e9985fabe49d0ce81b22c059e Mon Sep 17 00:00:00 2001 From: Wouter Horlings Date: Sun, 17 Dec 2017 11:53:29 +0100 Subject: [PATCH] discovery heeft magic gekregen --- Equipment/prologix_discovery.m | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/Equipment/prologix_discovery.m b/Equipment/prologix_discovery.m index 10425c5..7136295 100644 --- a/Equipment/prologix_discovery.m +++ b/Equipment/prologix_discovery.m @@ -1,4 +1,4 @@ -function ipaddress = prologix_discovery(localhost) +function ipaddress = prologix_discovery() %% PROLOGIX_DISCOVERY Find your prologix GPIB device. % ipaddress = PROLOGIX_DISCOVERY() finds prologix on your % local network. When your prologix device is detected @@ -10,11 +10,11 @@ function ipaddress = prologix_discovery(localhost) %% setup correct variables. % if location of prologix is known: just return stored ip address -if nargin < 1 - localhostcellarray = getLocalIP(); -else - localhostcellarray{1} = localhost; -end +% if nargin < 1 +% localhostcellarray = getLocalIP(); +% else +% localhostcellarray{1} = localhost; +% end persistent stored_ipaddress; if ~isempty(stored_ipaddress) ipaddress = stored_ipaddress; @@ -23,9 +23,15 @@ end local_port = randi([49152 65535]); remote_port = 3040; +%%Magic +udpmagic = udp('10.255.255.255',12345); +fopen(udpmagic); +fwrite(udpmagic,'windows moet dood'); +fclose(udpmagic); +delete udpmagic + %% setup dsp to send and recieve udp packets. -for ipIndex = 1:length(localhostcellarray) - udpconnection = udp('10.255.255.255',3040); + udpconnection = udp('255.255.255.255',3040); %hudpr = dsp.UDPReceiver('LocalIPPort',local_port); % hudps = dsp.UDPSender('RemoteIPAddress','255.255.255.255','RemoteIPPort',remote_port,'LocalIPPortSource','Property','LocalIPPort',local_port); % start recieving udp packets @@ -53,10 +59,7 @@ for ipIndex = 1:length(localhostcellarray) end end fclose(udpconnection); - if ~isempty(msg) - break; - end -end + if isempty(msg) error('No prologix found on network'); end