The Canon driver reference | |||
---|---|---|---|
<<< Previous Page | Home |
#define CAMERA_MASK_BATTERY #define CAMERA_POWER_BAD #define CAMERA_POWER_OK #define CANON_ATTR_DOWNLOADED #define CANON_ATTR_NON_RECURS_ENT_DIR #define CANON_ATTR_RECURS_ENT_DIR #define CANON_ATTR_UNKNOWN_2 #define CANON_ATTR_UNKNOWN_4 #define CANON_ATTR_UNKNOWN_40 #define CANON_ATTR_UNKNOWN_8 #define CANON_ATTR_WRITE_PROTECTED #define CANON_CMD_ACK #define CANON_CMD_PING #define CANON_ESC #define CANON_FBEG #define CANON_FEND #define CANON_IDENT_OFFSET #define CANON_PCK_CMD #define CANON_PCK_EOT #define CANON_PCK_IDENT #define CANON_PCK_SOT #define CANON_USB_FUNCTION_CAMERA_CHOWN #define CANON_USB_FUNCTION_DELETE_FILE #define CANON_USB_FUNCTION_DISK_INFO #define CANON_USB_FUNCTION_FLASH_DEVICE_IDENT #define CANON_USB_FUNCTION_GET_DIRENT #define CANON_USB_FUNCTION_GET_FILE #define CANON_USB_FUNCTION_GET_TIME #define CANON_USB_FUNCTION_IDENTIFY_CAMERA #define CANON_USB_FUNCTION_MKDIR #define CANON_USB_FUNCTION_POWER_STATUS #define CANON_USB_FUNCTION_RMDIR #define CANON_USB_FUNCTION_SET_ATTR #define CANON_USB_FUNCTION_SET_TIME #define CANON_XOR struct CameraPrivateLibrary; #define DATA_BLOCK #define DIR_CREATE #define DIR_REMOVE #define DIR_REVERSE #define ERROR_ADDRESSED #define ERROR_LOWBATT #define ERROR_RECEIVED #define FATAL_ERROR #define FRAG_LEN_LSB #define FRAG_LEN_MSB #define FRAG_NUM #define GP_MODULE #define HDR_FIXED_LEN #define JPEG_A50_SOS #define JPEG_BEG #define JPEG_END #define JPEG_ESC #define JPEG_SOS #define MAX_MSG_SIZE #define MAX_PKT_PAYLOAD #define MAX_PKT_SIZE #define MAX_TRIES #define MSG_02 #define MSG_DIR #define MSG_HDR_LEN #define MSG_LEN_LSB #define MSG_LEN_MSB #define MSG_MTYPE #define NOERROR #define PKTACK_NACK #define PKT_ACK #define PKT_EOT #define PKT_HDR_LEN #define PKT_LEN_LSB #define PKT_LEN_MSB #define PKT_MSG #define PKT_NACK #define PKT_SEQ #define PKT_TYPE #define PKT_UPLOAD_EOT #define SPEED_115200 #define SPEED_19200 #define SPEED_38400 #define SPEED_57600 #define SPEED_9600 #define UPLOAD_DATA_BLOCK #define USB_BULK_READ_SIZE #define USLEEP1 #define USLEEP2 enum canonCamModel; int canon_int_delete_file (Camera *camera, const char *name, const char *dir, GPContext *context); int canon_int_directory_operations (Camera *camera, const char *path, int action, GPContext *context); int canon_int_get_battery (Camera *camera, int *pwr_status, int *pwr_source, 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_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_get_time (Camera *camera, time_t *camera_time, GPContext *context); int canon_int_identify_camera (Camera *camera, GPContext *context); int canon_int_put_file (Camera *camera, CameraFile *file, char *destname, char *destpath, GPContext *context); int canon_int_ready (Camera *camera, GPContext *context); int canon_int_set_file_attributes (Camera *camera, const char *file, const char *dir, unsigned char attrs, GPContext *context); int canon_int_set_owner_name (Camera *camera, const char *name, GPContext *context); int canon_int_set_time (Camera *camera, time_t date, GPContext *context); int canon_psa50_chk_crc (unsigned char *pkt, int len, unsigned short crc); unsigned short canon_psa50_gen_crc (unsigned char *pkt, int len); int canon_serial_change_speed (GPPort *gdev, int speed); unsigned char* canon_serial_dialogue (Camera *camera, GPContext *context, unsigned char mtype, unsigned char dir, int *len, ...); int canon_serial_end (Camera *camera); void canon_serial_error_type (Camera *camera); int canon_serial_get_byte (GPPort *gdev); int canon_serial_get_cts (GPPort *gdev); unsigned char* canon_serial_get_file (Camera *camera, const char *name, int *length, GPContext *context); int canon_serial_init (Camera *camera); int canon_serial_off (Camera *camera); int canon_serial_put_file (Camera *camera, CameraFile *file, char *destname, char *destpath, GPContext *context); unsigned char* canon_serial_recv_frame (Camera *camera, int *len); unsigned char* canon_serial_recv_msg (Camera *camera, unsigned char mtype, unsigned char dir, int *total, GPContext *context); unsigned char* canon_serial_recv_packet (Camera *camera, unsigned char *type, unsigned char *seq, int *len); int canon_serial_send (Camera *camera, unsigned char *buf, int len, int sleep); int canon_serial_send_frame (Camera *camera, unsigned char *pkt, int len); int canon_serial_send_packet (Camera *camera, unsigned char type, unsigned char seq, unsigned char *pkt, int len); int canon_serial_wait_for_ack (Camera *camera); int canon_usb_camera_init (Camera *camera, GPContext *context); unsigned char* canon_usb_dialogue (Camera *camera, int canon_funct, int *return_length, const char *payload, int payload_length); int canon_usb_get_file (Camera *camera, const char *name, unsigned char **data, int *length, GPContext *context); int canon_usb_get_thumbnail (Camera *camera, const char *name, unsigned char **data, int *length, GPContext *context); int canon_usb_init (Camera *camera, GPContext *context); int canon_usb_long_dialogue (Camera *camera, int canon_funct, unsigned char **data, int *data_length, int max_data_size, const char *payload, int payload_length, int display_status, GPContext *context); int canon_usb_put_file (Camera *camera, CameraFile *file, char *destname, char *destpath, GPContext *context); void clear_readiness (Camera *camera); void dump_hex (Camera *camera, const char *msg, unsigned char *buf, int len); int is_crw (const char *name); int is_image (const char *name); int is_jpeg (const char *name); int is_movie (const char *name); int is_thumbnail (const char *name); void serial_flush_input (GPPort *gdev); void serial_flush_output (GPPort *gdev); void serial_set_timeout (GPPort *gdev, int to); |
struct CameraPrivateLibrary { struct canonCamModelData *md; int speed; /* The speed we're using for this camera */ char ident[32]; /* Model ID string given by the camera */ char owner[32]; /* Owner name */ char firmwrev[4]; /* Firmware revision */ unsigned char psa50_eot[8]; int receive_error; int first_init; /* first use of camera 1 = yes 0 = no */ int uploading; /* 1 = yes ; 0 = no */ int slow_send; /* to send data via serial with a usleep(1) * between each byte 1 = yes ; 0 = no */ unsigned char seq_tx; unsigned char seq_rx; #ifdef CANON_EXPERIMENTAL_CAPTURE int capturing; /* whether we are capturing or not hack to speed up usb_dialogue when not capturing [no sleep(2)] */ #endif /* CANON_EXPERIMENTAL_CAPTURE */ /* driver settings * leave these as int, as gp_widget_get_value sets them as int! */ int list_all_files; /* whether to list all files, not just know types */ #ifdef CANON_EXPERIMENTAL_UPLOAD int upload_keep_filename; /* 0=DCIF compatible filenames (AUT_*), 1=keep original filename */ #endif /* CANON_EXPERIMENTAL_UPLOAD */ char *cached_drive; /* usually something like C: */ int cached_ready; /* whether the camera is ready to rock */ /* * Directory access may be rather expensive, so we cached some information. * This is now done by libgphoto2, so we are continuously removing this stuff. * So the following variables are OBSOLETE. */ int cached_disk; int cached_capacity; int cached_available; }; |
typedef enum { CANON_PS_A5, CANON_PS_A5_ZOOM, CANON_PS_A50, CANON_PS_S10, CANON_PS_S20, CANON_PS_S30, CANON_PS_S40, CANON_PS_A70, 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_S45, CANON_PS_S230, CANON_PS_G3 } canonCamModel; |
int canon_int_delete_file (Camera *camera, const char *name, const char *dir, GPContext *context); |
camera : | |
name : | |
dir : | |
context : | |
Returns : |
|
int canon_int_directory_operations (Camera *camera, const char *path, int action, GPContext *context); |
camera : | |
path : | |
action : | |
context : | |
Returns : |
|
int canon_int_get_battery (Camera *camera, int *pwr_status, int *pwr_source, GPContext *context); |
Gets battery status.
camera : | the camera to work on |
pwr_status : | pointer to integer determining power status |
pwr_source : | pointer to integer determining power source |
context : | |
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 : | |
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 : | |
Returns : | boolean value denoting success (FIXME: ATTENTION!) |
int canon_int_get_file (Camera *camera, const char *name, unsigned char **data, int *length, GPContext *context); |
camera : | |
name : | |
data : | |
length : | |
context : | |
Returns : |
|
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 : | |
Returns : | GPError. |
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 : | |
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 : | |
Returns : | gphoto2 error code |
int canon_int_put_file (Camera *camera, CameraFile *file, char *destname, char *destpath, GPContext *context); |
camera : | |
file : | |
destname : | |
destpath : | |
context : | |
Returns : |
|
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 : | |
Returns : | gphoto2 error code |
int canon_int_set_file_attributes (Camera *camera, const char *file, const char *dir, unsigned char attrs, GPContext *context); |
Sets a file's attributes. See the 'Protocol' file for details.
camera : | camera to work with |
file : | file to work on dir: directory to work in |
dir : | |
attrs : | attribute bit field |
context : | |
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 : | |
Returns : |
|
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 : | |
Returns : | gphoto2 error code |
int canon_psa50_chk_crc (unsigned char *pkt, int len, unsigned short crc); |
pkt : | |
len : | |
Param3 : | |
Returns : |
|
unsigned short canon_psa50_gen_crc (unsigned char *pkt, int len); |
pkt : | |
len : | |
Returns : |
|
int canon_serial_change_speed (GPPort *gdev, int speed); |
gdev : | |
speed : | |
Returns : |
|
unsigned char* canon_serial_dialogue (Camera *camera, GPContext *context, unsigned char mtype, unsigned char dir, int *len, ...); |
mtype : type dir : direction len : length of the received payload @... : The rest of the arguments will be put together to fill up the payload of the request message.
Higher level function: sends a message and waits for a reply from the camera.
Payload: each argument after "len" goes by 2: the variable itself, and the next argument has to be its length. You also have to finish the list by a "NULL".
Example: To send a string called "name" : canon_serial_dialogue(0x05,0x12,&len,name,strlen(name)+1,NULL);
camera : | |
context : | |
mtype : | |
dir : | |
len : | |
... : | |
Returns : |
|
int canon_serial_end (Camera *camera); |
Switches the camera off
camera : | the camera to switch off |
Returns : | GP_OK |
unsigned char* canon_serial_get_file (Camera *camera, const char *name, int *length, GPContext *context); |
camera : | |
name : | |
length : | |
context : | |
Returns : |
|
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_serial_put_file (Camera *camera, CameraFile *file, char *destname, char *destpath, GPContext *context); |
camera : | |
file : | |
destname : | |
destpath : | |
context : | |
Returns : |
|
unsigned char* canon_serial_recv_frame (Camera *camera, int *len); |
camera : | |
len : | |
Returns : |
|
unsigned char* canon_serial_recv_msg (Camera *camera, unsigned char mtype, unsigned char dir, int *total, GPContext *context); |
camera : | |
mtype : | |
dir : | |
total : | |
context : | |
Returns : |
|
unsigned char* canon_serial_recv_packet (Camera *camera, unsigned char *type, unsigned char *seq, int *len); |
camera : | |
type : | |
seq : | |
len : | |
Returns : |
|
int canon_serial_send (Camera *camera, unsigned char *buf, int len, int sleep); |
camera : | |
buf : | |
len : | |
sleep : | |
Returns : |
|
int canon_serial_send_frame (Camera *camera, unsigned char *pkt, int len); |
camera : | |
pkt : | |
len : | |
Returns : |
|
int canon_serial_send_packet (Camera *camera, unsigned char type, unsigned char seq, unsigned char *pkt, int len); |
camera : | |
type : | |
seq : | |
pkt : | |
len : | |
Returns : |
|
int canon_usb_camera_init (Camera *camera, GPContext *context); |
camera : | |
context : | |
Returns : |
|
unsigned char* canon_usb_dialogue (Camera *camera, int canon_funct, int *return_length, const char *payload, int payload_length); |
USB version of the canon_serial_dialogue function.
We construct a packet with the known command values (cmd{1,2,3}) of the function requested (canon_funct) to the camera. If return_length exists for this function, we read return_length bytes back from the camera and return this camera response to the caller.
Example :
This function gets called with canon_funct = CANON_USB_FUNCTION_SET_TIME payload = already constructed payload with the new time we construct a complete command packet and send this to the camera. The canon_usb_cmdstruct indicates that command CANON_USB_FUNCTION_SET_TIME returns four bytes, so we read those four bytes into our buffer and return a pointer to the buffer to the caller.
This should probably be changed so that the caller supplies a unsigned char ** which can be pointed to our buffer and an int returned with GP_OK or some error code.
camera : | the Camera to work with |
canon_funct : | integer constant that identifies function we are execute |
return_length : | number of bytes to read from the camera as response |
payload : | data we are to send to the camera |
payload_length : | length of payload |
Returns : | a char * that points to the data read from the camera (or NULL on failure), and sets what return_length points to to the number of bytes read. |
int canon_usb_get_file (Camera *camera, const char *name, unsigned char **data, int *length, GPContext *context); |
camera : | |
name : | |
data : | |
length : | |
context : | |
Returns : |
|
int canon_usb_get_thumbnail (Camera *camera, const char *name, unsigned char **data, int *length, GPContext *context); |
camera : | |
name : | |
data : | |
length : | |
context : | |
Returns : |
|
int canon_usb_long_dialogue (Camera *camera, int canon_funct, unsigned char **data, int *data_length, int max_data_size, const char *payload, int payload_length, int display_status, GPContext *context); |
This function is used to invoke camera commands which return L (long) data. It calls #canon_usb_dialogue(), if it gets a good response it will malloc() memory and read the entire returned data into this malloc'd memory and store a pointer to the malloc'd memory in 'data'.
camera : | the Camera to work with |
canon_funct : | integer constant that identifies function we are execute |
data : | Pointer to pointer to allocated memory holding the data returned from the camera |
data_length : | Pointer to where you want the number of bytes read from the camera |
max_data_size : | Max realistic data size so that we can abort if something goes wrong |
payload : | data we are to send to the camera |
payload_length : | length of payload |
display_status : | Whether you want progress bar for this operation or not |
context : | |
Returns : |
|
int canon_usb_put_file (Camera *camera, CameraFile *file, char *destname, char *destpath, GPContext *context); |
camera : | |
file : | |
destname : | |
destpath : | |
context : | |
Returns : |
|
void dump_hex (Camera *camera, const char *msg, unsigned char *buf, int len); |
camera : | |
msg : | |
buf : | |
len : |
|
int is_crw (const char *name); |
Test whether the name given corresponds to a raw CRW image (.CRW).
name : | name of file to examine |
Returns : |
|
int is_image (const char *name); |
Test whether the given name corresponds to an image (.JPG or .CRW).
name : | name of file to examine |
Returns : |
|
int is_jpeg (const char *name); |
Test whether the given name corresponds to a JPEG image (.JPG).
name : | name of file to examine |
Returns : |
|
int is_movie (const char *name); |
Test whether the name given corresponds to a movie (.AVI)
name : | name of file to examine |
Returns : |
|
int is_thumbnail (const char *name); |
name : | name of file to examine Test whether the given name corresponds to a thumbnail (.THM). |
Returns : |
|