![]() | ![]() | ![]() | The Canon driver reference | ![]() |
---|
#include <canon.h> const char* canon2gphotopath (Camera *camera, const char *path); const char* gphoto2canonpath (Camera *camera, const char *path, GPContext *context); 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);
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 |
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")
Canon cameras use FAT with upper case internally, so we convert into that.
camera : | camera to use |
path : | gphoto2 path |
context : | context for error reporting |
Returns : | immutable string with converted path name |
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 |
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 |
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 |
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!) |
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 |
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 |
context : | context for error reporting |
Returns : | gphoto2 error code |
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 |
context : | context for error reporting |
Returns : | gphoto2 error code, file contents in |
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 |
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 |
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 |
int canon_serial_end (Camera *camera);
Switches the camera
off
camera : | the camera to switch off |
Returns : | GP_OK |
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 |
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 |
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 |
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 |
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 |
<<< Internal Glue Functions | Utility Macros >>> |