diff options
author | Hubert Figuiere <hub@figuiere.net> | 2001-11-13 07:43:05 +0000 |
---|---|---|
committer | Hubert Figuiere <hub@figuiere.net> | 2001-11-13 07:43:05 +0000 |
commit | 4144ddc7a769703be7d4b04b0c53259f43d24af7 (patch) | |
tree | cc198d3d76e4ec6f7997bb93a0a0b1cf29cc2dca /camlibs/kodak | |
parent | f35526a080b925222979b63ffd86b1735b11464e (diff) | |
download | libgphoto2-4144ddc7a769703be7d4b04b0c53259f43d24af7.tar.gz |
* camlibs/kodak/dc240/library.c: Handle GP_ERROR_IO_TIMEOUT errors. Better
handling of checksums. (patch by Peter Fales <psfales@lucent.com>)
* camlibs/kodak/dc240/dc240.c (camera_init): camera reset sends garbage
within the 1500ms timeout. Handle that properly with 2 read. (patch by
Peter Fales <psfales@lucent.com>)
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@3004 67ed7778-7388-44ab-90cf-0a291f65f57c
Diffstat (limited to 'camlibs/kodak')
-rw-r--r-- | camlibs/kodak/dc240/dc240.c | 12 | ||||
-rw-r--r-- | camlibs/kodak/dc240/library.c | 7 |
2 files changed, 15 insertions, 4 deletions
diff --git a/camlibs/kodak/dc240/dc240.c b/camlibs/kodak/dc240/dc240.c index 1d6dc3920..0f7023ae0 100644 --- a/camlibs/kodak/dc240/dc240.c +++ b/camlibs/kodak/dc240/dc240.c @@ -221,11 +221,19 @@ camera_init (Camera *camera) return (ret); if (camera->port->type == GP_PORT_SERIAL) { + char buf[8]; /* Reset the camera to 9600 */ gp_port_send_break(camera->port, 1); - /* Wait for it to reset */ - GP_SYSTEM_SLEEP(1500); + /* Used to have a 1500 msec pause here to give + * the camera time to reset - but, since + * the serial port sometimes returns a garbage + * character or two after the break, we do + * a couple of TIMEOUT (750 msec) pauses here + * force the delay as well as flush the port + */ + gp_port_read(camera->port, buf, 8); + gp_port_read(camera->port, buf, 8); ret = dc240_set_speed (camera, selected_speed); if (ret < 0) diff --git a/camlibs/kodak/dc240/library.c b/camlibs/kodak/dc240/library.c index af394808e..16ced746d 100644 --- a/camlibs/kodak/dc240/library.c +++ b/camlibs/kodak/dc240/library.c @@ -134,6 +134,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: break; default: @@ -170,6 +171,7 @@ 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 */ @@ -228,7 +230,8 @@ 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)) { + if ((retval == GP_ERROR) || (retval == GP_ERROR_TIMEOUT) || + (retval == GP_ERROR_IO_TIMEOUT) ) { /* ERROR reading response/data */ if (retries++ > RETRIES) return (GP_ERROR); @@ -248,7 +251,7 @@ read_data_read_again: for (i = 1; i < block_size + 1; i++) { check_sum ^= packet [i]; } - if (check_sum != packet [i]) { + if ( block_size > 1 && check_sum != packet [i]) { dc240_packet_write_nak (camera); goto read_data_read_again; } |