take.c

Go to the documentation of this file.
00001 
00020 #include "edtinc.h"
00021 #ifdef DO_JPEG
00022 #include "edt_jpeg.h"
00023 #endif
00024 
00025 #define FOURGB ((double) (0x1000000) * 16.0)
00026 
00027 /*
00028  * defines
00029  */
00030 #define STARTSIG 0xa5
00031 #define ENDSIG   0x5a
00032 
00033     int
00034 get_usps_lines_xferred(PdvDev *pdv_p, int buffer)
00035 {
00036     u_int rasterlines;
00037 
00038     rasterlines = buffer % pdv_p->ring_buffer_numbufs;
00039 
00040     edt_ioctl(pdv_p, EDTG_LINES_XFERRED, &rasterlines);
00041 
00042     return rasterlines;
00043 
00044 }
00045 
00046 /*
00047  * fwd ref
00048  */
00049 void
00050 crop_and_subsample(int subsample, int src_width, int src_height,
00051         int x0, int y0, int x1, int y1, u_char * src, u_char * dst);
00052 void
00053 resolve_fname(char *fname, char *newname, int loops, char *ext);
00054 static void usage(char *progname, char *errmsg, int exitval);
00055 
00056 /*
00057  * globals
00058  */
00059 int     ASnum = 0;
00060 int     ASinc = 1;
00061 
00062     void
00063 dumpbuf(char *name, u_short * buf, int size)
00064 {
00065     FILE   *fp = fopen(name, "wb");
00066 
00067     fwrite(buf, sizeof(short), size / 2, fp);
00068     fclose(fp);
00069 }
00070 
00071 static int quiet = 0;
00072 
00073 /*******************************
00074  *
00075  * simple method to suppress messages
00076  * using quiet variable
00077  *
00078  *******************************/
00079 
00080     int
00081 take_printf(char *format,...)
00082 
00083 {
00084     va_list stack;
00085 
00086     if (quiet)
00087         return 0;
00088 
00089     va_start(stack, format);
00090 
00091     return vprintf(format, stack);
00092 
00093 }
00094 
00095 /* write a windows bitmap file */
00096     int
00097 write_bmp_file(char *tmpname, u_char * image_p,
00098         int s_width, int s_height, int s_depth)
00099 {
00100     int     s_db = bits2bytes(s_depth);
00101     u_char *bbuf = NULL;
00102     int retval;
00103 
00104 
00105     /*
00106      * write bmp file. Switch on number of bytes per pixel
00107      */
00108     switch (s_db)
00109     {
00110         case 1:
00111             take_printf("writing %dx%dx%d bmp file to %s\n",
00112                     s_width, s_height, s_depth, tmpname);
00113 
00114             retval = dvu_write_bmp(tmpname, image_p, s_width, s_height);
00115             break;
00116 
00117         case 2:
00118             take_printf("converting %dx%dx%d image to 8 bits, writing to %s\n",
00119                     s_width, s_height, s_depth, tmpname);
00120 
00121             if (!bbuf)
00122                 bbuf = (u_char *) pdv_alloc(s_width * s_height);
00123 
00124             if (bbuf == NULL)
00125             {
00126                 pdv_perror("data buf malloc");
00127                 exit(1);
00128             }
00129             dvu_word2byte((u_short *) image_p, (u_char *) bbuf,
00130                     s_width * s_height, s_depth);
00131             retval = dvu_write_bmp(tmpname, bbuf, s_width, s_height);
00132             break;
00133 
00134         case 3:
00135             take_printf("writing %dx%dx%d bmp file to %s\n",
00136                     s_width, s_height, s_depth, tmpname);
00137 
00138             retval = dvu_write_bmp_24(tmpname, (u_char *) image_p, s_width, s_height);
00139             break;
00140 
00141         default:
00142             take_printf("invalid image depth for file write...!\n");
00143             return -1;
00144             break;
00145     }
00146 
00147     return retval;
00148 }
00149 
00150 /* keep this until we find out why without it, process cannot exit */
00151 /* even though wakeup from WAITBUF detects interrupt and does wakeup */
00152 
00153 int GetOut = 0 ;
00154 #ifdef __APPLE__
00155     static int
00156 gotit()
00157 {
00158     GetOut = 1 ;
00159     return 0;
00160 }
00161 #endif
00162 
00163 char cmdstr[80] ;
00164 
00165 /*
00166  * Main module. NO_MAIN is typically only defined when compiling for vxworks; if you
00167  * want to use this code outside of a main module in any other OS, just copy the code
00168  * and modify it to work as a standalone subroutine, including adding parameters in
00169  * place of the command line arguments
00170  */
00171 #ifdef NO_MAIN
00172 #include "opt_util.h"
00173 char   *argument;
00174 int     option;
00175 
00176     int
00177 take(char *command_line)
00178 #else
00179     int
00180 main(int argc, char *argv[])
00181 #endif
00182 {
00183     int     i, lc;
00184     int     waited = 0;
00185     int     unit = 0;
00186     char   *unitstr = "0";
00187     int     loops = 1;
00188     int     wait_for_enter = 0;
00189     int     user_delay = 0;
00190     int     numbufs = 4;
00191     int     do_ring = 1;
00192     int     verbose = 0;
00193     int     do_file = 0;
00194     int     rbtimeout = 0;
00195     int     bytesread;
00196     int     started;
00197     int     done;
00198     char    cfgfname[128];
00199     char    bmpfname[128];
00200     char    jpgfname[128];
00201     char    rawfname[128];
00202     char    edt_devname[256];
00203     char   *progname = "take";
00204     u_char *imagebuf = NULL;
00205     u_char *subimage = NULL;
00206     u_char *image_p = NULL;
00207     PdvDev *pdv_p;
00208     int     timeouts=0, last_timeouts=0;
00209     int     in_timeout_cleanup = 0;
00210     int     overruns=0, overrun;
00211     char    tmpname[128];
00212     int     subsample = 0, crop = 0;
00213     int     debug_timeout = 0;
00214     int     width, height, depth, imagesize, dmasize, bufsize, db;
00215     int     s_width, s_height, s_depth, s_size, s_db;
00216     int     crop_x0, crop_x1, crop_y0, crop_y1;
00217     int     exposure, gain, offset;
00218     int     set_exposure = 0, set_gain = 0, set_offset = 0;
00219     int     set_timeout = 0;
00220     int     do_timestamp = 0;
00221     int     do_timetype = 0;
00222     int     timetype = 0;
00223     int     do_lasttest = 0;
00224     int     timeout_val = 0;
00225     int     enable_burst_en = 1;
00226     int     si = -1;
00227     int     sc = -1;
00228     int     vskip, vactv, hskip, hactv;
00229     int     set_roi = 0;
00230     int     unset_roi = 0;
00231     int     checksig = 0, checkcount = 0;
00232     int     checksim = 0;
00233     int     checkclsim = 0;
00234     int     checkclk = 0;
00235     int     badstart = 0, badend = 0;
00236     int     just_print_the_last_one = 0;
00237     u_short startsig = STARTSIG, endsig = ENDSIG;
00238     u_int   sigcount;
00239     int     siginit = 0;
00240     char    errstr[64];
00241     u_int   timestamp[2];
00242     u_int   freqbuf[2];
00243     double  dtime;
00244     double  svtime = 0;
00245     double  curtime = 0;
00246     double  frequency = 0;
00247     double  sumsize = 0;
00248     int     checkfrm = 0;
00249     int     binning = 0;
00250     int     opto_trigger = 0;
00251     int     fldid_trigger = 0;
00252 
00253     int     channel = 0;
00254 
00255 
00256     int     mosaic = 0;
00257     int     mosaic_sample = 0;
00258     int     sample_height = 10;
00259     int     mosaic_size = 0;
00260     int     mosaic_width = 0;
00261     int     mosaic_height = 0;
00262     char    dvcmode[8];
00263     unsigned char *mosaic_ptr = NULL;
00264     unsigned char *mosaic_image = NULL;
00265     int     arg_channel = -1;
00266     int     dl;
00267 
00268     int noreset = 0;
00269 
00270 #ifdef NO_MAIN
00271     char  **argv = 0;
00272     int     argc = 0;
00273 
00274     opt_create_argv("take", command_line, &argc, &argv);
00275 #endif
00276 
00277 
00278     cfgfname[0] = '\0';
00279     rawfname[0] = '\0';
00280     bmpfname[0] = '\0';
00281     jpgfname[0] = '\0';
00282     edt_devname[0] = '\0';
00283     dvcmode[0] = '\0';
00284     tmpname[0] = '\0';
00285     ASnum = 0;
00286     quiet = 0 ;
00287     siginit = 0 ;
00288 
00289 #ifdef __APPLE__
00290     /* debug for interrupted wakeup */
00291     signal(SIGINT,gotit);
00292 #endif
00293 
00294     --argc;
00295     ++argv;
00296     while (argc && ((argv[0][0] == '-') || (argv[0][0] == '/')))
00297     {
00298         switch (argv[0][1])
00299         {
00300             case 'u':           /* device unit number */
00301                 ++argv;
00302                 --argc;
00303                 if (argc < 1) 
00304                 {
00305                     usage(progname, "Error: option 'u' requires a numeric argument\n", 1);
00306                 }
00307                 if ((argv[0][0] >= '0') && (argv[0][0] <= '9'))
00308                 {
00309                     unitstr = argv[0];
00310                 }
00311                 else 
00312                 {
00313                     usage(progname, "Error: option 'u' requires a numeric argument\n", 1);
00314                 }
00315                 break;
00316 
00317             case 'B':           /* turn off burst enable */
00318                 ++argv;
00319                 --argc;
00320                 if (argc > 0)
00321                     enable_burst_en = atoi(argv[0]);
00322                 else
00323                     enable_burst_en = 1;
00324                 break;
00325 
00326             case 'v':           /* verbose */
00327                 verbose = 1;
00328                 break;
00329 
00330             case 'w':           /* wait for user <cr> between frames */
00331                 wait_for_enter = 1;
00332                 break;
00333 
00334             case 'T':           /* on timeout, dump data to timeout.raw */
00335                 debug_timeout = 1;
00336                 break;
00337 
00338             case 'd':           /* timestamp */
00339                 do_timestamp = 1;
00340                 break;
00341 
00342             case 'D':           /* dvc mode setting (diagnostic) */
00343                 ++argv;
00344                 --argc;
00345                 strcpy(dvcmode, argv[0]);
00346                 break;
00347 
00348             case 'X':           /* use timer */
00349                 ++argv;
00350                 --argc;
00351                 timetype = atoi(argv[0]);
00352                 do_timetype = 1;
00353                 break;
00354 
00355             case 'y':
00356                 opto_trigger = 1;
00357                 break;
00358 
00359             case 'Y':
00360                 fldid_trigger = 1;
00361                 break;
00362 
00363             case 'J':
00364                 just_print_the_last_one = 1;
00365                 break;
00366 
00367             case 'L':
00368                 do_lasttest = 1;        /* freerun/bytecount with wait for next frame */
00369                 break;
00370 
00371             case 'm':           /* microsec sleep between frames */
00372                 ++argv;
00373                 --argc;
00374                 if (argc < 1) 
00375                 {
00376                     usage(progname, "Error: option 'm' requires a numeric argument\n", 1);
00377                 }
00378                 if ((argv[0][0] >= '0') && (argv[0][0] <= '9'))
00379                 {
00380                     user_delay = atoi(argv[0]);
00381                 }
00382                 else 
00383                 {
00384                     usage(progname, "Error: option 'm' requires a numeric argument\n", 1);
00385                 }
00386                 break;
00387 
00388             case 'N':           /* specify numbufs */
00389                 ++argv;
00390                 --argc;
00391                 if (argc < 1) 
00392                 {
00393                     usage(progname, "Error: option 'N' requires a numeric argument\n", 1);
00394                 }
00395                 if ((argv[0][0] >= '0') && (argv[0][0] <= '9'))
00396                 {
00397                     numbufs = atoi(argv[0]);
00398                     if (!numbufs)
00399                         do_ring = 0; /* if 0 just use pdv_read not ring buffers */
00400                 }
00401                 else 
00402                 {
00403                     usage(progname, "Error: option 'N' requires a numeric argument\n", 1);
00404                 }
00405                 break;
00406 
00407             case 'H':           /* check count signature from testgen */
00408                 checksim = 1;
00409                 checksig = 0;
00410                 checkcount = 0;
00411                 break;
00412 
00413             case 'P':           /* check count signature from PCI CD sim */
00414                 checkcount = 1;
00415                 checksig = 0;
00416                 break;
00417 
00418             case 'p':           /* check fixed signature from PCI CD sim */
00419                 checksig = 1;
00420                 checkcount = 0;
00421                 break;
00422 
00423             case 'G':           /* check count signature from testgen */
00424                 checkclsim = 1;
00425                 checksim = 0;
00426                 checksig = 0;
00427                 checkcount = 0;
00428                 break;
00429 
00430             case 'q':           /* binning */
00431                 ++argv;
00432                 --argc;
00433                 binning = atoi(argv[0]);
00434                 break;
00435 
00436             case 'Q':           /* turn on quiet mode */
00437                 quiet = 1;
00438                 break;
00439 
00440             case 't':           /* microsec sleep between frames */
00441                 /* if no subarg, set to -1 (auto timeout) */
00442                 if ((argc < 2) || (argv[1][0] == '-'))
00443                 {
00444                     set_timeout = 1;
00445                     timeout_val = -1;
00446                 }
00447                 else
00448                 {
00449                     ++argv;
00450                     --argc;
00451                     set_timeout = 1;
00452                     if ((argv[0][0] >= '0') && (argv[0][0] <= '9'))
00453                         timeout_val = atoi(argv[0]);
00454                 }
00455                 break;
00456 
00457             case 'l':           /* loops */
00458                 ++argv;
00459                 --argc;
00460                 if (argc < 1) 
00461                 {
00462                     usage(progname, "Error: option 'l' requires a numeric argument\n", 1);
00463                 }
00464                 if ((argv[0][0] >= '0') && (argv[0][0] <= '9'))
00465                 {
00466                     loops = atoi(argv[0]);
00467                 }
00468                 else 
00469                 {
00470                     usage(progname, "Error: option 'l' requires a numeric argument\n", 1);
00471                 }
00472                 break;
00473 
00474             case 'f':           /* save filename */
00475                 ++argv;
00476                 --argc;
00477                 strcpy(rawfname, argv[0]);
00478                 do_file = 1;
00479                 break;
00480 
00481             case 'S':           /* subsample */
00482                 ++argv;
00483                 --argc;
00484                 subsample = atoi(argv[0]);
00485                 break;
00486 
00487             case 'C':           /* crop x0, y0, x1, y1 */
00488                 crop = 1;
00489                 ++argv;
00490                 --argc;
00491                 crop_x0 = atoi(argv[0]);
00492 
00493                 ++argv;
00494                 --argc;
00495                 crop_y0 = atoi(argv[0]);
00496 
00497                 ++argv;
00498                 --argc;
00499                 crop_x1 = atoi(argv[0]);
00500 
00501                 ++argv;
00502                 --argc;
00503                 crop_y1 = atoi(argv[0]);
00504                 break;
00505 
00506             case 'n':           /* autosequence start only */
00507                 ++argv;
00508                 --argc;
00509                 ASnum = atoi(argv[0]);
00510                 break;
00511 
00512             case 's':           /* autosequence start and inc */
00513                 ++argv;
00514                 --argc;
00515                 ASnum = atoi(argv[0]);
00516                 break;
00517 
00518             case 'e':           /* exposure time */
00519                 ++argv;
00520                 --argc;
00521                 set_exposure = 1;
00522                 exposure = atoi(argv[0]);
00523                 break;
00524 
00525             case 'g':           /* gain */
00526                 ++argv;
00527                 --argc;
00528                 set_gain = 1;
00529                 gain = atoi(argv[0]);
00530                 break;
00531 
00532             case 'o':           /* offset (blacklevel) */
00533                 ++argv;
00534                 --argc;
00535                 set_offset = 1;
00536                 offset = atoi(argv[0]);
00537                 break;
00538 
00539             case 'I':           /* # to increment for multiple file writes */
00540                 ++argv;
00541                 --argc;
00542                 ASinc = atoi(argv[0]);
00543                 break;
00544 
00545 #ifdef DO_JPEG
00546             case 'j':
00547                 ++argv;
00548                 --argc;
00549                 strcpy(jpgfname, argv[0]);
00550                 break;
00551 #endif
00552 
00553             case 'b':           /* bitmap save filename */
00554             case 'i':
00555                 ++argv;
00556                 --argc;
00557                 strcpy(bmpfname, argv[0]);
00558                 do_file = 1;
00559                 break;
00560 
00561             case 'c':           /* channel */
00562                 ++argv;
00563                 --argc;
00564                 if (argc < 1) 
00565                 {
00566                     usage(progname, "Error: option 'c' requires a numeric argument\n", 1);
00567                 }
00568                 if ((argv[0][0] >= '0') && (argv[0][0] <= '9'))
00569                 {
00570                     arg_channel = atoi(argv[0]);
00571                 }
00572                 else 
00573                 {
00574                     usage(progname, "Error: option 'c' requires a numeric argument\n", 1);
00575                 }
00576                 break;
00577 
00578             case 'r':           /* ROI */
00579                 if (argc < 5)
00580                 {
00581                     usage(progname, "Error: option 'r' requires subsequent arguments", 1);
00582                     exit(1);
00583                 }
00584                 ++argv;
00585                 --argc;
00586                 hskip = atoi(argv[0]);
00587                 ++argv;
00588                 --argc;
00589                 hactv = atoi(argv[0]);
00590                 ++argv;
00591                 --argc;
00592                 vskip = atoi(argv[0]);
00593                 ++argv;
00594                 --argc;
00595                 vactv = atoi(argv[0]);
00596                 set_roi = 1;
00597                 break;
00598 
00599             case 'R':           /* disable ROI */
00600                 unset_roi = 1;
00601                 break;
00602 
00603             case 'O':           /* try noreset - will be obsolete on clink? */
00604                 noreset = 1 ;
00605                 break;
00606 
00607             case 'x':           /* experimental -- strobe testing */
00608                 ++argv;
00609                 --argc;
00610                 si = atoi(argv[0]);
00611                 ++argv;
00612                 --argc;
00613                 sc = atoi(argv[0]);
00614                 break;
00615 
00616             case 'M':           /* mosaic */
00617                 mosaic = 1;
00618                 break;
00619 
00620             case 'a':           /* call pdv_checkfrm */
00621                 checkfrm = 1;
00622                 break;
00623             case 'A':
00624                 checkclk = 1;
00625                 break;
00626 
00627             default:
00628                 fprintf(stderr, "unknown flag -'%c'\n", argv[0][1]);
00629             case '?':
00630             case 'h':
00631                 usage(progname, "", 0);
00632                 exit(0);
00633         }
00634         argc--;
00635         argv++;
00636     }
00637 
00638 
00639     unit = edt_parse_unit_channel(unitstr, edt_devname, "pdv", &channel);
00640 
00641     if (arg_channel != -1)
00642     {
00643         channel = arg_channel;
00644     }
00645 
00646     unit = edt_parse_unit(unitstr, edt_devname, "pdv");
00647 
00648     /*
00649      * pdv_open_channel is just pdv_open with an extra argument, the channel,
00650      * which is normally 0 unless you're running multiple cameras (2nd base
00651      * mode on a PCI DV C-Link or dasy-chained RCI boxes off a single PCI
00652      * FOI)
00653      */
00654     if ((pdv_p = pdv_open_channel(edt_devname, unit, channel)) == NULL)
00655     {
00656         sprintf(errstr, "pdv_open(%s%d_%d)", edt_devname, unit, channel);
00657         pdv_perror(errstr);
00658         return (1);
00659     }
00660 
00661     if (pdv_is_simulator(pdv_p))
00662     {
00663         fprintf(stderr, "%s unit %d is a simulator board; take is only for use with framegrbbers\n", edt_devname, unit);
00664         pdv_close(pdv_p);
00665         exit(1);
00666     }
00667 
00668     pdv_flush_fifo(pdv_p);
00669 
00670     if (*dvcmode)
00671         pdv_set_mode_dvc(pdv_p, dvcmode);
00672 
00673     if (set_exposure)
00674         pdv_set_exposure(pdv_p, exposure);
00675 
00676     if (set_gain)
00677         pdv_set_gain(pdv_p, gain);
00678 
00679     if (set_offset)
00680         pdv_set_blacklevel(pdv_p, offset);
00681 
00682     if (set_timeout)
00683         pdv_set_timeout(pdv_p, timeout_val);
00684 
00685     if (opto_trigger)
00686         pdv_enable_external_trigger(pdv_p, PDV_PHOTO_TRIGGER);
00687 
00688     else if (fldid_trigger)
00689         pdv_enable_external_trigger(pdv_p, PDV_FLDID_TRIGGER);
00690 
00691 
00692     if (set_roi)
00693     {
00694         pdv_set_roi(pdv_p, hskip, hactv, vskip, vactv);
00695         pdv_enable_roi(pdv_p, 1);
00696     }
00697     else if (unset_roi)
00698     {
00699         pdv_enable_roi(pdv_p, 0);
00700     }
00701 
00702     if (binning)
00703     {
00704         pdv_set_binning(pdv_p, binning, binning);
00705     }
00706 
00707     if (checksig)
00708         take_printf("checking PCI CD Simulator fixed signature -- use simple_putframe -p\n");
00709     if (checksim)
00710         take_printf("checking testgen signature\n");
00711     if (checkclsim)
00712         take_printf("checking cl simulator signature\n");
00713     if (checkcount)
00714         take_printf("checking PCI CD Simulator count signature -- use simple_putframe -P\n");
00715 
00716     if (do_timetype)
00717     {
00718         edt_set_timetype(pdv_p, EDT_TM_FREQ);
00719         edt_get_reftime(pdv_p, freqbuf);
00720         frequency = (double) freqbuf[0] * FOURGB + freqbuf[1];
00721         edt_set_timetype(pdv_p, timetype);
00722     }
00723 
00724     /*
00725      * set size variables for image and initial subimage
00726      */
00727     width = s_width = pdv_get_width(pdv_p);
00728     height = s_height = pdv_get_height(pdv_p);
00729     depth = s_depth = pdv_get_depth(pdv_p);
00730     db = s_db = bits2bytes(depth);
00731     imagesize = s_size = pdv_get_imagesize(pdv_p);
00732     dmasize = s_size = pdv_get_dmasize(pdv_p);
00733 
00734     subimage = NULL;
00735     /*
00736      * turn off merge
00737      */
00738     edt_set_merge(pdv_p, 0, 0, 0, 0);
00739 
00740     if (s_size <= 0)
00741     {
00742         printf("%s%d: Invalid image size. Make sure device has been initialized.\n", edt_devname, unit);
00743         exit(1);
00744     }
00745 
00746     if (mosaic)
00747     {
00748         mosaic_sample = width * sample_height * db;
00749 
00750         mosaic_size = loops * mosaic_sample;
00751 
00752         mosaic_image = pdv_alloc(mosaic_size);
00753 
00754         mosaic_ptr = mosaic_image;
00755 
00756         mosaic_width = width * db;
00757 
00758         mosaic_height = loops * sample_height;
00759 
00760     }
00761 
00762     if (do_ring)
00763     {
00764         /* Construct a ring buffer */
00765         if (pdv_multibuf(pdv_p, numbufs) == -1)
00766         {
00767             char    msg[64];
00768 
00769             sprintf(msg, "pdv_multibuf(0x%p, %d)", pdv_p, numbufs);
00770             pdv_perror(msg);
00771             return (0);
00772         }
00773     }
00774     else
00775     {
00776         bufsize = ((dmasize > imagesize)? dmasize: imagesize);
00777         imagebuf = (u_char *) pdv_alloc(bufsize);
00778         if (imagebuf == NULL)
00779         {
00780             pdv_perror("data buf malloc");
00781             exit(1);
00782         }
00783     }
00784 
00785     pdv_cl_reset_fv_counter(pdv_p) ;
00786 
00787     /*
00788      * check for crazy subsample and crop values and sort out the params as
00789      * needed
00790      */
00791 
00792     if (do_file && (subsample || crop))
00793     {
00794         if ((subsample < 0)
00795                 || (subsample > height / 4)
00796                 || (subsample > width / 4))
00797         {
00798             printf("-S <subsample> arg out of range\n");
00799             usage(progname, "", 1);
00800             exit(1);
00801         }
00802 
00803         /* force subsample since its used as an arg in processing */
00804         if (crop && (subsample == 0))
00805             subsample = 1;
00806 
00807         if (crop)
00808         {
00809             int     tmp;
00810 
00811             if (crop_x0 > crop_x1)
00812             {
00813                 tmp = crop_x1;
00814                 crop_x1 = crop_x0;
00815                 crop_x0 = tmp;
00816             }
00817             if (crop_y0 > crop_y1)
00818             {
00819                 tmp = crop_y1;
00820                 crop_y1 = crop_y0;
00821                 crop_y0 = tmp;
00822             }
00823 
00824             if (crop_x0 < 0)
00825                 crop_x0 = 0;
00826             if (crop_y0 < 0)
00827                 crop_y0 = 0;
00828             if (crop_x1 > width - 1)
00829                 crop_x1 = width - 1;
00830             if (crop_y1 > height - 1)
00831                 crop_y1 = height - 1;
00832         }
00833         else
00834         {
00835             crop_x0 = 0;
00836             crop_y0 = 0;
00837             crop_x1 = width - 1;
00838             crop_y1 = height - 1;
00839         }
00840 
00841         s_width = ((crop_x1 - crop_x0) + subsample) / subsample;
00842         s_height = ((crop_y1 - crop_y0) + subsample) / subsample;
00843         s_size = s_width * s_height * s_db;
00844         subimage = (u_char *) malloc(s_size);
00845     }
00846 
00847     /*
00848      * should normally only be set from the config file as "start_delay:",
00849      * but for testing allow it to be set here too
00850      */
00851     if (user_delay)
00852         pdv_p->dd_p->start_delay = user_delay;
00853 
00854     if (pdv_p->dd_p->start_delay)
00855         take_printf("%d millisecond delay added between images\n", pdv_p->dd_p->start_delay);
00856     if (pdv_p->dd_p->force_single)
00857         take_printf("force_single set; prestarting one image at a time\n");
00858 
00859 #ifdef WIN2K
00860     edt_get_kernel_event(pdv_p, EDT_EVENT_BUF);
00861 #endif
00862 
00863     /*
00864      * acquire the image
00865      */
00866     {
00867         char header_size[32];
00868         if (pdv_get_header_size(pdv_p))
00869             sprintf(header_size,"hdr %d", pdv_get_header_size(pdv_p));
00870         else
00871             header_size[0] = 0;
00872 
00873         if (dmasize != imagesize)
00874             take_printf("reading image from %s\nwidth %d height %d depth %d %s total bytes %d (DMA %d)\n",
00875                     pdv_get_cameratype(pdv_p),
00876                     pdv_get_width(pdv_p),
00877                     pdv_get_height(pdv_p),
00878                     pdv_get_depth(pdv_p),
00879                     header_size,
00880                     imagesize,
00881                     dmasize);
00882         else
00883             take_printf("reading image from %s\nwidth %d height %d depth %d %s total bytes %d\n",
00884                     pdv_get_cameratype(pdv_p),
00885                     pdv_get_width(pdv_p),
00886                     pdv_get_height(pdv_p),
00887                     pdv_get_depth(pdv_p),
00888                     header_size,
00889                     imagesize);
00890     }
00891 
00892     if (do_ring)
00893     {
00894         if (pdv_p->dd_p->force_single)
00895         {
00896             pdv_start_image(pdv_p);
00897             started = 1;
00898         }
00899         else if (do_lasttest)
00900         {
00901             /* start freerun */
00902             pdv_start_images(pdv_p, 0);
00903         }
00904         else if (wait_for_enter)
00905         {
00906             printf("hit enter for first image");
00907             getchar();
00908             pdv_start_images(pdv_p, 1);
00909             started = 1;
00910         }
00911         else
00912         {
00913             pdv_start_images(pdv_p, numbufs);
00914             started = numbufs;
00915         }
00916     }
00917     if (do_lasttest)
00918     {
00919         for (;;)
00920         {
00921             int     ret;
00922             u_char  tmpbuf[80];
00923 
00924 #if 0
00925             printf("return to check");
00926             getchar();
00927 #endif
00928             take_printf("%d done count %x\n", edt_done_count(pdv_p), edt_get_bytecount(pdv_p));
00929             edt_send_msg(pdv_p, 0, "w a07a 6", 8);
00930             ret = edt_serial_wait(pdv_p, 1000, 0);
00931             if (ret > 0)
00932             {
00933                 take_printf("got %d resp\n", ret);
00934                 edt_get_msg(pdv_p, (char *) tmpbuf, sizeof(tmpbuf));
00935                 take_printf("resp %x %x %x\n", tmpbuf[0], tmpbuf[1], tmpbuf[2]);
00936                 if (tmpbuf[2])
00937                 {
00938                     printf("got %s - return to continue", &tmpbuf[2]);
00939                     getchar();
00940                 }
00941             }
00942             else
00943             {
00944                 printf("bad resp from serial wait %d\n", ret);
00945                 getchar();
00946             }
00947             edt_send_msg(pdv_p, 0, "w a07a 4", 8);
00948             ret = edt_serial_wait(pdv_p, 1000, 0);
00949             if (ret > 0)
00950             {
00951                 printf("got %d resp\n", ret);
00952                 edt_get_msg(pdv_p, (char *) tmpbuf, sizeof(tmpbuf));
00953                 printf("resp %x %x %x\n", tmpbuf[0], tmpbuf[1], tmpbuf[2]);
00954                 if (tmpbuf[2])
00955                 {
00956                     printf("got %s - return to continue", &tmpbuf[2]);
00957                     getchar();
00958                 }
00959             }
00960             else
00961             {
00962                 printf("bad resp from serial wait %d\n", ret);
00963                 getchar();
00964             }
00965         }
00966     }
00967     done = 0;
00968     (void) edt_dtime();         /* init time for check */
00969     for (lc = 0; lc < loops && !GetOut; lc++)
00970     {
00971         if (wait_for_enter)
00972         {
00973             printf("hit enter for next image");
00974             getchar();
00975         }
00976 
00977         if (do_ring)
00978         {
00979 
00980             if (do_timestamp)
00981             {
00982                 imagebuf = pdv_wait_image_timed(pdv_p, timestamp);
00983                 switch (timetype)
00984                 {
00985                     case EDT_TM_SEC_NSEC:
00986                         /* secs, nsec */
00987                         curtime = (double) timestamp[0] * 1000000000L + timestamp[1];
00988                         curtime /= 1000000000.0;
00989                         break;
00990                     case EDT_TM_CLICKS:
00991                         /* cpu cycles high32/low32 */
00992                         curtime = (double) timestamp[0] * FOURGB + timestamp[1];
00993                         break;
00994                     case EDT_TM_COUNTER:
00995                         /* counter high32/low32 */
00996                         curtime = (double) timestamp[0] * FOURGB + timestamp[1];
00997                         curtime /= frequency;
00998                         break;
00999                 }
01000                 take_printf("\ntime %3.9f ", curtime);
01001                 if (svtime > 0)
01002                 {
01003                     take_printf(" delta %3.9f ", (curtime - svtime));
01004                 }
01005                 svtime = curtime;
01006             }
01007             else
01008                 imagebuf = pdv_wait_image(pdv_p);
01009             ++waited;
01010         }
01011         else
01012         {
01013             if (wait_for_enter && done == 0)
01014             {
01015                 printf("hit enter for first image");
01016                 getchar();
01017             } 
01018 
01019             bytesread = pdv_read(pdv_p, imagebuf, dmasize);
01020 
01021             if (bytesread != dmasize)
01022             {
01023                 printf("dmasize 0x%x read 0x%x\n", dmasize, bytesread);
01024             }
01025             if (bytesread < 0)
01026             {
01027                 pdv_perror(edt_devname);
01028                 exit(1);
01029             }
01030         }
01031         if (checkfrm)
01032             pdv_checkfrm(pdv_p, (u_short *) imagebuf, width * height, verbose);
01033         timeouts = pdv_timeouts(pdv_p);
01034         if ((overrun = (edt_reg_read(pdv_p, PDV_STAT) & PDV_OVERRUN)))
01035         {
01036             ++overruns;
01037         }
01038 
01039         if (timeouts > last_timeouts)
01040         {
01041             bytesread = edt_get_timeout_count(pdv_p);
01042             if (debug_timeout)
01043             {
01044                 FILE   *tmpf;
01045 
01046                 tmpf = fopen("timeout.raw", "wb");
01047                 if (tmpf)
01048                 {
01049                     printf("saving timeout data\n");
01050                     fwrite(imagebuf, imagesize, 1, tmpf);
01051                     fclose(tmpf);
01052                 }
01053                 printf("got timeout xfer %d - return to continue: ",
01054                         edt_get_bytecount(pdv_p));
01055                 getchar();
01056             }
01057 
01058             /*
01059              * pdv_timeout_cleanup recovers from the timeout, in particular
01060              * when you've prestarted multiple buffers returns how many
01061              * buffers were pending before the reset so we can restart that
01062              * many again
01063              */
01064             if (do_ring)
01065             {
01066                 pdv_timeout_restart(pdv_p,TRUE);
01067                 in_timeout_cleanup = TRUE;
01068             }
01069 
01070             last_timeouts = timeouts;
01071             rbtimeout = 1;
01072 
01073         }
01074         else if (in_timeout_cleanup)
01075         {
01076             pdv_timeout_restart(pdv_p,TRUE);
01077             in_timeout_cleanup = FALSE;
01078         }
01079 
01080         done++;
01081 
01082         if (verbose)
01083         {
01084             int     j;
01085             u_char *tmp_p;
01086             int     lastval = 0;
01087 
01088             tmp_p = imagebuf;
01089 
01090             for (j = 0; j < 16; j++)
01091                 take_printf("%02x ", imagebuf[j]);
01092             take_printf("\n");
01093             for (j = imagesize - 16; j < imagesize; j++)
01094                 take_printf("%02x ", imagebuf[j]);
01095             take_printf("\n");
01096             if (checkclk)
01097             {
01098                 for (j = 0; j < 512; j++)
01099                 {
01100                     static int k = 0;
01101                     u_short tmpval = tmp_p[1] << 8 | tmp_p[0];
01102 
01103                     if (tmpval != lastval + 1)
01104                         printf("*");
01105                     else
01106                         printf(" ");
01107                     lastval = tmpval;
01108 
01109                     printf("%04x", tmpval);
01110 
01111                     if ((++k % 16) == 0)
01112                         printf("\n");
01113                     tmp_p += 4;
01114                 }
01115                 printf("\n");
01116             }
01117         }
01118         /*
01119          * check signature pixels from PCI CD simulator if -p or -P flag
01120          * specified -- expects first and last pixel to be count if -p, or
01121          * 0xA5 and 0x5A,  if -P, bombs out on first frame where this is not
01122          * the case
01123          */
01124         if (checksig || checkcount || checksim || checkclsim)
01125         {
01126             u_short bitmask = 0;
01127 
01128             for (i = 0; i < s_depth; i++)
01129                 bitmask += 1 << i;
01130 
01131             /*
01132              * signature counter -- pick up the first one we come to
01133              */
01134             if (checkcount)
01135             {
01136                 if (!siginit)
01137                 {
01138                     startsig = endsig = sigcount = ((u_short *) imagebuf)[0] & bitmask;
01139                     siginit = 1;
01140                 }
01141                 else
01142                     startsig = endsig = sigcount & bitmask;
01143                 ++sigcount;
01144             }
01145             if (checksim)
01146             {
01147                 if (!siginit)
01148                 {
01149                     u_short *sp = (u_short *) imagebuf;
01150 
01151                     startsig = sp[0];
01152                     endsig = sp[(imagesize / 2) - 1];
01153                     siginit = 1;
01154                 }
01155                 else
01156                 {
01157                     startsig ^= 0xffff;
01158                     endsig ^= 0xffff;
01159                 }
01160             }
01161             if (checkclsim)
01162             {
01163                 if (!siginit)
01164                 {
01165                     u_short *sp = (u_short *) imagebuf;
01166 
01167                     startsig = sp[0];
01168                     /* find 3333 */
01169                     if (sp[1] == 0x3333)
01170                         printf("init start  to %04x\n", startsig) ;
01171                     else
01172                         printf("buf is already not aligned\n") ;
01173 
01174                     siginit = 1;
01175                 }
01176                 else
01177                 {
01178                     if (startsig == 0x7fff) startsig = 0 ;
01179                     else startsig = startsig + 1 ;
01180                 }
01181             }
01182 
01183 
01184             if (depth > 8 || checkclsim)
01185             {
01186                 u_short *sp = (u_short *) imagebuf;
01187                 u_short firstword = sp[0];
01188 
01189                 /*
01190                  * -4 because of one test xilinx which went into grid mode
01191                  * when fifo empty
01192                  */
01193                 u_short lastword = sp[(imagesize / 2) - 4];
01194 
01195                 if (checkclsim)
01196                 {
01197                     u_int frmcnt = pdv_cl_get_fv_counter(pdv_p) ;
01198                     int k ;
01199 
01200                     if (firstword != startsig)
01201                         badstart = 1;
01202                     k = 0 ;
01203                     /* deal with 3333rd image */
01204                     if (sp[0] == 0x3333 && sp[1] == 0x3333) k = 1 ;
01205                     for (; k < imagesize/2 ; k++)
01206                     {
01207                         if (sp[k] == 0x3333)
01208                         {
01209                             if (k != 1)
01210                             {
01211                                 printf("image1 3333 at %x\n",k) ;
01212                                 badend = 1 ;
01213                             }
01214                             printf("frm %x count %04x stat %04x reg %08x\n",
01215                                     frmcnt,
01216                                     sp[k-1],
01217                                     edt_reg_read(pdv_p,PDV_STAT),
01218                                     edt_reg_read(pdv_p,PDV_CL_JERRYDBG)) ;
01219                             break ;
01220                         }
01221                     }
01222                 }
01223                 else
01224                 {
01225                     if (firstword != startsig)
01226                         badstart = 1;
01227                     if (lastword != endsig)
01228                         badend = 1;
01229                 }
01230 
01231                 if (badstart || badend)
01232                 {
01233                     u_char **buf = edt_buffer_addresses(pdv_p);
01234 
01235                     printf("\n\nstat %04x reg %08x\n",
01236                             edt_reg_read(pdv_p,PDV_STAT),
01237                             edt_reg_read(pdv_p,PDV_CL_JERRYDBG)) ;
01238 
01239                     /*
01240                      * if we just missed a frame, report it and go on
01241                      */
01242                     if (checksim
01243                             && (firstword == (startsig ^ 0xffff))
01244                             && (lastword == (endsig ^ 0xffff)))
01245                     {
01246                         printf("\nMISSED a frame! start %04x s/b %04x, end %04x s/b %04x\n", firstword, startsig, lastword, endsig);
01247                         printf("buffers %d donecount %d PDV_STAT %02x\n",
01248                                 waited, edt_done_count(pdv_p), edt_reg_read(pdv_p, PDV_STAT));
01249                         startsig ^= 0xffff;
01250                         endsig ^= 0xffff;
01251                     }
01252                     else
01253                     {
01254                         printf("\nbad signature! start %04x s/b %04x, end %04x s/b %04x\n",
01255                                 firstword, startsig, lastword, endsig);
01256                         printf("bad buf addr at %p %04x %04x\n", sp, firstword, lastword);
01257                         printf("buffers %d donecount %d PDV_STAT %02x\n",
01258                                 waited, edt_done_count(pdv_p), edt_reg_read(pdv_p, PDV_STAT));
01259 
01260                         edt_stop_buffers(pdv_p);
01261 
01262                         sprintf(cmdstr,"setdebug -d 0 -u %d -g >setdebug.out\n",unit);
01263                         printf("%s\n",cmdstr) ;
01264                         system(cmdstr) ;
01265 
01266 
01267                         printf("dumping %d buffers to buf01.raw, buf02.raw, ....\n",
01268                                 numbufs);
01269                         for (i = 0; i < numbufs; i++)
01270                         {
01271                             char    bufname[32];
01272 
01273                             sprintf(bufname, "buf%02d.raw", i);
01274                             printf("dump buf %d from %p\n", i, buf[i]);
01275                             dumpbuf(bufname, (u_short *) buf[i], imagesize);
01276                         }
01277 
01278                         printf("return to continue");
01279                         getchar();
01280                         if (!(checkcount||checkclsim))
01281                         {
01282                             for (i = 0; i < imagesize / 2; i++)
01283                                 if (((sp[i] & bitmask) == startsig)
01284                                         || (sp[i] & bitmask) == endsig)
01285                                     printf("found %04x at %d\n", sp[i], i);
01286                         }
01287                         exit(1);
01288                     }
01289                 }
01290                 /*
01291                  * sp[0] = 0xaaaa ; sp[imagesize/2 - 1] = 0x5555 ;
01292                  */
01293             }
01294             else
01295             {
01296                 u_char *cp = imagebuf;
01297 
01298                 if (cp[0] != startsig)
01299                     badstart = 1;
01300                 if (cp[imagesize - 1] != endsig)
01301                     badend = 1;
01302                 if (badstart || badend)
01303                 {
01304                     printf("\nbad signature! start %02x s/b %02x, end %02x s/b %02x\n",
01305                             cp[0], startsig, cp[imagesize-1], endsig);
01306 
01307                     if (!checkcount)
01308                     {
01309                         for (i = 0; i < imagesize; i++)
01310                             if ((cp[i] == startsig)
01311                                     || (cp[i] == endsig))
01312                                 printf("found %02x at %d\n", cp[i], i);
01313                     }
01314                     exit(1);
01315                 }
01316             }
01317         }
01318         if (do_ring && started < loops)
01319         {
01320             if (!do_lasttest)
01321             {
01322                 pdv_start_images(pdv_p, 1);
01323             }
01324             started++;
01325         }
01326 
01327         /*
01328          * process subimage if needed, set up args for write
01329          */
01330         if (do_file && (subimage != NULL))
01331         {
01332             crop_and_subsample(subsample, width, height,
01333                     crop_x0, crop_y0, crop_x1, crop_y1, imagebuf, subimage);
01334             image_p = subimage;
01335         }
01336         else
01337             image_p = imagebuf;
01338 
01339 
01340         if (pdv_p->dd_p->fval_done)
01341         {       
01342             int lines = pdv_get_lines_xferred(pdv_p);
01343             s_size = s_width * lines * s_db;
01344         }
01345 
01346         /*
01347          * write the image to raw data file (no formatting)
01348          */
01349         sumsize += s_size;
01350 
01351         if (*rawfname)
01352         {
01353             resolve_fname(rawfname, tmpname, loops, ".raw");
01354             take_printf("writing %dx%dx%d raw file to %s (actual size %d)\n",
01355                     s_width, s_height, s_depth, tmpname, s_size);
01356 
01357             (void) dvu_write_raw(s_size, image_p, tmpname);
01358         }
01359 
01360 #if DO_JPEG
01361         if (*jpgfname)
01362         {
01363             char filename[256];
01364 
01365             if ((strcmp(&jpgfname[strlen(jpgfname) - 4], ".jpg") == 0)
01366             || (strcmp(&jpgfname[strlen(jpgfname) - 4], ".JPG") == 0))
01367                 jpgfname[strlen(jpgfname)] = '\0';
01368                 sprintf(filename, "%s%02d.jpg", jpgfname, i);
01369 
01370             edt_save_jpeg(filename, width, height, bits2bytes(depth), 0, image_p);
01371         }
01372 #endif
01373 
01374         /*
01375          * write the image to Windows bitmap format file and
01376          * fix up the filename extension
01377          */
01378         if (*bmpfname && !mosaic)
01379         {
01380             resolve_fname(bmpfname, tmpname, loops, ".bmp");
01381             if (write_bmp_file(tmpname, image_p,
01382                     s_width, s_height, s_depth) != 0)
01383                         printf("file write failed\n");
01384         }
01385         else if (mosaic)
01386         {
01387             memcpy(mosaic_ptr, image_p, mosaic_sample);
01388             mosaic_ptr += mosaic_sample;
01389         }
01390 
01391         dl = pdv_debug_level();
01392 
01393         if (rbtimeout)
01394         {
01395             if (bytesread == 0)
01396                 take_printf("%d images %d timeouts %d overruns 0 bytes", done, timeouts, overruns);
01397             else take_printf("%d images %d timeouts %d overruns %d bytes (%d short)", done, timeouts, overruns, bytesread, dmasize-bytesread);
01398         }
01399         else if (just_print_the_last_one)
01400         {
01401             if (lc == loops-1)
01402                 take_printf("%d images %d timeouts %d overruns\n", done, timeouts, overruns);
01403         }
01404         else take_printf("%d images %d timeouts %d overruns", done, timeouts, overruns);
01405 
01406         if (!just_print_the_last_one)
01407         {
01408             if (verbose | rbtimeout | wait_for_enter | (pdv_debug_level() > 0))
01409                 take_printf("\n");
01410             else take_printf("                                \r");
01411         }
01412 
01413         rbtimeout = 0;
01414         fflush(stdout);
01415     }
01416     take_printf("\n");
01417 
01418     if (mosaic && *bmpfname)
01419     {
01420         if (write_bmp_file(bmpfname, mosaic_image,
01421                 s_width, mosaic_height, s_depth) != 0)
01422                         printf("file write failed\n");
01423     }
01424    
01425     if (loops > 3)
01426     {
01427         dtime = edt_dtime();
01428         printf("%lf bytes/sec\n", sumsize / dtime);
01429         printf("%lf frames/sec\n", (double) (loops) / dtime);
01430     }
01431 
01432     if (!do_ring)
01433         pdv_free(imagebuf);
01434     /* else */
01435     pdv_stop_continuous(pdv_p);
01436 
01437     if (binning)
01438     {
01439         pdv_set_binning(pdv_p, 1, 1);
01440     }
01441 
01442     pdv_close(pdv_p);
01443 #ifdef NO_MAIN
01444     if (overruns || timeouts)
01445         return (2);
01446     return (0);
01447 #else
01448     if (overruns || timeouts)
01449         exit(2);
01450     exit(0);
01451 #endif
01452 }
01453 
01454     void
01455 resolve_fname(char *fname, char *newname, int loops, char *ext)
01456 {
01457     int     l = (int)strlen(fname);
01458     char    tmpname[256];
01459     char    tmpext[5];
01460 
01461     strcpy(tmpname, fname);
01462     if ((l > 4) && (tmpname[l - 4] == '.'))
01463     {
01464         strcpy(tmpext, &tmpname[l - 4]);
01465         tmpname[l - 4] = '\0';
01466     }
01467     else
01468         strcpy(tmpext, ext);
01469 
01470     if (loops > 1)
01471     {
01472         sprintf(newname, "%s%04d%s", tmpname, ASnum, tmpext);
01473         ASnum += ASinc;
01474     }
01475     else
01476         sprintf(newname, "%s%s", tmpname, tmpext);
01477 }
01478 
01479 
01480 /*
01481  * process the image, return in subimage. Handles both subsampling and
01482  * cropping.
01483  * 
01484  * NOTE: this only works on single-byte images (so far)
01485  */
01486 
01487     void
01488 crop_and_subsample(int subsample, int src_width, int src_height,
01489         int x0, int y0, int x1, int y1, u_char * src, u_char * dst)
01490 {
01491     u_char *next_fromptr = src + (y0 * src_width) + x0;
01492     int     to_width = (x1 - x0) + 1;
01493     int     lines = (y1 - y0) + 1;
01494     u_char *to = dst;
01495     u_char *from;
01496     u_char *from_end;
01497 
01498     while (lines > 0)
01499     {
01500         from = (u_char *) next_fromptr;
01501         from_end = from + to_width;
01502 
01503         while (from < from_end)
01504         {
01505             *to++ = *from;
01506             from += subsample;
01507         }
01508         next_fromptr += src_width * subsample;
01509         lines -= subsample;
01510     }
01511 }
01512 
01513 
01514     void
01515 usage(char *progname, char *errmsg, int exitval)
01516 {
01517     printf("\n");
01518     printf("%s", errmsg);
01519     printf("\n%s: Image acquisition and optional save for EDT PCI DV family digital\n", progname);
01520     printf("DMA interface products. Many options make it useful for diagnostics and\n");
01521     printf("also as an example for various methods of doing acquisition with EDT PCI DV\n");
01522     printf("family products. For a much a simpler example, see simple_take.c\n\n");
01523     printf("usage: %s\n", progname);
01524     printf("  -e exposuretime   - set exposure time before acquiring (if supported)\n");
01525     printf("  -g gain           - set camera gain (if supported)\n");
01526     printf("  -o offset         - set camera offset (if supported)\n");
01527     printf("  -l loopcount      - loop for loopcount images\n");
01528     printf("  -m msecs          - delay msecs milliseconds between images\n");
01529     printf("  -f out_fname      - output to raw file(s)\n");
01530     printf("  -b fname.bmp      - output to Microsoft bitmap file(s)\n");
01531 #ifdef DO_JPEG
01532     printf("  -j fname.jpg      - output to jpeg format file(s)\n");
01533 #endif
01534     printf("  -C x0 y0 x1 y1    - crop the output image to the coordinates given\n");
01535     printf("  -N n              - number of multiple buffers (default 4, 0 forces pdv_read()\n");
01536     printf("  -r [hs ha vs va]  - region of interest -- to disable use -r alone (no subargs)\n");
01537     printf("  -t [msecs]        - timeout # of msecs. if 0, disables timeouts, if no subarg,\n");
01538     printf("  -T                - if image times out, dump any recieved data to timeout.raw\n");
01539     printf("                        re-enables auto timeouts\n");
01540     printf("  -w                - wait for <CR> between images\n");
01541     printf("  -s start inc      - specify start and increment for auto-numbered file-\n");
01542     printf("                        names (use with -l of 2 or more for auto-numbered filenames)\n");
01543     printf("  -I inc            - specify increment for auto-numbered file (see -s)\n");
01544     printf("  -v                - verbose output\n");
01545     printf("  -q binval         - set binning (applicable cameras only)\n");
01546     printf("  -p                - check pci dv simulator signature, exit if bad\n");
01547     printf("  -d                - get and print a driver timestamp with every image\n");
01548     printf("  -J                - just output the last take line (for output to file)\n");
01549     printf("  -c channel        - channel # if multiple channels (2nd base Camera Link\n");
01550     printf("                        connector or multiple RCI units on one FOI card (default 0)\n");
01551     printf("  -u unit           - pdv unit number (default 0)\n");
01552     printf("                        A full device pathname can also be used\n");
01553     printf("  -B                - turn off burst enable\n");
01554     printf("  -X                - use timer\n");
01555     printf("  -L                - freerun/bytecount with wait for next frame\n");
01556     printf("  -H                - check count signature from testgen\n");
01557     printf("  -P                - check count signature from PCI CD sim\n");
01558     printf("  -G                - check count signature from testgen\n");
01559     printf("  -Q                - turn on quiet mode\n");
01560     printf("  -n                - autosequence start only\n");
01561     printf("  -R                - disable ROI\n");
01562     printf("  -O                - try noreset - will be obsolete on clink?\n");
01563     printf("  -x                - experimental - strobe testing\n");
01564     printf("  -M                - mosaic\n");
01565     printf("  -a                - call pdv_checkfrm\n");
01566     printf("  -D                - dvc mode setting - diagnostic\n");
01567     printf("  -y                - turns on triggering through the optical coupler\n");
01568     printf("  -Y                - turns on triggering via the field id\n");
01569     printf("  -h                - this help message\n");
01570     exit(exitval);
01571 }

Generated on 19 Jun 2015 by  doxygen 1.4.7