ChangeFps.cc
Go to the documentation of this file.
1 
36 #ifdef WIN32
37 #ifndef WIN32_LEAN_AND_MEAN
38 #define WIN32_LEAN_AND_MEAN 1
39 #endif
40 
41 #include <windows.h>
42 #include <winsock2.h>
43 #else
44 #include <unistd.h>
45 #include <netdb.h>
46 #include <sys/socket.h>
47 #include <netinet/in.h>
48 #include <arpa/inet.h>
49 #endif
50 
51 #include <stdio.h>
52 #include <stdlib.h>
53 #include <string>
54 #include <fstream>
55 #include <iostream>
56 #include <iomanip>
57 
58 #include <errno.h>
59 #include <string.h>
60 
63 
67 
69 
70 namespace { // anonymous
71 
72 void usage(const char *programNameP)
73 {
74  fprintf(stderr, "USAGE: %s [<options>]\n", programNameP);
75  fprintf(stderr, "Where <options> are:\n");
76  fprintf(stderr, "\t-a <current_address> : CURRENT IPV4 address (default=10.66.171.21)\n");
77  fprintf(stderr, "\t-f fps\n");
78 
79 
80  exit(-1);
81 }
82 
83 } // anonymous
84 
85 using namespace crl::multisense;
86 
87 int main(int argc,
88  char **argvPP)
89 {
90  std::string currentAddress = "10.66.171.21";
91 
92  //
93  // Parse args
94 
95  int c;
96  float fps = 10;
97 
98  while(-1 != (c = getopt(argc, argvPP, "a:f:")))
99  switch(c) {
100  case 'a':
101  currentAddress = std::string(optarg);
102  break;
103  case 'f':
104  fps = static_cast<float> (atof(optarg));
105  break;
106  default:
107  usage(*argvPP);
108  break;
109  }
110 
111  //
112  // Initialize communications.
113 
114  Channel *channelP = Channel::Create(currentAddress);
115  if (NULL == channelP) {
116  std::cerr << "Failed to establish communications with \"" << currentAddress << "\"" << std::endl;
117  return -1;
118  }
119 
120  //
121  // Query version
122 
123  Status status;
125 
126  status = channelP->getVersionInfo(v);
127  if (Status_Ok != status) {
128  std::cerr << "Failed to query sensor version: " << Channel::statusString(status) << std::endl;
129  goto clean_out;
130  }
131 
132  std::cout << "API build date : " << v.apiBuildDate << "\n";
133  std::cout << "API version : 0x" << std::hex << std::setw(4) << std::setfill('0') << v.apiVersion << "\n";
134  std::cout << "Firmware build date : " << v.sensorFirmwareBuildDate << "\n";
135  std::cout << "Firmware version : 0x" << std::hex << std::setw(4) << std::setfill('0') << v.sensorFirmwareVersion << "\n";
136  std::cout << "Hardware version : 0x" << std::hex << v.sensorHardwareVersion << "\n";
137  std::cout << "Hardware magic : 0x" << std::hex << v.sensorHardwareMagic << "\n";
138  std::cout << "FPGA DNA : 0x" << std::hex << v.sensorFpgaDna << "\n";
139  std::cout << std::dec;
140 
141  //
142  // Change framerate
143 
144  {
145  image::Config cfg;
146 
147  status = channelP->getImageConfig(cfg);
148  if (Status_Ok != status) {
149  std::cerr << "Failed to get image config: " << Channel::statusString(status) << std::endl;
150  goto clean_out;
151  } else {
152 
153  cfg.setFps(fps);
154 
155  status = channelP->setImageConfig(cfg);
156  if (Status_Ok != status) {
157  std::cerr << "Failed to configure sensor: " << Channel::statusString(status) << std::endl;
158  goto clean_out;
159  }
160  }
161  }
162 
163 clean_out:
164 
165  Channel::Destroy(channelP);
166  return 0;
167 }
static const char * statusString(Status status)
Definition: channel.cc:649
static Channel * Create(const std::string &sensorAddress)
Definition: channel.cc:623
virtual Status getVersionInfo(system::VersionInfo &v)=0
int main(int argc, char **argvPP)
Definition: ChangeFps.cc:87
int getopt(int argc, char **argv, char *opts)
Definition: getopt.c:31
static CRL_CONSTEXPR Status Status_Ok
virtual Status setImageConfig(const image::Config &c)=0
def usage(progname)
static void Destroy(Channel *instanceP)
Definition: channel.cc:636
char * optarg
Definition: getopt.c:29
virtual Status getImageConfig(image::Config &c)=0


multisense_lib
Author(s):
autogenerated on Sun Mar 14 2021 02:34:50