Internal Glue Functions

Internal Glue Functions —

Synopsis


#include <canon.h>


const char* canon2gphotopath                (Camera *camera,
                                             const char *path);
const char* gphoto2canonpath                (Camera *camera,
                                             const char *path,
                                             GPContext *context);
enum        canonCamModel;
enum        canonCaptureSupport;
int         canon_int_ready                 (Camera *camera,
                                             GPContext *context);
char*       canon_int_get_disk_name         (Camera *camera,
                                             GPContext *context);
int         canon_int_get_disk_name_info    (Camera *camera,
                                             const char *name,
                                             int *capacity,
                                             int *available,
                                             GPContext *context);
int         canon_int_capture_image         (Camera *camera,
                                             CameraFilePath *path,
                                             GPContext *context);
int         canon_int_capture_preview       (Camera *camera,
                                             unsigned char **data,
                                             int *length,
                                             GPContext *context);
int         canon_int_get_file              (Camera *camera,
                                             const char *name,
                                             unsigned char **data,
                                             int *length,
                                             GPContext *context);
int         canon_int_get_thumbnail         (Camera *camera,
                                             const char *name,
                                             unsigned char **retdata,
                                             int *length,
                                             GPContext *context);
int         canon_int_put_file              (Camera *camera,
                                             CameraFile *file,
                                             char *destname,
                                             char *destpath,
                                             GPContext *context);
int         canon_int_delete_file           (Camera *camera,
                                             const char *name,
                                             const char *dir,
                                             GPContext *context);
int         canon_serial_end                (Camera *camera);
int         canon_serial_off                (Camera *camera);
int         canon_int_get_time              (Camera *camera,
                                             time_t *camera_time,
                                             GPContext *context);
int         canon_int_set_time              (Camera *camera,
                                             time_t date,
                                             GPContext *context);
int         canon_int_identify_camera       (Camera *camera,
                                             GPContext *context);
int         canon_int_set_owner_name        (Camera *camera,
                                             const char *name,
                                             GPContext *context);

Description

Details

canon2gphotopath ()

const char* canon2gphotopath                (Camera *camera,
                                             const char *path);

convert canon style path (e.g. "D:\DCIM\116CANON\IMG_1240.JPG") into gphoto2 path (e.g. "/DCIM/116CANON/IMG_1240.JPG")

Assumes path to start with drive name followed by a colon. It just drops the drive name.

camera : camera to use
path : canon style path
Returns : immutable string with gphoto2 path

gphoto2canonpath ()

const char* gphoto2canonpath                (Camera *camera,
                                             const char *path,
                                             GPContext *context);

convert gphoto2 path (e.g. "/DCIM/116CANON/IMG_1240.JPG") into canon style path (e.g. "D:\DCIM\116CANON\IMG_1240.JPG")

camera : camera to use
path : gphoto2 path
context : context for error reporting
Returns : string with converted path name

enum canonCamModel

typedef enum {
	CANON_PS_A5,
	CANON_PS_A5_ZOOM,
	CANON_PS_A50,
	CANON_PS_A60,
	CANON_PS_A70,
	CANON_PS_A80,
	CANON_PS_S10,
	CANON_PS_S20,
	CANON_PS_S30,
	CANON_PS_S40,
	CANON_PS_PRO70,
	CANON_PS_S100,
	CANON_PS_S300,
	CANON_PS_G1,
	CANON_PS_G2,
	CANON_PS_A10,
	CANON_PS_A20,
	CANON_PS_A30,
	CANON_PS_A40,
	CANON_EOS_D30,
	CANON_PS_PRO90_IS,
	CANON_PS_S330,
	CANON_PS_S200,
	CANON_EOS_D60,
	CANON_PS_A100,
	CANON_PS_A200,
	CANON_PS_A300,
	CANON_PS_S50,
	CANON_PS_S45,
	CANON_PS_G3,
	CANON_PS_S230,
	CANON_MV630I,
	CANON_EOS_10D,
	CANON_OPT_200,
	/* In Mac OS Image Capture, but not yet seen in the wild. */
	CANON_PS_UNK1,
	CANON_PS_UNK2,
	CANON_PS_UNK3,
	CANON_ZR70MC,
	CANON_PS_UNK5,
	/* other cameras */
	CANON_PS_S400,
	CANON_PS_SD100,
	CANON_EOS_300D,
	CANON_PS_G5,
	CANON_OPT_20,
	CANON_OPT_10
} canonCamModel;

Enumeration of all camera types currently supported.

CANON_PS_A5 PowerShot A5
CANON_PS_A5_ZOOM PowerShot A5 Zoom
CANON_PS_A50 PowerShot A50
CANON_PS_A60 PowerShot A60
CANON_PS_A70 PowerShot A70
CANON_PS_A80 PowerShot A80
CANON_PS_S10 PowerShot S10
CANON_PS_S20 PowerShot S20
CANON_PS_S30 PowerShot S30
CANON_PS_S40 PowerShot S40
CANON_PS_PRO70 PowerShot Pro70
CANON_PS_S100 PowerShot S100, PowerShot S110, IXY DIGITAL, Digital IXUS, DIGITAL IXUS v
CANON_PS_S300 PowerShot S300, Digital IXUS 300
CANON_PS_G1 PowerShot G1
CANON_PS_G2 PowerShot G2
CANON_PS_A10 PowerShot A10
CANON_PS_A20 PowerShot A20
CANON_PS_A30 PowerShot A30
CANON_PS_A40 PowerShot A40
CANON_EOS_D30 EOS D30
CANON_PS_PRO90_IS PowerShot Pro90 IS
CANON_PS_S330 Digital IXUS 330
CANON_PS_S200 PowerShot S200, Digital IXUS v2
CANON_EOS_D60 EOS D60
CANON_PS_A100 PowerShot A100
CANON_PS_A200 PowerShot A200
CANON_PS_A300 PowerShot A300
CANON_PS_S50 PowerShot S50
CANON_PS_S45 PowerShot S45
CANON_PS_G3 PowerShot G3
CANON_PS_S230 PowerShot S230, Digital IXUS v3
CANON_MV630I MV630i camcorder
CANON_EOS_10D EOS 10D
CANON_OPT_200 Optura 200 MC, MVX2i
CANON_PS_UNK1 Unknown camera seen in Mac OS X Image Capture
CANON_PS_UNK2 Unknown camera seen in Mac OS X Image Capture
CANON_PS_UNK3 Unknown camera seen in Mac OS X Image Capture
CANON_ZR70MC Canon ZR70MC Mini-DV Camcorder
CANON_PS_UNK5 Unknown camera seen in Mac OS X Image Capture
CANON_PS_S400 PowerShot S400, Digital IXUS 400
CANON_PS_SD100 PowerShot SD100, Digital IXUS II
CANON_EOS_300D EOS 300D / Digital Rebel / KISS Rebel
CANON_PS_G5 PowerShot G5
CANON_OPT_20 Optura 20
CANON_OPT_10 Optura 10

enum canonCaptureSupport

typedef enum {
	CAP_NON = 0, /* no support */
	CAP_SUP,     /* supported */
	CAP_EXP      /* experimental support */
} canonCaptureSupport;

State of capture support Non-zero if any support exists, but lets caller know if support is to be trusted.

CAP_NON No support for capture with this camera
CAP_SUP Capture is fully supported for this camera
CAP_EXP Capture support for this camera is experimental, i.e. it has known problems

canon_int_ready ()

int         canon_int_ready                 (Camera *camera,
                                             GPContext *context);

Switches the camera on, detects the model and sets its speed.

camera : camera to get ready
context : context for error reporting
Returns : gphoto2 error code

canon_int_get_disk_name ()

char*       canon_int_get_disk_name         (Camera *camera,
                                             GPContext *context);

Ask the camera for the name of the flash storage device. Usually "D:" or something like that.

camera : camera to ask for disk drive
context : context for error reporting
Returns : name of disk

canon_int_get_disk_name_info ()

int         canon_int_get_disk_name_info    (Camera *camera,
                                             const char *name,
                                             int *capacity,
                                             int *available,
                                             GPContext *context);

Gets available room and max capacity of a disk given by name.

camera : camera to ask about disk
name : name of the disk
capacity : returned maximum disk capacity
available : returned currently available disk capacity
context : context for error reporting
Returns : boolean value denoting success (FIXME: ATTENTION!)

canon_int_capture_image ()

int         canon_int_capture_image         (Camera *camera,
                                             CameraFilePath *path,
                                             GPContext *context);

Directs the camera to capture an image (remote shutter release via USB). See the 'Protocol' file for details. Capture through serial port is not (yet) supported.

camera : camera to work with
path : gets filled in with the path and filename of the captured image, in canonical gphoto2 format.
context : context for error reporting
Returns : gphoto2 error code

canon_int_capture_preview ()

int         canon_int_capture_preview       (Camera *camera,
                                             unsigned char **data,
                                             int *length,
                                             GPContext *context);

Directs the camera to capture an image without storing it on the camera. (remote shutter release via USB). The thumbnail will be returned in data. See the 'Protocol' file for details. Capture through serial port is not (yet) supported.

camera : camera to work with
data : gets thumbnail image data.
length : gets length of data.
context : context for error reporting
Returns : gphoto2 error code

canon_int_get_file ()

int         canon_int_get_file              (Camera *camera,
                                             const char *name,
                                             unsigned char **data,
                                             int *length,
                                             GPContext *context);

Gets the directory tree of a given flash device.

camera :
name : name of file to fetch
data : to receive file data
length : length of data
context : context for error reporting
Returns : gphoto2 error code, file contents in data, length of file in length.

canon_int_get_thumbnail ()

int         canon_int_get_thumbnail         (Camera *camera,
                                             const char *name,
                                             unsigned char **retdata,
                                             int *length,
                                             GPContext *context);

NOTE: Since cameras that do not store the thumbnail in a separate file does not return just the thumbnail but the first 10813 bytes of the image (most oftenly the EXIF header with thumbnail data in it) this must be treated before called a true thumbnail.

camera : camera to work with
name : image to get thumbnail of
retdata : The thumbnail data
length : length of data returned
context : context for error reporting
Returns : result from canon_usb_get_thumbnail() or canon_serial_get_thumbnail()

canon_int_put_file ()

int         canon_int_put_file              (Camera *camera,
                                             CameraFile *file,
                                             char *destname,
                                             char *destpath,
                                             GPContext *context);

Uploads a file to the camera.

camera : camera to work with
file : gphoto2 file object to upload
destname : name for file on camera
destpath : directory in which to put the file
context : context for error reporting
Returns : result from canon_usb_put_file() or canon_serial_put_file()

canon_int_delete_file ()

int         canon_int_delete_file           (Camera *camera,
                                             const char *name,
                                             const char *dir,
                                             GPContext *context);

Deletes a file from the camera storage.

camera : camera to work with
name : image to delete
dir : directory from which to delete the file
context : context for error reporting
Returns : result from canon_usb_dialogue() or canon_serial_dialogue()

canon_serial_end ()

int         canon_serial_end                (Camera *camera);

Switches the camera off

camera : the camera to switch off
Returns : GP_OK

canon_serial_off ()

int         canon_serial_off                (Camera *camera);

Switches the camera off, and resets the serial driver to 9600 bauds, in order to be ready to switch the camera back on again if wanted. Should better be named psa50_serial_off

camera : the camera to switch off
Returns : GP_OK

canon_int_get_time ()

int         canon_int_get_time              (Camera *camera,
                                             time_t *camera_time,
                                             GPContext *context);

Get camera's current time.

The camera gives time in little endian format, therefore we need to swap the 4 bytes on big-endian machines.

Note: the time returned from the camera is not UTC but local time. This means you should only use functions that don't adjust the timezone, like gmtime(), instead of functions that do, like localtime() since otherwise you will end up with the wrong time.

We pass it along to calling functions in local time instead of UTC since it is more correct to say 'Camera time: 2002-01-01 00:00:00' if that is what the display says and not to display the cameras time converted to local timezone (which will of course be wrong if you are not in the timezone the cameras clock was set in).

camera : camera to get the current time of
camera_time : pointer to where you want the camera time (NOT IN UTC!!!)
context : context for error reporting
Returns : gphoto2 error code

canon_int_set_time ()

int         canon_int_set_time              (Camera *camera,
                                             time_t date,
                                             GPContext *context);

Set camera's current time.

Canon cameras know nothing about time zones so we have to convert it to local time (but still expressed in UNIX time format (seconds since 1970-01-01).

camera : camera to get the current time of
date : the date to set (in UTC)
context : context for error reporting
Returns : gphoto2 error code

canon_int_identify_camera ()

int         canon_int_identify_camera       (Camera *camera,
                                             GPContext *context);

Gets the camera identification string, usually the owner name.

This information is then stored in the "camera" structure, which is a global variable for the driver.

This function also gets the firmware revision in the camera struct.

camera : the camera to work with
context : context for error reporting
Returns : gphoto2 error code

canon_int_set_owner_name ()

int         canon_int_set_owner_name        (Camera *camera,
                                             const char *name,
                                             GPContext *context);

Sets the camera owner name. The string should not be more than 30 characters long. We call get_owner_name afterwards in order to check that everything went fine.

camera : the camera to set the owner name of
name : owner name to set the camera to
context : context for error reporting
Returns : gphoto2 error code