SR Research Support Site
Macros | Functions
Data file utilities

Macros

#define BAD_FILENAME   -2222
 
#define BAD_ARGUMENT   -2223
 
#define receive_data_file   receive_data_file_dialog
 

Functions

INT16 eyelink_request_file_read (const char FARTYPE *src)
 
INT16 eyelink_get_file_block (void FARTYPE *buf, INT32 FARTYPE *offset)
 
INT16 eyelink_request_file_block (UINT32 offset)
 
INT16 eyelink_end_file_transfer (void)
 
INT32 receive_data_file (const char *src, const char *dest, INT16 dest_is_path)
 
INT32 receive_data_file_feedback (const char *src, const char *dest, INT16 dest_is_path, void(*progress)(unsigned int size, unsigned int received))
 
INT32 send_data_file_feedback (char *src, char *dest, INT16 dest_is_path, void(*progress)(unsigned int size, unsigned int received))
 
INT16 open_data_file (char *name)
 
INT16 close_data_file (void)
 
void splice_fname (const char *fname, const char *path, char *ffname)
 
int check_filename_characters (const char *name)
 
int file_exists (const char *path)
 
int create_path (const char *path, INT16 create, INT16 is_dir)
 
INT32 receive_data_file_dialog (char *src, char *dest, INT16 dest_is_path)
 

Detailed Description

Macro Definition Documentation

#define BAD_ARGUMENT   -2223

Invalid argument

#define BAD_FILENAME   -2222

Bad file name

#define receive_data_file   receive_data_file_dialog

This macro is introduced so that the old eyelink projects compiled against new libraries, the file transfer behaves the same as the old receive_data_file in win32 platform See receive_data_file_dialog()

Function Documentation

int check_filename_characters ( const char *  name)

Checks file name for legality. Attempts to ensure cross-platform for viewer. No spaces allowed as this interferes with messages. Assume viewer will translate forward/backward slash. Windows: don't allow <>:"/| Also, device names, such as aux, con, lpt1, and prn are not allowed in windows. forward slashes is missed.

INT16 close_data_file ( void  )

Closes any open EDF file.

Returns
Returns 0 if success, else error code.
int create_path ( const char *  path,
INT16  create,
INT16  is_dir 
)

Checks if path exists. Will create directory if 'create'. Creates directory from last name in 'path', unless ends with '\' or 'is_dir' nonzero. Otherwise, last item is assumed to be filename and is dropped.

Returns
0 if exists, 1 if created, -1 if failed.
INT16 eyelink_end_file_transfer ( void  )

Aborts send of file.

Returns
0 if OK, else send error.
Remarks
Internal function. use receive_data_file()
INT16 eyelink_get_file_block ( void FARTYPE *  buf,
INT32 FARTYPE *  offset 
)

Get next block of file. If <offset> is not NULL, will be filled with block-start offset in file.

Returns
negative if error, NO_REPLY if waiting for packet, else block size (0..512). size is < 512 (can be 0) if at EOF.
Remarks
Internal function. use receive_data_file()
INT16 eyelink_request_file_block ( UINT32  offset)

Ask for next block of file, reads from <offset>.

Remarks
Internal function. use receive_data_file()
INT16 eyelink_request_file_read ( const char FARTYPE *  src)

Request send of file "src". If "", gets last data file.

Returns
0 if OK, else send error.
Remarks
Internal function. use receive_data_file()
int file_exists ( const char *  path)

Checks if file and/or path exists.

Returns
0 if does not exist, 1 if exists, -1 if cannot overwrite.
INT16 open_data_file ( char *  name)

Opens an EDF file, closes any existing file.

Parameters
nameName of data file,which can only use letters(uppercase and lowercase), numbers(0-9),and underscore(appears from 2nd place). The base file name should not exceed 8 characters; the name extension can only be .edf.
Returns
Returns 0 if success, else error code.
INT32 receive_data_file ( const char *  src,
const char *  dest,
INT16  dest_is_path 
)

This receives a data file from the EyeLink tracker PC.

Parameters
[in]srcName of eye tracker file (including extension). If "" (empty string), asks tracker for name of last opened data file.
[in]destName of local file to write to (including extension). This must be a valid file name or directory name.
[in]dest_is_pathIf nonzero, appends file name to <dest> as a directory path.
Returns
0 if file transfer was cancelled.
Size of file if successful.
-1 if file size is negative.
-2 if cannot create local file.
-3 if file transfer was cancelled.
-4 if file transfer was aborted.
-5 if error occurred while writing file.
-6 if link was terminated.
Example: See open_data_file()
See also
close_data_file() and open_data_file()
Remarks
If linked against eyelink_exptkit20.lib or w32_dialogs.h is included, the behaviour of this function is receive_data_file_dialog().
INT32 receive_data_file_dialog ( char *  src,
char *  dest,
INT16  dest_is_path 
)

This receives a data file from the EyeLink tracker PC with graphical progressbar. This function only available in Win32 platform.

Parameters
[in]srcName of eye tracker file (including extension). If "" (empty string), asks tracker for name of last opened data file.
[in]destName of local file to write to (including extension). If "" (empty string), prompts for file name.
[in]dest_is_pathIf nonzero, appends file name to <dest> as a directory path.
Returns
0 if file transfer was cancelled.
Size of file if successful.
FILE_CANT_OPEN if no such file.
FILE_XFER_ABORTED if data error.
\sa \c receive_data_file()
INT32 receive_data_file_feedback ( const char *  src,
const char *  dest,
INT16  dest_is_path,
void(*)(unsigned int size, unsigned int received)  progress 
)

This receives a data file from the EyeLink tracker PC. Exact same as receive_data_file(). except the feedback parameters can be used for showing what is the full size of the edf file and how much is received so far. This function is currently used internally only.

Parameters
[in]srcName of eye tracker file (including extension). If "" (empty string), asks tracker for name of last opened data file.
[in]destName of local file to write to (including extension). This must be a valid file name or directory name.
[in]dest_is_pathIf nonzero, appends file name to <dest> as a directory path.
[in]progressA function pointer, that takes size and received size integers. This allows, one to display progress bar on edf file transfer.
Returns
0 if file transfer was cancelled.
Size of file if successful.
-1 if file size is negative.
-2 if cannot create local file. -3 if file transfer was cancelled -4 if file transfer was aborted -5 if error occurred while writing file -6 if link was terminated
\sa \c receive_data_file, \c close_data_file() and \c open_data_file()
INT32 send_data_file_feedback ( char *  src,
char *  dest,
INT16  dest_is_path,
void(*)(unsigned int size, unsigned int received)  progress 
)

This function sends a file to the Eyelink tracker. Source destination file name should be given. Using this function, an image or video can be uploaded from the display PC to the host Tracker PC. The image can later be used as a Gaze Cursor Backdrop via a call to eyelink_send_command().

Parameters
srcName of local file (including extension).
destName of eye tracker file to write to (including extension).
dest_is_pathIf nonzero, appends file name to <dest> as a directory path.
progressA function pointer, that takes size and received size integers. This allows, one to display progress bar on file transfer.
Returns
Returns size of file if transferred file size is equal to the real file size.
-1 if fail to connect tracker ftpd.
-2 if fail to open file.
-4 if fail to receive reply from tracker ftpd.
-5 if transferred file size is unequal to the real file size.
void splice_fname ( const char *  fname,
const char *  path,
char *  ffname 
)

Splice 'path' to 'fname', store in 'ffname'. Tries to create valid concatenation. If 'fname' starts with '\', just adds drive from 'path'. If 'fname' contains drive specifier, it is not changed.


Copyright ©2002-2021, SR Research Ltd.