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': currentAddress = std::string(optarg); break;
101  case 'f': fps = atof(optarg); break;
102  default: usage(*argvPP); break;
103  }
104 
105  //
106  // Initialize communications.
107 
108  Channel *channelP = Channel::Create(currentAddress);
109  if (NULL == channelP) {
110  std::cerr << "Failed to establish communications with \"" << currentAddress << "\"" << std::endl;
111  return -1;
112  }
113 
114  //
115  // Query version
116 
117  Status status;
119 
120  status = channelP->getVersionInfo(v);
121  if (Status_Ok != status) {
122  std::cerr << "Failed to query sensor version: " << Channel::statusString(status) << std::endl;
123  goto clean_out;
124  }
125 
126  std::cout << "API build date : " << v.apiBuildDate << "\n";
127  std::cout << "API version : 0x" << std::hex << std::setw(4) << std::setfill('0') << v.apiVersion << "\n";
128  std::cout << "Firmware build date : " << v.sensorFirmwareBuildDate << "\n";
129  std::cout << "Firmware version : 0x" << std::hex << std::setw(4) << std::setfill('0') << v.sensorFirmwareVersion << "\n";
130  std::cout << "Hardware version : 0x" << std::hex << v.sensorHardwareVersion << "\n";
131  std::cout << "Hardware magic : 0x" << std::hex << v.sensorHardwareMagic << "\n";
132  std::cout << "FPGA DNA : 0x" << std::hex << v.sensorFpgaDna << "\n";
133  std::cout << std::dec;
134 
135  //
136  // Change framerate
137 
138  {
139  image::Config cfg;
140 
141  status = channelP->getImageConfig(cfg);
142  if (Status_Ok != status) {
143  std::cerr << "Failed to get image config: " << Channel::statusString(status) << std::endl;
144  goto clean_out;
145  } else {
146 
147  cfg.setFps(fps);
148 
149  status = channelP->setImageConfig(cfg);
150  if (Status_Ok != status) {
151  std::cerr << "Failed to configure sensor: " << Channel::statusString(status) << std::endl;
152  goto clean_out;
153  }
154  }
155  }
156 
157 clean_out:
158 
159  Channel::Destroy(channelP);
160  return 0;
161 }
static const char * statusString(Status status)
Definition: channel.cc:609
static Channel * Create(const std::string &sensorAddress)
Definition: channel.cc:583
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:34
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:596
char * optarg
Definition: getopt.c:32
virtual Status getImageConfig(image::Config &c)=0


multisense_lib
Author(s):
autogenerated on Sat Apr 6 2019 02:16:46