summaryrefslogtreecommitdiff
path: root/camlibs/jl2005c
diff options
context:
space:
mode:
authorTheodore Kilgore <kilgota@auburn.edu>2008-01-07 03:35:25 +0000
committerTheodore Kilgore <kilgota@auburn.edu>2008-01-07 03:35:25 +0000
commit135892aea8c6503eb3f0fb79b25aa348f78a741b (patch)
tree2ef1aaef250c3742d03a630d5bc19183d24a96b6 /camlibs/jl2005c
parent3fa81a4b9f480c854026ecb8a1777e470f053748 (diff)
downloadlibgphoto2-135892aea8c6503eb3f0fb79b25aa348f78a741b.tar.gz
Added JL2005D support, rewind function, support for non-sequential downloading of photos
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@10927 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'camlibs/jl2005c')
-rw-r--r--camlibs/jl2005c/ChangeLog10
-rw-r--r--camlibs/jl2005c/README.jl2005c118
-rw-r--r--camlibs/jl2005c/jl2005c.c165
-rw-r--r--camlibs/jl2005c/jl2005c.h5
-rw-r--r--camlibs/jl2005c/library.c131
5 files changed, 336 insertions, 93 deletions
diff --git a/camlibs/jl2005c/ChangeLog b/camlibs/jl2005c/ChangeLog
index 76303d02c..4b0d9209d 100644
--- a/camlibs/jl2005c/ChangeLog
+++ b/camlibs/jl2005c/ChangeLog
@@ -1,3 +1,13 @@
+2008-01-06 Theodore Kilgore <kilgota@auburn.edu>
+ * *.[c,h]: The camera of Patrick Simmons is determined to be a
+ JL2005D. Support is introduced for distinguishing the
+ B, C, and D versions in the places where that is needed.
+ Support is added for downloading an arbitrary photo from
+ the list of photos in the camera.
+ NOTE: All these cameras use compression, and how to
+ decompress is still unknown. Thus, raw files only.
+
+
2007-12-28 Theodore Kilgore <kilgota@auburn.edu>
* library.c: Added support for "Amazing Spiderman" reported by
Victor Hodge <vhodge@sympatico.ca> and for
diff --git a/camlibs/jl2005c/README.jl2005c b/camlibs/jl2005c/README.jl2005c
index cbff466e1..6345bfcd7 100644
--- a/camlibs/jl2005c/README.jl2005c
+++ b/camlibs/jl2005c/README.jl2005c
@@ -1,5 +1,6 @@
JEILIN STILLCAM DRIVER
-Copyright Theodore Kilgore <kilgota@auburn.edu> September 4, 2007.
+Copyright Theodore Kilgore <kilgota@auburn.edu> September 4, 2007. Most recent
+update is Janyary 6, 2008.
(Everything in libgphoto2/camlibs/jeilin is LGPL-licensed, including this
README. See any of the source files for a more complete statement of the
@@ -8,7 +9,8 @@ license.)
INTRODUCTION
This driver is intended to support cameras containing the JL2005C chip from
-Jeilin Technologies. The interface is proprietary, and these cameras are
+Jeilin Technologies and also the similar cameras which have in them the
+JL2005B or the JL2005D. The interface is proprietary, and these cameras are
supported commercially only in Windows. Jeilin Technologies also manufactures
chips which go into mass storage cameras. Those cameras, not to be confused
with these, can be accessed directly using mass storage support.
@@ -67,30 +69,32 @@ myself, and I.
WHAT DOES THIS CAMERA LIBRARY CURRENTLY DO?
-The answer is, not much. It will hook up the camera, and you can download a
-dump of any photo data in it (we hope). The only reason for doing this right
-now is to experiment with what the still-unknown decompression algorithm is
-doing.
+It will hook up the camera, and you ought to be able to download a dump of any
+photo data in it using the command gphoto2 --get-all-raw-data. The main reason
+you might want to do this right now is to participate in the development of
+support for these cameras by experimenting with the still-unknown decompression
+algorithm which they use. Also, some other infrastructural work has been done.
+The cameras will run gphoto --shell and even ought to honor a sequence such as
+
+get-raw jl_026.ppm
+
+followed by the next gphoto2 shell command
+
+get-raw jl_001.ppm
+
+without corruption of data.
I _think_ that I got the data size for the photos all correct, but I am not
sure about that, for the obvious reason that I cannot do finished photos.
-The camera does download without glitches all the photos in it, even if it is
-full, and will save them as raw files. I have taken the trouble to make each
-raw file slightly longer; I put at the end the single character (produced by
-the camera, actually) which contains encoded information about the intended
-size of the raw photo and about whether it is using low compression or high
-compression (at both of which settings the data is in fact compressed). The
-last byte will be one of 0x00, 0x01, 0x10, or 0x11, and the meanings are as
-follows:
-
- 00 640x480, low compression
- 10 640x480, high compression
- 01 320x240, low compression
- 11 320x240, high compression
-
-That is, a 1 in the first digit represents high compression, and a 1 in the
-second digit represents the smaller dimensions. This data will be found, as I
-said, at the end of every raw file which is produced.
+(Update 01/05/08: It has been verified for the JL2005D, the raw image data
+obtained by the OEM driver is the same as what this code is providing. I have
+been unable to verify this for a JL2005B camera, also unable to verify for a
+JL2005C). The camera does download without glitches all the photos in it, even
+if it is full, and will save them as raw files. I have taken the trouble to
+make each raw file slightly longer by adding the 16-byte line related to it
+which is found in the photo allocation table, the first block of data to be
+downloaded from the camera.
+
The reason why one cannot make finished photos right now is that these
cameras use a proprietary compression algorithm which Jeilin Technologies is
@@ -101,19 +105,73 @@ development can more easily take place.
!!!!!!!!!!!!!!! A SPECIAL WARNING !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-In view of the current uncertainty about how to compute the size of a photo's
-raw data to be downloaded, anyone testing out some theory about how to do
-decompression ought to stick to using the first photo in the camera. Just
-please reset the length of the photo to be equal to the total data to be
-downloaded, and you will be sure to capture it all. This until someone figures
-out for certain exactly how to compute the size of the raw data.
+How to compute the size and location of a photo's raw data to be downloaded,
+is probably correct now for all of these cameras. However, the basis for this
+computation remains in the realm of guesswork. Be on the lookout for the
+camera taking an inordinate amount of time to do some simple task such as to
+count the number of photos in it using gphoto2 -n. That is probably a sign of
+something previously gone wrong, which has jammed the camera. It may be needed
+to replug it in order to clear the jam.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ADDITIONAL REMARKS:
+
+These cameras use a proprietary compression algorithm, as already said. As a
+result, progress in the development of this driver will inevitably be slow.
+
+Another challenge is that these cameras use an extremely primitive command
+structure. The only thing that the camera knows how to do is to prepare to
+download all data on it, download all data on it, and to reset prior to being
+disconnected. Therefore, any other functionality has to be based on software
+fakery which fools the hardware. Suppose, for example, that there are ten
+photos in the camera. Then what the camera will do is:
+ -- report the number of photos (ten)
+ -- tell how much data needs to be downloaded in all (depends on how
+ much room was taken up by the raw data for the photos)
+ -- provide a table with one line for each photo, giving its size, start
+ location, output height and width, and some kind of code for the
+ compression method used on it.
+In the next step, one must request all the image data to be downloaded, in
+increments of which there is a maximum size. This does not need to be done
+all at once, so it is possible to download some initial block of the data and
+operate on whatever photos are already obtained, and then download another block.
+However, ALL of the data has to be downloaded before the driver program exits.
+One consequence of this is that the only way a command such as
+
+gphoto2 --get-raw-data 3
+
+can work is to download photos number 1 and 2 and throw away the data before
+downloading the desired number 3 which is to be kept as a raw file,
+and then downloading any data in the camera which comes after photo number 3
+after that, as a standard part of the exit routine. Another consequence is
+that the sequence of downloading number 10, say, followed by number 1 is even
+more complicated. The actual steps required are:
+ -- initialize the camera
+ -- download enough data to get photo number 10, throwing away all data
+ which is not part of photo number 10 but precedes it
+ -- download the data required for photo number 10
+ -- download the rest of the data
+ -- send a reset sequence to the camera
+ -- close and reopen the camera's port
+ -- run a "rewind" function consisting of a fake repetition of the
+ initialization sequence, including downloading again the allocation table
+ -- download enough data to process photo number 1
+ -- download all the rest of the data and throw it away.
+ -- send the reset sequence again, and, finally, disconnect
+
+Finally, if and when the decompression problem is resolved, then it ought to
+become possible to use other programs with this camera, such as a GUI frontend
+for libgphoto2. Any such program used with this camera must be willing to call
+and actually to use the camera_exit() function which is contained in this
+library, else, given the above constraints, it is obvious that the camera would
+not work properly with that frontend program.
+
WARRANTY?
Absolutely none. Remember, I did not sell you this software. I have written
this driver for my own edification and in the sincere hope that it might help
you to use of your camera. Please see also the warranty clauses
-in the LGPL license. \ No newline at end of file
+in the LGPL license.
+
diff --git a/camlibs/jl2005c/jl2005c.c b/camlibs/jl2005c/jl2005c.c
index a44f1bcf3..b620a10ce 100644
--- a/camlibs/jl2005c/jl2005c.c
+++ b/camlibs/jl2005c/jl2005c.c
@@ -45,10 +45,8 @@ jl2005c_init (Camera *camera, GPPort *port, CameraPrivateLibrary *priv)
memset(info,0, sizeof(info));
memset(command,0,sizeof(command));
GP_DEBUG("Running jl2005c_init\n");
-
-
+ set_usb_in_endpoint (camera, 0x84);
gp_port_write (port, "\x08\x00", 2);
-
usleep (10000);
gp_port_write (port, "\x95\x60", 2);
usleep (10000);
@@ -67,7 +65,7 @@ jl2005c_init (Camera *camera, GPPort *port, CameraPrivateLibrary *priv)
usleep (10000);
gp_port_write (port,"\x95\x63" , 2);
usleep (10000);
- gp_port_read (port, &response, 1);
+gp_port_read (port, &response, 1);
model_string[3]=response;
GP_DEBUG("Model string is %02x%02x%02x%02x\n",model_string[0], model_string[1],
model_string[2], model_string[3]);
@@ -147,7 +145,7 @@ jl2005c_init (Camera *camera, GPPort *port, CameraPrivateLibrary *priv)
gp_port_read (port, &response, 1);
usleep (10000);
- gp_port_write (port, "\x0a\x00", 2);
+ gp_port_write (port, "\x0a\x00", 2);
usleep (10000);
/* Switch the inep over to 0x82. It stays there ever after. */
@@ -159,12 +157,131 @@ jl2005c_init (Camera *camera, GPPort *port, CameraPrivateLibrary *priv)
usleep (10000);
memmove(priv->info, info, info_block_size);
priv->model=info[6];
-
+
GP_DEBUG("Leaving jl2005c_init\n");
return GP_OK;
}
+int
+jl2005c_rewind (Camera *camera, GPPort *port)
+{
+// gp_port_write (port, "\x0b\x00",2);
+ unsigned char command[2];
+ char response;
+ unsigned char info[0xe000];
+ int info_block_size = 0;
+ int junk_to_read = 0;
+ memset(info,0, sizeof(info));
+ memset(command,0,sizeof(command));
+ GP_DEBUG("Running jl2005c_rewind\n");
+ gp_port_close(port);
+ usleep (100000);
+ gp_port_open(port);
+
+ set_usb_in_endpoint (camera, 0x84);
+ gp_port_write (port, "\x08\x00", 2);
+
+ usleep (10000);
+ gp_port_write (port, "\x95\x60", 2);
+ usleep (10000);
+ gp_port_read (port, &response, 1);
+ usleep (10000);
+ gp_port_write (port, "\x95\x61", 2);
+ usleep (10000);
+ gp_port_read (port, &response, 1);
+ usleep (10000);
+ gp_port_write (port, "\x95\x62", 2);
+ usleep (10000);
+ gp_port_read (port, &response, 1);
+ usleep (10000);
+ gp_port_write (port,"\x95\x63" , 2);
+ usleep (10000);
+ gp_port_read (port, &response, 1);
+ usleep (10000);
+ gp_port_write (port, "\x95\x64", 2);
+ usleep (10000);
+ gp_port_read (port, &response, 1);
+
+ usleep (10000);
+ gp_port_write (port, "\x95\x65", 2);
+ usleep (10000);
+ gp_port_read (port, &response, 1);
+ info_block_size = ((unsigned)response * 0x10) + 2;
+ if (info_block_size%0x200)
+ info_block_size += 0x200 - (info_block_size%0x200);
+ usleep (10000);
+
+ gp_port_write (port, "\x95\x66", 2);
+ usleep (10000);
+ gp_port_read (port, &response, 1);
+ usleep (10000);
+
+ gp_port_write (port, "\x95\x67", 2);
+ usleep (10000);
+ gp_port_read (port, &response, 1);
+ usleep (10000);
+
+ gp_port_write (port, "\x95\x68", 2);
+ usleep (10000);
+ gp_port_read (port, &response, 1);
+ usleep (10000);
+
+ gp_port_write (port, "\x95\x69", 2);
+ usleep (10000);
+ gp_port_read (port, &response, 1);
+ usleep (10000);
+
+ gp_port_write (port, "\x95\x6a", 2);
+ usleep (10000);
+ gp_port_read (port, &response, 1);
+ usleep (10000);
+
+ gp_port_write (port, "\x95\x6b", 2);
+ usleep (10000);
+ gp_port_read (port, &response, 1);
+ usleep (10000);
+
+ gp_port_write (port, "\x95\x6c", 2);
+ usleep (10000);
+ gp_port_read (port, &response, 1);
+
+ junk_to_read = (response &0xff)*0x100;
+
+ gp_port_write (port, "\x95\x6d", 2);
+ usleep (10000);
+ gp_port_read (port, &response, 1);
+ usleep (10000);
+
+ junk_to_read += (response&0xff);
+ junk_to_read *= 0x200;
+ gp_port_write (port, "\x95\x6e", 2);
+ usleep (10000);
+ gp_port_read (port, &response, 1);
+ usleep (10000);
+ gp_port_write (port, "\x95\x6f", 2);
+ usleep (10000);
+ gp_port_read (port, &response, 1);
+ usleep (10000);
+ gp_port_write (port, "\x0a\x00", 2);
+
+ usleep (10000);
+
+ /* Switch the inep over to 0x82. It stays there ever after. */
+ set_usb_in_endpoint (camera, 0x82);
+ usleep (10000);
+ gp_port_read(port, (char *)info, info_block_size);
+
+ usleep (10000);
+ gp_port_write (port, "\x0b\x00",2);
+ usleep (10000);
+
+ GP_DEBUG("Completing jl2005c_rewind\n");
+
+ return GP_OK;
+}
+
+
int
jl2005c_get_pic_data_size (CameraPrivateLibrary *priv, Info *info, int n)
{
@@ -174,6 +291,7 @@ jl2005c_get_pic_data_size (CameraPrivateLibrary *priv, Info *info, int n)
size = info[0x30+0x10*n+6]*0x100+info[0x30+0x10*n+7];
switch (model) {
case 0x43:
+ case 0x44:
size *= 0x200;
break;
case 0x42:
@@ -199,6 +317,7 @@ jl2005c_get_start_of_photo(CameraPrivateLibrary *priv, Info *info,
info[0x30+0x0d];
switch (model) {
case 0x43:
+ case 0x44:
start *= 0x200;
break;
case 0x42:
@@ -217,9 +336,10 @@ set_usb_in_endpoint (Camera *camera, int inep)
{
GPPortSettings settings;
gp_port_get_settings ( camera ->port, &settings);
- settings.usb.inep = inep;
+ if(settings.usb.inep!=inep)
+ settings.usb.inep = inep;
GP_DEBUG("inep reset to %02X\n", inep);
- return gp_port_set_settings ( camera ->port, settings);
+ return gp_port_set_settings ( camera->port, settings);
}
@@ -236,13 +356,36 @@ jl2005c_get_picture_data (GPPort *port,
/*Data transfer begins*/
gp_port_read (port, data, size);
usleep (10000);
- return GP_OK;
+ return GP_OK;
}
int
jl2005c_reset (Camera *camera, GPPort *port)
{
- gp_port_write(port, "\x07\x00", 2);
- return GP_OK;
+ int blocksize = 0xfa00;
+ /* These cameras want all data to be dumped. If that is not yet done,
+ * then do it now, before exiting! */
+ while (camera->pl->bytes_read_from_camera <
+ camera->pl->total_data_in_camera ) {
+ if (! camera->pl->data_cache )
+ camera->pl->data_cache = malloc (0xfa00);
+ blocksize=0xfa00;
+ if (camera->pl->bytes_read_from_camera +0xfa00 >=
+ camera->pl->total_data_in_camera )
+ blocksize = camera->pl->total_data_in_camera -
+ camera->pl->bytes_read_from_camera;
+ if(blocksize)
+ jl2005c_get_picture_data (
+ camera->port,
+ (char *) camera->pl->data_cache,
+ blocksize);
+ camera->pl->bytes_read_from_camera
+ += blocksize;
+
+ }
+
+
+ gp_port_write(port, "\x07\x00", 2);
+ return GP_OK;
}
diff --git a/camlibs/jl2005c/jl2005c.h b/camlibs/jl2005c/jl2005c.h
index eeccaf88b..75bc4f499 100644
--- a/camlibs/jl2005c/jl2005c.h
+++ b/camlibs/jl2005c/jl2005c.h
@@ -28,7 +28,7 @@ typedef unsigned char Info;
struct _CameraPrivateLibrary {
unsigned char model;
- unsigned char *catalog;
+// unsigned char *catalog;
int nb_entries;
int last_fetched_entry;
unsigned long total_data_in_camera;
@@ -36,13 +36,14 @@ struct _CameraPrivateLibrary {
unsigned char *data_cache;
unsigned long bytes_read_from_camera;
int data_used_from_block;
- unsigned long bytes_put_away;
+ unsigned long bytes_put_away;
Info info[0xe000];
};
int jl2005c_init (Camera *camera, GPPort *port,
CameraPrivateLibrary *priv);
+int jl2005c_rewind (Camera *camera, GPPort *port);
int jl2005c_reset (Camera *camera, GPPort *port);
int jl2005c_get_num_pics (Info *info);
int jl2005c_get_resolution (Info *info, int n);
diff --git a/camlibs/jl2005c/library.c b/camlibs/jl2005c/library.c
index 68a119918..da1f43b40 100644
--- a/camlibs/jl2005c/library.c
+++ b/camlibs/jl2005c/library.c
@@ -164,43 +164,26 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
CameraFileType type, CameraFile *file, void *user_data,
GPContext *context)
{
- Camera *camera = user_data;
- int w, h = 0, b = 0, k;
- unsigned char *pic_data;
- int res_code;
- unsigned char photo_code, compressed;
+ Camera *camera = user_data;
+ int w, h = 0, b = 0, k;
+ unsigned char *pic_data, *pic_buffer;
+ int HEADERSIZE=16;
+ unsigned char compressed;
unsigned long start_of_photo;
unsigned int blocksize = 0;
int filled = 0;
- GP_DEBUG ("Downloading pictures!\n");
+ GP_DEBUG ("Downloading pictures!\n");
/* These are cheap cameras. There ain't no EXIF data. */
if (GP_FILE_TYPE_EXIF == type) return GP_ERROR_FILE_EXISTS;
-
- /* Get the number of the photo on the camera */
+ /* Get the number of the photo on the camera */
k = gp_filesystem_number (camera->fs, "/", filename, context);
- /* Determine the resolution setting from the PAT table */
- photo_code = camera->pl->info[48+16*k+2];
- res_code = photo_code & 0x0f;
- /* Compression presence or absence is seen here, and is given again
- * by the camera, in the header of raw data for each photo.
- */
- compressed = (photo_code >> 4) & 0x0f;
- switch (res_code) {
- case 0:
- w = 640;
- h = 480;
- break;
- case 1:
- w = 320;
- h = 240;
- break;
- default:
- GP_DEBUG("width is unknown\n");
- return GP_ERROR;
- }
-
+ /* Determine the "compression" setting from the PAT table */
+ compressed = (camera->pl->info[48+16*k+2]>>4) & 0x0f;
+ h = camera->pl->info[48+16*k+4];
+ w = camera->pl->info[48+16*k+5];
+
GP_DEBUG ("height is %i\n", h);
b = jl2005c_get_pic_data_size(camera->pl, camera->pl->info, k);
@@ -208,17 +191,16 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
start_of_photo = jl2005c_get_start_of_photo(camera->pl,
camera->pl->info, k);
GP_DEBUG("start_of_photo number %i = 0x%lx \n", k,start_of_photo);
- pic_data = malloc (b+1);
- if (!pic_data) return GP_ERROR_NO_MEMORY;
- memset (pic_data, 0, b+1);
- GP_DEBUG ("buffersize b = %i = 0x%x bytes\n", b+1,b+1);
- pic_data[b] = photo_code;
- GP_DEBUG("photo_code = %02x and pic_data[b+1] = %02x\n", photo_code, pic_data[b]);
-
- /* Camera downloads in blocks of 0xfa00, with last block possibly short.
- * So first we set up the permanent cache (if not done already).
+ pic_buffer = malloc (b+16);
+ if (!pic_buffer) return GP_ERROR_NO_MEMORY;
+ memset (pic_buffer, 0, b+16);
+ GP_DEBUG ("buffersize b+16 = %i = 0x%x bytes\n", b+16,b+16);
+ /* copy info line for photo from allocation table, as header */
+ memcpy(pic_buffer, camera->pl->info+48+16*k, 16);
+ /* Camera can download in blocks of 0xfa00, with last block possibly short.
+ * So first we set up a cache (if not done already) to hold raw data.
*/
-
+ pic_data = pic_buffer+HEADERSIZE;
if (! camera->pl->data_cache ) {
camera->pl->data_cache = malloc (0xfa00);
}
@@ -231,11 +213,42 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
* current photo, immediately. Update settings. But first a sanity check.
*/
- if (start_of_photo != camera->pl->bytes_put_away) {
+ if (start_of_photo < camera->pl->bytes_put_away) {
GP_DEBUG("photo number %i starts in a funny place!\n",k);
+// camera->pl->bytes_put_away=start_of_photo;
+// memset(camera->pl->data_cache, 0, 0xfa00);
+ jl2005c_reset(camera, camera->port);
+ jl2005c_rewind (camera, camera->port);
+ camera->pl->bytes_read_from_camera=0;
+// return (GP_ERROR);
+ }
+ if (start_of_photo+b > camera->pl->total_data_in_camera) {
+ GP_DEBUG("photo number %i ends in a funny place!\n",k);
+ GP_DEBUG("Allocation unit size may be wrong for this camera\n");
return (GP_ERROR);
}
- /* OK, good. */
+
+ /* This while loop is entered if the photo number k-1 was not requested
+ * and thus has not been downloaded. The camera's rudimentary hardware
+ * obliges us to download the corresponding data anyway and toss it.
+ */
+ while (camera->pl->bytes_read_from_camera <= start_of_photo) {
+
+ camera->pl->data_to_read = camera->pl->total_data_in_camera
+ - camera->pl->bytes_read_from_camera;
+ blocksize = 0xfa00;
+ if (camera->pl->data_to_read < blocksize)
+ blocksize = camera->pl->data_to_read;
+ GP_DEBUG("blocksize = 0x%x\n", blocksize);
+ if(blocksize)
+ jl2005c_get_picture_data (
+ camera->port,
+ (char *) camera->pl->data_cache,
+ blocksize);
+ camera->pl->bytes_read_from_camera += blocksize;
+ }
+
+ camera->pl->bytes_put_away=start_of_photo;
if (camera->pl->bytes_read_from_camera > start_of_photo) {
if(start_of_photo + b <= camera->pl->bytes_read_from_camera) {
@@ -247,7 +260,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
* Jump immediately to process the photo.
*/
} else {
-
+ /* photo starts in one block and ends in another */
filled = camera->pl->bytes_read_from_camera
- start_of_photo;
@@ -257,7 +270,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
camera->pl->bytes_put_away += filled;
}
- }
+ }
while (camera->pl->bytes_put_away < start_of_photo + b ) {
camera->pl->data_to_read = camera->pl->total_data_in_camera
@@ -272,6 +285,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
(char *) camera->pl->data_cache,
blocksize);
camera->pl->bytes_read_from_camera += blocksize;
+
if (camera->pl->bytes_read_from_camera >= start_of_photo + b ) {
GP_DEBUG("THIS ONE?\n");
memcpy(pic_data+filled, camera->pl->data_cache,
@@ -279,7 +293,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
camera->pl->bytes_put_away += b - filled;
break;
} else {
- GP_DEBUG("THIS ONE??\n");
+ GP_DEBUG("THIS ONE??\n");
if (!blocksize)
break;
memcpy(pic_data+filled, camera->pl->data_cache, blocksize);
@@ -288,15 +302,10 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
}
}
-
-
if (GP_FILE_TYPE_RAW == type) {
- memcpy (pic_data+b, &photo_code,1);
- GP_DEBUG("photo_code = %02x and pic_data[b+1] = %02x\n",
- photo_code, pic_data[b]);
gp_file_set_mime_type(file, GP_MIME_RAW);
gp_file_set_name(file, filename);
- gp_file_set_data_and_size(file, (char *)pic_data , b+1 );
+ gp_file_set_data_and_size(file, (char *)pic_buffer , b+16 );
return GP_OK;
} else return GP_ERROR_NOT_SUPPORTED;
@@ -315,7 +324,29 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
static int
camera_exit (Camera *camera, GPContext *context)
{
+// int blocksize = 0xfa00;
GP_DEBUG ("jl2005c camera_exit");
+ /* These cameras want all data to be dumped. If that is not yet done,
+ * then do it now, before exiting! */
+/* while (camera->pl->bytes_read_from_camera <
+ camera->pl->total_data_in_camera ) {
+ if (! camera->pl->data_cache )
+ camera->pl->data_cache = malloc (0xfa00);
+ blocksize=0xfa00;
+ if (camera->pl->bytes_read_from_camera +0xfa00 >=
+ camera->pl->total_data_in_camera )
+ blocksize = camera->pl->total_data_in_camera -
+ camera->pl->bytes_read_from_camera;
+ if(blocksize)
+ jl2005c_get_picture_data (
+ camera->port,
+ (char *) camera->pl->data_cache,
+ blocksize);
+ camera->pl->bytes_read_from_camera
+ += blocksize;
+
+ }
+*/
jl2005c_reset(camera, camera->port);
gp_port_close(camera->port);
if (camera->pl) {