1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
/*
* VISCA(tm) Camera Control Library Test Program
* Copyright (C) 2002 Damien Douxchamps
*
* Written by Damien Douxchamps <douxchamps@ieee.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */
#include <sys/ioctl.h>
#include "../src/libvisca.h"
#define EVI_D30
int
main(int argc, char **argv)
{
VISCAInterface_t interface;
VISCACamera_t camera;
unsigned char packet[3000];
int i, bytes, camera_num;
UInt8_t value;
UInt16_t zoom;
int pan_pos, tilt_pos;
if (argc<2)
{
fprintf(stderr,"%s usage: %s <serial port device>\n",argv[0],argv[0]);
exit(1);
}
if (VISCA_open_serial(&interface, argv[1])!=VISCA_SUCCESS)
{
fprintf(stderr,"%s: unable to open serial device %s\n",argv[0],argv[1]);
exit(1);
}
interface.broadcast=0;
VISCA_set_address(&interface, &camera_num);
camera.address=1;
VISCA_clear(&interface, &camera);
VISCA_get_camera_info(&interface, &camera);
fprintf(stderr,"Some camera info:\n------------------\n");
fprintf(stderr,"vendor: 0x%04x\n model: 0x%04x\n ROM version: 0x%04x\n socket number: 0x%02x\n",
camera.vendor, camera.model, camera.rom_version, camera.socket_num);
if (VISCA_set_zoom_value(&interface, &camera, 0x0000)!=VISCA_SUCCESS)
fprintf(stderr,"error setting zoom\n");
usleep(500000);
if (VISCA_set_zoom_value(&interface, &camera, 0x4000)!=VISCA_SUCCESS)
fprintf(stderr,"error setting zoom\n");
usleep(500000);
if (VISCA_set_zoom_value(&interface, &camera, 0x1234)!=VISCA_SUCCESS)
fprintf(stderr,"error setting zoom\n");
if (VISCA_get_zoom_value(&interface, &camera, &zoom)!=VISCA_SUCCESS)
fprintf(stderr,"error getting zoom\n");
else
fprintf(stderr,"Zoom value: 0x%04x\n",zoom);
usleep(500000);
if (VISCA_set_zoom_value(&interface, &camera, 0x0000)!=VISCA_SUCCESS)
fprintf(stderr,"error setting zoom\n");
if (VISCA_get_power(&interface, &camera, &value)!=VISCA_SUCCESS)
fprintf(stderr,"error getting power\n");
else
fprintf(stderr,"power status: 0x%02x\n",value);
#ifdef EVI_D30
if (VISCA_set_pantilt_reset(&interface, &camera)!=VISCA_SUCCESS)
fprintf(stderr,"error setting pan tilt home\n");
else
fprintf(stderr,"Setting pan tilt home\n");
if (VISCA_set_pantilt_absolute_position(&interface, &camera,5,5,-500,-200)!=VISCA_SUCCESS)
fprintf(stderr,"error setting pan tilt absolute position with negative position\n");
else
fprintf(stderr,"Setting pan tilt absolute position\n");
if (VISCA_get_pantilt_position(&interface, &camera, &pan_pos, &tilt_pos)!=VISCA_SUCCESS)
fprintf(stderr,"error getting pan tilt absolute position\n");
else
fprintf(stderr,"Absolute position, Pan value: %d, Tilt value: %d\n",pan_pos,tilt_pos);
if (VISCA_set_pantilt_absolute_position(&interface, &camera,18,14,500,200)!=VISCA_SUCCESS)
fprintf(stderr,"error setting pan tilt absolute position with positive position\n");
else
fprintf(stderr,"Setting pan tilt absolute position\n");
if (VISCA_get_pantilt_position(&interface, &camera, &pan_pos, &tilt_pos)!=VISCA_SUCCESS)
fprintf(stderr,"error getting pan tilt absolute position\n");
else
fprintf(stderr,"Absolute position, Pan value: %d, Tilt value: %d\n",pan_pos,tilt_pos);
if (VISCA_set_pantilt_home(&interface, &camera)!=VISCA_SUCCESS)
fprintf(stderr,"error setting pan tilt home\n");
else
fprintf(stderr,"Setting pan tilt home\n");
#endif
//if (VISCA_set_power(&interface, &camera, VISCA_ON)!=VISCA_SUCCESS)
// fprintf(stderr,"error setting power\n");
// read the rest of the data: (should be empty)
VISCA_set_zoom_value(&interface, &camera, 0x0D00);
VISCA_set_shutter_value(&interface, &camera, 0x0D00);
//usleep(1000000);
ioctl(interface.port_fd, FIONREAD, &bytes);
if (bytes>0)
{
fprintf(stderr, "ERROR: %d bytes not processed: ", bytes);
read(interface.port_fd, &packet, bytes);
for (i=0;i<bytes;i++)
fprintf(stderr,"%2x ",packet[i]);
fprintf(stderr,"\n");
}
VISCA_close_serial(&interface);
exit(0);
}
|