// sample_for_working_with_FFS.cpp program operations: // // - gets and displays the information about FFS status (XI_PRM_FREE_FFS_SIZE, XI_PRM_USED_FFS_SIZE) // - write short text from variable test_text to FFS as file with name test.txt // - read short text from FFS from file test.txt to variable read_text // - gets and displays the information about FFS status (XI_PRM_FREE_FFS_SIZE, XI_PRM_USED_FFS_SIZE) #include "stdafx.h" #ifdef __APPLE__ #include #include #else #include "xiApi.h" #include "xiExt.h" #endif #define HandleResult(res,place) if (res!=XI_OK) {printf("Error after %s (%d)\n",place,res);goto finish;} int _tmain(int argc, _TCHAR* argv[]) { // image buffer XI_IMG image; image.size = sizeof(XI_IMG); image.bp = NULL; image.bp_size = 0; // Sample for XIMEA API V2.10 HANDLE xiH = NULL; XI_RETURN stat = XI_OK; // Get number of camera devices DWORD dwNumberOfDevices = 0; stat = xiGetNumberDevices(&dwNumberOfDevices); HandleResult(stat,"xiGetNumberDevices (no camera found)"); if (!dwNumberOfDevices) { printf("No camera found\n"); goto finish; } // Retrieving a handle to the camera device stat = xiOpenDevice(0, &xiH); HandleResult(stat,"xiOpenDevice"); //--------------------------------------------------------------- // get FFS info int num_free = 0; int num_used = 0; // get FFS info stat = xiGetParamInt(xiH, XI_PRM_FREE_FFS_SIZE, &num_free); HandleResult(stat,"xiGetParamInt (XI_PRM_FREE_FFS_SIZE)"); stat = xiGetParamInt(xiH, XI_PRM_USED_FFS_SIZE, &num_used); HandleResult(stat,"xiGetParamInt (XI_PRM_USED_FFS_SIZE)\n\n"); printf("FFS stats:\n"); printf("Free bytes : %d \n", num_free); printf("Used bytes : %d \n", num_used); //--------------------------------------------------------------- // write file to FFS char test_file[MAX_PATH]="test.txt"; char test_text[MAX_PATH]="XIMEA was created by the group of industry leading Imaging and Vision veterans originating from DELARO and SOFTHARD companies."; stat = xiSetParamString(xiH, XI_PRM_FFS_FILE_NAME, test_file, MAX_PATH); HandleResult(stat,"xiSetParamString (XI_PRM_FFS_FILE_NAME)"); stat = xiSetParamString(xiH, XI_PRM_WRITE_FILE_FFS, test_text, MAX_PATH); HandleResult(stat,"xiSetParamString (XI_PRM_WRITE_FILE_FFS)"); //--------------------------------------------------------------- // read data from FFS char read_text[MAX_PATH]=""; stat = xiGetParamString(xiH, XI_PRM_READ_FILE_FFS, read_text, MAX_PATH); HandleResult(stat,"xiSetParamString (XI_PRM_READ_FILE_FFS)"); printf("Text read from FFS:\n%s\n\n", read_text); //--------------------------------------------------------------- // get FFS info stat = xiGetParamInt(xiH, XI_PRM_FREE_FFS_SIZE, &num_free); HandleResult(stat,"xiGetParamInt (XI_PRM_FREE_FFS_SIZE)"); stat = xiGetParamInt(xiH, XI_PRM_USED_FFS_SIZE, &num_used); HandleResult(stat,"xiGetParamInt (XI_PRM_USED_FFS_SIZE)\n\n"); printf("FFS stats:\n"); printf("Free bytes : %d \n", num_free); printf("Used bytes : %d \n", num_used); finish: // Close device if (xiH) xiCloseDevice(xiH); printf("Done\n"); getchar(); return 0; }