write_memory.cpp
Go to the documentation of this file.
00001 #include "prosilica/prosilica.h"
00002 #include <cstdio>
00003 #include <cassert>
00004 
00005 int main(int argc, char** argv)
00006 {
00007   if (argc < 3) {
00008     printf("Usage: %s <IP address> <file>\n", argv[0]);
00009     return 0;
00010   }
00011 
00012   char buffer[prosilica::Camera::USER_MEMORY_SIZE];
00013   FILE* file = fopen(argv[2], "rb");
00014   assert(file);
00015   fseek(file, 0, SEEK_END);
00016   size_t size = ftell(file);
00017   if (size > prosilica::Camera::USER_MEMORY_SIZE) {
00018     printf("File is too big!\n");
00019     return -1;
00020   }
00021   fseek(file, 0, SEEK_SET);
00022   size_t items_read = fread(buffer, 1, size, file);
00023   fclose(file);
00024 
00025   if (items_read != size)
00026   {
00027     printf("An error occurred reading the file\n");
00028     return -1;
00029   }
00030   
00031   prosilica::init();
00032 
00033   // Make sure cam's destructor is called before fini
00034   {
00035     prosilica::Camera cam(argv[1]);
00036     cam.writeUserMemory(buffer, size);
00037   }
00038 
00039   prosilica::fini();
00040   
00041   return 0;
00042 }


prosilica_camera
Author(s): Maintained by William Woodall - wwoodall@willowgarage.com
autogenerated on Mon Oct 6 2014 03:56:56