readcfg.c

Go to the documentation of this file.
00001 
00011 #include "edtinc.h"
00012 #include "initcam.h"
00013 #include <string.h>
00014 
00015 #define COMPARE(str1, str2) (strcasecmp(str1, str2) == 0)
00016 
00017 
00018 u_char *xilinx;                 /* pointer to programmable Xilinx area */
00019 int     nser = 0;
00020 
00021 void clear_dependent(Dependent * dd_p);
00022 int check_method_param(char *s, Dependent * dd_p, Edtinfo * ei_p, const char *cfgfile);
00023 int check_other_param(char *s, Dependent * dd_p, const char *cfgfile);
00024 int check_xilinx_param(char *s, Dependent * dd_p, const char *cfgfile);
00025 int check_cls_param(char *s, Dependent * dd_p, const char *cfgfile);
00026 int is_method(char *method_type, char *name);
00027 void strip_ctrlm(char *s);
00028 void strip_extra_whitespace(char *s);
00029 int resolve_cameratype(Dependent *dd_p);
00030 
00031 
00032 /* utility routine for embedded (nofs) config file arrays -- copies and changes '\"' to '"'*/
00033 char *
00034 get_next_string(int nofs_cfg, FILE *cfg_fp, char *ss, char *ds)
00035 {
00036 #ifdef NO_FS
00037     char *dp = ds;
00038     char *sp ;
00039     if (nofs_cfg)
00040     {
00041         sp = ss;
00042         if (!*sp)
00043             return 0;
00044 
00045         while(*sp)
00046         {
00047             if ((*sp == '\\') && (*(sp+1) == '\"'))
00048                 ++sp;
00049             *dp++ = *sp++;
00050         }
00051         *dp = '\0';
00052 
00053         return (char *)ds;
00054     }
00055     else
00056 #endif
00057     
00058     return fgets(ds, 255, cfg_fp);
00059 }
00060 
00061 
00062 #ifdef NO_FS
00063 /*
00064  * embedded config files, for 
00065  */
00066 #include "nofs_config.h"
00067 #endif
00068 
00069 
00070 char *dmy_cfg[] = {""};
00071 
00072 void
00073 dep_set_default(PdvDependent * dd_p)
00074 
00075 {
00076     int i;
00077 
00078    /*
00079      * clear dependent struct and set defaults to nonsense values
00080      */
00081     clear_dependent(dd_p);
00082     dd_p->rbtfile[0] = '\0';
00083     dd_p->cameratype[0] = '\0';
00084     dd_p->shutter_speed = NOT_SET;
00085     dd_p->default_shutter_speed = NOT_SET;
00086     dd_p->default_gain = NOT_SET;
00087     dd_p->default_offset = NOT_SET;
00088     dd_p->default_aperture = NOT_SET;
00089     dd_p->binx = 1;
00090     dd_p->biny = 1;
00091     dd_p->byteswap = NOT_SET;
00092     dd_p->serial_timeout = 1000;
00093     dd_p->serial_response[0] = '\r';
00094     dd_p->xilinx_rev = NOT_SET;
00095     dd_p->timeout = NOT_SET;
00096     dd_p->user_timeout = NOT_SET;
00097     dd_p->mode_cntl_norm = NOT_SET;
00098     dd_p->mc4 = 0;
00099     dd_p->pulnix = 0;
00100     dd_p->dbl_trig = 0;
00101     dd_p->shift = NOT_SET;
00102     dd_p->mask = 0xffff;
00103     dd_p->mode16 = NOT_SET;
00104     dd_p->serial_baud = NOT_SET;
00105     dd_p->serial_waitc = NOT_SET ;
00106     dd_p->serial_format = SERIAL_ASCII;
00107     strcpy(dd_p->serial_term, "\r");    /* term for most ASCII exc. ES4.0 */
00108     
00109     dd_p->kbs_red_row_first = 1;
00110     dd_p->kbs_green_pixel_first = 0;
00111   
00112 
00113     dd_p->htaps = NOT_SET;
00114     dd_p->vtaps = NOT_SET;
00115 
00116     dd_p->cameralink = 0;
00117     dd_p->start_delay = 0;
00118     dd_p->frame_period = NOT_SET;
00119     dd_p->frame_timing = NOT_SET;
00120 
00121     dd_p->strobe_enabled = NOT_SET;
00122     dd_p->register_wrap = 0;
00123     dd_p->serial_init_delay = NOT_SET;
00124 
00125     dd_p->irig_offset = 2;
00126 
00127     /*
00128      * xregwrite registers can be 0-ff. We need a way to flag the
00129      * end of the array, so just waste ff and call that "not set"
00130      */
00131     for (i=0; i<32; i++)
00132         dd_p->xilinx_flag[i] = 0xff;
00133 
00134 }
00135 
00136 int
00137 readcfg(const char *cfgfile, Dependent * dd_p, Edtinfo * ei_p, int nofs_cfg)
00138 {
00139 
00140 
00141     int     ret;
00142     char    **vx_p = dmy_cfg;
00143     FILE   *cfg_fp;
00144     char    s[256];
00145     char    *sp;
00146     int     lineno = 0;
00147     Edtinfo ei;
00148 #ifdef NO_FS
00149     char    *cf;
00150 #endif
00151 
00152     edt_msg(DEBUG2, "Reading/processing config file %s:\n\n", cfgfile);
00153 
00154     if (ei_p == NULL)
00155         ei_p = &ei;
00156 
00157     if (!nofs_cfg)
00158     {
00159         /*
00160          * Read and process the configuration file for this camera.
00161          */
00162         if ((cfg_fp = fopen(cfgfile, "r")) == NULL)
00163         {
00164             perror(cfgfile);
00165             return -1;
00166         }
00167     }
00168 
00169     dep_set_default(dd_p);
00170 
00171     ei_p->startdma = NOT_SET;
00172     ei_p->enddma = NOT_SET;
00173     ei_p->flushdma = NOT_SET;
00174 
00175      dd_p->startdma = NOT_SET;
00176     dd_p->enddma = NOT_SET;
00177     dd_p->flushdma = NOT_SET;
00178    
00179 
00180     strncpy(dd_p->cfgname, cfgfile, sizeof(dd_p->cfgname) - 1);
00181  
00182 #ifdef NO_FS
00183     if (nofs_cfg)
00184     {
00185         char *p;
00186 
00187         if ((cf = strrchr(cfgfile, '/')) != NULL)
00188             ++cf;
00189         else cf = cfgfile;
00190         p = cf;
00191 
00192         if ((strlen(cf) > 4) && (strcasecmp(&cf[strlen(cf)-4], ".cfg") == 0))
00193             cf[strlen(cf)-4] = '\0';
00194 
00195         /*
00196          * change dashes to underscores in name, to match variable names
00197          */
00198         do
00199         {
00200             if (*p == '-')
00201                 (*p = '_');
00202         } while(*(++p));
00203         MAPCONFIG(cf, vx_p); /* macro in nofs_config.h */
00204 
00205         if (vx_p == NULL)
00206         {
00207             printf("embedded specified, but no header file for '%s' included in source (nofs_config.h)\n", cf);
00208             exit(1);
00209         }
00210     }
00211 #endif
00212 
00213     while (get_next_string(nofs_cfg, cfg_fp, *vx_p, s))
00214     {
00215         char tmpstr[256];
00216         if (nofs_cfg)
00217             ++vx_p;
00218 
00219         lineno++;
00220 
00221         /* debug string printf */
00222         if (s[strlen(s)-1] == '\n')
00223             strcpy(tmpstr, s);
00224         else sprintf(tmpstr, "%s\n", s);
00225         edt_msg(DEBUG2, tmpstr);
00226 
00227         if (*s == '#' || *s == '\n' || *s == '\r')
00228             continue;
00229 
00230         strip_ctrlm(s);
00231         strip_extra_whitespace(s);
00232 
00233         if (*s == '#' || *s == '\n' || *s == '\r')
00234             continue;
00235 
00236         if ((ret = check_method_param(s, dd_p, ei_p, cfgfile)) < 0)
00237             return -1;
00238         if (ret == 1)
00239             continue;
00240 
00241         if ((ret = check_xilinx_param(s, dd_p, cfgfile)) < 0)
00242             return -1;
00243         if (ret == 1)
00244             continue;
00245 
00246         if ((ret = check_other_param(s, dd_p, cfgfile)) < 0)
00247             return -1;
00248 
00249         if (ret == 1)
00250             continue;
00251 
00252         if ((ret = check_cls_param(s, dd_p, cfgfile)) < 0)
00253             return -1;
00254 
00255         if (ret == 1)
00256             continue;
00257 
00258         {
00259             char    kw[256];
00260 
00261             sscanf(s, "%s", kw);
00262             edt_msg(DEBUG0, "WARNING: unrecognized argument \"%s\" line %d (ignored)\n", kw, lineno);
00263         }
00264     }
00265 
00266 #ifndef NO_FS
00267     fclose(cfg_fp);
00268 #endif
00269 
00270     /*
00271      * the cameratype directive (not the parameter though) is obsolete
00272      * so make it up from class and model if they are present (should be!)
00273      */
00274     resolve_cameratype(dd_p);
00275 
00276     /* deal with no taps/depth fields */
00277 
00278     if (dd_p->cl_data_path && dd_p->cls.taps == 0)
00279         dd_p->cls.taps = ((dd_p->cl_data_path >> 4) & 0xf) + 1;
00280 
00281     /*
00282      * pdv uses .bit files, not .rbt files, but some older config
00283      * might still reference the old extension
00284      */
00285     if (dd_p->rbtfile[0])
00286     {
00287         if ((sp = strrchr(dd_p->rbtfile, '.')) == NULL)
00288             sp = strchr(dd_p->rbtfile, '\0');
00289         if ((sp != NULL) && ((strcmp(sp, ".rbt") == 0) || (*sp == '\0')))
00290             sprintf(sp, ".bit");
00291     }
00292 
00293     return 0;
00294 }
00295 
00313 int
00314 pdv_readcfg(const char *cfgfile, Dependent * dd_p, Edtinfo *ei_p)
00315 {
00316     return readcfg(cfgfile, dd_p, ei_p, 0);
00317 }
00318 
00319 int
00320 pdv_readcfg_emb(char *cfgfile, Dependent * dd_p, Edtinfo *ei_p)
00321 {
00322     return readcfg(cfgfile, dd_p, ei_p, 1);
00323 }
00324 
00325 
00326 int
00327 translate_method_arg(char *method_arg, int *method_number)
00328 {
00329     /* Translate the method_arg to a method number */
00330     if (COMPARE(method_arg, "AIA_MCL_100US"))
00331         *method_number = AIA_MCL_100US;
00332     else if (COMPARE(method_arg, "AIA_MCL"))
00333         *method_number = AIA_MCL;
00334     else if (COMPARE(method_arg, "AIA_TRIG"))
00335         *method_number = AIA_TRIG;
00336     else if (COMPARE(method_arg, "KODAK_AIA_MCL"))
00337         *method_number = KODAK_AIA_MCL;
00338     else if (COMPARE(method_arg, "AIA_MC4"))
00339         *method_number = AIA_MC4;
00340     else if (COMPARE(method_arg, "HAMAMATSU_4880_8X"))
00341         *method_number = HAM_4880_8X;
00342     else if (COMPARE(method_arg, "HAMAMATSU_4880_SER"))
00343         *method_number = HAM_4880_SER;
00344     else if (COMPARE(method_arg, "SU320_SERIAL"))
00345         *method_number = SU320_SERIAL;
00346     else if (COMPARE(method_arg, "BASLER202K_SERIAL"))
00347         *method_number = BASLER202K_SERIAL;
00348     else if (COMPARE(method_arg, "ADIMEC_SERIAL"))
00349         *method_number = ADIMEC_SERIAL;
00350     else if (COMPARE(method_arg, "TIMC1001_SERIAL"))
00351         *method_number = TIMC1001_SERIAL;
00352     else if (COMPARE(method_arg, "PTM6710_SERIAL"))
00353         *method_number = PTM6710_SERIAL;
00354     else if (COMPARE(method_arg, "PTM1020_SERIAL"))
00355         *method_number = PTM1020_SERIAL;
00356     else if (COMPARE(method_arg, "PULNIX_TM1000"))
00357         *method_number = PULNIX_TM1000;
00358     else if (COMPARE(method_arg, "PULNIX_TM9700"))
00359         *method_number = PULNIX_TM9700;
00360     else if (COMPARE(method_arg, "IRC_160"))
00361         *method_number = IRC_160;
00362     else if (COMPARE(method_arg, "KODAK_AIA_SER_CTRL"))
00363         *method_number = KODAK_AIA_SER_CTRL;
00364     else if (COMPARE(method_arg, "AIA_SER_CTRL"))
00365         *method_number = AIA_SER_CTRL;
00366     else if (COMPARE(method_arg, "KODAK_AIA_SER"))
00367         *method_number = KODAK_AIA_SER;
00368     else if (COMPARE(method_arg, "SMD_SERIAL"))
00369         *method_number = SMD_SERIAL;
00370     else if (COMPARE(method_arg, "AIA_SER_ES40"))
00371         *method_number = AIA_SERIAL_ES40;
00372     else if (COMPARE(method_arg, "AIA_SER"))
00373         *method_number = AIA_SERIAL;
00374     else if (COMPARE(method_arg, "KODAK_SER_14I"))
00375         *method_number = KODAK_SER_14I;
00376     else if (COMPARE(method_arg, "SER_14I"))
00377         *method_number = KODAK_SER_14I;
00378     else if (COMPARE(method_arg, "SPECINST_SERIAL"))
00379         *method_number = SPECINST_SERIAL;
00380     else if (COMPARE(method_arg, "KODAK_XHF_INTLC"))
00381         *method_number = PDV_BYTE_INTLV;
00382     else if (COMPARE(method_arg, "BYTE_INTLV"))
00383         *method_number = PDV_BYTE_INTLV;
00384     else if (COMPARE(method_arg, "FIELD_INTLC"))
00385         *method_number = PDV_FIELD_INTLC;
00386     else if (COMPARE(method_arg, "BYTE_TEST1"))
00387         *method_number = PDV_BYTE_TEST1;
00388     else if (COMPARE(method_arg, "BYTE_TEST2"))
00389         *method_number = PDV_BYTE_TEST2;
00390     else if (COMPARE(method_arg, "BYTE_TEST3"))
00391         *method_number = PDV_BYTE_TEST3;
00392     else if (COMPARE(method_arg, "WORD_INTLV_HILO"))
00393         *method_number = PDV_WORD_INTLV_HILO;
00394     else if (COMPARE(method_arg, "WORD_INTLV_TOPBOTTOM"))
00395         *method_number = PDV_WORD_INTLV_TOPBOTTOM;
00396     else if (COMPARE(method_arg, "BYTE_INTLV_INOUT"))
00397         *method_number = PDV_BYTE_INTLV_INOUT;
00398     else if (COMPARE(method_arg, "WORD_INTLV_INOUT"))
00399         *method_number = PDV_WORD_INTLV_INOUT;
00400     else if (COMPARE(method_arg, "WORD_INTLV_ODD"))
00401         *method_number = PDV_WORD_INTLV_ODD;
00402     else if (COMPARE(method_arg, "ES10_WORD_INTLC"))
00403         *method_number = PDV_WORD_INTLV;
00404     else if (COMPARE(method_arg, "WORD_INTLV"))
00405         *method_number = PDV_WORD_INTLV;
00406     else if (COMPARE(method_arg, "DALSA_4CH_INTLV"))
00407         *method_number = PDV_DALSA_4CH_INTLV;
00408     else if (COMPARE(method_arg, "PIRANHA_4CH_INTLV"))
00409         *method_number = PDV_PIRANHA_4CH_INTLV;
00410     else if (COMPARE(method_arg, "PIRANHA_4CH_HWINTLV"))
00411         *method_number = PDV_PIRANHA_4CH_HWINTLV;
00412     else if (COMPARE(method_arg, "SPECINST_4PORT_INTLV"))
00413         *method_number = PDV_SPECINST_4PORT_INTLV;
00414     else if (COMPARE(method_arg, "ILLUNIS_INTLV"))
00415         *method_number = PDV_ILLUNIS_INTLV;
00416     else if (COMPARE(method_arg, "ES10_BGGR_INTLV"))
00417         *method_number = PDV_ES10_BGGR;
00418     else if (COMPARE(method_arg, "ES10_WORD_BGGR_INTLV"))
00419         *method_number = PDV_ES10_WORD_BGGR;
00420     else if (COMPARE(method_arg, "ES10_WORD_ODD_BGGR_INTLV"))
00421         *method_number = PDV_ES10_WORD_ODD_BGGR;
00422     else if (COMPARE(method_arg, "ILLUNIS_BGGR"))
00423         *method_number = PDV_ILLUNIS_BGGR;
00424     else if (COMPARE(method_arg, "QUADRANT_INTLV"))
00425         *method_number = PDV_QUADRANT_INTLV;
00426     else if (COMPARE(method_arg, "DALSA_2CH_INTLV"))
00427         *method_number = PDV_DALSA_2CH_INTLV;
00428     else if (COMPARE(method_arg, "INVERT_RIGHT_INTLV_24_12"))
00429         *method_number = PDV_INV_RT_INTLV_24_12;
00430     else if (COMPARE(method_arg, "INTLV_24_12"))
00431         *method_number = PDV_INTLV_24_12;
00432    else if (COMPARE(method_arg, "INTLV_1_8_MSB7"))
00433         *method_number = PDV_INTLV_1_8_MSB7;
00434    else if (COMPARE(method_arg, "INTLV_1_8_MSB0"))
00435         *method_number = PDV_INTLV_1_8_MSB0;
00436     else if (COMPARE(method_arg, "INVERT_RIGHT_INTLV"))
00437         *method_number = PDV_INVERT_RIGHT_INTLV;
00438     else if (COMPARE(method_arg, "INVERT_RIGHT_BGGR_INTLV"))
00439         *method_number = PDV_INVERT_RIGHT_BGGR_INTLV;
00440     else if (COMPARE(method_arg, "DALSA_2M30_INTLV"))
00441         *method_number = PDV_DALSA_2M30_INTLV;
00442     else if (COMPARE(method_arg, "EVEN_RIGHT_INTLV"))
00443         *method_number = PDV_EVEN_RIGHT_INTLV;
00444     else if (COMPARE(method_arg, "LINE_INTLV_P3_8X4"))
00445         *method_number = PDV_LINE_INTLV_P3_8X4;
00446     else if (COMPARE(method_arg, "BGGR_DUAL"))
00447         *method_number = PDV_BGGR_DUAL;
00448     else if (COMPARE(method_arg, "BGGR_WORD"))
00449         *method_number = PDV_BGGR_WORD;
00450     else if (COMPARE(method_arg, "BGGR"))
00451         *method_number = PDV_BGGR;
00452     else if (COMPARE(method_arg, "BGR_2_RGB"))
00453         *method_number = PDV_INTLV_BGR_2_RGB;
00454     else if (COMPARE(method_arg, "KODAK_XHF_SKIP"))
00455         *method_number = PDV_BYTE_INTLV_SKIP;
00456     else if (COMPARE(method_arg, "BYTE_INTLV_SKIP"))
00457         *method_number = PDV_BYTE_INTLV_SKIP;
00458     else if (COMPARE(method_arg, "HW_ONLY"))
00459         *method_number = HW_ONLY;
00460     else if (COMPARE(method_arg, "FMRATE_ENABLE"))
00461         *method_number = PDV_FMRATE_ENABLE;
00462     else if (COMPARE(method_arg, "FVAL_ADJUST"))
00463         *method_number = PDV_FVAL_ADJUST;
00464     else if (COMPARE(method_arg, "BASLER_202K"))
00465         *method_number = BASLER_202K;
00466     else if (COMPARE(method_arg, "DUNCAN_2131"))
00467         *method_number = DUNCAN_2131;
00468 
00469     else if (COMPARE(method_arg, "FOI_REMOTE_AIA"))
00470         *method_number = FOI_REMOTE_AIA;
00471 
00472     else if (COMPARE(method_arg, "DALSA_CONTINUOUS"))
00473         *method_number = DALSA_CONTINUOUS;
00474 
00475     else if (COMPARE(method_arg, "EDT_ACT_NEVER"))
00476         *method_number = EDT_ACT_NEVER;
00477     else if (COMPARE(method_arg, "EDT_ACT_ONCE"))
00478         *method_number = EDT_ACT_ONCE;
00479     else if (COMPARE(method_arg, "EDT_ACT_ALWAYS"))
00480         *method_number = EDT_ACT_ALWAYS;
00481     else if (COMPARE(method_arg, "EDT_ACT_ONELEFT"))
00482         *method_number = EDT_ACT_ONELEFT;
00483     else if (COMPARE(method_arg, "EDT_ACT_CYCLE"))
00484         *method_number = EDT_ACT_CYCLE;
00485     else if (COMPARE(method_arg, "EDT_ACT_KBS"))
00486         *method_number = EDT_ACT_KBS;
00487 
00488     else if (COMPARE(method_arg, "BINARY"))
00489         *method_number = SERIAL_BINARY;
00490     else if (COMPARE(method_arg, "ASCII_HEX"))
00491         *method_number = SERIAL_ASCII_HEX;
00492     else if (COMPARE(method_arg, "TOSHIBA_SERIAL"))
00493         *method_number = TOSHIBA_SERIAL;
00494     else if (COMPARE(method_arg, "COHU_SERIAL"))
00495         *method_number = COHU_SERIAL;
00496     else if (COMPARE(method_arg, "ASCII_NOSPACE"))
00497         *method_number = SERIAL_ASCII_NOSPACE;
00498     else if (COMPARE(method_arg, "ASCII"))
00499         *method_number = SERIAL_ASCII;
00500     else if (COMPARE(method_arg, "PULNIX_1010"))
00501         *method_number = SERIAL_PULNIX_1010;
00502     else if (COMPARE(method_arg, "DALSA_LS"))
00503         *method_number = PDV_DALSA_LS;
00504     else if (COMPARE(method_arg, "HEADER_BEFORE"))
00505         *method_number = HeaderBefore;
00506     else if (COMPARE(method_arg, "HEADER_AFTER"))
00507         *method_number = HeaderAfter;
00508     else if (COMPARE(method_arg, "HEADER_WITHIN"))
00509         *method_number = HeaderBegin;
00510     else if (COMPARE(method_arg, "HEADER_BEGIN"))
00511         *method_number = HeaderBegin;
00512     else if (COMPARE(method_arg, "HEADER_MIDDLE"))
00513         *method_number = HeaderMiddle;
00514     else if (COMPARE(method_arg, "HEADER_END"))
00515         *method_number = HeaderEnd;
00516     else if (COMPARE(method_arg, "DDCAM"))
00517         *method_number = PDV_DDCAM;
00518     else if (COMPARE(method_arg, "RS232"))
00519         *method_number = PDV_SERIAL_RS232;
00520     else if (COMPARE(method_arg, "BASLER_FRAMING"))
00521         *method_number = SERIAL_BASLER_FRAMING;
00522     else if (COMPARE(method_arg, "DUNCAN_FRAMING"))
00523         *method_number = SERIAL_DUNCAN_FRAMING;
00524     else if (COMPARE(method_arg, "IRIG1"))
00525         *method_number = HDR_TYPE_IRIG1;
00526     else if (COMPARE(method_arg, "FRAMECNT"))
00527         *method_number = HDR_TYPE_FRAMECNT;
00528     else if (COMPARE(method_arg, "IRIG2"))
00529         *method_number = HDR_TYPE_IRIG2;
00530     else
00531         return 0;
00532 
00533     return 1;
00534 }
00535 
00536 int
00537 check_label(char *str, char *label)
00538 {
00539     char    tmplabel[64];
00540 
00541     sprintf(tmplabel, "%s:", label);
00542     if (strncmp(str, tmplabel, strlen(tmplabel)) == 0)
00543         return 1;
00544     return 0;
00545 }
00546 
00547 int
00548 set_method(Dependent * dd_p, Edtinfo * ei_p, char *method_type, int method_number)
00549 {
00550     /* new for speed only */
00551     if (is_method(method_type, "camera_shutter_speed"))
00552         dd_p->camera_shutter_speed = method_number;
00553 
00554     /* ALERT: OBSOLETE */
00555     else if (is_method(method_type, "shutter_speed"))
00556         dd_p->camera_shutter_timing = method_number;
00557 
00558     else if (is_method(method_type, "camera_shutter_timing"))
00559         dd_p->camera_shutter_timing = method_number;
00560 
00561     else if (is_method(method_type, "lock_shutter"))
00562         dd_p->lock_shutter = method_number;
00563 
00564     else if (is_method(method_type, "camera_continuous"))
00565         dd_p->camera_continuous = method_number;
00566 
00567     else if (is_method(method_type, "camera_binning"))
00568         dd_p->camera_binning = method_number;
00569 
00570     else if (is_method(method_type, "camera_data_rate"))
00571         dd_p->camera_data_rate = method_number;
00572 
00573     else if (is_method(method_type, "pixelclock_speed")) /* alias */
00574         dd_p->camera_data_rate = method_number;
00575 
00576     else if (is_method(method_type, "camera_download"))
00577         dd_p->camera_download = method_number;
00578 
00579     else if (is_method(method_type, "get_gain"))
00580         dd_p->get_gain = method_number;
00581 
00582     else if (is_method(method_type, "get_offset"))
00583         dd_p->get_offset = method_number;
00584 
00585     else if (is_method(method_type, "set_gain"))
00586         dd_p->set_gain = method_number;
00587 
00588     else if (is_method(method_type, "set_offset"))
00589         dd_p->set_offset = method_number;
00590 
00591     else if (is_method(method_type, "first_open"))
00592         dd_p->first_open = method_number;
00593 
00594     else if (is_method(method_type, "last_close"))
00595         dd_p->last_close = method_number;
00596 
00597     else if (is_method(method_type, "interlace"))
00598     {
00599         if (method_number == PDV_PIRANHA_4CH_HWINTLV) /* special case hardware methods */
00600             dd_p->hwinterlace = method_number;
00601         else dd_p->swinterlace = method_number;
00602     }
00603     else if (is_method(method_type, "pingpong_varsize"))
00604         dd_p->pingpong_varsize = method_number;
00605 
00606     else if (is_method(method_type, "serial_format"))
00607         dd_p->serial_format = method_number;
00608 
00609     else if (is_method(method_type, "serial_mode"))
00610         dd_p->serial_mode = method_number;
00611 
00612     else if (is_method(method_type, "frame_timing"))
00613         dd_p->frame_timing = method_number;
00614 
00615     else if (is_method(method_type, "startdma"))
00616     {
00617         ei_p->startdma = method_number;
00618         dd_p->startdma = method_number;
00619     }
00620     else if (is_method(method_type, "enddma"))
00621     {
00622         ei_p->enddma = method_number;
00623         dd_p->enddma = method_number;
00624     }
00625 
00626     else if (is_method(method_type, "flushdma"))
00627     {
00628         ei_p->flushdma = method_number;
00629         dd_p->flushdma = method_number;
00630      }
00631 
00632     else if (is_method(method_type, "header_position"))
00633         dd_p->header_position = method_number;
00634 
00635     else if (is_method(method_type, "header_type"))
00636         dd_p->header_type = method_number;
00637 
00638     else
00639     {
00640         edt_msg(DEBUG0, "WARNING: unknown method direcive \"%s\" (ignored)\n", method_type);
00641         return 0;
00642     }
00643     return 1;
00644 }
00645 
00646 int
00647 is_method(char *method_type, char *name)
00648 {
00649     char    method_name[64];
00650 
00651     sprintf(method_name, "method_%s", name);
00652     if (COMPARE(method_name, method_type))
00653         return 1;
00654     return 0;
00655 }
00656 
00657 /*
00658  * clear dependent struct
00659  */
00660 void
00661 clear_dependent(Dependent * dd_p)
00662 {
00663     memset(dd_p, 0, sizeof(Dependent));
00664 }
00665 
00666 
00667 /*
00668  * check_xx_method return 1 if found, 0 if not found, -1 (and print msg) if
00669  * error.
00670  */
00671 int
00672 check_int_method(char *line, char *label, int *arg, const char *cfgfile)
00673 {
00674     char    format[32];
00675     int     ret = 0;
00676     int     n;
00677 
00678     if (check_label(line, label))
00679     {
00680         sprintf(format, "%s: %%d", label);
00681         if ((n = sscanf(line, format, arg)) != 1)
00682         {
00683             edt_msg(DEBUG2,
00684                     "Error in parsing %s.\nExpected:\n\n\t%s: <parameter>\n",
00685                     cfgfile, label);
00686             edt_msg(DEBUG2, "\nGot:\n\n\t%s\n", line);
00687             ret = -1;
00688         }
00689         else
00690             ret = 1;
00691     }
00692 
00693     return ret;
00694 }
00695 
00696 int
00697 check_ulong_method(char *line, char *label, u_long * arg, const char *cfgfile)
00698 {
00699     char    format[32];
00700     int     ret = 0;
00701     int     n;
00702 
00703     if (check_label(line, label))
00704     {
00705         sprintf(format, "%s: %%lu", label);
00706         if ((n = sscanf(line, format, arg)) != 1)
00707         {
00708             edt_msg(DEBUG2,
00709                     "Error in parsing %s.\nExpected:\n\n\t%s: <parameter>\n",
00710                     cfgfile, label);
00711             edt_msg(DEBUG2, "\nGot:\n\n\t%s\n", line);
00712             ret = -1;
00713         }
00714         else
00715             ret = 1;
00716     }
00717 
00718     return ret;
00719 }
00720 
00721 int
00722 check_float_method(char *line, char *label, float * arg, const char *cfgfile)
00723 {
00724     char    format[32];
00725     int     ret = 0;
00726     int     n;
00727 
00728     if (check_label(line, label))
00729     {
00730         sprintf(format, "%s: %%f", label);
00731         if ((n = sscanf(line, format, arg)) != 1)
00732         {
00733             edt_msg(DEBUG2,
00734                     "Error in parsing %s.\nExpected:\n\n\t%s: <parameter>\n",
00735                     cfgfile, label);
00736             edt_msg(DEBUG2, "\nGot:\n\n\t%s\n", line);
00737             ret = -1;
00738         }
00739         else
00740             ret = 1;
00741     }
00742 
00743     return ret;
00744 }
00745 
00746 int
00747 check_ushort_method(char *line, char *label, u_short * arg, const char *cfgfile)
00748 {
00749     char    format[32];
00750     int     ret = 0;
00751     int     n;
00752     int     v;
00753 
00754     if (check_label(line, label))
00755     {
00756         sprintf(format, "%s: %%u", label);
00757         if ((n = sscanf(line, format, &v)) != 1)
00758         {
00759             edt_msg(DEBUG2,
00760                     "Error in parsing %s.\nExpected:\n\n\t%s: <parameter>\n",
00761                     cfgfile, label);
00762             edt_msg(DEBUG2, "\nGot:\n\n\t%s\n", line);
00763             ret = -1;
00764         }
00765         else
00766         {
00767             *arg = v;
00768             ret = 1;
00769         }
00770     }
00771 
00772     return ret;
00773 }
00774 
00775 int
00776 check_byte_method(char *line, char *label, u_char * arg, const char *cfgfile)
00777 {
00778     char    format[32];
00779     int     ret = 0;
00780     int     n;
00781     int     v;
00782 
00783     if (check_label(line, label))
00784     {
00785         sprintf(format, "%s: %%u", label);
00786         if ((n = sscanf(line, format, &v)) != 1)
00787         {
00788             edt_msg(DEBUG2,
00789                     "Error in parsing %s.\nExpected:\n\n\t%s: <parameter>\n",
00790                     cfgfile, label);
00791             edt_msg(DEBUG2, "\nGot:\n\n\t%s\n", line);
00792             ret = -1;
00793         }
00794         else
00795         {
00796             *arg = v;
00797             ret = 1;
00798         }
00799     }
00800 
00801     return ret;
00802 }
00803 
00804 /*
00805  * parse a hex string -- 2 digit bytes separated by spaces, put into
00806  * char buffer
00807  */
00808 int
00809 parse_hex_str(char *str, char *buf)
00810 {
00811     int i = 0;
00812     u_int ibyte;
00813     char *sp = str;
00814 
00815     while ((*(sp+2) == ' ') || (*(sp+2) == '\0'))
00816     {
00817         sscanf(sp, "%02x ", &ibyte);
00818         buf[i++] = (char)ibyte;
00819         if (*(sp+2) == '\0')
00820             break;
00821         sp += 3;
00822     }
00823     buf[i] = '\0';
00824     return 1;
00825 }
00826 
00827 /*
00828  * check string method -- return 0 on failure, 1 on success
00829  */
00830 int
00831 check_str_method(char *line, char *label, char *arg, int max, const char *cfgfile)
00832 {
00833     int     ret = 1;
00834     char   *p = NULL;
00835     char   *sp = NULL;
00836     char   *ep;
00837     char    endchar;
00838     char    tmp_arg[MAXINIT];
00839 
00840     p = strchr(line, ':');
00841     if (!p)
00842         return (0);
00843 
00844     if ((sp = strchr(p, '"')) != NULL)
00845         endchar = '"';
00846     else if ((sp = strchr(p, '<')) != NULL)
00847         endchar = '>';
00848     else return 0;
00849 
00850     ep = strrchr(sp, endchar);
00851 
00852     if (!check_label(line, label))
00853         return 0;
00854 
00855     if ((int) strlen(sp) > max)
00856     {
00857         edt_msg(DEBUG0,
00858                 "WARNING parsing %s: '%s' arg exceeds %d char max (truncating)\n",
00859                 cfgfile, label, max - 3);
00860     }
00861 
00862     if ((p == NULL)
00863         || (sp == NULL)
00864         || (ep == NULL)
00865         || (ep == p))
00866 
00867     {
00868         edt_msg(DEBUG2,
00869                 "Error in parsing %s.\nExpected:\n\n\t%s: \"command\" (up to %d chars);\n",
00870                 cfgfile, label, max - 2);
00871         if (sp)
00872             edt_msg(DEBUG2, "\nGot:\n\n\t%s, %d chars\n", sp, strlen(sp));
00873         else
00874             edt_msg(DEBUG2, "\nGot: Nothing\n");
00875         return 0;
00876     }
00877 
00878     strcpy(tmp_arg, ++sp);
00879     if ((int) strlen(sp) > max)
00880         tmp_arg[max-1] = '\0';
00881 
00882     /*
00883      * find last double quote, get rid of it
00884      */
00885     if ((ep = strrchr(tmp_arg, endchar)) != NULL)
00886         *ep = '\0';
00887 
00888     if (endchar == '>')
00889         ret = parse_hex_str(tmp_arg, arg);
00890     else strncpy(arg, tmp_arg, max);
00891 
00892     return ret;
00893 }
00894 
00895 
00896 int
00897 check_path_method(char *line, char *label, char *arg, const char *cfgfile)
00898 {
00899     int     ret = 0;
00900     int     n;
00901     char    format[32];
00902 
00903     if (check_label(line, label))
00904     {
00905         sprintf(format, "%s: %%s", label);
00906         if ((n = sscanf(line, format, arg)) != 1)
00907         {
00908             edt_msg(DEBUG2,
00909                     "Error in parsing %s.\nExpected:\n\n\t%s: <parameter>\n",
00910                     cfgfile, label);
00911             edt_msg(DEBUG2, "\nGot:\n\n\t%s\n", line);
00912             ret = -1;
00913         }
00914         else
00915             ret = 1;
00916     }
00917 
00918     return ret;
00919 }
00920 
00921 
00922 /* ALERT: check if this is same as check_foi_init -- hopefully so */
00923 int
00924 check_serial_init_method(char *line, char *label, char *cmd, const char *cfgfile)
00925 {
00926     char   *p = NULL;
00927     char   *sp = NULL;
00928     char   *ep;
00929     char    tmp_arg[128];
00930 
00931     p = strchr(line, ':');
00932     if (!p)
00933         return 0;
00934     sp = strchr(p, '"');
00935     if (!sp)
00936         return 0;
00937     if (!check_label(line, label))
00938         return 0;
00939 
00940     if ((p == NULL)
00941         || (*(p + 1) == '\0')
00942         || (sp == NULL)
00943         || (strlen(sp) > (MAXINIT - 2))
00944         || ((ep = strrchr(sp, '"')) == NULL))
00945 
00946     {
00947         edt_msg(DEBUG2,
00948                 "Error in parsing %s.\nExpected:\n\n\t%s: \"command\" (up to %d chars);\n",
00949                 cfgfile, label, MAXINIT - 2);
00950         if (sp)
00951             edt_msg(DEBUG2, "\nGot:\n\n\t%s, %d chars\n", sp, strlen(sp));
00952         else edt_msg(DEBUG2, "\nGot: Nothing\n");
00953         return 0;
00954     }
00955 
00956     strcpy(tmp_arg, ++sp);
00957 
00958     /* find last double quote, get rid of it  */
00959     /* also tack on trailing ':' if not there  */
00960     ep = strrchr(tmp_arg, '"');
00961     if ((*(ep - 1) != ':') || (*(ep - 2) == '\\'))
00962         *ep++ = ':';
00963     *ep = '\0';
00964 
00965     strncpy(cmd, tmp_arg, MAXINIT);
00966     return 1;
00967 }
00968 
00969 /*
00970  * return 1 on success, 0 on failure.
00971  */
00972 int
00973 check_hex_method(char *line, char *label, u_int * method, const char *cfgfile)
00974 {
00975     char    format[32];
00976     char    hexstr[32];
00977 
00978     if (!check_label(line, label))
00979         return 0;
00980 
00981     sprintf(format, "%s: %%s", label);
00982     if (sscanf(line, format, hexstr) != 1)
00983     {
00984         edt_msg(DEBUG2, "Error in parsing %s.  Expected:\n\n\t%s: <hex_parameter>\n", cfgfile, label);
00985         edt_msg(DEBUG2, "\nGot:\n\n\t%s\n", line);
00986         return 0;
00987     }
00988     *method = strtol(hexstr, NULL, 16);
00989     return 1;
00990 }
00991 
00992 /*
00993  * check int, long, hex, string methods
00994  * 
00995  * return 1 if found, 0 if not found, -1 if error
00996  */
00997 int
00998 check_other_param(char *s, Dependent * dd_p, const char *cfgfile)
00999 {
01000     int     ret;
01001     int     tr;
01002     char    tmpstr[256];
01003 
01004     /*
01005      * integer methods
01006      */
01007     if ((ret = check_int_method(s, "width", &dd_p->width, cfgfile)))
01008         return ret;
01009     if ((ret = check_int_method(s, "height", &dd_p->height, cfgfile)))
01010         return ret;
01011     if ((ret = check_int_method(s, "cam_width", &dd_p->cam_width, cfgfile)))
01012         return ret;
01013     if ((ret = check_int_method(s, "cam_height", &dd_p->cam_height, cfgfile)))
01014         return ret;
01015     if ((ret = check_int_method(s, "depth", &dd_p->depth, cfgfile)))
01016         return ret;
01017     if ((ret = check_int_method(s, "extdepth", &dd_p->extdepth, cfgfile)))
01018         return ret;
01019     if ((ret = check_int_method(s, "slop", &dd_p->slop, cfgfile)))
01020         return ret;
01021     if ((ret = check_int_method(s, "hwpad", &dd_p->hwpad, cfgfile)))
01022         return ret;
01023     if ((ret = check_int_method(s, "rgb30", &dd_p->rgb30, cfgfile)))
01024         return ret;
01025     if ((ret = check_int_method(s, "irris_strip", &dd_p->hwpad, cfgfile)))
01026         return ret;
01027     if ((ret = check_int_method(s, "byteswap", &dd_p->byteswap, cfgfile)))
01028         return ret;
01029     if ((ret = check_int_method(s, "shortswap", &dd_p->shortswap, cfgfile)))
01030         return ret;
01031     if ((ret = check_int_method(s, "skip", &dd_p->skip, cfgfile)))
01032         return ret;
01033     if ((ret = check_int_method(s, "gendata", &dd_p->gendata, cfgfile)))
01034         return ret;
01035     if ((ret = check_int_method(s, "skipfrm", &dd_p->gendata, cfgfile)))
01036         return ret;
01037     if ((ret = check_int_method(s, "fixedlen", &dd_p->fixedlen, cfgfile)))
01038         return ret;
01039     if ((ret = check_int_method(s, "interlace", &dd_p->interlace, cfgfile)))
01040         return ret;
01041     if ((ret = check_int_method(s, "simulator_speed", &dd_p->sim_speed, cfgfile)))
01042         return ret;
01043     if ((ret = check_int_method(s, "cameratest", &dd_p->cameratest, cfgfile)))
01044         return ret;
01045     if ((ret = check_int_method(s, "genericsim", &dd_p->genericsim, cfgfile)))
01046         return ret;
01047     if ((ret = check_int_method(s, "disable_mdout", &dd_p->disable_mdout, cfgfile)))
01048         return ret;
01049     if ((ret = check_int_method(s, "sim_width", &dd_p->sim_width, cfgfile)))
01050         return ret;
01051     if ((ret = check_int_method(s, "sim_height", &dd_p->sim_height, cfgfile)))
01052         return ret;
01053     if ((ret = check_int_method(s, "sim_ctl", (int *) (&dd_p->sim_ctl), cfgfile)))
01054         return ret;
01055     if ((ret = check_int_method(s, "line_delay", &dd_p->line_delay, cfgfile)))
01056         return ret;
01057     if ((ret = check_int_method(s, "frame_delay", &dd_p->frame_delay, cfgfile)))
01058         return ret;
01059     if ((ret = check_int_method(s, "frame_height", &dd_p->frame_height, cfgfile)))
01060         return ret;
01061     if ((ret = check_int_method(s, "fv_once", &dd_p->fv_once, cfgfile)))
01062         return ret;
01063     if ((ret = check_int_method(s, "fval_once", &dd_p->fv_once, cfgfile))) /* alias */
01064         return ret;
01065     if ((ret = check_int_method(s, "fval_done", &dd_p->fval_done, cfgfile)))
01066         return ret;
01067     if ((ret = check_int_method(s, "fv_done", &dd_p->fval_done, cfgfile))) /* alias */
01068         return ret;
01069     if ((ret = check_int_method(s, "pingpong_varsize", &dd_p->pingpong_varsize, cfgfile)))
01070         return ret;
01071     if ((ret = check_int_method(s, "continuous", &dd_p->continuous, cfgfile)))
01072         return ret;
01073     if ((ret = check_int_method(s, "clr_continuous_end", &dd_p->clr_cont_end, cfgfile)))
01074         return ret;
01075     if ((ret = check_int_method(s, "clr_continuous_start", &dd_p->clr_cont_start,
01076                                cfgfile)))
01077         return ret;
01078     if ((ret = check_int_method(s, "cnt_continuous", (int *) (&dd_p->cnt_continuous), cfgfile)))
01079         return ret;
01080 
01081     if ((ret = check_int_method(s, "shutter_speed_frontp", &dd_p->shutter_speed_frontp, cfgfile)))
01082         return ret;
01083     if ((ret = check_int_method(s, "shutter_speed", &dd_p->shutter_speed, cfgfile)))
01084         return ret;
01085 
01086     if ((ret = check_int_method(s, "shutter_speed_min", &dd_p->shutter_speed_min, cfgfile)))
01087         return ret;
01088     if ((ret = check_int_method(s, "shutter_speed_max", &dd_p->shutter_speed_max, cfgfile)))
01089         return ret;
01090     /* aliases */
01091     if ((ret = check_int_method(s, "exposure_min", &dd_p->shutter_speed_min, cfgfile)))
01092         return ret;
01093     if ((ret = check_int_method(s, "exposure_max", &dd_p->shutter_speed_max, cfgfile)))
01094         return ret;
01095 
01096     if ((ret = check_int_method(s, "aperture_min", &dd_p->aperture_min, cfgfile)))
01097         return ret;
01098     if ((ret = check_int_method(s, "aperture_max", &dd_p->aperture_max, cfgfile)))
01099         return ret;
01100     if ((ret = check_int_method(s, "default_shutter_speed", &dd_p->default_shutter_speed, cfgfile)))
01101         return ret;
01102     /* alias */
01103     if ((ret = check_int_method(s, "default_exposure", &dd_p->default_shutter_speed, cfgfile)))
01104         return ret;
01105     if ((ret = check_int_method(s, "default_aperture", &dd_p->default_aperture, cfgfile)))
01106         return ret;
01107 
01108     if ((ret = check_int_method(s, "gain_min", &dd_p->gain_min, cfgfile)))
01109         return ret;
01110     if ((ret = check_int_method(s, "gain_max", &dd_p->gain_max, cfgfile)))
01111         return ret;
01112     if ((ret = check_int_method(s, "default_gain", &dd_p->default_gain, cfgfile)))
01113         return ret;
01114     if ((ret = check_int_method(s, "gain_frontp", &dd_p->gain_frontp, cfgfile)))
01115         return ret;
01116 
01117     if ((ret = check_int_method(s, "offset_min", &dd_p->offset_min, cfgfile)))
01118         return ret;
01119     if ((ret = check_int_method(s, "offset_max", &dd_p->offset_max, cfgfile)))
01120         return ret;
01121     if ((ret = check_int_method(s, "offset_frontp", &dd_p->offset_frontp, cfgfile)))
01122         return ret;
01123     if ((ret = check_int_method(s, "default_offset", &dd_p->default_offset, cfgfile)))
01124         return ret;
01125     if ((ret = check_int_method(s, "serial_baud", &dd_p->serial_baud, cfgfile)))
01126         return ret;
01127     if ((ret = check_int_method(s, "DUAL_CHANNEL", &dd_p->dual_channel, cfgfile)))
01128         return ret;
01129     if ((ret = check_int_method(s, "DOUBLE_RATE", &dd_p->double_rate, cfgfile)))
01130         return ret;
01131     if ((ret = check_int_method(s, "ENABLE_DALSA", &dd_p->enable_dalsa, cfgfile)))
01132         return ret;
01133     if ((ret = check_int_method(s, "INV_SHUTTER", &dd_p->inv_shutter, cfgfile)))
01134         return ret;
01135     if ((ret = check_int_method(s, "INV_PTRIG", &dd_p->inv_ptrig, cfgfile)))
01136         return ret;
01137     /* OBSOLETE */
01138     if ((ret = check_int_method(s, "INV_LVALID", &dd_p->inv_ptrig, cfgfile)))
01139         return ret;
01140     /* OBSOLETE */
01141     if ((ret = check_int_method(s, "INV_FVALID", &dd_p->inv_fvalid, cfgfile)))
01142         return ret;
01143     if ((ret = check_int_method(s, "TRIG_PULSE", &dd_p->trig_pulse, cfgfile)))
01144         return ret;
01145     if ((ret = check_int_method(s, "DIS_SHUTTER", &dd_p->dis_shutter, cfgfile)))
01146         return ret;
01147 
01148     if ((ret = check_int_method(s, "image_offset", &dd_p->image_offset, cfgfile)))
01149         return ret;
01150 
01151     if ((ret = check_int_method(s, "markras", &dd_p->markras, cfgfile)))
01152         return ret;
01153     if ((ret = check_int_method(s, "markbin", &dd_p->markbin, cfgfile)))
01154         return ret;
01155     if ((ret = check_int_method(s, "markrx", &dd_p->markrasx, cfgfile)))
01156         return ret;
01157     if ((ret = check_int_method(s, "markry", &dd_p->markrasy, cfgfile)))
01158         return ret;
01159     if ((ret = check_int_method(s, "xilinx_rev", &dd_p->xilinx_rev, cfgfile)))
01160         return ret;
01161     if ((ret = check_int_method(s, "timeout_multiplier", &dd_p->timeout_multiplier, cfgfile)))
01162         return ret;
01163     if ((ret = check_int_method(s, "user_timeout", &dd_p->user_timeout, cfgfile)))
01164         return ret;
01165     if ((ret = check_int_method(s, "timeout", &dd_p->timeout, cfgfile)))
01166         return ret;
01167     if ((ret = check_int_method(s, "linerate", &dd_p->linerate, cfgfile)))
01168         return ret;
01169     if ((ret = check_int_method(s, "header_size", &dd_p->header_size, cfgfile)))
01170         return ret;
01171     if ((ret = check_int_method(s, "photo_trig", &dd_p->photo_trig, cfgfile)))
01172         return ret;
01173     if ((ret = check_int_method(s, "fieldid_trig", &dd_p->fieldid_trig, cfgfile)))
01174         return ret;
01175     if ((ret = check_int_method(s, "slaved_trig", &tr, cfgfile)))
01176     {
01177         dd_p->photo_trig = 1;
01178         dd_p->fieldid_trig = 1;
01179         return ret;
01180     }
01181     if ((ret = check_int_method(s, "acquire_mult", &dd_p->acquire_mult, cfgfile)))
01182         return ret;
01183     if ((ret = check_int_method(s, "sim_enable", &dd_p->sim_enable, cfgfile)))
01184         return ret;
01185     if ((ret = check_int_method(s, "xilinx_clk", &dd_p->xilinx_clk, cfgfile)))
01186         return ret;
01187     if ((ret = check_int_method(s, "serial_timeout", &dd_p->serial_timeout, cfgfile)))
01188         return ret;
01189     if ((ret = check_int_method(s, "strobe_count", &dd_p->strobe_count, cfgfile)))
01190         return ret;
01191     if ((ret = check_int_method(s, "strobe_interval", &dd_p->strobe_interval, cfgfile)))
01192         return ret;
01193     if ((ret = check_int_method(s, "mc4", &dd_p->mc4, cfgfile)))
01194         return ret;
01195     if ((ret = check_int_method(s, "expexsync", &dd_p->mc4, cfgfile)))
01196         return ret;
01197     if ((ret = check_int_method(s, "sel_mc4", &dd_p->sel_mc4, cfgfile)))
01198         return ret;
01199     if ((ret = check_int_method(s, "dbl_trig", &dd_p->dbl_trig, cfgfile)))
01200         return ret;
01201     if ((ret = check_int_method(s, "pulnix", &dd_p->pulnix, cfgfile)))
01202         return ret;
01203     if ((ret = check_int_method(s, "interlace", &dd_p->interlace, cfgfile)))
01204         return ret;
01205     if ((ret = check_int_method(s, "image_offset", &dd_p->image_offset, cfgfile)))
01206         return ret;
01207     if ((ret = check_int_method(s, "hskip", &dd_p->hskip, cfgfile)))
01208         return ret;
01209     if ((ret = check_int_method(s, "hactv", &dd_p->hactv, cfgfile)))
01210         return ret;
01211     if ((ret = check_int_method(s, "vskip", &dd_p->vskip, cfgfile)))
01212         return ret;
01213     if ((ret = check_int_method(s, "vactv", &dd_p->vactv, cfgfile)))
01214         return ret;
01215     if ((ret = check_int_method(s, "cameralink", &dd_p->cameralink, cfgfile)))
01216         return ret;
01217     if ((ret = check_int_method(s, "start_delay", &dd_p->start_delay, cfgfile)))
01218         return ret;
01219     if ((ret = check_int_method(s, "pclock_speed", &dd_p->pclock_speed, cfgfile)))
01220         return ret;
01221     if ((ret = check_int_method(s, "frame_period", &dd_p->frame_period, cfgfile)))
01222         return ret;
01223 
01224     /* kbs stuff */
01225     if ((ret = check_int_method(s, "kbs_red_row_first", &dd_p->kbs_red_row_first, cfgfile)))
01226         return ret;
01227     if ((ret = check_int_method(s, "kbs_green_pixel_first", &dd_p->kbs_green_pixel_first, cfgfile)))
01228         return ret;
01229 
01230     if ((ret = check_int_method(s, "force_single", &dd_p->force_single, cfgfile)))
01231         return ret;
01232     if ((ret = check_int_method(s, "pause_for_serial", &dd_p->pause_for_serial, cfgfile)))
01233         return ret;
01234     if ((ret = check_int_method(s, "variable_size", &dd_p->variable_size, cfgfile)))
01235         return ret;
01236     if ((ret = check_int_method(s, "header_dma", &dd_p->header_dma, cfgfile)))
01237         return ret;
01238     if ((ret = check_int_method(s, "header_offset", &dd_p->header_offset, cfgfile)))
01239         return ret;
01240 
01241     if ((ret = check_int_method(s, "htaps", &dd_p->htaps, cfgfile)))
01242         return ret;
01243     if ((ret = check_int_method(s, "vtaps", &dd_p->vtaps, cfgfile)))
01244         return ret;
01245 
01246     if ((ret = check_int_method(s, "serial_init_delay", &dd_p->serial_init_delay, cfgfile)))
01247         return ret;
01248 
01249     if ((ret = check_int_method(s, "mode16", &dd_p->mode16, cfgfile)))
01250         return ret;
01251 
01252     if ((ret = check_byte_method(s, "irig_raw", &dd_p->irig_raw, cfgfile)))
01253         return ret;
01254     if ((ret = check_byte_method(s, "irig_offset", &dd_p->irig_offset, cfgfile)))
01255         return ret;
01256     if ((ret = check_byte_method(s, "irig_slave", &dd_p->irig_slave, cfgfile)))
01257         return ret;
01258         
01259     /*
01260      * hexidecimal methods
01261      */
01262     if ((ret = check_hex_method(s, "DIRECTION", (u_int *) &dd_p->direction, cfgfile)))
01263         return ret;
01264     if ((ret = check_hex_method(s, "MODE_CNTL_NORM", (u_int *) &dd_p->mode_cntl_norm, cfgfile)))
01265         return ret;
01266 
01267     if ((ret = check_hex_method(s, "CL_DATA_PATH_NORM", (u_int *) &dd_p->cl_data_path, cfgfile)))
01268     {
01269         dd_p->cameralink = 1;
01270         return ret;
01271     }
01272     if ((ret = check_hex_method(s, "CL_CFG_NORM", (u_int *) &dd_p->cl_cfg, cfgfile)))
01273     {
01274         dd_p->cameralink = 1;
01275         return ret;
01276     }
01277     if ((ret = check_hex_method(s, "CL_CFG2_NORM", (u_int *) &dd_p->cl_cfg2, cfgfile)))
01278     {
01279         dd_p->cameralink = 1;
01280         return ret;
01281     }
01282     if ((ret = check_hex_method(s, "CL_HMAX_NORM", (u_int *) &dd_p->cl_hmax, cfgfile)))
01283     {
01284         dd_p->cameralink = 1;
01285         return ret;
01286     }
01287     
01288     if ((ret = check_hex_method(s, "trigdiv", (u_int *) &dd_p->trigdiv, cfgfile)))
01289         return ret;
01290     if ((ret = check_hex_method(s, "maxdmasize", (u_int *) &dd_p->maxdmasize, cfgfile)))
01291         return ret;
01292     if ((ret = check_hex_method(s, "util2", (u_int *) &dd_p->util2, cfgfile)))
01293         return ret;
01294     if ((ret = check_hex_method(s, "shift", (u_int *) &dd_p->shift, cfgfile)))
01295         return ret;
01296     if ((ret = check_hex_method(s, "UTIL24", (u_int *) &dd_p->shift, cfgfile)))
01297         return ret;
01298     if ((ret = check_hex_method(s, "mask", (u_int *) &dd_p->mask, cfgfile)))
01299         return ret;
01300    
01301 
01302     if ((ret = check_hex_method(s, "serial_waitc", &dd_p->serial_waitc, cfgfile)))
01303         return ret;
01304 
01305     /* alias */
01306     if ((ret = check_hex_method(s, "serial_waitchar", &dd_p->serial_waitc, cfgfile)))
01307         return ret;
01308 
01309     /*
01310      * path methods (no quotes or spaces)
01311      */
01312     if ((ret = check_path_method(s, "rbtfile", dd_p->rbtfile, cfgfile)))
01313         return ret;
01314 
01315     /*
01316      * if ((ret = check_path_method(s, "foi_rbtfile", dd_p->foi_rbtfile,
01317      * cfgfile)) return ret;
01318      */
01319 
01320     if ((ret = check_path_method(s, "interlace_module", dd_p->interlace_module, cfgfile)))
01321         {
01322                 dd_p->swinterlace = PDV_INTLV_USER;
01323                 return ret;
01324         }
01325     if ((ret = check_path_method(s, "foi_remote_rbtfile", dd_p->foi_remote_rbtfile, cfgfile)))
01326         return ret;
01327 
01328       /*
01329      * NOTE: to conserve space, we overload kbs_ccm_file with some
01330      * other non-conflicting #defined names
01331      */
01332 
01333     if ((ret = check_path_method(s, "camera_download_file", dd_p->camera_download_file, cfgfile)))
01334         return ret;
01335 
01336     if ((ret = check_path_method(s, "camera_command_file", dd_p->camera_command_file, cfgfile)))
01337         return ret;
01338 
01339      /*
01340      * serial_init_method (quoted, colon sep. and terminated, w/spaces)
01341      */
01342     if ((ret = check_serial_init_method(s, "serial_init", tmpstr, cfgfile)))
01343     {
01344         if (strlen(tmpstr) + strlen(dd_p->serial_init) > 255)
01345         {
01346             edt_msg(DEBUG2, "Error in parsing %s.\nSerial initialization exceeds max of %s chars\n", s, MAXINIT);
01347             dd_p->serial_init[0] = 0;
01348             return 0;
01349         }
01350         strcat(dd_p->serial_init, tmpstr);
01351         return ret;
01352     }
01353     if ((ret = check_serial_init_method(s, "foi_init", dd_p->foi_init, cfgfile)))
01354         return ret;
01355     if ((ret = check_serial_init_method(s, "xilinx_init", dd_p->xilinx_init, cfgfile)))
01356         return ret;
01357 
01358     if ((ret = check_str_method(s, "serial_init_hex", dd_p->serial_init, MAXINIT, cfgfile)))
01359     {
01360         dd_p->serial_binit = dd_p->serial_init; 
01361         dd_p->serial_format = SERIAL_BINARY;
01362         return ret;
01363     }
01364 
01365     /* old label, now using serial_init_hex */
01366     if ((ret = check_str_method(s, "serial_binit", dd_p->serial_init, MAXINIT, cfgfile)))
01367     {
01368         dd_p->serial_binit = dd_p->serial_init; 
01369         dd_p->serial_format = SERIAL_BINARY;
01370         return ret;
01371     }
01372     if ((ret = check_str_method(s, "serial_init_baslerf", dd_p->serial_init, MAXINIT, cfgfile)))
01373     {
01374         dd_p->serial_format = SERIAL_BASLER_FRAMING;
01375         return ret;
01376     }
01377     if ((ret = check_str_method(s, "serial_init_duncanf", dd_p->serial_init, MAXINIT, cfgfile)))
01378     {
01379         dd_p->serial_format = SERIAL_DUNCAN_FRAMING;
01380         return ret;
01381     }
01382     if ((ret = check_str_method(s, "cameratype", dd_p->cameratype, CAMNAMELEN, cfgfile)))
01383         return ret;
01384     if ((ret = check_str_method(s, "camera_class", dd_p->camera_class, CAMCLASSLEN, cfgfile)))
01385         return ret;
01386     if ((ret = check_str_method(s, "camera_model", dd_p->camera_model, MAXSER, cfgfile)))
01387         return ret;
01388     if ((ret = check_str_method(s, "camera_info", dd_p->camera_info, MAXSER*2, cfgfile)))
01389         return ret;
01390     if ((ret = check_str_method(s, "serial_gain", dd_p->serial_gain, MAXSER, cfgfile)))
01391         return ret;
01392     if ((ret = check_str_method(s, "serial_offset", dd_p->serial_offset, MAXSER, cfgfile)))
01393         return ret;
01394     if ((ret = check_str_method(s, "serial_exposure", dd_p->serial_exposure, MAXSER, cfgfile)))
01395         return ret;
01396     if ((ret = check_str_method(s, "serial_prefix", dd_p->serial_prefix, MAXSER, cfgfile)))
01397         return ret;
01398     if ((ret = check_str_method(s, "serial_binning", dd_p->serial_binning, MAXSER, cfgfile)))
01399         return ret;
01400     if ((ret = check_str_method(s, "serial_term", dd_p->serial_term, MAXSER, cfgfile)))
01401         return ret;
01402     if ((ret = check_str_method(s, "serial_response", dd_p->serial_response, MAXSER, cfgfile)))
01403         return ret;
01404     if ((ret = check_str_method(s, "serial_trigger", dd_p->serial_trigger, MAXSER, cfgfile)))
01405         return ret;
01406     {
01407         char line_interleave[81];
01408         if ((ret = check_str_method(s, "line_interleave", line_interleave, 80, cfgfile)))
01409         {
01410         /* parse line */
01411             int i;
01412             char *tok = strtok(line_interleave, " \t");
01413             dd_p->n_intlv_taps = atoi(tok);
01414             for (i=0;i<dd_p->n_intlv_taps;i++)
01415             {
01416                 char *tok1 = strtok(NULL," \t");
01417                 char *tok2 = strtok(NULL," \t");
01418 
01419                 if (tok1 == NULL || tok2 == NULL)
01420                 {
01421                     edt_msg(DEBUG2,
01422                         "Error in parsing interleave in %s.\nNot Enough arguments for %d channels\n",
01423                             cfgfile, dd_p->n_intlv_taps);
01424                     return -1;
01425                 }
01426                 else
01427                 {
01428                     dd_p->intlv_taps[i].startx = atoi(tok1);
01429                     dd_p->intlv_taps[i].dx = atoi(tok2);
01430                 }
01431             }
01432 
01433             dd_p->swinterlace = PDV_LINE_INTLV;
01434 
01435             return ret;
01436         }
01437     }
01438 
01439     return 0;
01440 }
01441 
01442 int
01443 check_cls_param(char *s, PdvDependent *dd_p, const char *cfgfile)
01444 
01445 {
01446     int ret;
01447 
01448     int val;
01449 
01450     if ((ret = check_int_method(s, "cls_linescan", &val, cfgfile)))
01451     {
01452         dd_p->cls.flags.Cfg.linescan = val;
01453         return ret;
01454     }
01455     if ((ret = check_int_method(s, "cls_lvcont", &val, cfgfile)))
01456     {
01457         dd_p->cls.flags.Cfg.lvcont = val;
01458         return ret;
01459     }
01460     if ((ret = check_int_method(s, "cls_rven", &val, cfgfile)))
01461     {
01462         dd_p->cls.flags.Cfg.rven = val;
01463         return ret;
01464     }
01465     if ((ret = check_int_method(s, "cls_uartloop", &val, cfgfile)))
01466     {
01467         dd_p->cls.flags.Cfg.uartloop = val;
01468         return ret;
01469     }
01470     if ((ret = check_int_method(s, "cls_smallok", &val, cfgfile)))
01471     {
01472         dd_p->cls.flags.Cfg.smallok = val;
01473         return ret;
01474     }
01475     if ((ret = check_int_method(s, "cls_intlven", &val, cfgfile)))
01476     {
01477         dd_p->cls.flags.Cfg.intlven = val;
01478         return ret;
01479     }
01480     if ((ret = check_int_method(s, "cls_firstfc", &val, cfgfile)))
01481     {
01482         dd_p->cls.flags.Cfg.firstfc = val;
01483         return ret;
01484     }
01485     if ((ret = check_int_method(s, "cls_datacnt", &val, cfgfile)))
01486     {
01487         dd_p->cls.flags.Cfg.datacnt = val;
01488         return ret;
01489     }
01490 
01491     if ((ret = check_int_method(s, "cls_dvskip", &val, cfgfile)))
01492     {
01493         dd_p->cls.flags.Cfg.dvskip = val;
01494         return ret;
01495     }
01496 
01497     if ((ret = check_int_method(s, "cls_dvmode", &val, cfgfile)))
01498     {
01499         dd_p->cls.flags.Cfg.dvmode = val;
01500         return ret;
01501     }
01502    if ((ret = check_int_method(s, "cls_led", &val, cfgfile)))
01503     {
01504         dd_p->cls.flags.Cfg.led = val;
01505         return ret;
01506     }
01507    if ((ret = check_int_method(s, "cls_trigsrc", &val, cfgfile)))
01508     {
01509         dd_p->cls.flags.Cfg.trigsrc = val;
01510         return ret;
01511     }
01512    if ((ret = check_int_method(s, "cls_trigpol", &val, cfgfile)))
01513     {
01514         dd_p->cls.flags.Cfg.trigpol = val;
01515         return ret;
01516     }
01517    if ((ret = check_int_method(s, "cls_taps", &val, cfgfile)))
01518     {
01519         dd_p->cls.taps = val;
01520         return ret;
01521     }
01522    if ((ret = check_int_method(s, "cls_trigframe", &val, cfgfile)))
01523     {
01524         dd_p->cls.flags.Cfg.trigframe = val;
01525         return ret;
01526     }
01527 
01528    if ((ret = check_int_method(s, "cls_trigline", (int *) &val, cfgfile)))
01529     {
01530         dd_p->cls.flags.Cfg.trigline = val;
01531         return ret;
01532     }
01533 
01534     if ((ret = check_hex_method(s, "cls_filla", (u_int *)&val, cfgfile)))
01535     {
01536         dd_p->cls.FillA = val;
01537         return ret;
01538     }   
01539 
01540     if ((ret = check_hex_method(s, "cls_fillb", (u_int *)&val, cfgfile)))
01541     {
01542         dd_p->cls.FillB = val;
01543         return ret;
01544     }
01545 
01546     if ((ret = check_ushort_method(s, "cls_hgap", &dd_p->cls.hblank, cfgfile)))
01547         return ret;
01548     if ((ret = check_ushort_method(s, "cls_hcntmax", 
01549             &dd_p->cls.Hcntmax, cfgfile)))
01550         return ret;
01551 
01552     if ((ret = check_ulong_method(s, "cls_vgap", (u_long *)&dd_p->cls.vblank, cfgfile)))
01553         return ret;
01554     if ((ret = check_ulong_method(s, "cls_vcntmax", (u_long *)&dd_p->cls.Vcntmax, cfgfile)))
01555         return ret;
01556 
01557     if ((ret = check_ushort_method(s, "cls_hfvstart", &dd_p->cls.Hfvstart, cfgfile)))
01558         return ret;
01559     if ((ret = check_ushort_method(s, "cls_hfvend", &dd_p->cls.Hfvend, cfgfile)))
01560         return ret;
01561  
01562     if ((ret = check_ushort_method(s, "cls_hlvstart", &dd_p->cls.Hlvstart, cfgfile)))
01563         return ret;
01564     if ((ret = check_ushort_method(s, "cls_hlvend", &dd_p->cls.Hlvend, cfgfile)))
01565         return ret;
01566   
01567     if ((ret = check_ushort_method(s, "cls_hrvstart", &dd_p->cls.Hrvstart, cfgfile)))
01568         return ret;
01569     if ((ret = check_ushort_method(s, "cls_hrvend", &dd_p->cls.Hrvend, cfgfile)))
01570         return ret;
01571 
01572     if ((ret = check_float_method(s, "cls_pixel_clock", &dd_p->cls.pixel_clock, cfgfile)))
01573         return ret;
01574   
01575 
01576     return 0;
01577 }
01578 
01579 int
01580 check_xilinx_param(char *s, Dependent * dd_p, const char *cfgfile)
01581 {
01582     int     index = 0;
01583     u_int   reg = 0;
01584     u_int   value = 0;
01585     char    hexstr[10];
01586 
01587     if (strncmp(s, "xregwrite_", 10) == 0)
01588     {
01589         if (sscanf(s, "xregwrite_%d: %s", &reg, hexstr) != 2)
01590         {
01591             edt_msg(DEBUG2,
01592                 "Error in parsing %s.  Expected:\n\n\txregwrite_<reg>: <hex_parameter>\n", cfgfile);
01593             edt_msg(DEBUG2, "\nGot:\n\n\t%s\n", s);
01594             return 0;
01595         }
01596 
01597         if (reg > 0xfe)
01598         {
01599             edt_msg(DEBUG2,
01600             "Error in parsing %s.  Address %d is out of range for xilinx_%d.\n",
01601                         cfgfile, reg, reg);
01602             edt_msg(DEBUG2, "Legal values are 0 through 254\n");
01603             return -1;
01604         }
01605 
01606         value = strtol(hexstr, NULL, 16);
01607 
01608         if (value > 0xff)
01609         {
01610             edt_msg(DEBUG2,
01611                     "Error in parsing %s.  Value %x is out of range for xilinx_%d.\n",
01612                     cfgfile, value, reg);
01613             edt_msg(DEBUG2, "Legal values are 0 through ff\n");
01614             return -1;
01615         }
01616 
01617         /*
01618          * xilinx_flag used to just be just a flag 0 or 1, now it's the actual
01619          * address of the register, 0-254
01620          */
01621         while ((index < 32) && dd_p->xilinx_flag[index] != 0xff)
01622             ++index;
01623 
01624         if (index >= 32)
01625             printf("Error! Too_many xregwrite_ directives (max 32)\n");
01626         else
01627         {
01628             dd_p->xilinx_flag[index] = reg;
01629             dd_p->xilinx_value[index] = value;
01630         }
01631         return 1;
01632     }
01633     else return 0;
01634 
01635 }
01636 
01637 int
01638 check_method_param(char *s, Dependent * dd_p, Edtinfo * ei_p, const char *cfgfile)
01639 {
01640     int     ret = 0;
01641     int     method_number;
01642     char    method_type[64], method_arg[128];
01643     int     n;
01644 
01645     if (strncmp(s, "method_", 7) == 0)
01646     {
01647         if ((n = sscanf(s, "%s %s", method_type, method_arg)) != 2)
01648         {
01649             edt_msg(DEBUG2,
01650             "Error in parsing %s.\nExpected:\n\n\t%s: <method>: <parameter>\n",
01651                         cfgfile, method_type);
01652             edt_msg(DEBUG2, "\nGot:\n\n\t%s\n", s);
01653             return -1;
01654         }
01655         method_type[strlen(method_type) - 1] = '\0';    /* strip off ':' */
01656 
01657         if (translate_method_arg(method_arg, &method_number))
01658         {
01659             ret = set_method(dd_p, ei_p, method_type, method_number);
01660         }
01661         else
01662             ret = 0;
01663     }
01664     return ret;
01665 }
01666 
01667 int
01668 printcfg(Dependent * dd_p)
01669 {
01670     edt_msg(DEBUG2, "\nDependent Struct -- %d bytes (max %d)\n", sizeof(dd_p));
01671     edt_msg(DEBUG2, "-------------------------------------------\n");
01672     edt_msg(DEBUG2, "cameratype '%s'\n", dd_p->cameratype);
01673     edt_msg(DEBUG2, "rbtfile '%s'\n", dd_p->rbtfile);
01674     edt_msg(DEBUG2, "cfgname '%s'\n", dd_p->cfgname);
01675     edt_msg(DEBUG2, "foi_remote_rbtfile '%s'\n", dd_p->foi_remote_rbtfile);
01676     edt_msg(DEBUG2, "interlace_module '%s'\n", dd_p->interlace_module);
01677     edt_msg(DEBUG2, "width %d\n", dd_p->width);
01678     edt_msg(DEBUG2, "height %d\n", dd_p->height);
01679     edt_msg(DEBUG2, "depth %d\n", dd_p->depth);
01680     edt_msg(DEBUG2, "extdepth %d\n", dd_p->extdepth);
01681     edt_msg(DEBUG2, "slop %d\n", dd_p->slop);
01682     edt_msg(DEBUG2, "image_offset %d\n", dd_p->image_offset);
01683     edt_msg(DEBUG2, "interlace %d\n", dd_p->interlace);
01684     edt_msg(DEBUG2, "swinterlace %d\n", dd_p->swinterlace);
01685     edt_msg(DEBUG2, "default_shutter_speed %d\n", dd_p->default_shutter_speed);
01686     edt_msg(DEBUG2, "shutter_speed_frontp %d\n", dd_p->shutter_speed_frontp);
01687     edt_msg(DEBUG2, "shutter_speed_min %d\n", dd_p->shutter_speed_min);
01688     edt_msg(DEBUG2, "shutter_speed_max %d\n", dd_p->shutter_speed_max);
01689     edt_msg(DEBUG2, "shutter_speed %d\n", dd_p->shutter_speed);
01690     edt_msg(DEBUG2, "default_aperture %d\n", dd_p->default_aperture);
01691     edt_msg(DEBUG2, "aperture_min %d\n", dd_p->aperture_min);
01692     edt_msg(DEBUG2, "aperture_max %d\n", dd_p->aperture_max);
01693     edt_msg(DEBUG2, "aperture %d\n", dd_p->aperture);
01694     edt_msg(DEBUG2, "default_gain %d\n", dd_p->default_gain);
01695     edt_msg(DEBUG2, "gain_frontp %d\n", dd_p->gain_frontp);
01696     edt_msg(DEBUG2, "gain_min %d\n", dd_p->gain_min);
01697     edt_msg(DEBUG2, "gain_max %d\n", dd_p->gain_max);
01698     edt_msg(DEBUG2, "default_offset %d\n", dd_p->default_offset);
01699     edt_msg(DEBUG2, "offset_frontp %d\n", dd_p->offset_frontp);
01700     edt_msg(DEBUG2, "offset_min %d\n", dd_p->offset_min);
01701     edt_msg(DEBUG2, "offset_max %d\n", dd_p->offset_max);
01702     edt_msg(DEBUG2, "continuous %d\n", dd_p->continuous);
01703     edt_msg(DEBUG2, "inv_shutter %d\n", dd_p->inv_shutter);
01704     edt_msg(DEBUG2, "trig_pulse %d\n", dd_p->trig_pulse);
01705     edt_msg(DEBUG2, "dis_shutter %d\n", dd_p->dis_shutter);
01706     edt_msg(DEBUG2, "mode_cntl_norm %04x\n", dd_p->mode_cntl_norm);
01707     edt_msg(DEBUG2, "trigdiv %d\n", dd_p->trigdiv);
01708     edt_msg(DEBUG2, "maxdmasize %d\n", dd_p->maxdmasize);
01709     edt_msg(DEBUG2, "direction %04x\n", dd_p->direction);
01710     edt_msg(DEBUG2, "cameratest %d\n", dd_p->cameratest);
01711     edt_msg(DEBUG2, "genericsim %d\n", dd_p->genericsim);
01712     edt_msg(DEBUG2, "sim_width %d\n", dd_p->sim_width);
01713     edt_msg(DEBUG2, "sim_height %d\n", dd_p->sim_height);
01714     edt_msg(DEBUG2, "line_delay %d\n", dd_p->line_delay);
01715     edt_msg(DEBUG2, "frame_delay %d\n", dd_p->frame_delay);
01716     edt_msg(DEBUG2, "frame_height %d\n", dd_p->frame_height);
01717     edt_msg(DEBUG2, "fv_once %d\n", dd_p->fv_once);
01718     edt_msg(DEBUG2, "enable_dalsa %d\n", dd_p->enable_dalsa);
01719     edt_msg(DEBUG2, "lock_shutter %d\n", dd_p->lock_shutter);
01720     edt_msg(DEBUG2, "camera_shutter_timing %d\n", dd_p->camera_shutter_timing);
01721     edt_msg(DEBUG2, "camera_continuous %d\n", dd_p->camera_continuous);
01722     edt_msg(DEBUG2, "camera_binning %d\n", dd_p->camera_binning);
01723     edt_msg(DEBUG2, "camera_data_rate %d\n", dd_p->camera_data_rate);
01724     edt_msg(DEBUG2, "camera_download %d\n", dd_p->camera_download);
01725     edt_msg(DEBUG2, "get_gain %d\n", dd_p->get_gain);
01726     edt_msg(DEBUG2, "get_offset %d\n", dd_p->get_offset);
01727     edt_msg(DEBUG2, "set_gain %d\n", dd_p->set_gain);
01728     edt_msg(DEBUG2, "set_offset %d\n", dd_p->set_offset);
01729     edt_msg(DEBUG2, "first_open %d\n", dd_p->first_open);
01730     edt_msg(DEBUG2, "last_close %d\n", dd_p->last_close);
01731     edt_msg(DEBUG2, "image_depth %d\n", dd_p->image_depth);
01732     edt_msg(DEBUG2, "header_type %d\n", dd_p->header_type);
01733     edt_msg(DEBUG2, "interlace_offset %d\n", dd_p->interlace_offset);
01734     edt_msg(DEBUG2, "serial_init %s", dd_p->serial_init);
01735     edt_msg(DEBUG2, "serial_exposure %s", dd_p->serial_exposure);
01736     edt_msg(DEBUG2, "serial_gain '%s'", dd_p->serial_gain);
01737     edt_msg(DEBUG2, "serial_offset '%s'x'\n", dd_p->serial_offset);
01738     edt_msg(DEBUG2, "serial_prefix %s'x\n", dd_p->serial_prefix);
01739     edt_msg(DEBUG2, "serial_term %s'x\n", dd_p->serial_term);
01740     edt_msg(DEBUG2, "timeout_multiplier %d\n", dd_p->timeout_multiplier);
01741     edt_msg(DEBUG2, "datapath_reg %04x\n", dd_p->datapath_reg);
01742     edt_msg(DEBUG2, "config_reg %04x\n", dd_p->config_reg);
01743     edt_msg(DEBUG2, "rgb30 %d\n", dd_p->rgb30);
01744     edt_msg(DEBUG2, "markras %04x\n", dd_p->markras);
01745     edt_msg(DEBUG2, "markrasx %04x\n", dd_p->markrasx);
01746     edt_msg(DEBUG2, "markrasy %04x\n", dd_p->markrasy);
01747     edt_msg(DEBUG2, "markbin %04x\n", dd_p->markbin);
01748     edt_msg(DEBUG2, "disable_mdout %d\n", dd_p->disable_mdout);
01749     return (sizeof(Dependent));
01750 }
01751 
01752 
01753 void
01754 strip_ctrlm(char *s)
01755 {
01756     if (s)
01757         if (s[strlen(s) - 1] == '\r')
01758             s[strlen(s) - 1] = '\0';
01759 }
01760 
01761 void
01762 strip_extra_whitespace(char *s)
01763 {
01764     unsigned int i, j=0;
01765     int got_colon = 0;
01766     char tmpstr[256];
01767 
01768     for (i=0; i<strlen(s); i++)
01769     {
01770         if (s[i] == ':')
01771             got_colon = 1;
01772         if (got_colon)
01773             tmpstr[j++] = s[i];
01774         else if ((s[i] != ' ') && (s[i] != '    '))
01775             tmpstr[j++] = s[i];
01776         /* else skip whitespace */
01777     }
01778     tmpstr[j] = '\0';
01779     strcpy(s, tmpstr);
01780 }
01781 
01782 int
01783 resolve_cameratype(Dependent *dd_p)
01784 {
01785     char tmpstr[256];
01786 
01787     if (!(*dd_p->cameratype))
01788     {
01789         sprintf(dd_p->cameratype, "%s%s%s%s%s", dd_p->camera_class,
01790                             *dd_p->camera_model? " ":"", dd_p->camera_model,
01791                             *dd_p->camera_info? " ":"", dd_p->camera_info);
01792     }
01793 
01794     /*
01795      * make sure class (manufacturer)) isn't duplicated
01796      */
01797     if ((*dd_p->cameratype && *dd_p->camera_class))
01798     {
01799         if (strncmp(dd_p->camera_class, dd_p->cameratype,
01800                                         strlen(dd_p->camera_class)) != 0)       
01801         {
01802             sprintf(tmpstr, "%s %s", dd_p->camera_class, dd_p->cameratype);
01803             strcpy(dd_p->cameratype, tmpstr);
01804         }
01805     }
01806 
01807     if (*dd_p->cameratype)
01808         return 1;
01809     return 0;
01810 }

Generated on Mon Mar 21 14:14:54 2011 by  doxygen 1.4.7