added patch from mariusz to fix deleting bug. added canon patch from phillipe to fix thumbnailing bug and add detection of IXUS
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@783 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
@@ -90,40 +90,16 @@ char *models_serialandUSB[] = {
|
||||
|
||||
int camera_id(char *id)
|
||||
{
|
||||
strcpy(id, "canon");
|
||||
strcpy(id, "canon");
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
int camera_file_put (Camera *camera, CameraFile *file)
|
||||
{
|
||||
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
int camera_capture(Camera *camera, CameraFile *file, CameraCaptureInfo *info)
|
||||
{
|
||||
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
int camera_config_get (Camera *camera, CameraWidget *window)
|
||||
{
|
||||
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
int camera_config_set (Camera *camera, CameraSetting *setting, int count)
|
||||
{
|
||||
|
||||
return GP_ERROR;
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
int camera_manual(Camera *camera, CameraText *manual)
|
||||
{
|
||||
strcpy(manual->text, "Manual Not Available");
|
||||
strcpy(manual->text, "Manual Not Available");
|
||||
|
||||
return GP_OK;
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
int camera_abilities(CameraAbilities *abilities, int *count)
|
||||
@@ -133,7 +109,6 @@ int camera_abilities(CameraAbilities *abilities, int *count)
|
||||
CameraAbilities a;
|
||||
|
||||
strcpy(a.model, "");
|
||||
a.port = GP_PORT_SERIAL | GP_PORT_USB;
|
||||
a.speed[0] = 9600;
|
||||
a.speed[1] = 19200;
|
||||
a.speed[2] = 38400;
|
||||
@@ -147,6 +122,7 @@ int camera_abilities(CameraAbilities *abilities, int *count)
|
||||
a.file_put = 0;
|
||||
|
||||
i=0;
|
||||
a.port = GP_PORT_SERIAL | GP_PORT_USB;
|
||||
while (i<NUM_SERIAL_USB) {
|
||||
memcpy(&abilities[x], &a, sizeof(a));
|
||||
strcpy(abilities[x].model, models_serialandUSB[i]);
|
||||
@@ -155,7 +131,7 @@ int camera_abilities(CameraAbilities *abilities, int *count)
|
||||
}
|
||||
|
||||
i=0;
|
||||
a.port = GP_PORT_USB;
|
||||
a.port = GP_PORT_USB;
|
||||
while (i<NUM_USB) {
|
||||
memcpy(&abilities[x], &a, sizeof(a));
|
||||
strcpy(abilities[x].model, models_USB[i]);
|
||||
@@ -164,7 +140,7 @@ int camera_abilities(CameraAbilities *abilities, int *count)
|
||||
}
|
||||
|
||||
i=0;
|
||||
a.port = GP_PORT_SERIAL;
|
||||
a.port = GP_PORT_SERIAL;
|
||||
while (i<NUM_SERIAL) {
|
||||
memcpy(&abilities[x], &a, sizeof(a));
|
||||
strcpy(abilities[x].model, models_serial[i]);
|
||||
@@ -172,6 +148,7 @@ int camera_abilities(CameraAbilities *abilities, int *count)
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
*count = x;
|
||||
|
||||
return GP_OK;
|
||||
@@ -208,90 +185,95 @@ static int check_readiness(void)
|
||||
|
||||
void switch_camera_off(void)
|
||||
{
|
||||
psa50_off();
|
||||
clear_readiness();
|
||||
psa50_off();
|
||||
clear_readiness();
|
||||
}
|
||||
|
||||
int camera_exit(Camera *camera)
|
||||
{
|
||||
CanonDataStruct *cs = (CanonDataStruct*)camera->camlib_data;
|
||||
switch_camera_off();
|
||||
|
||||
free(cs);
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
int canon_get_batt_status(int *pwr_status, int *pwr_source) {
|
||||
if (!check_readiness())
|
||||
return -1;
|
||||
int canon_get_batt_status(int *pwr_status, int *pwr_source)
|
||||
{
|
||||
if (!check_readiness())
|
||||
return -1;
|
||||
|
||||
return psa50_get_battery(pwr_status, pwr_source);
|
||||
return psa50_get_battery(pwr_status, pwr_source);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void canon_set_owner(GtkWidget *win,GtkWidget *owner)
|
||||
{
|
||||
char *entry;
|
||||
char *entry;
|
||||
|
||||
gp_camera_status(NULL, "Setting owner name.");
|
||||
entry = gtk_entry_get_text(GTK_ENTRY(owner));
|
||||
debug_message("New owner name: %s\n",entry);
|
||||
psa50_set_owner_name(entry);
|
||||
gp_camera_status(NULL, "Setting owner name.");
|
||||
entry = gtk_entry_get_text(GTK_ENTRY(owner));
|
||||
debug_message("New owner name: %s\n",entry);
|
||||
psa50_set_owner_name(entry);
|
||||
}
|
||||
#endif
|
||||
|
||||
char *camera_model_string()
|
||||
{
|
||||
if (!check_readiness())
|
||||
return "Camera unavailable";
|
||||
|
||||
switch (camera_data.model) {
|
||||
case CANON_PS_A5:
|
||||
return "Powershot A5";
|
||||
case CANON_PS_A5_ZOOM:
|
||||
return "Powershot A5 Zoom";
|
||||
case CANON_PS_A50:
|
||||
return "Powershot A50";
|
||||
case CANON_PS_A70:
|
||||
return "Powershot Pro70";
|
||||
case CANON_PS_S10:
|
||||
return "Powershot S10";
|
||||
case CANON_PS_S20:
|
||||
return "Powershot S20";
|
||||
default:
|
||||
return "Unknown model !";
|
||||
}
|
||||
if (!check_readiness())
|
||||
return "Camera unavailable";
|
||||
|
||||
switch (camera_data.model) {
|
||||
case CANON_PS_A5:
|
||||
return "Powershot A5";
|
||||
case CANON_PS_A5_ZOOM:
|
||||
return "Powershot A5 Zoom";
|
||||
case CANON_PS_A50:
|
||||
return "Powershot A50";
|
||||
case CANON_PS_A70:
|
||||
return "Powershot Pro70";
|
||||
case CANON_PS_S10:
|
||||
return "Powershot S10";
|
||||
case CANON_PS_S20:
|
||||
return "Powershot S20";
|
||||
case CANON_PS_S100:
|
||||
return "Powershot S100 / DIGITAL IXUS";
|
||||
default:
|
||||
return "Unknown model !";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int update_disk_cache(void)
|
||||
{
|
||||
char root[10]; /* D:\ or such */
|
||||
char *disk;
|
||||
char root[10]; /* D:\ or such */
|
||||
char *disk;
|
||||
|
||||
if (cached_disk) return 1;
|
||||
if (!check_readiness()) return 0;
|
||||
disk = psa50_get_disk();
|
||||
if (!disk) {
|
||||
gp_camera_status(NULL, "No response");
|
||||
return 0;
|
||||
}
|
||||
strcpy(cached_drive,disk);
|
||||
sprintf(root,"%s\\",disk);
|
||||
if (!psa50_disk_info(root,&cached_capacity,&cached_available)) {
|
||||
gp_camera_status(NULL, "No response");
|
||||
return 0;
|
||||
}
|
||||
cached_disk = 1;
|
||||
return 1;
|
||||
if (cached_disk) return 1;
|
||||
if (!check_readiness()) return 0;
|
||||
disk = psa50_get_disk();
|
||||
if (!disk) {
|
||||
gp_camera_status(NULL, "No response");
|
||||
return 0;
|
||||
}
|
||||
strcpy(cached_drive,disk);
|
||||
sprintf(root,"%s\\",disk);
|
||||
if (!psa50_disk_info(root,&cached_capacity,&cached_available)) {
|
||||
gp_camera_status(NULL, "No response");
|
||||
return 0;
|
||||
}
|
||||
cached_disk = 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int is_image(const char *name)
|
||||
{
|
||||
const char *pos;
|
||||
const char *pos;
|
||||
|
||||
pos = strchr(name,'.');
|
||||
if (!pos) return 0;
|
||||
return !strcmp(pos,".JPG");
|
||||
pos = strchr(name,'.');
|
||||
if (!pos) return 0;
|
||||
return !strcmp(pos,".JPG");
|
||||
}
|
||||
|
||||
/* This function is only used by A5 */
|
||||
@@ -546,6 +528,7 @@ static int get_all(struct psa50_dir *entry) {
|
||||
for (; entry->name; entry++)
|
||||
if (!get_all(entry)) return 0;
|
||||
return 1;
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1003,7 +986,7 @@ static char *canon_get_picture(int picture_number, int thumbnail, int *size)
|
||||
char path[300];
|
||||
char attribs;
|
||||
char file[300], dir[300];
|
||||
int size2,j;
|
||||
int j;
|
||||
void *ptr;
|
||||
|
||||
|
||||
@@ -1056,8 +1039,6 @@ static char *canon_get_picture(int picture_number, int thumbnail, int *size)
|
||||
if (!picture_number || picture_number > cached_images) {
|
||||
gp_camera_status(NULL, "Invalid index");
|
||||
free(image);
|
||||
/* if (command_line_mode==1)
|
||||
psa50_end(); */
|
||||
return NULL;
|
||||
}
|
||||
strcpy(path,cached_drive);
|
||||
@@ -1071,23 +1052,9 @@ static char *canon_get_picture(int picture_number, int thumbnail, int *size)
|
||||
if (thumbnail) {
|
||||
ptr=image;
|
||||
if ( (image = psa50_get_thumbnail(path,size)) == NULL) {
|
||||
/* if (command_line_mode == 1)
|
||||
psa50_end(); */
|
||||
free(ptr);
|
||||
return NULL;
|
||||
}
|
||||
/* we count the byte returned until the end of the jpeg data
|
||||
which is FF D9 */
|
||||
|
||||
/* 24/07/2000 (pm) I've commented out following code
|
||||
do we really need that now that we use exif to parse data ?
|
||||
*/
|
||||
|
||||
/* for(size2=1;size2<size;size2++)
|
||||
if(image[size2]==JPEG_END) {
|
||||
if(image[size2-1]==JPEG_ESC) break;
|
||||
}
|
||||
size = size2+1; */
|
||||
}
|
||||
else {
|
||||
image = psa50_get_file(path,size);
|
||||
@@ -1100,8 +1067,6 @@ static char *canon_get_picture(int picture_number, int thumbnail, int *size)
|
||||
attribs = attribs & 0xdf; // 0xdf = !0x20
|
||||
psa50_set_file_attributes(file,dir,attribs);
|
||||
}
|
||||
/* if (command_line_mode==1)
|
||||
psa50_end(); */
|
||||
if (image) return image;
|
||||
//if(receive_error==FATAL_ERROR) clear_readiness();
|
||||
free(image);
|
||||
@@ -1143,10 +1108,11 @@ int camera_file_get(Camera *camera, CameraFile *file, int index)
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
int camera_file_get_preview(Camera *camera, CameraFile *preview, int index)
|
||||
{
|
||||
char *data;
|
||||
int buflen,j,i;
|
||||
int buflen,j,i,size;
|
||||
char attribs=0;
|
||||
char path[300], filename[300];
|
||||
|
||||
@@ -1157,17 +1123,37 @@ int camera_file_get_preview(Camera *camera, CameraFile *preview, int index)
|
||||
|
||||
preview->data = data;
|
||||
strcpy(preview->type, "image/jpeg");
|
||||
|
||||
/* we count the byte returned until the end of the jpeg data
|
||||
which is FF D9 */
|
||||
/* It would be prettier to get that info from the exif tags */
|
||||
|
||||
for(size=1;size<buflen;size++)
|
||||
if(data[size]==JPEG_END) {
|
||||
if(data[size-1]==JPEG_ESC) break;
|
||||
}
|
||||
buflen = size+1;
|
||||
|
||||
preview->size = buflen;
|
||||
|
||||
pick_nth(index,path,&attribs);
|
||||
j = strrchr(path, '\\') - path;
|
||||
|
||||
i=0;
|
||||
if (A5==0) {
|
||||
filename[i++]='t';
|
||||
filename[i++]='h';
|
||||
filename[i++]='u';
|
||||
filename[i++]='m';
|
||||
filename[i++]='b';
|
||||
filename[i++]='_';
|
||||
}
|
||||
while(path[j+1] != '\0') {
|
||||
filename[i] = tolower(path[j+1]);
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
|
||||
filename[i]='\0';
|
||||
|
||||
snprintf(preview->name, sizeof(preview->name), "%s",
|
||||
@@ -1190,8 +1176,6 @@ int camera_file_count(Camera *camera)
|
||||
case CANON_PS_A5_ZOOM:
|
||||
return cached_images/2; /* Odd is pictures even is thumbs */
|
||||
default:
|
||||
/* if (command_line_mode==1)
|
||||
psa50_end(); */
|
||||
return cached_images;
|
||||
}
|
||||
};
|
||||
@@ -1203,32 +1187,36 @@ int camera_file_count(Camera *camera)
|
||||
*/
|
||||
int camera_init(Camera *camera, CameraInit *init)
|
||||
{
|
||||
char fname[1024];
|
||||
FILE *conf;
|
||||
char fname[1024];
|
||||
FILE *conf;
|
||||
CanonDataStruct *cs;
|
||||
|
||||
/* First, set up all the function pointers */
|
||||
camera->functions->id = camera_id;
|
||||
camera->functions->abilities = camera_abilities;
|
||||
camera->functions->init = camera_init;
|
||||
camera->functions->exit = camera_exit;
|
||||
camera->functions->folder_list= camera_folder_list;
|
||||
camera->functions->folder_set = camera_folder_set;
|
||||
camera->functions->file_count = camera_file_count;
|
||||
camera->functions->file_get = camera_file_get;
|
||||
camera->functions->file_get_preview = camera_file_get_preview;
|
||||
camera->functions->file_put = camera_file_put;
|
||||
camera->functions->file_delete= camera_file_delete;
|
||||
camera->functions->config_get = camera_config_get;
|
||||
camera->functions->config_set = camera_config_set;
|
||||
camera->functions->capture = camera_capture;
|
||||
camera->functions->summary = camera_summary;
|
||||
camera->functions->manual = camera_manual;
|
||||
camera->functions->about = camera_about;
|
||||
/* First, set up all the function pointers */
|
||||
camera->functions->id = camera_id;
|
||||
camera->functions->abilities = camera_abilities;
|
||||
camera->functions->init = camera_init;
|
||||
camera->functions->exit = camera_exit;
|
||||
camera->functions->folder_list= camera_folder_list;
|
||||
camera->functions->folder_set = camera_folder_set;
|
||||
camera->functions->file_count = camera_file_count;
|
||||
camera->functions->file_get = camera_file_get;
|
||||
camera->functions->file_get_preview = camera_file_get_preview;
|
||||
camera->functions->file_put = camera_file_put;
|
||||
camera->functions->file_delete= camera_file_delete;
|
||||
camera->functions->config_get = camera_config_get;
|
||||
camera->functions->config_set = camera_config_set;
|
||||
camera->functions->capture = camera_capture;
|
||||
camera->functions->summary = camera_summary;
|
||||
camera->functions->manual = camera_manual;
|
||||
camera->functions->about = camera_about;
|
||||
|
||||
gphoto2_debug = init->debug;
|
||||
fprintf(stderr,"canon_initialize()\n");
|
||||
/* Default speed */
|
||||
camera_data.speed = 9600;
|
||||
cs = (CanonDataStruct*)malloc(sizeof(CanonDataStruct));
|
||||
camera->camlib_data = cs;
|
||||
|
||||
gphoto2_debug = init->debug;
|
||||
fprintf(stderr,"canon_initialize()\n");
|
||||
/* Default speed */
|
||||
camera_data.speed = 9600;
|
||||
|
||||
setFileName(fname);
|
||||
if ((conf = fopen(fname, "r"))) {
|
||||
@@ -1360,11 +1348,10 @@ int camera_summary(Camera *camera, CameraText *summary)
|
||||
case CANON_PS_A70: model = "Canon Powershot A70"; break;
|
||||
case CANON_PS_S10: model = "Canon Powershot S10"; break;
|
||||
case CANON_PS_S20: model = "Canon Powershot S20"; break;
|
||||
case CANON_PS_S100: model = "Canon Powershot S100 / DIGITAL IXUS"; break;
|
||||
}
|
||||
sprintf(summary->text,"%s\nDrive %s\n%11s bytes total\n%11s bytes available\n",
|
||||
model,cached_drive,a,b);
|
||||
/* if (!(camera_data.model == CANON_PS_A5
|
||||
|| camera_data.model == CANON_PS_A5_ZOOM) && command_line_mode==1) psa50_end(); */
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
@@ -1372,13 +1359,14 @@ int camera_summary(Camera *camera, CameraText *summary)
|
||||
|
||||
int camera_about(Camera *camera, CameraText *about)
|
||||
{
|
||||
strcpy(about->text, "Canon PowerShot series driver by\n"
|
||||
"Wolfgang G. Reissnegger,\n"
|
||||
"Werner Almesberger,\n"
|
||||
"Edouard Lafargue,\n"
|
||||
"Philippe Marzouk,\n"
|
||||
"A5 additions by Ole W. Saastad\n"
|
||||
);
|
||||
strcpy(about->text,
|
||||
"Canon PowerShot series driver by\n"
|
||||
"Wolfgang G. Reissnegger,\n"
|
||||
"Werner Almesberger,\n"
|
||||
"Edouard Lafargue,\n"
|
||||
"Philippe Marzouk,\n"
|
||||
"A5 additions by Ole W. Saastad\n"
|
||||
);
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
@@ -1387,70 +1375,69 @@ int camera_about(Camera *camera, CameraText *about)
|
||||
|
||||
int camera_file_delete(Camera *camera, int picture_number)
|
||||
{
|
||||
char path[300];
|
||||
char file[300], dir[300], atrs;
|
||||
int j;
|
||||
char path[300];
|
||||
char file[300], dir[300], atrs;
|
||||
int j;
|
||||
|
||||
/*clear_readiness();*/
|
||||
if (!check_readiness()) {
|
||||
return 0;
|
||||
}
|
||||
if (!(camera_data.model == CANON_PS_A5 ||
|
||||
camera_data.model == CANON_PS_A5_ZOOM)) { /* this is tested only on powershot A50 */
|
||||
/*clear_readiness();*/
|
||||
if (!check_readiness()) {
|
||||
return 0;
|
||||
}
|
||||
if (!(camera_data.model == CANON_PS_A5 ||
|
||||
camera_data.model == CANON_PS_A5_ZOOM)) { /* this is tested only on powershot A50 */
|
||||
|
||||
if (!update_dir_cache()) {
|
||||
gp_camera_status(NULL, "Could not obtain directory listing");
|
||||
return 0;
|
||||
}
|
||||
/* gphoto2 numbering starts at 0 but we start at 1 */
|
||||
picture_number++;
|
||||
if (!picture_number || picture_number > cached_images) {
|
||||
gp_camera_status(NULL, "Invalid index");
|
||||
/* psa50_end(); */
|
||||
return 0;
|
||||
}
|
||||
strcpy(path,cached_drive);
|
||||
atrs=0;
|
||||
pick_nth(picture_number,path,&atrs);
|
||||
gp_camera_status(NULL, path);
|
||||
|
||||
j = strrchr(path, '\\') - path;
|
||||
strncpy(dir,path,j);
|
||||
dir[j]='\0';
|
||||
strcpy(file, path+j+1);
|
||||
if (!update_dir_cache()) {
|
||||
gp_camera_status(NULL, "Could not obtain directory listing");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (psa50_delete_file(file,dir)) {
|
||||
gp_camera_status(NULL, "error deleting file");
|
||||
/* psa50_end(); */
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
/* psa50_end(); */
|
||||
cached_ready = 0; /*RAA: do smarter!*/
|
||||
cached_disk = 0;
|
||||
if (cached_dir) clear_dir_cache();
|
||||
cached_dir = 0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
/* gphoto2 numbering starts at 0 but we start at 1 */
|
||||
picture_number++;
|
||||
if (!picture_number || picture_number > cached_images) {
|
||||
gp_camera_status(NULL, "Invalid index");
|
||||
return 0;
|
||||
}
|
||||
strcpy(path,cached_drive);
|
||||
atrs=0;
|
||||
pick_nth(picture_number,path,&atrs);
|
||||
gp_camera_status(NULL, path);
|
||||
|
||||
j = strrchr(path, '\\') - path;
|
||||
strncpy(dir,path,j);
|
||||
dir[j]='\0';
|
||||
strcpy(file, path+j+1);
|
||||
|
||||
if (psa50_delete_file(file,dir)) {
|
||||
gp_camera_status(NULL, "error deleting file");
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
cached_ready = 0; /*RAA: do smarter!*/
|
||||
cached_disk = 0;
|
||||
if (cached_dir) clear_dir_cache();
|
||||
cached_dir = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
/*
|
||||
static struct Image *canon_get_preview(void) { return NULL; }
|
||||
static int canon_take_picture(void) { return 0; };
|
||||
|
||||
struct _Camera canon =
|
||||
int camera_file_put(Camera *camera, CameraFile *file)
|
||||
{
|
||||
canon_initialize,
|
||||
canon_get_picture,
|
||||
canon_get_preview,
|
||||
canon_delete_image,
|
||||
canon_take_picture,
|
||||
canon_number_of_pictures,
|
||||
canon_configure,
|
||||
canon_summary,
|
||||
canon_description
|
||||
};
|
||||
*/
|
||||
return GP_OK;
|
||||
}
|
||||
int camera_config_get(Camera *camera, CameraWidget *window)
|
||||
{
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
int camera_config_set(Camera *camera, CameraSetting *setting, int count)
|
||||
{
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
int camera_capture(Camera *camera, CameraFile *file, CameraCaptureInfo *info)
|
||||
{
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,12 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
typedef struct {
|
||||
gpio_device *dev;
|
||||
gpio_device_settings settings;
|
||||
int speed;
|
||||
int debug;
|
||||
} CanonDataStruct;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ static unsigned char *psa50_recv_packet(unsigned char *type,unsigned char *seq,
|
||||
|
||||
|
||||
/**
|
||||
* Waits for an "ACK" from the camera_data.
|
||||
* Waits for an "ACK" from the camera.
|
||||
*
|
||||
* Return values:
|
||||
* 1 : ACK received
|
||||
@@ -274,7 +274,7 @@ static int psa50_wait_for_ack(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message to the camera_data.
|
||||
* Sends a message to the camera.
|
||||
*
|
||||
* See the "Protocol" file for an explanation of the various
|
||||
* elements needed to create a message.
|
||||
@@ -344,7 +344,7 @@ static int psa50_send_msg(unsigned char mtype,unsigned char dir,
|
||||
|
||||
|
||||
/**
|
||||
* Receive a message from the camera_data.
|
||||
* Receive a message from the camera.
|
||||
*
|
||||
* See the "Protocol" file for an explanation of the various
|
||||
* elements needed to handle a message.
|
||||
@@ -484,7 +484,7 @@ static unsigned char *psa50_recv_msg(unsigned char mtype,unsigned char dir,
|
||||
|
||||
/**
|
||||
* Higher level function: sends a message and waits for a
|
||||
* reply from the camera_data.
|
||||
* reply from the camera.
|
||||
*
|
||||
* Arguments:
|
||||
* mtype : type
|
||||
@@ -862,6 +862,13 @@ int psa50_ready()
|
||||
A5 = 0;
|
||||
return 1;
|
||||
}
|
||||
else if ((!strcmp("Canon DIGITAL IXUS",camera_data.ident))
|
||||
|| (!strcmp("Canon PowerShot S100",camera_data.ident))) {
|
||||
gp_camera_status(NULL, "Detected a Digital IXUS / Powershot S100");
|
||||
camera_data.model = CANON_PS_S100;
|
||||
A5=0;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf ("Unknown camera!\n");
|
||||
@@ -977,10 +984,16 @@ int psa50_ready()
|
||||
gp_camera_status(NULL, "Detected a Powershot S20");
|
||||
camera_data.model = CANON_PS_S20;
|
||||
A5 = 0;
|
||||
} else {
|
||||
gp_camera_status(NULL, "Detected a Powershot S10");
|
||||
camera_data.model = CANON_PS_S10;
|
||||
A5 = 0;
|
||||
} else if ((!strcmp("Canon DIGITAL IXUS",psa50_id))
|
||||
|| (!strcmp("Canon PowerShot S100",psa50_id)))
|
||||
{
|
||||
gp_camera_status(NULL, "Detected a Digital IXUS / Powershot S100");
|
||||
camera_data.model = CANON_PS_S100;
|
||||
A5=0;
|
||||
} else {
|
||||
gp_camera_status(NULL, "Detected a Powershot S10");
|
||||
camera_data.model = CANON_PS_S10;
|
||||
A5 = 0;
|
||||
}
|
||||
|
||||
// 5 seconds delay should be enough for big flash cards. By
|
||||
|
||||
@@ -42,7 +42,8 @@ typedef enum {
|
||||
CANON_PS_A50,
|
||||
CANON_PS_S10,
|
||||
CANON_PS_S20,
|
||||
CANON_PS_A70
|
||||
CANON_PS_A70,
|
||||
CANON_PS_S100
|
||||
} canonCamModel;
|
||||
|
||||
|
||||
|
||||
@@ -165,22 +165,22 @@ int camera_init (Camera *camera, CameraInit *init) {
|
||||
gpio_set_timeout(fd->dev, TIMEOUT);
|
||||
|
||||
if (gpio_open(fd->dev)==GPIO_ERROR) {
|
||||
gp_message("Can not open the port");
|
||||
gp_camera_message(camera, "Can not open the port");
|
||||
return (GP_ERROR);
|
||||
}
|
||||
|
||||
if (fujitsu_ping(camera)==GP_ERROR) {
|
||||
gp_message("Can not talk to camera");
|
||||
gp_camera_message(camera, "Can not talk to camera");
|
||||
return (GP_ERROR);
|
||||
}
|
||||
|
||||
if (fujitsu_set_speed(camera, init->port_settings.speed)==GP_ERROR) {
|
||||
gp_message("Can not set the serial port speed");
|
||||
gp_camera_message(camera, "Can not set the serial port speed");
|
||||
return (GP_ERROR);
|
||||
}
|
||||
|
||||
if (fujitsu_get_int_register(camera, 1, &value)==GP_ERROR) {
|
||||
gp_message("Could not communicate with camera after speed change");
|
||||
gp_camera_message(camera, "Could not communicate with camera after speed change");
|
||||
return (GP_ERROR);
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ int camera_start(Camera *camera) {
|
||||
FujitsuData *fd = (FujitsuData*)camera->camlib_data;
|
||||
|
||||
if (fujitsu_set_speed(camera, fd->speed)==GP_ERROR) {
|
||||
gp_message("Can not set the serial port speed");
|
||||
gp_camera_message(camera, "Can not set the serial port speed");
|
||||
return (GP_ERROR);
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ int camera_stop(Camera *camera) {
|
||||
FujitsuData *fd = (FujitsuData*)camera->camlib_data;
|
||||
|
||||
if (fujitsu_set_speed(camera, -1)==GP_ERROR) {
|
||||
gp_message("Can not set the serial port speed");
|
||||
gp_camera_message(camera, "Can not set the serial port speed");
|
||||
return (GP_ERROR);
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ int camera_exit (Camera *camera) {
|
||||
|
||||
/* obsoleted by start/stop
|
||||
if (fujitsu_end_session(camera)==GP_ERROR) {
|
||||
gp_message("Can not end camera session");
|
||||
gp_camera_message(camera, "Can not end camera session");
|
||||
return (GP_ERROR);
|
||||
}
|
||||
*/
|
||||
@@ -280,7 +280,7 @@ return (GP_ERROR);
|
||||
debug_print(fd, "Counting files");
|
||||
|
||||
if (fujitsu_get_int_register(camera, 10, &value)==GP_ERROR) {
|
||||
gp_message("Could not get number of files on camera.");
|
||||
gp_camera_message(camera, "Could not get number of files on camera.");
|
||||
return (GP_ERROR);
|
||||
}
|
||||
|
||||
@@ -313,13 +313,13 @@ return (GP_ERROR);
|
||||
|
||||
/* Set the current picture number */
|
||||
if (fujitsu_set_int_register(camera, 4, file_number+1)==GP_ERROR) {
|
||||
gp_message("Can not set current image");
|
||||
gp_camera_message(camera, "Can not set current image");
|
||||
return (GP_ERROR);
|
||||
}
|
||||
|
||||
/* Get the size of the current picture number */
|
||||
if (fujitsu_get_int_register(camera, regl, &length)==GP_ERROR) {
|
||||
gp_message("Can not get current image length");
|
||||
gp_camera_message(camera, "Can not get current image length");
|
||||
return (GP_ERROR);
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ return (GP_ERROR);
|
||||
|
||||
/* Get the picture filename */
|
||||
if (fujitsu_get_string_register(camera, 79, NULL, file->name, &length)==GP_ERROR) {
|
||||
gp_message("Can not get picture filename");
|
||||
gp_camera_message(camera, "Can not get picture filename");
|
||||
return (GP_ERROR);
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ return (GP_ERROR);
|
||||
|
||||
/* Get the picture data */
|
||||
if (fujitsu_get_string_register(camera, regd, file, NULL, NULL)==GP_ERROR) {
|
||||
gp_message("Can not get picture");
|
||||
gp_camera_message(camera, "Can not get picture");
|
||||
return (GP_ERROR);
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ char glob_model[64];
|
||||
char glob_folder[128];
|
||||
int glob_speed;
|
||||
|
||||
Camera *glob_camera;
|
||||
Camera *glob_camera=NULL;
|
||||
CameraAbilities glob_abilities;
|
||||
|
||||
int glob_debug;
|
||||
@@ -863,7 +863,6 @@ OPTION_CALLBACK(manual) {
|
||||
}
|
||||
printf("Camera Manual:\n%s\n", buf.text);
|
||||
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
@@ -1185,6 +1184,8 @@ e.g. SET CAMLIBS=C:\\GPHOTO2\\CAM\n");
|
||||
}
|
||||
|
||||
/* Exit gPhoto core */
|
||||
if (glob_camera)
|
||||
gp_camera_free(glob_camera);
|
||||
gp_exit();
|
||||
|
||||
return (EXIT_SUCCESS);
|
||||
|
||||
@@ -621,15 +621,20 @@ void camera_select_update_camera(GtkWidget *entry, gpointer data) {
|
||||
for (x=0; x<num_ports; x++) {
|
||||
append=0;
|
||||
if (gp_port_info(x, &info)==GP_OK) {
|
||||
if ((info.type == GP_PORT_SERIAL) && (a.serial))
|
||||
if ((info.type == GP_PORT_SERIAL) &&
|
||||
SERIAL_SUPPORTED(a.port))
|
||||
append=1;
|
||||
if ((info.type == GP_PORT_PARALLEL) && (a.parallel))
|
||||
if ((info.type == GP_PORT_PARALLEL) &&
|
||||
PARALLEL_SUPPORTED(a.port))
|
||||
append=1;
|
||||
if ((info.type == GP_PORT_IEEE1394) && (a.ieee1394))
|
||||
if ((info.type == GP_PORT_IEEE1394) &&
|
||||
IEEE1394_SUPPORTED(a.port))
|
||||
append=1;
|
||||
if ((info.type == GP_PORT_NETWORK) && (a.network))
|
||||
if ((info.type == GP_PORT_NETWORK) &&
|
||||
NETWORK_SUPPORTED(a.port))
|
||||
append=1;
|
||||
if ((info.type == GP_PORT_USB) && (a.usb))
|
||||
if ((info.type == GP_PORT_USB) &&
|
||||
USB_SUPPORTED(a.port))
|
||||
append=1;
|
||||
if (append) {
|
||||
sprintf(buf, "%s (%s)", info.name, info.path);
|
||||
@@ -664,7 +669,7 @@ void camera_select_update_camera(GtkWidget *entry, gpointer data) {
|
||||
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(port), FALSE);
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(speed), FALSE);
|
||||
if (a.serial || a.parallel || a.ieee1394 || a.network || a.usb)
|
||||
if (a.port)
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(port), TRUE);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
|
||||
/* Physical Connection Types */
|
||||
typedef enum {
|
||||
GP_PORT_NONE = 1 << 0,
|
||||
GP_PORT_SERIAL = 1 << 1,
|
||||
GP_PORT_PARALLEL = 1 << 2,
|
||||
GP_PORT_USB = 1 << 3,
|
||||
GP_PORT_IEEE1394 = 1 << 4,
|
||||
GP_PORT_NETWORK = 1 << 5
|
||||
GP_PORT_NONE = 0,
|
||||
GP_PORT_SERIAL = 1 << 0,
|
||||
GP_PORT_PARALLEL = 1 << 1,
|
||||
GP_PORT_USB = 1 << 2,
|
||||
GP_PORT_IEEE1394 = 1 << 3,
|
||||
GP_PORT_NETWORK = 1 << 4
|
||||
} CameraPortType;
|
||||
|
||||
/* Some macros for determining what type of ports the camera supports */
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/* Camera List */
|
||||
/* ------------------------------------------------ */
|
||||
int glob_camera_count = 0;
|
||||
CameraChoice glob_camera[512];
|
||||
CameraChoice glob_camera_list[512];
|
||||
CameraAbilities glob_camera_abilities[512];
|
||||
char *glob_camera_id[512];
|
||||
int glob_camera_id_count = 0;
|
||||
@@ -90,7 +90,7 @@ int gp_init (int debug) {
|
||||
printf("core: List of cameras found:\n");
|
||||
for (x=0; x<glob_camera_count; x++)
|
||||
printf("core:\t\"%s\" uses %s\n",
|
||||
glob_camera[x].name, glob_camera[x].library);
|
||||
glob_camera_list[x].name, glob_camera_list[x].library);
|
||||
if (glob_camera_count == 0)
|
||||
printf("core:\tNone\n");
|
||||
printf("core: Initializing the gPhoto IO library (libgpio)\n");
|
||||
@@ -156,7 +156,7 @@ int gp_camera_name (int camera_number, char *camera_name) {
|
||||
if (camera_number > glob_camera_count)
|
||||
return (GP_ERROR);
|
||||
|
||||
strcpy(camera_name, glob_camera[camera_number].name);
|
||||
strcpy(camera_name, glob_camera_list[camera_number].name);
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ int gp_camera_abilities_by_name (char *camera_name, CameraAbilities *abilities)
|
||||
|
||||
int x=0;
|
||||
while (x < glob_camera_count) {
|
||||
if (strcmp(glob_camera[x].name, camera_name)==0)
|
||||
if (strcmp(glob_camera_list[x].name, camera_name)==0)
|
||||
return (gp_camera_abilities(x, abilities));
|
||||
x++;
|
||||
}
|
||||
@@ -194,7 +194,7 @@ int gp_camera_new (Camera **camera, int camera_number, CameraPortInfo *settings)
|
||||
*camera = (Camera*)malloc(sizeof(Camera));
|
||||
|
||||
/* Initialize the members */
|
||||
strcpy((*camera)->model, glob_camera[camera_number].name);
|
||||
strcpy((*camera)->model, glob_camera_list[camera_number].name);
|
||||
(*camera)->debug = glob_debug;
|
||||
(*camera)->port = (CameraPortInfo*)malloc(sizeof(CameraPortInfo));
|
||||
(*camera)->abilities = (CameraAbilities*)malloc(sizeof(CameraAbilities));
|
||||
@@ -205,7 +205,7 @@ int gp_camera_new (Camera **camera, int camera_number, CameraPortInfo *settings)
|
||||
|
||||
memcpy((*camera)->port, settings, sizeof(CameraPortInfo));
|
||||
|
||||
if (load_library(*camera, glob_camera[camera_number].name)==GP_ERROR) {
|
||||
if (load_library(*camera, glob_camera_list[camera_number].name)==GP_ERROR) {
|
||||
gp_camera_free(*camera);
|
||||
return (GP_ERROR);
|
||||
}
|
||||
@@ -213,9 +213,9 @@ int gp_camera_new (Camera **camera, int camera_number, CameraPortInfo *settings)
|
||||
/* Initialize the camera library */
|
||||
if (glob_debug)
|
||||
printf("core: Initializing \"%s\" (%s)...\n",
|
||||
glob_camera[camera_number].name,
|
||||
glob_camera[camera_number].library);
|
||||
strcpy(ci.model, glob_camera[camera_number].name);
|
||||
glob_camera_list[camera_number].name,
|
||||
glob_camera_list[camera_number].library);
|
||||
strcpy(ci.model, glob_camera_list[camera_number].name);
|
||||
memcpy(&ci.port_settings, settings, sizeof(CameraPortInfo));
|
||||
|
||||
if (gp_camera_init(*camera, &ci)==GP_ERROR) {
|
||||
@@ -246,7 +246,7 @@ int gp_camera_new_by_name (Camera **camera, char *camera_name, CameraPortInfo *s
|
||||
int x=0;
|
||||
|
||||
while (x < glob_camera_count) {
|
||||
if (strcmp(glob_camera[x].name, camera_name)==0)
|
||||
if (strcmp(glob_camera_list[x].name, camera_name)==0)
|
||||
return (gp_camera_new(camera, x, settings));
|
||||
x++;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ extern int glob_debug;
|
||||
/* total cameras found */
|
||||
extern int glob_camera_count;
|
||||
/* camera/library list */
|
||||
extern CameraChoice glob_camera[512];
|
||||
extern CameraChoice glob_camera_list[512];
|
||||
/* camera abilities */
|
||||
extern CameraAbilities glob_camera_abilities[512];
|
||||
/* camera library id's */
|
||||
|
||||
@@ -19,11 +19,8 @@ int is_library(char *library_filename) {
|
||||
#else
|
||||
sprintf(buf, "%s/%s", CAMLIBS, library_filename);
|
||||
#endif
|
||||
if ((lh = dlopen(buf, RTLD_LAZY))==NULL) {
|
||||
if (glob_debug)
|
||||
perror("core:\tis_library");
|
||||
if ((lh = dlopen(buf, RTLD_LAZY))==NULL)
|
||||
return (GP_ERROR);
|
||||
}
|
||||
|
||||
dlclose(lh);
|
||||
|
||||
@@ -36,8 +33,8 @@ int load_library (Camera *camera, char *camera_name) {
|
||||
void *lh;
|
||||
int x;
|
||||
for (x=0; x<glob_camera_count; x++) {
|
||||
if (strcmp(glob_camera[x].name, camera_name)==0) {
|
||||
sprintf(buf, "%s/%s", CAMLIBS, glob_camera[x].library);
|
||||
if (strcmp(glob_camera_list[x].name, camera_name)==0) {
|
||||
sprintf(buf, "%s/%s", CAMLIBS, glob_camera_list[x].library);
|
||||
if ((lh = dlopen(buf, RTLD_LAZY))==NULL) {
|
||||
if (glob_debug)
|
||||
perror("core:\tload_library");
|
||||
@@ -105,10 +102,10 @@ int load_camera_list (char *library_filename) {
|
||||
|
||||
/* Copy over the camera name */
|
||||
for (x=glob_camera_count; x<glob_camera_count+count; x++) {
|
||||
strcpy(glob_camera[x].name, glob_camera_abilities[x].model);
|
||||
strcpy(glob_camera[x].library, library_filename);
|
||||
strcpy(glob_camera_list[x].name, glob_camera_abilities[x].model);
|
||||
strcpy(glob_camera_list[x].library, library_filename);
|
||||
if (glob_debug)
|
||||
printf("core:\t camera model: %s\n", glob_camera[x].name);
|
||||
printf("core:\t camera model: %s\n", glob_camera_list[x].name);
|
||||
}
|
||||
|
||||
glob_camera_count += count;
|
||||
@@ -161,11 +158,11 @@ int load_cameras() {
|
||||
/* Sort the camera list */
|
||||
for (x=0; x<glob_camera_count-1; x++) {
|
||||
for (y=x+1; y<glob_camera_count; y++) {
|
||||
z = strcmp(glob_camera[x].name, glob_camera[y].name);
|
||||
z = strcmp(glob_camera_list[x].name, glob_camera_list[y].name);
|
||||
if (z > 0) {
|
||||
memcpy(&t, &glob_camera[x], sizeof(t));
|
||||
memcpy(&glob_camera[x], &glob_camera[y], sizeof(t));
|
||||
memcpy(&glob_camera[y], &t, sizeof(t));
|
||||
memcpy(&t, &glob_camera_list[x], sizeof(t));
|
||||
memcpy(&glob_camera_list[x], &glob_camera_list[y], sizeof(t));
|
||||
memcpy(&glob_camera_list[y], &t, sizeof(t));
|
||||
|
||||
memcpy(&a, &glob_camera_abilities[x], sizeof(t));
|
||||
memcpy(&glob_camera_abilities[x], &glob_camera_abilities[y],
|
||||
|
||||
Reference in New Issue
Block a user