gusucode.com > vnt工具箱matlab源码程序 > vnt/vntblks/vntmasks/private/privatevntslparsehwinfo.m
function [allDevices objConstructors] = privatevntslparsehwinfo() %PRIVATEVNTSLPARSEHWINFO Parse the serial port hardware information. % % [ALLDEVICES OBJCONSTRUCTORS] = PRIVATEVNTSLPARSEHWINFO parses the % CAN hardware information into a cell array of device names, % returned as ALLDEVICES and OBJCONSTRUCTORS. % SS 04-01-08 % Copyright 2008-2015 The MathWorks, Inc. narginchk(0,0); % Query the system for the hardware. hwInfo = canHWInfo; allDevices = cell(0,1); objConstructors = cell(0,1); % If no hardware installed, just return. if isempty(hwInfo.VendorInfo) allDevices = {'(none)'}; objConstructors = {'(none)'}; return; else % Vendor info is not empty, although channels may not be present. isChannelListEmpty = true; for vendorLoop = 1:length(hwInfo.VendorInfo) if ~isempty(hwInfo.VendorInfo(vendorLoop).ChannelInfo) isChannelListEmpty = false; break; end end % Return if channel list is empty. if isChannelListEmpty allDevices = {'(none)'}; objConstructors = {'(none)'}; return; end end for vendorLoop = 1:length(hwInfo.VendorInfo) if strcmpi(hwInfo.VendorInfo(vendorLoop).VendorDriverDescription, 'NI-XNET') vendorName = 'NI-XNET'; else vendorName = hwInfo.VendorInfo(vendorLoop).VendorName; end for index = 1:length(hwInfo.VendorInfo(vendorLoop).ChannelInfo) if strcmpi(vendorName, 'NI') || strcmpi(vendorName, 'NI-XNET') || strcmpi(vendorName, 'PEAK-System') deviceName = hwInfo.VendorInfo(vendorLoop).ChannelInfo(index).DeviceType; channelName = hwInfo.VendorInfo(vendorLoop).ChannelInfo(index).Device; else deviceName = hwInfo.VendorInfo(vendorLoop).ChannelInfo(index).Device; channelName = sprintf('Channel %d', ... hwInfo.VendorInfo(vendorLoop).ChannelInfo(index).DeviceChannelIndex); end allDevices{end+1} = sprintf('%s %s (%s)', vendorName, deviceName, channelName); %#ok<AGROW> objConstructors{end+1} = hwInfo.VendorInfo(vendorLoop).ChannelInfo(index).ObjectConstructor; %#ok<AGROW> end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%