2002-03-28 Lutz M�ller <lutz@users.sourceforge.net>

* library.c: Formatting.
        * sierra.c: Ping the camera before changing the speed.


git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@4358 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
Lutz Mueller
2002-03-29 11:33:43 +00:00
parent ebe20b77bf
commit a7d4e26e9e
3 changed files with 35 additions and 35 deletions

View File

@@ -1,3 +1,8 @@
2002-03-28 Lutz Müller <lutz@users.sourceforge.net>
* library.c: Formatting.
* sierra.c: Ping the camera before changing the speed.
2002-03-14 Patrick Mansfield <patman@aracnet.com>
* sierra.c (camera_get_config_olympus, camera_set_config_olympus):

View File

@@ -322,7 +322,7 @@ sierra_get_memory_left (Camera *camera, int *memory, GPContext *context)
static int
sierra_write_packet (Camera *camera, char *packet)
{
int x, ret, r, checksum=0, length;
int x, checksum=0, length;
GP_DEBUG ("* sierra_write_packet");
@@ -345,26 +345,13 @@ sierra_write_packet (Camera *camera, char *packet)
packet[length-1] = (checksum >> 8) & 0xff;
}
/* USB */
if (camera->port->type == GP_PORT_USB) {
if (camera->pl->usb_wrap)
return (usb_wrap_write_packet (camera->port, packet,
length));
else
return (gp_port_write (camera->port, packet, length));
if (camera->pl->usb_wrap) {
CHECK (usb_wrap_write_packet (camera->port, packet, length));
} else {
CHECK (gp_port_write (camera->port, packet, length));
}
/* SERIAL */
for (r = 0; r < RETRIES; r++) {
ret = gp_port_write (camera->port, packet, length);
if (ret == GP_ERROR_TIMEOUT)
continue;
return (ret);
}
return (GP_ERROR_TIMEOUT);
return (GP_OK);
}
static int
@@ -721,17 +708,13 @@ sierra_write_ack (Camera *camera)
return (GP_OK);
}
int sierra_ping (Camera *camera, GPContext *context)
int
sierra_ping (Camera *camera, GPContext *context)
{
char buf[4096], packet[4096];
GP_DEBUG ("* sierra_ping");
GP_DEBUG ("Pinging camera...");
if (camera->port->type == GP_PORT_USB) {
GP_DEBUG ("* sierra_ping no ping for USB");
return (GP_OK);
}
packet[0] = NUL;
CHECK (sierra_write_packet (camera, packet));
@@ -742,7 +725,7 @@ int sierra_ping (Camera *camera, GPContext *context)
return (GP_OK);
default:
gp_context_error (context, _("Got unexpected result "
"%i. Please contact "
"0x%x. Please contact "
"<gphoto-devel@gphoto.org>."), buf[0]);
return GP_ERROR;
}

View File

@@ -100,8 +100,9 @@
} \
}
int camera_start(Camera *camera, GPContext *context);
int camera_stop(Camera *camera, GPContext *context);
static int camera_start (Camera *camera, GPContext *context);
static int camera_stop (Camera *camera, GPContext *context);
int get_jpeg_data(const char *data, int data_size, char **jpeg_data, int *jpeg_size);
/* Useful markers */
@@ -362,9 +363,12 @@ set_info_func (CameraFilesystem *fs, const char *folder, const char *filename,
return (camera_stop (camera, context));
}
int camera_start (Camera *camera, GPContext *context)
static int
camera_start (Camera *camera, GPContext *context)
{
GP_DEBUG ("*** camera_start");
GPPortSettings settings;
GP_DEBUG ("Establishing connection...");
/*
* Opening and closing of the port happens in libgphoto2. All we
@@ -372,18 +376,26 @@ int camera_start (Camera *camera, GPContext *context)
*/
switch (camera->port->type) {
case GP_PORT_SERIAL:
CHECK_STOP (camera, sierra_set_speed (camera,
camera->pl->speed, context));
/* Let's see if the camera is alive. */
CHECK (sierra_ping (camera, context));
/* If needed, change speed. */
if (camera->pl->speed != settings.serial.speed)
CHECK (sierra_set_speed (camera, camera->pl->speed,
context));
return (GP_OK);
case GP_PORT_USB:
CHECK_STOP (camera, gp_port_set_timeout (camera->port, 5000));
CHECK (gp_port_set_timeout (camera->port, 5000));
return (GP_OK);
default:
return (GP_OK);
}
}
int camera_stop (Camera *camera, GPContext *context)
static int
camera_stop (Camera *camera, GPContext *context)
{
GP_DEBUG ("*** camera_stop");