summaryrefslogtreecommitdiff
path: root/camlibs/fuji
diff options
context:
space:
mode:
authorMatt Martin <matt.martin@ieee.org>2002-04-21 20:22:59 +0000
committerMatt Martin <matt.martin@ieee.org>2002-04-21 20:22:59 +0000
commita167e725a07037551ed317b4182e48a4bca8427b (patch)
treedbcf42ff0d7c347dad4456c8300a4c9a4af23090 /camlibs/fuji
parent6f70e38e46c9f5daf4c85f3e9f47f0fa9158da39 (diff)
downloadlibgphoto2-a167e725a07037551ed317b4182e48a4bca8427b.tar.gz
Fixed some pointer errors in CFR macro calls.
Added quick escaping of 0xff codes, needs to become a function like get_byte of old driver. Made provisions for DS-7 which does not support file-length query. Fixed FUJI_CMD_PIC_GET vs PIC_GET_THUMB swap. git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@4458 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'camlibs/fuji')
-rw-r--r--camlibs/fuji/fuji.c17
-rw-r--r--camlibs/fuji/fuji.h6
2 files changed, 15 insertions, 8 deletions
diff --git a/camlibs/fuji/fuji.c b/camlibs/fuji/fuji.c
index 103aa5809..5bd7ce023 100644
--- a/camlibs/fuji/fuji.c
+++ b/camlibs/fuji/fuji.c
@@ -90,6 +90,7 @@
#define ESC 0x10
#define ETB 0x17 /* End of transmission block */
#define NAK 0x15
+#define PERR 0xff
#define FUJI_ACK 0x00
#define FUJI_NAK 0x01
@@ -436,6 +437,7 @@ fuji_recv (Camera *camera, unsigned char *buf, unsigned int *buf_len,
/* Read the data. Unescape it. Calculate the checksum. */
for (i = 0; i < *buf_len; i++) {
CR (gp_port_read (camera->port, buf + i, 1));
+ if (buf[i]==PERR) CR (gp_port_read (camera->port, buf + i, 1));
if (buf[i] == ESC) {
CR (gp_port_read (camera->port, buf + i, 1));
if (buf[i] != ESC) {
@@ -508,6 +510,7 @@ fuji_transmit (Camera *camera, unsigned char *cmd, unsigned int cmd_len,
/* Receive ACK (hopefully) */
CR (gp_port_read (camera->port, &c, 1));
+ if (c==PERR) CR (gp_port_read (camera->port, &c, 1));
switch (c) {
case ACK:
break;
@@ -552,7 +555,7 @@ fuji_transmit (Camera *camera, unsigned char *cmd, unsigned int cmd_len,
retries++;
while (gp_port_read (camera->port, &c, 1) >= 0);
if (++retries > 2)
- return (r);
+ return (r);
GP_DEBUG ("Retrying...");
c = NAK;
CR (gp_port_write (camera->port, &c, 1));
@@ -695,7 +698,8 @@ fuji_pic_get_thumb (Camera *camera, unsigned int i, unsigned char **data,
cmd[4] = i;
cmd[5] = (i >> 8);
- CRF (fuji_transmit (camera, cmd, 6, *data, size, context), data);
+ CRF (fuji_transmit (camera, cmd, 6, *data, size, context), *data);
+ GP_DEBUG("rec'd thumb \n");
return (GP_OK);
}
@@ -710,7 +714,9 @@ fuji_pic_get (Camera *camera, unsigned int i, unsigned char **data,
* First, get the size of the picture and allocate the necessary
* memory.
*/
- CR (fuji_pic_size (camera, i, size, context));
+ /*CR (fuji_pic_size (camera, i, size, context));*/
+ if (fuji_pic_size (camera, i, size, context)<0) *size=66000;
+
*data = malloc (sizeof (char) * *size);
if (!*data) {
gp_context_error (context, _("Could not allocate "
@@ -725,7 +731,8 @@ fuji_pic_get (Camera *camera, unsigned int i, unsigned char **data,
cmd[4] = i;
cmd[5] = (i >> 8);
- CRF (fuji_transmit (camera, cmd, 6, *data, size, context), data);
+ CRF (fuji_transmit (camera, cmd, 6, *data, size, context), *data);
+ GP_DEBUG("Got %d",*size);
return (GP_OK);
}
@@ -1290,7 +1297,7 @@ static int download_picture(int n,int thumb,CameraFile *file,CameraPrivateLibrar
static int fuji_free_memory (void)
{
- cmd0 (0, 0x1B);
+ cmd0 (0, FUJI_CMD_FREE_MEM);
return answer[5] + (answer[6]<<8) + (answer[7]<<16) + (answer[8]<<24);
}
diff --git a/camlibs/fuji/fuji.h b/camlibs/fuji/fuji.h
index 70688ac9c..5f41ce4c6 100644
--- a/camlibs/fuji/fuji.h
+++ b/camlibs/fuji/fuji.h
@@ -26,8 +26,8 @@
typedef enum _FujiCmd FujiCmd;
enum _FujiCmd {
- FUJI_CMD_PIC_GET = 0x00,
- FUJI_CMD_PIC_GET_THUMB = 0x02,
+ FUJI_CMD_PIC_GET = 0x02,
+ FUJI_CMD_PIC_GET_THUMB = 0x00,
FUJI_CMD_SPEED = 0x07,
FUJI_CMD_VERSION = 0x09,
FUJI_CMD_PIC_NAME = 0x0a,
@@ -39,7 +39,7 @@ enum _FujiCmd {
FUJI_CMD_UNKNOWN5 = 0x13,
FUJI_CMD_PIC_SIZE = 0x17,
FUJI_CMD_PIC_DEL = 0x19,
- FUJI_CMD_UNKNOWN9 = 0x1b,
+ FUJI_CMD_FREE_MEM = 0x1b,
FUJI_CMD_UNKNOWN10 = 0x20,
FUJI_CMD_UNKNOWN11 = 0x22,
FUJI_CMD_TAKE = 0x27,