ChangeTransmitDelay.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-d transmit delay in ms\n");
78 
79  exit(-1);
80 }
81 
82 }; // anonymous
83 
84 using namespace crl::multisense;
85 
86 int main(int argc,
87  char **argvPP)
88 {
89  std::string currentAddress = "10.66.171.21";
90  int delay = 0;
91 
92  //
93  // Parse args
94 
95  int c;
96 
97  while(-1 != (c = getopt(argc, argvPP, "a:d:")))
98  switch(c) {
99  case 'a': currentAddress = std::string(optarg); break;
100  case 'd': delay = atoi(optarg); break;
101  default: usage(*argvPP); break;
102  }
103 
104  //
105  // Initialize communications.
106 
107  Channel *channelP = Channel::Create(currentAddress);
108  if (NULL == channelP) {
109  std::cerr << "Failed to establish communications with \"" << currentAddress << "\"" << std::endl;
110  return -1;
111  }
112 
113  //
114  // Query version
115 
116  Status status;
118 
119  status = channelP->getVersionInfo(v);
120  if (Status_Ok != status) {
121  std::cerr << "Failed to query sensor version: " << Channel::statusString(status) << std::endl;
122  goto clean_out;
123  }
124 
125  std::cout << "API build date : " << v.apiBuildDate << "\n";
126  std::cout << "API version : 0x" << std::hex << std::setw(4) << std::setfill('0') << v.apiVersion << "\n";
127  std::cout << "Firmware build date : " << v.sensorFirmwareBuildDate << "\n";
128  std::cout << "Firmware version : 0x" << std::hex << std::setw(4) << std::setfill('0') << v.sensorFirmwareVersion << "\n";
129  std::cout << "Hardware version : 0x" << std::hex << v.sensorHardwareVersion << "\n";
130  std::cout << "Hardware magic : 0x" << std::hex << v.sensorHardwareMagic << "\n";
131  std::cout << "FPGA DNA : 0x" << std::hex << v.sensorFpgaDna << "\n";
132  std::cout << std::dec;
133 
134  //
135  // Change framerate
136 
137  {
138  image::TransmitDelay TransmitDelay;
139 
140  status = channelP->getTransmitDelay(TransmitDelay);
141  if (Status_Ok != status) {
142  std::cerr << "Failed to get transmit delay: " << Channel::statusString(status) << std::endl;
143  goto clean_out;
144  } else {
145 
146  TransmitDelay.delay = delay;
147 
148  status = channelP->setTransmitDelay(TransmitDelay);
149  if (Status_Ok != status) {
150  std::cerr << "Failed to configure transmit delay: " << Channel::statusString(status) << std::endl;
151  goto clean_out;
152  }
153  }
154  }
155 
156 clean_out:
157 
158  Channel::Destroy(channelP);
159  return 0;
160 }
static const char * statusString(Status status)
Definition: channel.cc:609
static Channel * Create(const std::string &sensorAddress)
Definition: channel.cc:583
int main(int argc, char **argvPP)
virtual Status getVersionInfo(system::VersionInfo &v)=0
int getopt(int argc, char **argv, char *opts)
Definition: getopt.c:34
virtual Status getTransmitDelay(image::TransmitDelay &c)=0
static CRL_CONSTEXPR Status Status_Ok
def usage(progname)
virtual Status setTransmitDelay(const image::TransmitDelay &c)=0
static void Destroy(Channel *instanceP)
Definition: channel.cc:596
char * optarg
Definition: getopt.c:32


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