;+
; NAME:
;     fst_call_dsread
; PURPOSE:
;     Wrapper function for calling DS_Read function from DS.DLL
; CATEGORY:
;     OVRO FST DATA ANALYSIS
; CALLING SEQUENCE:
;     error=fst_call_dsread(source=source,bytestr=bytestr,timeout=timeout, path=path)
; INPUTS:
;     source- datasocket URL
;             if not provided it is set to the default 'dstp://localhost/lv2idl'
;     bytestr- an array of bytes to store the number of bytes to be read.
;             if not provided it is set to a default [0b,0b,0b,0b]
;
; OPTIONAL (KEYWORD) INPUT PARAMETERS:
;     timeout- ms to wait for the operation to be completed (default 1000ms)
;     path- the complete path of the DS.DLL external lybrary
;
; ROUTINES CALLED: 'DS.DLL'
; OUTPUTS:
;  return value: error code
;                0 - no error,
;                56-  The network operation exceeded
;                     the user-specified or system time limit.
;                63-  The network connection was refused by the server.
; COMMENTS:
;
; SIDE EFFECTS:
; RESTRICTIONS:
; DS.DLL external lybrary should be in the current directory,
;  or the correct path should be provided.
; The Host machine datasocket server must be started
;  before attempting to connect to it.
; MODIFICATION HISTORY:
;     Written March 31-2005 by Gelu Nita (gnita@njit.edu)
;     June 3-2006 Modified default source='dstp://solar_fst.ovro.caltech.edu/lv2idl'
;                 Modified default timeout=1000
;     April 18-2008 Modified default source='dstp://solar_fst.solar.ovro.caltech.edu/lv2idl'
function fst_call_dsread,source=source,bytestr=bytestr,timeout=timeout,path=path
 if n_elements(source) eq 0 then source='dstp://solar_fst.solar.ovro.caltech.edu/lv2idl'
 if n_elements(timeout) eq 0 then timeout=1000l
 if n_elements(bytestr) eq 0 then bytestr=bytarr(4)
 if n_elements(path) eq 0 then path='DS'
 error=CALL_EXTERNAL(path, 'DS_Read', source,timeout,bytestr,n_elements(bytestr),VALUE=[1,1,0,1],/AUTO_GLUE)
 return,error
end