ChangeTransmitDelay.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-d transmit delay in ms\n");
00078     
00079     exit(-1);
00080 }
00081 
00082 }; // anonymous
00083 
00084 using namespace crl::multisense;
00085 
00086 int main(int    argc, 
00087          char **argvPP)
00088 {
00089     std::string currentAddress = "10.66.171.21";
00090     int delay = 0;
00091 
00092     //
00093     // Parse args
00094 
00095     int c;
00096 
00097     while(-1 != (c = getopt(argc, argvPP, "a:d:")))
00098         switch(c) {
00099         case 'a': currentAddress = std::string(optarg);    break;
00100         case 'd': delay         = atoi(optarg);            break;
00101         default: usage(*argvPP);                           break;
00102         }
00103 
00104     //
00105     // Initialize communications.
00106 
00107     Channel *channelP = Channel::Create(currentAddress);
00108     if (NULL == channelP) {
00109                 std::cerr << "Failed to establish communications with \"" << currentAddress << "\"" << std::endl;
00110         return -1;
00111     }
00112 
00113     //
00114     // Query version
00115 
00116     Status status;
00117     system::VersionInfo v;
00118 
00119     status = channelP->getVersionInfo(v);
00120     if (Status_Ok != status) {
00121                 std::cerr << "Failed to query sensor version: " << Channel::statusString(status) << std::endl;
00122         goto clean_out;
00123     }
00124 
00125         std::cout << "API build date      :  " << v.apiBuildDate << "\n";
00126         std::cout << "API version         :  0x" << std::hex << std::setw(4) << std::setfill('0') << v.apiVersion << "\n";
00127         std::cout << "Firmware build date :  " << v.sensorFirmwareBuildDate << "\n";
00128         std::cout << "Firmware version    :  0x" << std::hex << std::setw(4) << std::setfill('0') << v.sensorFirmwareVersion << "\n";
00129         std::cout << "Hardware version    :  0x" << std::hex << v.sensorHardwareVersion << "\n";
00130         std::cout << "Hardware magic      :  0x" << std::hex << v.sensorHardwareMagic << "\n";
00131         std::cout << "FPGA DNA            :  0x" << std::hex << v.sensorFpgaDna << "\n";
00132         std::cout << std::dec;
00133 
00134     //
00135     // Change framerate
00136 
00137     {
00138         image::TransmitDelay TransmitDelay;
00139 
00140     status = channelP->getTransmitDelay(TransmitDelay);
00141         if (Status_Ok != status) {
00142                         std::cerr << "Failed to get transmit delay: " << Channel::statusString(status) << std::endl;
00143             goto clean_out;
00144         } else {
00145 
00146             TransmitDelay.delay = delay;
00147         
00148             status = channelP->setTransmitDelay(TransmitDelay);
00149             if (Status_Ok != status) {
00150                                 std::cerr << "Failed to configure transmit delay: " << Channel::statusString(status) << std::endl;
00151                 goto clean_out;
00152             }
00153         }
00154     }
00155 
00156 clean_out:
00157 
00158     Channel::Destroy(channelP);
00159     return 0;
00160 }


multisense_lib
Author(s):
autogenerated on Mon Oct 9 2017 03:06:21