Просмотр исходного кода

meer commentaar en begonnen met autodetect.

master^2
Wouter Horlings 7 лет назад
Родитель
Сommit
c75b263307
3 измененных файлов: 54 добавлений и 3 удалений
  1. +1
    -0
      Equipment/prologix_discovery.m
  2. +17
    -0
      OOequipment/debug/discovery.m
  3. +36
    -3
      OOequipment/subfiles/EquipmentClass.m

+ 1
- 0
Equipment/prologix_discovery.m Просмотреть файл

@@ -25,6 +25,7 @@ remote_port = 3040;

%% setup dsp to send and recieve udp packets.
udpconnection = udp('255.255.255.255',3040);
udpconnection.LocalHost = '130.89.143.33';
%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


+ 17
- 0
OOequipment/debug/discovery.m Просмотреть файл

@@ -0,0 +1,17 @@

ipPrefix='10.0.0';
ipPrefixRegex = '10\.0\.0';
if ispc()
system(['for /L %a in (1,1,254) do @start /b ping ' ipPrefix '.%a -w 100 -n 2 >nul']);
[~,arptable] = system('arp -a');
ipaddresses = regexp(arptable,[ipPrefixRegex '\.(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])(?=[-a-f0-9\s]*dynamic)'],'match');
elseif isunix()
[~,ipaddresses] = system(['echo $(seq 254) | xargs -P255 -I% -d" " ping -W 1 -c 1 ' ipPrefix '.% | grep -P -o "[0-1].*?(?=:)"']);
elseif ismac()
else
end


%% find prologix

+ 36
- 3
OOequipment/subfiles/EquipmentClass.m Просмотреть файл

@@ -368,9 +368,42 @@ classdef EquipmentClass < handle
structname = matlab.lang.makeValidName(['ip',cleanip,'_',num2str(port)]);
end
function equipmentstruct = discover()
function ipaddress = getInterfaceIP()
if ispc
% Code to run on Windows plaform
[status,result]=system('ipconfig');
if ~(status == 0)
error('Failed to find local IP address');
end
ipaddress = regexp(result,'(?<=\n IPv4 Address[ \.]*: )([0-9]{1,3}\.?){4}','match');
elseif ismac
% Code to run on Mac platform
[status,result]=system('ifconfig');
if ~(status == 0)
error('Failed to find local IP address');
end
ipaddress = regexp(result,'(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])(?=\/)','match');
elseif isunix
% Code to run on Unix platform
[status,result]=system('ip addr show');
if ~(status == 0)
error('Failed to find local IP address');
end
ipaddress = regexp(result,'(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])(?=\/)','match');
else
error('Platform not supported');
end
end
function prologixIP = discoverPrologix()
persistent stored_ipaddress;
if ~isempty(stored_ipaddress)
prologixIP = stored_ipaddress;
return
end
ipaddress = getInterfaceIP()
udpconnection = udp('255.255.255.255',3040);
udpconnection.LocalHost = localhost;
end
end
end

Загрузка…
Отмена
Сохранить