ChangeFps.cc
Go to the documentation of this file.
00001 
00036 #ifdef WIN32
00037 #ifndef WIN32_LEAN_AND_MEAN
00038 #define WIN32_LEAN_AND_MEAN 1
00039 #endif
00040 
00041 #include <windows.h>
00042 #include <winsock2.h>
00043 #else
00044 #include <unistd.h>
00045 #include <netdb.h>
00046 #include <sys/socket.h>
00047 #include <netinet/in.h>
00048 #include <arpa/inet.h>
00049 #endif
00050 
00051 #include <stdio.h>
00052 #include <stdlib.h>
00053 #include <string>
00054 #include <fstream>
00055 #include <iostream>
00056 #include <iomanip>
00057 
00058 #include <errno.h>
00059 #include <string.h>
00060 
00061 #include <LibMultiSense/details/utility/Portability.hh>
00062 #include <LibMultiSense/MultiSenseChannel.hh>
00063 
00064 #include <LibMultiSense/details/utility/BufferStream.hh>
00065 #include <LibMultiSense/details/wire/Protocol.h>
00066 #include <LibMultiSense/details/wire/SysNetworkMessage.h>
00067 
00068 #include <Utilities/portability/getopt/getopt.h>
00069 
00070 namespace {  // anonymous
00071 
00072 void usage(const char *programNameP) 
00073 {
00074     fprintf(stderr, "USAGE: %s [<options>]\n", programNameP);
00075     fprintf(stderr, "Where <options> are:\n");
00076     fprintf(stderr, "\t-a <current_address>    : CURRENT IPV4 address (default=10.66.171.21)\n");
00077     fprintf(stderr, "\t-f fps\n");
00078 
00079     
00080     exit(-1);
00081 }
00082 
00083 }; // anonymous
00084 
00085 using namespace crl::multisense;
00086 
00087 int main(int    argc, 
00088          char **argvPP)
00089 {
00090     std::string currentAddress = "10.66.171.21";
00091 
00092     //
00093     // Parse args
00094 
00095     int c;
00096     float fps = 10;
00097 
00098     while(-1 != (c = getopt(argc, argvPP, "a:f:")))
00099         switch(c) {
00100         case 'a': currentAddress = std::string(optarg);    break;
00101         case 'f': fps            = atof(optarg);           break;
00102         default: usage(*argvPP);                           break;
00103         }
00104 
00105     //
00106     // Initialize communications.
00107 
00108     Channel *channelP = Channel::Create(currentAddress);
00109     if (NULL == channelP) {
00110                 std::cerr << "Failed to establish communications with \"" << currentAddress << "\"" << std::endl;
00111         return -1;
00112     }
00113 
00114     //
00115     // Query version
00116 
00117     Status status;
00118     system::VersionInfo v;
00119 
00120     status = channelP->getVersionInfo(v);
00121     if (Status_Ok != status) {
00122                 std::cerr << "Failed to query sensor version: " << Channel::statusString(status) << std::endl;
00123         goto clean_out;
00124     }
00125 
00126         std::cout << "API build date      :  " << v.apiBuildDate << "\n";
00127         std::cout << "API version         :  0x" << std::hex << std::setw(4) << std::setfill('0') << v.apiVersion << "\n";
00128         std::cout << "Firmware build date :  " << v.sensorFirmwareBuildDate << "\n";
00129         std::cout << "Firmware version    :  0x" << std::hex << std::setw(4) << std::setfill('0') << v.sensorFirmwareVersion << "\n";
00130         std::cout << "Hardware version    :  0x" << std::hex << v.sensorHardwareVersion << "\n";
00131         std::cout << "Hardware magic      :  0x" << std::hex << v.sensorHardwareMagic << "\n";
00132         std::cout << "FPGA DNA            :  0x" << std::hex << v.sensorFpgaDna << "\n";
00133         std::cout << std::dec;
00134 
00135     //
00136     // Change framerate
00137 
00138     {
00139         image::Config cfg;
00140 
00141         status = channelP->getImageConfig(cfg);
00142         if (Status_Ok != status) {
00143                         std::cerr << "Failed to get image config: " << Channel::statusString(status) << std::endl;
00144             goto clean_out;
00145         } else {
00146 
00147             cfg.setFps(fps);
00148         
00149             status = channelP->setImageConfig(cfg);
00150             if (Status_Ok != status) {
00151                                 std::cerr << "Failed to configure sensor: " << Channel::statusString(status) << std::endl;
00152                 goto clean_out;
00153             }
00154         }
00155     }
00156 
00157 clean_out:
00158 
00159     Channel::Destroy(channelP);
00160     return 0;
00161 }


multisense_lib
Author(s):
autogenerated on Fri Apr 5 2019 02:28:24