% get_data          - Save IOC buffer to file, copy over and read in
%
% Copyright (c) 2006 Dimtel, Inc., All Rights Reserved
%
% $Id: get_data.m,v 1.1.1.1 2010/10/05 16:43:01 dim Exp $
% $Date: 2010/10/05 16:43:01 $
% $Author: dim $
% $Revision: 1.1.1.1 $
% $Log: get_data.m,v $
% Revision 1.1.1.1  2010/10/05 16:43:01  dim
% Initial import of iGp12
%
% Revision 1.2  2008/04/29 19:54:53  dim
% Transitioned from wget to urlwrite(), DCCT support, added FE/BE channels
% to saved parameters list.
%
% Revision 1.1  2007/10/28 08:23:15  dim
% Tools to include in the distribution
%
% Revision 1.1  2007/03/14 08:35:58  dim
% Matlab tools for data acquisition and testing with file-based data exchange
%
%

function x = get_data(pvroot)

fpga_rev = lcaGet([pvroot, 'REVISION']);

% Save the data
lcaPut([pvroot, 'DATARD'], 1);
lcaPut([pvroot, 'DATARD'], 0);
ip = lcaGet([pvroot, 'IP_ADDR']);

urlwrite(['http://', ip{1}, '/acq.dat'], 'acq.dat');
fid = fopen('acq.dat');
if (fpga_rev < 3)
  [x, count] = fread(fid, inf, 'int8');
else
  [x, count] = fread(fid, inf, 'int16');
end
fclose(fid);
x = x';
system('rm acq.dat');
