Initialization
[EDT Digital Video Library]


Detailed Description

Read configuration files and initialize the board and camera.

Typically the external utility program initcam handles these tasks (possibly invoked by an EDT application such as pdvshow or camconfig.) initcam calls these subroutines to do the work, and they are avaiable as well for programmers who wish to invoke them directly from a user application. See the initcam.c source code for an example of how how to use these subroutines to read configration files and initialize the board from within an application.


Functions

Dependentpdv_alloc_dependent ()
 Allocates a dependent structure, for use by pdv_readcfg and pdv_initcam, and checks for and reports error conditions as a result of the alloc.
int pdv_auto_set_timeout (PdvDev *pdv_p)
 Sets a reasonable image timeout value based on image size and exposure time (if set) and pixel clock speed (also if set).
int pdv_initcam (EdtDev *pdv_p, Dependent *dd_p, int unit, Edtinfo *edtinfo, char *cfgfname, char *bitdir, int pdv_debug)
 Initializes the board and camera.
int pdv_readcfg (char *cfgfile, Dependent *dd_p, Edtinfo *ei_p)
 Reads a configuration file and fills in the dependent and edtinfo structures based on the information in the file.


Function Documentation

Dependent* pdv_alloc_dependent (  ) 

Allocates a dependent structure, for use by pdv_readcfg and pdv_initcam, and checks for and reports error conditions as a result of the alloc.

The structure can be deallocated with free() later.

Returns:
pointer to a Dependent structure (defined in camera.h).
See also:
pdv_initcam, initcam.c and camera.h source files.

Definition at line 239 of file pdv_initcam.c.

int pdv_auto_set_timeout ( PdvDev pdv_p  ) 

Sets a reasonable image timeout value based on image size and exposure time (if set) and pixel clock speed (also if set).

Note:
This subroutine is called by pdv_initcam so it generally isn't necessary to call it from a user application. Nevertheless it can be useful to know how initcam sets the default timeout value (and how to override it); hence this description.

pdv_initcam calls this subroutine after reading in the various camera parameters from the config file. Since most configs don't (presently) have a pclock_speed directive specified, it assumes a conservative 5 Mhz pixel clock speed, which can make for a long timeout value. As a result, for faster cameras in general, and large format ones specifically, if data loss occurs for whatever reason, the pdv_wait acquisition routines may block for an excessively long time if data loss occurs. To get around this, either add a pclock_speed directive to the config file (preferred), or set your own fixed timeout override with the user_timeout directive or pdv_set_timeout.

See also:
pdv_initcam, pdv_set_timeout, pdv_set_exposure, pclock_speed & user_timeout camera configuration directives
Returns:
0 on success, -1 on failure.

int pdv_initcam ( EdtDev pdv_p,
Dependent dd_p,
int  unit,
Edtinfo *  edtinfo,
char *  cfgfname,
char *  bitdir,
int  pdv_debug 
)

Initializes the board and camera.

This is the "guts" of the inticam program that gets executed to initialize when you choose a camera. The library subroutine is provided for programmers who wish to incorporate the initialization procedure into their own applications.

Parameters:
pdv_p pointer to edt device structure returned by edt_open
dd_p pointer to a previously allocated (via pdv_alloc_dependent) and initialized (through pdv_readcfg) dependent structure. The library uses this until it is either free'd by pdv_close, or no longer used by later calls to this function (which means that if you call pdv_initcam again, you should free() pdv_p->dd_p first to avoid memory leaks).
unit unit number of the device. The first unit is 0.
edtinfo miscellaneous variable information structure, defined in initcam.h, initialized via pdv_readcfg.
cfgfname path name of configuration file.
bitdir directory path name for .bit (FPGA) files. If NULL, pdv_initcam will search for bitfiles under ".", then "./camera_config/bitfiles".
pdv_debug should be set to 0 (but is ignored currently).
Returns:
0 on success, -1 on failure
Note:
Unlike most PDV library functions, this one takes an EdtDev returned by edt_open.
Example
Note:
The following is simplified example code. Normally, we would check the return values and handle error conditions. See initcam.c for a complete example of reading the configuration file and configuring the pdv device driver and camera.
 Dependent *dd_p;
 Edtinfo edtinfo;
 EdtDev *pdv_p;

 dep = pdv_alloc_dependent();
 pdv_readcfg(cfgfname, dd_p, &edtinfo);
 unit = edt_parse_unit(unitstr, edt_devname, "pdv");
 pdv_p = edt_open(edt_devname, unit);
 pdv_initcam(pdv_p, dd_p, unit, &edtinfo, cfgfname, bitdir, 0);
 edt_close(pdv_p);
 free(dd_p);

See also:
initcam.c source code

Definition at line 130 of file pdv_initcam.c.

int pdv_readcfg ( char *  cfgfile,
Dependent dd_p,
Edtinfo *  ei_p 
)

Reads a configuration file and fills in the dependent and edtinfo structures based on the information in the file.

These structures can then be passed in to pdv_initcam to initialize the board and camera.

Parameters:
cfgfile path name of configuration file to read
dd_p device and camera dependent information structure to fill in, defined in camera.h (user-allocated -- see pdv_alloc_dependent)
ei_p structure with miscellaneous driver flags to fill in (information not in dd_p). Defined in initcam.h.
Returns:
0 on success, -1 on failure
See also:
initcam.c source code

Definition at line 313 of file readcfg.c.


Generated on Mon May 12 16:39:10 2008 by  doxygen 1.5.1