2001-12-11 Lutz M�ller <urc8@rz.uni-karlsruhe.de>

* camlibs: Remove references to GP_ERROR_IO_TIMEOUT - we use
          GP_ERROR_TIMEOUT instead.


git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@3482 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
Lutz Mueller
2001-12-11 12:29:56 +00:00
parent dd56bbba59
commit f967e2d00d
9 changed files with 134 additions and 74 deletions

View File

@@ -1,3 +1,8 @@
2001-12-11 Lutz Müller <urc8@rz.uni-karlsruhe.de>
* camlibs: Remove references to GP_ERROR_IO_TIMEOUT - we use
GP_ERROR_TIMEOUT instead.
2001-12-08 Marcus Meissner <marcus@jet.franken.de>
* camlibs/stv0680: Added 'capture-image'. Tried implementing a

View File

@@ -215,7 +215,7 @@ canon_serial_get_byte (GPPort *gdev)
}
recv = gp_port_read (gdev, cache, 1);
if (recv == GP_ERROR || recv == GP_ERROR_IO_TIMEOUT)
if (recv == GP_ERROR || recv == GP_ERROR_TIMEOUT)
return -1;
cachep = cache;

View File

@@ -114,7 +114,7 @@ static int get_raw_byte (void)
ret=gp_port_read(thedev,buffer,1);
/*ret = read(devfd, buffer, 128);*/
DBG2("GOT %d",ret);
if (ret == GP_ERROR_IO_TIMEOUT)
if (ret == GP_ERROR_TIMEOUT)
return -1; /* timeout */
if (ret == GP_ERROR) {
return -1; /* error */

View File

@@ -499,13 +499,13 @@ int jamcam_write_packet (Camera *camera, char *packet, int length) {
for (r = 0; r < RETRIES; r++) {
ret = gp_port_write (camera->port, packet, length);
if (ret == GP_ERROR_IO_TIMEOUT)
if (ret == GP_ERROR_TIMEOUT)
continue;
return (ret);
}
return (GP_ERROR_IO_TIMEOUT);
return (GP_ERROR_TIMEOUT);
}
@@ -519,7 +519,7 @@ int jamcam_read_packet (Camera *camera, char *packet, int length) {
for (r = 0; r < RETRIES; r++) {
bytes_read = gp_port_read (camera->port, packet, length);
if (bytes_read == GP_ERROR_IO_TIMEOUT)
if (bytes_read == GP_ERROR_TIMEOUT)
continue;
if (bytes_read < 0)
return (bytes_read);
@@ -529,7 +529,7 @@ int jamcam_read_packet (Camera *camera, char *packet, int length) {
}
}
return (GP_ERROR_IO_TIMEOUT);
return (GP_ERROR_TIMEOUT);
}
@@ -549,13 +549,13 @@ int jamcam_enq (Camera *camera)
strcpy((char *)buf, "KB99" );
ret = jamcam_write_packet (camera, (char *)buf, 4);
if (ret == GP_ERROR_IO_TIMEOUT)
if (ret == GP_ERROR_TIMEOUT)
continue;
if (ret != GP_OK)
return (ret);
ret = jamcam_read_packet (camera, (char *)buf, 4);
if (ret == GP_ERROR_IO_TIMEOUT)
if (ret == GP_ERROR_TIMEOUT)
continue;
if (ret != GP_OK)
return (ret);
@@ -609,7 +609,7 @@ int jamcam_enq (Camera *camera)
break;
}
return (GP_ERROR_IO_TIMEOUT);
return (GP_ERROR_TIMEOUT);
}
int jamcam_query_mmc_card (Camera *camera)
@@ -629,13 +629,13 @@ int jamcam_query_mmc_card (Camera *camera)
for (r = 0; r < RETRIES; r++) {
ret = jamcam_write_packet (camera, buf, 4);
if (ret == GP_ERROR_IO_TIMEOUT)
if (ret == GP_ERROR_TIMEOUT)
continue;
if (ret != GP_OK)
return (ret);
ret = jamcam_read_packet (camera, buf, 4);
if (ret == GP_ERROR_IO_TIMEOUT)
if (ret == GP_ERROR_TIMEOUT)
continue;
if (ret != GP_OK)
return (ret);
@@ -651,6 +651,6 @@ int jamcam_query_mmc_card (Camera *camera)
return (GP_OK);
}
return (GP_ERROR_IO_TIMEOUT);
return (GP_ERROR_TIMEOUT);
}

View File

@@ -141,8 +141,7 @@ static int dc240_wait_for_completion (Camera *camera) {
case GP_ERROR:
return (GP_ERROR);
break;
case GP_ERROR_IO_TIMEOUT:
case GP_ERROR_TIMEOUT:
case GP_ERROR_TIMEOUT:
break;
default:
done = 1;
@@ -178,7 +177,6 @@ static int dc240_wait_for_busy_completion (Camera *camera)
case GP_ERROR:
return retval;
break;
case GP_ERROR_IO_TIMEOUT:
case GP_ERROR_IO_READ:
case GP_ERROR_TIMEOUT:
/* in busy state, GP_ERROR_IO_READ can happend */
@@ -237,8 +235,7 @@ read_data_read_again:
/* Read the response/data */
retval = dc240_packet_read(camera, packet, block_size+2);
if ((retval == GP_ERROR) || (retval == GP_ERROR_TIMEOUT) ||
(retval == GP_ERROR_IO_TIMEOUT) ) {
if ((retval == GP_ERROR) || (retval == GP_ERROR_TIMEOUT)) {
/* ERROR reading response/data */
if (retries++ > RETRIES)
return (GP_ERROR);

View File

@@ -51,45 +51,99 @@
#define CHECK_NULL(r) {if (!(r)) return (GP_ERROR_BAD_PARAMETERS);}
#define CHECK_FREE(r,f) {int ret = (r); if (ret < 0) {free (f); return (ret);}}
static int
l_ping_rec (GPPort *device, unsigned int level)
{
unsigned char c;
/* Write ENQ and read the response. */
c = ENQ;
CHECK (gp_port_write (device, &c, 1));
CHECK (gp_port_read (device, &c, 1));
switch (c) {
case ACK:
return (GP_OK);
case NACK:
/*
* Uh, lets try again a couple of times, but
* make sure we don't recurse forever.
*/
if (level < 30)
return (l_ping_rec (device, level + 1));
else
return (GP_ERROR_CORRUPTED_DATA);
case ENQ:
/*
* ENQ received. It seems that the camera would like
* to send us data, but we do not want it and
* therefore simply reject it. The camera will try
* two more times with ENQ to get us to receive data
* before finally giving up and sending us ACK.
*/
/* Write NACK. */
c = NACK;
CHECK (gp_port_write (device, &c, 1));
for (;;) {
CHECK (gp_port_read (device, &c, 1));
switch (c) {
case ENQ:
/* The camera has not yet given up. */
continue;
case ACK:
/* ACK received. We can proceed. */
return (GP_OK);
default:
/* This should not happen. */
return (GP_ERROR_CORRUPTED_DATA);
}
break;
}
break;
default:
/*
* The camera seems to send us data. We'll
* simply ignore it and try again (but make
* sure that we don't loop forever).
*/
CHECK (gp_port_flush (device, 0));
CHECK (gp_port_flush (device, 1));
if (level > 50)
return (GP_ERROR_CORRUPTED_DATA);
else
return (l_ping_rec (device, level + 1));
}
return (GP_OK);
}
static int
l_ping (GPPort *device)
{
return (l_ping_rec (device, 0));
}
int
l_init (GPPort *device)
{
unsigned char c;
int i, result;
unsigned int i;
int result = GP_OK;
CHECK_NULL (device);
CHECK (gp_port_set_timeout (device, DEFAULT_TIMEOUT));
for (i = 0; ; i++) {
/* Write ENQ. */
CHECK (gp_port_write (device, "\5", 1));
if ((result = gp_port_read (device, &c, 1)) < 1) {
/*
* We didn't receive anything. We'll try up to four
* times.
*/
if (i == 4)
return (result);
continue;
}
switch (c) {
case ACK:
/* ACK received. We can proceed. */
return (GP_OK);
default:
/*
* The camera seems to be sending something. We'll
* dump all bytes we get and try again.
*/
while (gp_port_read (device, &c, 1) > 0);
i--;
for (i = 0; i < 3; i++) {
result = l_ping (device);
if (result != GP_ERROR_TIMEOUT)
break;
}
}
return (result);
}
static int
@@ -146,6 +200,8 @@ l_send (GPPort *device, unsigned char *send_buffer,
CHECK_NULL (device && send_buffer);
CHECK (gp_port_set_timeout (device, 1000));
#if 0
for (;;) {
/* Write ENQ. */
@@ -215,6 +271,8 @@ l_send (GPPort *device, unsigned char *send_buffer,
}
break;
}
#endif
/********************************************************/
/* We will write: */
/* - STX */

View File

@@ -416,13 +416,13 @@ int coolshot_write_packet (Camera *camera, char *packet) {
for (r = 0; r < RETRIES; r++) {
ret = gp_port_write (camera->port, packet, length);
if (ret == GP_ERROR_IO_TIMEOUT)
if (ret == GP_ERROR_TIMEOUT)
continue;
return (ret);
}
return (GP_ERROR_IO_TIMEOUT);
return (GP_ERROR_TIMEOUT);
}
@@ -447,7 +447,7 @@ read_packet_again:
for (r = 0; r < RETRIES; r++) {
bytes_read = gp_port_read (camera->port, packet, blocksize);
if (bytes_read == GP_ERROR_IO_TIMEOUT)
if (bytes_read == GP_ERROR_TIMEOUT)
continue;
if (bytes_read < 0)
return (bytes_read);
@@ -469,7 +469,7 @@ read_packet_again:
}
bytes_read = gp_port_read (camera->port, packet + 1, 3 );
if (bytes_read == GP_ERROR_IO_TIMEOUT)
if (bytes_read == GP_ERROR_TIMEOUT)
continue;
if (bytes_read < 0)
return (bytes_read);
@@ -480,7 +480,7 @@ read_packet_again:
( strncmp( packet + 2, "SB", 2 ) == 0 )) {
/* normal 16-byte packet, so read the other 12 bytes */
ret = gp_port_read (camera->port, packet + 4, 12 );
if (ret == GP_ERROR_IO_TIMEOUT) {
if (ret == GP_ERROR_TIMEOUT) {
/* fixme */
/*
coolshot_nak (camera);
@@ -512,7 +512,7 @@ read_packet_again:
/* fixme, error detection */
x = 0;
while(( ret == GP_ERROR_IO_TIMEOUT ) &&
while(( ret == GP_ERROR_TIMEOUT ) &&
( x < RETRIES )) {
x++;
ret = gp_port_read (camera->port, packet + 8, length );
@@ -524,7 +524,7 @@ read_packet_again:
if (done) break;
}
return (GP_ERROR_IO_TIMEOUT);
return (GP_ERROR_TIMEOUT);
}
@@ -540,12 +540,12 @@ int coolshot_ack (Camera *camera)
for (r = 0; r < RETRIES; r++) {
ret = coolshot_write_packet (camera, buf);
if (ret == GP_ERROR_IO_TIMEOUT)
if (ret == GP_ERROR_TIMEOUT)
continue;
if (ret == GP_OK)
return (ret);
}
return (GP_ERROR_IO_TIMEOUT);
return (GP_ERROR_TIMEOUT);
}
int coolshot_nak (Camera *camera)
@@ -560,12 +560,12 @@ int coolshot_nak (Camera *camera)
for (r = 0; r < RETRIES; r++) {
ret = coolshot_write_packet (camera, buf);
if (ret == GP_ERROR_IO_TIMEOUT)
if (ret == GP_ERROR_TIMEOUT)
continue;
if (ret == GP_OK)
return (ret);
}
return (GP_ERROR_IO_TIMEOUT);
return (GP_ERROR_TIMEOUT);
}
int coolshot_enq (Camera *camera)
@@ -580,13 +580,13 @@ int coolshot_enq (Camera *camera)
for (r = 0; r < RETRIES; r++) {
ret = coolshot_write_packet (camera, buf);
if (ret == GP_ERROR_IO_TIMEOUT)
if (ret == GP_ERROR_TIMEOUT)
continue;
if (ret != GP_OK)
return (ret);
ret = coolshot_read_packet (camera, buf);
if (ret == GP_ERROR_IO_TIMEOUT)
if (ret == GP_ERROR_TIMEOUT)
continue;
if (ret != GP_OK)
return (ret);
@@ -597,7 +597,7 @@ int coolshot_enq (Camera *camera)
return (GP_ERROR_CORRUPTED_DATA);
}
return (GP_ERROR_IO_TIMEOUT);
return (GP_ERROR_TIMEOUT);
}

View File

@@ -380,13 +380,13 @@ sierra_write_packet (Camera *camera, char *packet)
for (r = 0; r < RETRIES; r++) {
ret = gp_port_write (camera->port, packet, length);
if (ret == GP_ERROR_IO_TIMEOUT)
if (ret == GP_ERROR_TIMEOUT)
continue;
return (ret);
}
return (GP_ERROR_IO_TIMEOUT);
return (GP_ERROR_TIMEOUT);
}
static int
@@ -532,7 +532,7 @@ sierra_read_packet (Camera *camera, char *packet)
}
/* Retry on IO error only */
if (ret_status == GP_ERROR_IO_TIMEOUT) {
if (ret_status == GP_ERROR_TIMEOUT) {
sierra_write_nak (camera);
GP_SYSTEM_SLEEP(10);
}
@@ -608,13 +608,13 @@ int sierra_ping (Camera *camera)
for (r = 0; r < RETRIES; r++) {
ret = sierra_write_packet (camera, buf);
if (ret == GP_ERROR_IO_TIMEOUT)
if (ret == GP_ERROR_TIMEOUT)
continue;
if (ret != GP_OK)
return ret;;
ret = sierra_read_packet (camera, buf);
if (ret == GP_ERROR_IO_TIMEOUT)
if (ret == GP_ERROR_TIMEOUT)
continue;
if (ret != GP_OK)
return ret;
@@ -766,7 +766,7 @@ int sierra_set_int_register (Camera *camera, int reg, int value)
CHECK (sierra_write_packet (camera, p));
ret = sierra_read_packet (camera, buf);
if (ret == GP_ERROR_IO_TIMEOUT)
if (ret == GP_ERROR_TIMEOUT)
continue;
CHECK (ret);
@@ -810,7 +810,7 @@ int sierra_get_int_register (Camera *camera, int reg, int *value)
CHECK (sierra_write_packet (camera, packet));
ret = sierra_read_packet (camera, buf);
if (ret == GP_ERROR_IO_TIMEOUT)
if (ret == GP_ERROR_TIMEOUT)
continue;
CHECK (ret);
@@ -892,12 +892,12 @@ int sierra_set_string_register (Camera *camera, int reg, const char *s, long int
while ((r++ < RETRIES) && (!done)) {
ret = sierra_write_packet (camera, packet);
if (ret == GP_ERROR_IO_TIMEOUT)
if (ret == GP_ERROR_TIMEOUT)
continue;
CHECK (ret);
ret = sierra_read_packet (camera, buf);
if (ret == GP_ERROR_IO_TIMEOUT)
if (ret == GP_ERROR_TIMEOUT)
continue;
CHECK (ret);
@@ -1036,12 +1036,12 @@ int sierra_delete (Camera *camera, int picture_number)
while ((!done) && (r++<RETRIES)) {
ret = sierra_write_packet (camera, packet);
if (ret == GP_ERROR_IO_TIMEOUT)
if (ret == GP_ERROR_TIMEOUT)
continue;
CHECK (ret);
ret = sierra_read_packet (camera, buf);
if (ret == GP_ERROR_IO_TIMEOUT)
if (ret == GP_ERROR_TIMEOUT)
continue;
CHECK (ret);

View File

@@ -135,7 +135,7 @@ static int stv0680_try_cmd(GPPort *port, unsigned char cmd,
while(retries--) {
/* data3 was always 0 */
switch(ret=stv0680_cmd(port,cmd,(data>>8)&0xff,data&0xff,0,response,response_len)) {
case GP_ERROR_IO_TIMEOUT:
case GP_ERROR_TIMEOUT:
case GP_ERROR_BAD_PARAMETERS:
break;
default: