reconfigure_cam.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2009-2010, Willow Garage, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the Willow Garage nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34 
37 #include <string.h>
38 #include <cstdio>
39 #include <cstdlib>
40 #include <cstring>
41 #include <cassert>
42 
43 int main(int argc, char** argv)
44 {
45  if (argc != 2 || !strcmp(argv[1], "--help")) {
46  fprintf(stderr, "Usage: %s <camera URL>\n", argv[0]);
47  fprintf(stderr, "Sends the camera a PacketReconfigureFPGA packet.\n");
48  fprintf(stderr, "Note: Currently reconfigure_cam and reset_cam have the same effect.\n");
49  fprintf(stderr, "In future versions reset_cam may reset the camera without reconfiguring\n");
50  fprintf(stderr, "the FPGA.\n");
51  return 0;
52  }
53  char* camera_url = argv[1];
54 
55  // Find the camera matching the URL
56  IpCamList camera;
57 
58  const char *errmsg;
59  int outval = wge100FindByUrl(camera_url, &camera, SEC_TO_USEC(0.1), &errmsg);
60  if (outval)
61  {
62  fprintf(stderr, "Matching URL %s : %s\n", camera_url, errmsg);
63  return -1;
64  }
65 
66  // Configure the camera with its IP address, wait up to 500ms for completion
67  int retval = wge100Configure(&camera, camera.ip_str, SEC_TO_USEC(0.5));
68  if (retval != 0) {
69  if (retval == ERR_CONFIG_ARPFAIL) {
70  fprintf(stderr, "Unable to create ARP entry (are you root?), continuing anyway\n");
71  } else {
72  fprintf(stderr, "IP address configuration failed\n");
73  return -1;
74  }
75  }
76 
77  if ( wge100TriggerControl( &camera, TRIG_STATE_INTERNAL ) != 0) {
78  fprintf(stderr, "Could not communicate with camera after configuring IP. Is ARP set? Is %s accessible from %s?\n", camera.ip_str, camera.ifName);
79  return -1;
80  }
81 
82  if ( wge100ReconfigureFPGA( &camera ) != 0) {
83  fprintf(stderr, "Error sending ReconfigureFPGA to camera.\n");
84  return -1;
85  }
86 
87  fprintf(stderr, "Success!\n");
88 
89  return 0;
90 }
#define TRIG_STATE_INTERNAL
Definition: wge100lib.h:58
int wge100Configure(IpCamList *camInfo, const char *ipAddress, unsigned wait_us)
Definition: wge100lib.c:532
#define ERR_CONFIG_ARPFAIL
Definition: wge100lib.h:116
#define SEC_TO_USEC(sec)
Definition: host_netutil.h:65
int wge100FindByUrl(const char *url, IpCamList *camera, unsigned wait_us, const char **errmsg)
Definition: wge100lib.c:94
char ip_str[16]
Definition: list.h:296
int wge100TriggerControl(const IpCamList *camInfo, uint32_t triggerType)
Definition: wge100lib.c:1135
int main(int argc, char **argv)
char ifName[128]
Definition: list.h:293
int wge100ReconfigureFPGA(IpCamList *camInfo)
Definition: wge100lib.c:750


wge100_camera
Author(s): Blaise Gassend, Patrick Mihelich, Eric MacIntosh, David Palchak
autogenerated on Mon Jun 10 2019 15:44:15