//+---------------------------------------------------------------------------- // // File: main.cpp // // Module: Kodak DC210 plus communication program // // Synopsis: Program entry point. // // Copyright (c) 1999 Scott Gasch // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF // SUCH DAMAGE. // // $Id: main.cpp,v 1.3 2000/01/15 18:34:30 scott Exp scott $ // // Author: sgasch // // Created 4 Jun 1999 // //+---------------------------------------------------------------------------- #include #include #include #include #include #include #include "global.h" #include "utils.h" #include "trace.h" #include "debug.h" #include "dc210camera.h" #include "dc210photo.h" CKodakDC210 camera("/dev/cuaa0", 38400); // // Needed for getopt. // extern char *optarg; extern int optind; //+---------------------------------------------------------------------------- // // Function: Usage // // Synopsis: Print out a brief description of command syntax and exit. // // Arguments: void // // Returns: void // // History: sgasch Created Header 22 Jun 1999 // //+---------------------------------------------------------------------------- void Usage(void) { printf("usage:\n\n" "camera [-d][-p serial-device][-BYTE baud-rate] command " "[arguments]\n" "camera [-h]\n\n"); exit(0); } //+---------------------------------------------------------------------------- // // Function: main // // Synopsis: Main entry point; parse arguments and control camera. // // Arguments: int argc - arg count // char *argv[] - arguments // // Returns: int - status to OS // // History: sgasch Created Header 22 Jun 1999 // //+---------------------------------------------------------------------------- int main(int argc, char *argv[]) { char ch; char szCommand[256]; while ((ch = getopt(argc, argv, "p:b:d?h")) != -1) { switch (ch) { // // We are in debug mode -- extra tracing and more retries. // case 'd': g_iMaxAttempts = 10; break; case 'b': g_iSpeed = atoi(optarg); if ((g_iSpeed != 9600) && (g_iSpeed != 19200) && (g_iSpeed != 38400) && (g_iSpeed != 57600) && (g_iSpeed != 115200)) { Trace("main: Illegal speed (%d) specified; legal speeds " "are:\n\n" "9600, 19200, 38400, 57600, and 115200.\n\n" "main: Defaulting to to 9600 baud.\n", g_iSpeed); g_iSpeed = 9600; } break; case 'p': memset(g_szCameraSerialPort, 0, PATH_MAX); strncpy(g_szCameraSerialPort, optarg, PATH_MAX); break; case '?': case 'h': default: Usage(); return(0); } argc -= optind; argv += optind; } do { if (NULL == (gets(szCommand))) { break; } if (!strcasecmp("snap", szCommand)) { Trace("Snapping...\n"); (void) camera.TakePicture(); } } while(1); return(0); }