optimized the fujitsu USB support. little change in folder-display in the cli

git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@864 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
Scott Fritzinger
2000-08-10 21:19:21 +00:00
parent 28378c68d8
commit 2abe022a77
5 changed files with 149 additions and 115 deletions

View File

@@ -24,67 +24,66 @@ int camera_id (CameraText *id) {
return (GP_OK);
}
char *models[] = {
"Agfa ePhoto 307",
"Agfa ePhoto 780",
"Agfa ePhoto 780C",
"Agfa ePhoto 1280",
"Agfa ePhoto 1680",
"Apple QuickTake 150",
"Apple QuickTake 200",
"Chinon ES-1000",
"Epson PhotoPC 500",
"Epson PhotoPC 550",
"Epson PhotoPC 600",
"Epson PhotoPC 700",
"Epson PhotoPC 800",
"Nikon CoolPix 100",
"Nikon CoolPix 300",
"Nikon CoolPix 700",
"Nikon CoolPix 800",
"Nikon CoolPix 900",
"Nikon CoolPix 900S",
"Nikon CoolPix 950",
"Nikon CoolPix 950S",
"Olympus D-100Z",
"Olympus D-200L",
"Olympus D-220L",
"Olympus D-300L",
"Olympus D-320L",
"Olympus D-330R",
"Olympus D-340L",
"Olympus D-340R",
"Olympus D-360L",
"Olympus D-400L Zoom",
"Olympus D-450Z",
"Olympus D-460Z",
"Olympus D-500L",
"Olympus D-600L",
"Olympus D-620L",
"Olympus C-400L",
"Olympus C-410L",
"Olympus C-800L",
"Olympus C-820L",
"Olympus C-830L",
"Olympus C-840L",
"Olympus C-900 Zoom",
"Olympus C-900L Zoom",
"Olympus C-1000L",
"Olympus C-1400L",
"Olympus C-2000Z",
"Olympus C-2500Z",
"Olympus C-3030Z",
"Panasonic Coolshot KXl-600A",
"Panasonic Cardshot NV-DCF5E",
"Polaroid PDC 640",
"Sanyo DSC-X300",
"Sanyo DSC-X350",
"Sanyo VPC-G200",
"Sanyo VPC-G200EX",
"Sanyo VPC-G210",
"Sanyo VPC-G250",
"Sierra Imaging SD640",
FujitsuCamera *cameras = {
{"Agfa ePhoto 307", 0, 0 },
{"Agfa ePhoto 780", 0, 0 },
{"Agfa ePhoto 780C", 0, 0 },
{"Agfa ePhoto 1280", 0, 0 },
{"Agfa ePhoto 1680", 0, 0 },
{"Apple QuickTake 150", 0, 0 },
{"Apple QuickTake 200", 0, 0 },
{"Chinon ES-1000", 0, 0 },
{"Epson PhotoPC 500", 0, 0 },
{"Epson PhotoPC 550", 0, 0 },
{"Epson PhotoPC 600", 0, 0 },
{"Epson PhotoPC 700", 0, 0 },
{"Epson PhotoPC 800", 0, 0 },
{"Nikon CoolPix 100", 0, 0 },
{"Nikon CoolPix 300", 0, 0 },
{"Nikon CoolPix 700", 0, 0 },
{"Nikon CoolPix 800", 0, 0 },
{"Nikon CoolPix 900", 0, 0 },
{"Nikon CoolPix 900S", 0, 0 },
{"Nikon CoolPix 950", 0, 0 },
{"Nikon CoolPix 950S", 0, 0 },
{"Olympus D-100Z", 0, 0 },
{"Olympus D-200L", 0, 0 },
{"Olympus D-220L", 0, 0 },
{"Olympus D-300L", 0, 0 },
{"Olympus D-320L", 0, 0 },
{"Olympus D-330R", 0, 0 },
{"Olympus D-340L", 0, 0 },
{"Olympus D-340R", 0, 0 },
{"Olympus D-360L", 0, 0 },
{"Olympus D-400L Zoom", 0, 0 },
{"Olympus D-450Z", 0, 0 },
{"Olympus D-460Z", 0, 0 },
{"Olympus D-500L", 0, 0 },
{"Olympus D-600L", 0, 0 },
{"Olympus D-620L", 0, 0 },
{"Olympus C-400L", 0, 0 },
{"Olympus C-410L", 0, 0 },
{"Olympus C-800L", 0, 0 },
{"Olympus C-820L", 0, 0 },
{"Olympus C-830L", 0, 0 },
{"Olympus C-840L", 0, 0 },
{"Olympus C-900 Zoom", 0, 0 },
{"Olympus C-900L Zoom", 0, 0 },
{"Olympus C-1000L", 0, 0 },
{"Olympus C-1400L", 0, 0 },
{"Olympus C-2000Z", 0, 0 },
{"Olympus C-2500Z", 0, 0 },
{"Olympus C-3030Z", 0, 0 },
{"Panasonic Coolshot KXl-600A", 0, 0 },
{"Panasonic Coolshot NV-DCF5E", 0, 0 },
{"Polaroid PDC 640", 0, 0 },
{"Sanyo DSC-X300", 0, 0 },
{"Sanyo DSC-X350", 0, 0 },
{"Sanyo VPC-G200", 0, 0 },
{"Sanyo VPC-G200EX", 0, 0 },
{"Sanyo VPC-G210", 0, 0 },
{"Sanyo VPC-G250", 0, 0 },
{"Sierra Imaging SD640", 0, 0 },
NULL
};
@@ -93,9 +92,9 @@ int camera_abilities (CameraAbilitiesList *list) {
int x=0;
CameraAbilities *a;
while (models[x]) {
while (cameras[x]) {
a = gp_abilities_new();
strcpy(a->model, models[x]);
strcpy(a->model, cameras[x]->model);
a->port = GP_PORT_SERIAL | GP_PORT_USB;
a->speed[0] = 9600;
a->speed[1] = 19200;
@@ -108,6 +107,8 @@ int camera_abilities (CameraAbilitiesList *list) {
a->file_delete = 1;
a->file_preview = 1;
a->file_put = 0;
a->usb_product = cameras[x]->usb_product;
a->usb_vendor = cameras[x]->usb_vendor;
gp_abilities_list_append(list, a);
x++;
@@ -484,16 +485,15 @@ int camera_file_get_generic (Camera *camera, CameraFile *file,
if (camera_start(camera)==GP_ERROR)
return (GP_ERROR);
/* Get the file number from the CameraFileSystem */
file_number = gp_filesystem_number(fd->fs, folder, filename);
if (thumbnail) {
sprintf(buf, "Getting file preview #%i", file_number);
sprintf(buf, "Getting thumbnail \"%s\" (#%i)", filename, file_number+1);
regl = 13;
regd = 15;
} else {
sprintf(buf, "Getting file #%i", file_number);
sprintf(buf, "Getting photo \"%s\" (#%i)", filename, file_number+1);
regl = 12;
regd = 14;
}
@@ -549,6 +549,8 @@ return (GP_ERROR);
fujitsu_debug_print(fd, buf);
ret = fujitsu_delete(camera, file_number+1);
if (ret == GPIO_OK)
gp_filesystem_delete(fd->fs, folder, filename);
if (camera_stop(camera)==GP_ERROR)
return (GP_ERROR);

View File

@@ -9,4 +9,10 @@ typedef struct {
CameraFilesystem *fs;
} FujitsuData;
typedef struct {
char model[64];
int usb_vendor;
int usb_product;
} FujitsuCamera;
void fujitsu_debug_print(FujitsuData *fd, char *message);

View File

@@ -169,6 +169,7 @@ int fujitsu_write_packet (Camera *camera, char *packet) {
int fujitsu_read_packet (Camera *camera, char *packet) {
int x, y, r=0, ret, done, length=0;
int blocksize, bytes_read;
char buf[4096], msg[4096];
FujitsuData *fd = (FujitsuData*)camera->camlib_data;
@@ -180,62 +181,77 @@ read_packet_again:
// usleep(QUICKSLEEP);
/* For USB support */
#ifdef GPIO_USB
if (fd->type == GP_PORT_USB) {
ret = gpio_read(fd->dev, packet, 2070);
gpio_usb_clear_halt(fd->dev);
fujitsu_dump_packet(camera, packet);
return ret;
}
#endif
done = 0;
if (fd->type == GP_PORT_USB)
gpio_usb_clear_halt(fd->dev);
while (!done && (r++<RETRIES)) {
ret = gpio_read(fd->dev, packet, 1);
if (ret == GPIO_ERROR) {
switch (fd->type) {
#ifdef GPIO_USB
case GP_PORT_USB:
blocksize = 256;
break;
#endif
case GP_PORT_SERIAL:
blocksize = 1;
break;
default:
return (GP_ERROR);
}
bytes_read = gpio_read(fd->dev, packet, blocksize);
if (bytes_read == GPIO_ERROR) {
fujitsu_debug_print(fd, " read error (packet type)");
return (GP_ERROR);
}
if (fujitsu_valid_type(packet[0])==GP_OK)
done = 1;
}
if (r>RETRIES) {
fujitsu_debug_print(fd, " read error (too many retries on packet type)");
return (GP_ERROR);
}
if ((packet[0] == TYPE_COMMAND) ||
(packet[0] == TYPE_DATA) ||
(packet[0] == TYPE_DATA_END)) {
if (gpio_read(fd->dev, &packet[1], 3)==GPIO_ERROR) {
fujitsu_debug_print(fd, " read error (header)");
if (r>RETRIES) {
fujitsu_debug_print(fd, " read error (too many retries on packet type)");
return (GP_ERROR);
}
length = ((unsigned char)packet[2]) +
((unsigned char)packet[3] * 256);
length += 6;
} else {
fujitsu_dump_packet(camera, packet);
return (fujitsu_valid_packet(camera, packet));
}
for (y=4; y < length; y++) {
ret = gpio_read(fd->dev, &packet[y], 1);
if (ret == GPIO_TIMEOUT) {
sprintf(msg, " timeout! (%i)\n", y);
fujitsu_debug_print(fd, msg);
fujitsu_write_nak(camera);
goto read_packet_again;
/* Determine the packet type */
if ((packet[0] == TYPE_COMMAND) ||
(packet[0] == TYPE_DATA) ||
(packet[0] == TYPE_DATA_END)) {
/* It's a response/command packet */
if (fd->type == GP_PORT_SERIAL) {
bytes_read = gpio_read(fd->dev, &packet[1], 3);
if (bytes_read == GPIO_ERROR) {
fujitsu_debug_print(fd, " read error (header)");
return (GP_ERROR);
}
bytes_read = 4;
}
/* Determine the packet length */
length = ((unsigned char)packet[2]) +
((unsigned char)packet[3] * 256);
length += 6;
} else {
/* It's a single byte response. dump and validate */
fujitsu_dump_packet(camera, packet);
return (fujitsu_valid_packet(camera, packet));
}
if (ret ==GPIO_ERROR) {
fujitsu_debug_print(fd, " read error (data)");
return (GP_ERROR);
for (y=bytes_read; y < length; y+=blocksize) {
ret = gpio_read(fd->dev, &packet[y], blocksize);
if (ret == GPIO_TIMEOUT) {
sprintf(msg, " timeout! (%i)\n", y);
fujitsu_debug_print(fd, msg);
fujitsu_write_nak(camera);
goto read_packet_again;
}
if (ret ==GPIO_ERROR) {
fujitsu_debug_print(fd, " read error (data)");
return (GP_ERROR);
}
}
}
fujitsu_dump_packet(camera, packet);
if (fd->type == GP_PORT_USB)
gpio_usb_clear_halt(fd->dev);
return (GP_OK);
@@ -586,17 +602,17 @@ int fujitsu_get_string_register (Camera *camera, int reg, int file_number,
}
switch (reg) {
case 14:
/* Get the size of the current thumbnail */
/* Get the size of the current image */
if (fujitsu_get_int_register(camera, 12, &l)==GP_ERROR) {
gp_camera_message(camera, "Can not get current image length");
return (GP_ERROR);
}
break;
case 15:
/* Get the size of the current picture */
if (fujitsu_get_int_register(camera, 12, &l)==GP_ERROR) {
gp_camera_message(camera, "Can not get current image length");
/* Get the size of the current thumbnail */
if (fujitsu_get_int_register(camera, 13, &l)==GP_ERROR) {
gp_camera_message(camera, "Can not get thumbnail image length");
return (GP_ERROR);
}
break;
@@ -696,6 +712,8 @@ int fujitsu_delete(Camera *camera, int picture_number) {
return (GP_ERROR);
}
usleep(QUICKSLEEP);
return (GP_OK);
}

View File

@@ -449,8 +449,11 @@ int for_each_image(char *folder, image_action action, int recurse) {
for (i = 0; i < gp_list_count(&filelist); i++) {
entry = gp_list_entry(&filelist, i);
if (action(folder, entry->name) == GP_ERROR)
printf("folder=%s filename=%s\n", folder, entry->name);
if (action(folder, entry->name) == GP_ERROR) {
printf("error!\n");
return (GP_ERROR);
}
}
if (recurse) {
@@ -471,9 +474,9 @@ OPTION_CALLBACK(list_folders) {
int print_folder(char *subfolder) {
/* print paths relative to glob_folder */
if (strcmp(glob_folder, "/") != 0)
printf("%s\n", subfolder + strlen(glob_folder) + 1);
printf("\"%s\"\n", subfolder + strlen(glob_folder) + 1);
else
printf("%s\n", subfolder + strlen(glob_folder));
printf("\"%s\"\n", subfolder + strlen(glob_folder));
return (GP_OK);
}
@@ -482,7 +485,7 @@ OPTION_CALLBACK(list_folders) {
return (GP_ERROR);
if (!glob_quiet)
printf("Subfolders of %s:\n", glob_folder);
printf("Subfolders of \"%s\":\n", glob_folder);
return for_each_subfolder(glob_folder, print_folder, glob_recurse);
}

View File

@@ -143,6 +143,11 @@ typedef struct {
int capture;
/* Camera can do a capture */
int usb_vendor;
int usb_product;
/* Vendor and product id's for USB cameras */
/* Terminated with a 0 for both */
/* Don't touch below. for core use */
char library[1024];
char id[64];