function dxsample if exist('dxlib2.h') ~= 2; disp('header undefined'); return; end if ~libisloaded('dxlib2') loadlibrary('dxlib2.dll','dxlib2.h');end pcom = '\\.\COM3'; br = 1000000; tout = 100; devid = calllib('dxlib2','DX_OpenPort',pcom,br); if devid==0; disp('Open failed!'); unloadlibrary('dxlib2'); return; end Err = libpointer('uint16Ptr', 0); for i = 0:252 Ret = calllib('dxlib2', 'DX_Ping', devid, i+1, tout, Err); if Ret; fprintf('Found ID=%d\n', i+1); else fprintf('Not found ID=%d [$%04x]\n', i+1, Err.Value); end end calllib('dxlib2','DX_ClosePort',devid); unloadlibrary('dxlib2'); disp('Normal end');