function [status, results] = warplab_networkCheck(numNodes) warplab_defines; status = 0; TIMEOUT = 3; %%%% results is a cell array of two elements %%%% {1} a struct containing system-level diagnoses %%%% {2} an array of structs containing node-level diagnoses %%%% Note: cell {2} is only populated if system-level checks pass results{1} = struct('nicSetup',[],'pnet',[]); %%%% Check that a WARP subnet exists fprintf('checking set up of computer network interfaces...\n') if(ispc) [status, temp] = system('ipconfig /all'); temp = strfind(temp,strcat(WARP_subnet,ComputerAddr)); if(isempty(temp)) myMsg = sprintf('no interface found for IP %s',strcat(WARP_subnet,ComputerAddr)); fprintf('----Error! %s\n',myMsg) status = -1; results{1}.nicSetup = -1; return; else results{1}.nicSetup = 0; fprintf('\b ok\n'); end elseif(ismac||isunix) [status, temp] = system('ifconfig -a'); temp = strfind(temp,strcat(WARP_subnet,ComputerAddr)); if(isempty(temp)) myMsg = sprintf('no interface found for IP %s',strcat(WARP_subnet,ComputerAddr)); fprintf('----Error! %s\n',myMsg) status = -1; results{1}.nicSetup = -1; return; else results{1}.nicSetup = 0; fprintf('\b ok\n'); end end %%%% %%%% Checking Status of pnet Installation fprintf('checking installation of pnet...\n') temp = which('pnet'); if(isempty(temp)) myMsg = 'pnet not found in path'; fprintf('----Error! %s\n',myMsg) status = -1; results{1}.pnet = -1; return; elseif(strcmp(temp((end-length(mexext)+1):end),mexext)==0) myMsg = 'pnet found, but it is not a compiled mex file'; fprintf('----Error! %s\n',myMsg) status = -1; results{1}.pnet = -1; return; else results{1}.pnet = 0; fprintf('\b ok\n'); end %%%% pnet('closeall'); %[socketHandles, packetNum] = warplab_initialize(numNodes); nodes = 1:numNodes; IPAddrs = warplab_IP2int(strcat(WARP_subnet,'.0')) + nodes; UDP_Ports = NodeStartingPort + nodes-1; packetNum = 1; syncSock = pnet('udpsocket', SyncPort); pnet(syncSock, 'setreadtimeout', 1); pnet(syncSock, 'udpconnect', strcat(WARP_subnet,SyncAddr), SyncPort); packetNum = 1; for currNode = 1:numNodes nodeStruct(currNode) = struct('serialNumber',[],'fpgaDNA',[],'numRadios',[],'hwGeneration',[],'warplabVersion',[],'respondsToCommands',[],'receivesSync',[]); %UDP Connections to individual nodes thisSock = pnet('udpsocket', UDP_Ports(currNode)); pnet(thisSock, 'udpconnect', warplab_int2IP(IPAddrs(currNode)), UDP_Ports(currNode)); pnet(thisSock, 'setreadtimeout', 1); disp(sprintf('checking configuration of Node %d...',currNode)) %%%% Check to make sure sync packets are being received temp = warplab_sendCmd(thisSock, NETWORKCHECK, packetNum); warplab_sendSync(syncSock); if(length(temp)==1) if(temp==0) myMsg = 'node not responding to commands'; fprintf('----Error! %s\n',myMsg) status = -1; nodeStruct(currNode).respondsToCommands = -1; continue; end else nodeStruct(currNode).respondsToCommands = 0; end pause(TIMEOUT) temp = warplab_sendCmd(thisSock, NETWORKCHECK, packetNum); warplab_sendSync(syncSock); pause(TIMEOUT) if(temp(4)~=1) myMsg = 'sync packet not received'; fprintf('----Error! %s\n',myMsg) status = -1; nodeStruct(currNode).receivesSync = -1; else fprintf('\b ok\n'); nodeStruct(currNode).receivesSync = 0; end %%%% %%%% Read board information and verify that the latest version of WARPLab %%%% isbeing used temp = warplab_sendCmd(thisSock, BOARDINFO, packetNum); nodeStruct(currNode).serialNumber = temp(4); nodeStruct(currNode).fpgaDNA = bitshift(temp(5),32)+temp(6); nodeStruct(currNode).hwGeneration = bitand(bitshift(temp(7),-24),255); nodeStruct(currNode).numRadios = bitand(bitshift(temp(7),-16),255); nodeStruct(currNode).warplabVersion = double(bitand(bitshift(temp(7),-8),255))+double(bitand(temp(7),255))/10; %%%% end results{2} = nodeStruct; fprintf('\n\nResults Summary:\n'); fprintf('Node | S/N |HWGEN|WLVER|RADIO| ACK | SYNC\n'); for currNode = 1:numNodes fprintf('-----------------------------------------\n'); if(nodeStruct(currNode).respondsToCommands==0) ackStat = ' OK'; else ackStat = ' FAIL'; end if(nodeStruct(currNode).receivesSync==0) syncStat = ' OK'; else syncStat = ' FAIL'; end if(nodeStruct(currNode).respondsToCommands==0) fprintf('%5d|%5d|%5d|%5.1f|%5d|%s|%s\n',currNode,nodeStruct(currNode).serialNumber,nodeStruct(currNode).hwGeneration,nodeStruct(currNode).warplabVersion,nodeStruct(currNode).numRadios,ackStat,syncStat); else fprintf('%5d| | | | |%s|%s\n',currNode,ackStat,syncStat); end end pnet('closeall');