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;
/* 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 */
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;
int cached_dir;
struct canon_dir *cached_tree;
int cached_images;
char **cached_paths; /* only used by A5 */
};
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
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 :
Returns :
boolean value denoting success (FIXME: ATTENTION!)
canon_int_get_file ()
int canon_int_get_file (Camera *camera,
const char *name,
unsigned char **data,
int *length,
GPContext *context);
camera :
name :
data :
length :
context :
Returns :
canon_int_get_thumbnail ()
int canon_int_get_thumbnail (Camera *camera,
const char *name,
unsigned char **retdata,
int *length,
GPContext *context);
camera :
camera to work with
name :
image to get thumbnail of
retdata :
The thumbnail data
length :
length of data returned
context :
Returns :
GPError.
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 :
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.
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
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 :
Returns :
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 :
Returns :
gphoto2 error code
canon_psa50_chk_crc ()
int canon_psa50_chk_crc (unsigned char *pkt,
int len,
unsigned short crc);
pkt :
len :
Param3 :
Returns :
canon_psa50_gen_crc ()
unsigned short canon_psa50_gen_crc (unsigned char *pkt,
int len);
pkt :
len :
Returns :
canon_serial_change_speed ()
int canon_serial_change_speed (GPPort *gdev,
int speed);
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);
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
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.
canon_usb_get_file ()
int canon_usb_get_file (Camera *camera,
const char *name,
unsigned char **data,
int *length,
GPContext *context);
camera :
name :
data :
length :
context :
Returns :
canon_usb_get_thumbnail ()
int canon_usb_get_thumbnail (Camera *camera,
const char *name,
unsigned char **data,
int *length,
GPContext *context);
camera :
name :
data :
length :
context :
Returns :
canon_usb_init ()
int canon_usb_init (Camera *camera,
GPContext *context);
camera :
context :
Returns :
canon_usb_long_dialogue ()
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 :
canon_usb_put_file ()
int canon_usb_put_file (Camera *camera,
CameraFile *file,
char *destname,
char *destpath);