2001-09-01 Chris Pinkham <cpinkham@infi.net>

* configure.in: added line to generate
        camlibs/panasonic/coolshot/Makefile
        * MAINTAINERS: added line for camlibs/panasonic/coolshot driver
        * camlibs/panasonic/Makefile.am: added coolshot to SUBDIRS declaration
        * camlibs/panasonic/coolshot/Makefile.am
        * camlibs/panasonic/coolshot/README
        * camlibs/panasonic/coolshot/TODO
        * camlibs/panasonic/coolshot/coolshot.[c,h]
        * camlibs/panasonic/coolshot/library.[c,h]:added files to support
        Panasonic Coolshot KXL-600A & KXL-601A digital cameras.


git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@2165 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
Lutz Mueller
2001-09-02 09:01:09 +00:00
parent 28ceb67ece
commit cb459d1d05
10 changed files with 988 additions and 3 deletions

View File

@@ -2,6 +2,19 @@
* frontends/command-line/options.c: #include <config.h>
2001-09-01 Chris Pinkham <cpinkham@infi.net>
* configure.in: added line to generate
camlibs/panasonic/coolshot/Makefile
* MAINTAINERS: added line for camlibs/panasonic/coolshot driver
* camlibs/panasonic/Makefile.am: added coolshot to SUBDIRS declaration
* camlibs/panasonic/coolshot/Makefile.am
* camlibs/panasonic/coolshot/README
* camlibs/panasonic/coolshot/TODO
* camlibs/panasonic/coolshot/coolshot.[c,h]
* camlibs/panasonic/coolshot/library.[c,h]:added files to support
Panasonic Coolshot KXL-600A & KXL-601A digital cameras.
2001-09-01 Lutz Müller <urc8@rz.uni-karlsruhe.de>
* camlibs/casio: New

View File

@@ -8,6 +8,9 @@ libgphoto2_port:
libgphoto2:
Scott Fritzinger <scottf@unr.edu>
camlibs/barbie:
Scott Fritzinger <scottf@unr.edu>
camlibs/canon:
Philippe Marzouk <philm@users.sourceforge.net>
@@ -26,8 +29,8 @@ camlibs/kodak/dc120:
camlibs/kodak/dc240:
Hubert Figuiere <hfiguiere@teaser.fr>
camlibs/barbie:
Scott Fritzinger <scottf@unr.edu>
camlibs/panasonic/coolshot:
Chris Pinkham <cpinkham@infi.net>
camlibs/sierra:
Scott Fritzinger <scottf@unr.edu>

View File

@@ -1,4 +1,4 @@
SUBDIRS = l859
SUBDIRS = coolshot l859
camlibdir = $(prefix)/lib/gphoto2
camlib_LTLIBRARIES =\

View File

@@ -0,0 +1,6 @@
Makefile.in
Makefile
.libs
.deps
*.lo
*.la

View File

@@ -0,0 +1,11 @@
camlibdir = $(prefix)/lib/gphoto2
camlib_LTLIBRARIES = libgphoto2_panasonic_coolshot.la
INCLUDES = -I$(top_srcdir)/include
libgphoto2_panasonic_coolshot_la_SOURCES = coolshot.c coolshot.h library.c library.h
libgphoto2_panasonic_coolshot_la_LDFLAGS =\
-avoid-version -L$(shell pwd)/$(top_builddir)/libgphoto2/.libs
libgphoto2_panasonic_coolshot_la_LIBADD = -lgphoto2

View File

@@ -0,0 +1,12 @@
Panasonic KXL-600A and KXL-601A a.k.a. "Coolshot"
+
This driver is based upon protocol reverse-engineered
using ComLite32 under Windows 95. Known protocol info
along with some sample captured data is in the file
protocol.txt.
For questions/comments, email the library author:
Chris Pinkham
cpinkham@infi.net

View File

@@ -0,0 +1,294 @@
/****************************************************************/
/* coolshot.c - Gphoto2 library for accessing the Panasonic */
/* Coolshot KXL-600A & KXL-601A digital cameras. */
/* */
/* Copyright (C) 2001 Chris Pinkham */
/* */
/* Author: Chris Pinkham <cpinkham@infi.net> */
/* */
/* This program is free software; you can redistribute it */
/* and/or modify it under the terms of the GNU General Public */
/* License as published by the Free Software Foundation; either */
/* version 2 of the License, or (at your option) any later */
/* version. */
/* */
/* This program is distributed in the hope that it will be */
/* useful, but WITHOUT ANY WARRANTY; without even the implied */
/* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR */
/* PURPOSE. See the GNU General Public License for more */
/* details. */
/* */
/* You should have received a copy of the GNU General Public */
/* License along with this program; if not, write to the Free */
/* Software Foundation, Inc., 59 Temple Place, Suite 330, */
/* Boston, MA 02111-1307, USA. */
/****************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <gphoto2.h>
#ifdef ENABLE_NLS
# include <libintl.h>
# undef _
# define _(String) dgettext (PACKAGE, String)
# ifdef gettext_noop
# define N_(String) gettext_noop (String)
# else
# define _(String) (String)
# define N_(String) (String)
# endif
#else
# define _(String) (String)
# define N_(String) (String)
#endif
#include "library.h"
#define TIMEOUT 2000
#define DEFAULT_SPEED 9600
#define COOLSHOT_VERSION "0.2"
#define COOLSHOT_LAST_MOD "09/01/2001 23:03 EST"
/* define what cameras we support */
char *coolshot_cameras[] = {
"Panasonic Coolshot KXL-600A",
"Panasonic Coolshot KXL-601A",
""
};
int camera_id (CameraText *id)
{
strcpy(id->text, "coolshot");
return (GP_OK);
}
int camera_abilities (CameraAbilitiesList *list)
{
int x = 0;
char *ptr;
CameraAbilities *a;
ptr = coolshot_cameras[x++];
while( *ptr ) {
gp_abilities_new( &a );
strcpy (a->model, ptr );
a->port = GP_PORT_SERIAL;
a->speed[0] = 9600;
a->speed[1] = 19200;
a->speed[2] = 38400;
a->speed[3] = 57600;
a->speed[4] = 115200;
a->speed[5] = 0;
/* fixme, need to set these operations lists to correct values */
a->operations = GP_OPERATION_NONE;
a->file_operations = GP_FILE_OPERATION_NONE;
/* fixme, believe supports GP_FOLDER_PUT_FILE */
a->folder_operations = GP_FOLDER_OPERATION_NONE;
gp_abilities_list_append (list, a);
ptr = coolshot_cameras[x++];
}
return (GP_OK);
}
static int camera_start (Camera *camera)
{
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** camera_start");
CHECK( coolshot_sb( camera, camera->port_info->speed ));
return( GP_OK );
}
static int camera_stop (Camera *camera)
{
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** camera_stop");
CHECK( coolshot_sb( camera, DEFAULT_SPEED ));
return( GP_OK );
}
static int file_list_func (CameraFilesystem *fs, const char *folder,
CameraList *list, void *data)
{
Camera *camera = data;
int count;
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** file_list_func");
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** folder: %s", folder);
CHECK (camera_start (camera));
count = coolshot_file_count (camera);
CHECK (gp_filesystem_populate (fs, "/", "pic_%04i.jpg", count));
return (camera_stop (camera));
}
static int get_info_func (CameraFilesystem *fs, const char *folder,
const char *filename, CameraFileInfo *info, void *data)
{
Camera *camera = data;
int file_number;
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** get_info_func");
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** folder: %s", folder);
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** filename: %s", filename);
CHECK (camera_start (camera));
/* Get the file number from the CameraFileSystem */
file_number = gp_filesystem_number (camera->fs, folder, filename);
if (file_number < 0)
return (file_number);
/* fixme, get file size also */
info->file.fields = GP_FILE_INFO_TYPE;
strcpy (info->file.type, GP_MIME_JPEG );
info->preview.fields = GP_FILE_INFO_TYPE;
strcpy (info->preview.type, GP_MIME_JPEG );
return (camera_stop (camera));
}
static int camera_exit (Camera *camera)
{
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** camera_exit");
return (GP_OK);
}
static int camera_file_get (Camera *camera, const char *folder,
const char *filename, CameraFileType type,
CameraFile *file)
{
char data[128000];
int size;
int number;
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** camera_file_get");
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** folder: %s", folder);
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** filename: %s", filename);
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** type: %d", type);
CHECK( camera_start(camera));
switch( type ) {
case GP_FILE_TYPE_PREVIEW:
/* fixme, preview/thumbnail downloads full image with this commented...
sscanf( filename, "thm_%d.jpg", &number );
coolshot_request_thumbnail( camera, data, &size, number );
break;
*/
case GP_FILE_TYPE_NORMAL:
sscanf( filename, "pic_%d.jpg", &number );
coolshot_request_image( camera, data, &size, number );
break;
default:
return( GP_ERROR_NOT_SUPPORTED );
}
gp_file_set_mime_type( file, GP_MIME_JPEG );
gp_file_set_name( file, filename );
gp_file_append(file, data, size);
return (camera_stop (camera));
}
static int camera_summary (Camera *camera, CameraText *summary)
{
int count;
char tmp[1024];
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** camera_summary");
CHECK( camera_start(camera));
/* possibly get # pics, mem free, etc. */
count = coolshot_file_count (camera);
sprintf( tmp, "Frames Taken : %4d\n", count );
strcat( summary->text, tmp );
return (camera_stop (camera));
}
static int camera_manual (Camera *camera, CameraText *manual)
{
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** camera_manual");
strcpy (manual->text, _("Some notes:\n"
" No notes here yet.\n"));
return (GP_OK);
}
static int camera_about (Camera *camera, CameraText *about)
{
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** camera_about");
strcpy (about->text,
_("coolshot library v" COOLSHOT_VERSION " " COOLSHOT_LAST_MOD "\n"
"Chris Pinkham <cpinkham@infi.net>\n"
"Support for Panasonic Coolshot digital cameras\n"
"based on reverse engineering serial protocol.\n"
"\n"));
return (GP_OK);
}
int camera_init (Camera *camera)
{
int count;
gp_port_settings settings;
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** camera_init");
/* First, set up all the function pointers */
camera->functions->exit = camera_exit;
camera->functions->file_get = camera_file_get;
camera->functions->summary = camera_summary;
camera->functions->manual = camera_manual;
camera->functions->about = camera_about;
camera->camlib_data = NULL;
strcpy (settings.serial.port, camera->port_info->path);
settings.serial.speed = DEFAULT_SPEED;
settings.serial.bits = 8;
settings.serial.parity = 0;
settings.serial.stopbits = 1;
CHECK( gp_port_settings_set (camera->port, settings));
CHECK( gp_port_timeout_set (camera->port, TIMEOUT));
CHECK( gp_port_open( camera->port ));
/* check to see if camera is really there */
CHECK( coolshot_enq (camera));
coolshot_sm( camera );
/* get number of images */
count = coolshot_file_count (camera);
if (count < 0)
return (count);
CHECK( camera_start (camera));
CHECK(gp_filesystem_set_list_funcs (camera->fs,
file_list_func, NULL, camera));
CHECK(gp_filesystem_set_info_funcs (camera->fs,
get_info_func, NULL, camera));
return (camera_stop (camera));
}

View File

@@ -0,0 +1,594 @@
/****************************************************************/
/* library.c - Gphoto2 library for accessing the Panasonic */
/* Coolshot KXL-600A & KXL-601A digital cameras. */
/* */
/* Copyright (C) 2001 Chris Pinkham */
/* */
/* Author: Chris Pinkham <cpinkham@infi.net> */
/* */
/* This program is free software; you can redistribute it */
/* and/or modify it under the terms of the GNU General Public */
/* License as published by the Free Software Foundation; either */
/* version 2 of the License, or (at your option) any later */
/* version. */
/* */
/* This program is distributed in the hope that it will be */
/* useful, but WITHOUT ANY WARRANTY; without even the implied */
/* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR */
/* PURPOSE. See the GNU General Public License for more */
/* details. */
/* */
/* You should have received a copy of the GNU General Public */
/* License along with this program; if not, write to the Free */
/* Software Foundation, Inc., 59 Temple Place, Suite 330, */
/* Boston, MA 02111-1307, USA. */
/****************************************************************/
#include <stdio.h>
#include <string.h>
#include <gphoto2.h>
#include <time.h>
#include "library.h"
#include <unistd.h>
#define COOL_SLEEP 10000
int packet_size = 500;
/* ??set mode?? */
int coolshot_sm( Camera *camera ) {
char buf[16];
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_sm");
memset( buf, 0, sizeof( buf ));
buf[0] = COOLSHOT_PKT;
buf[2] = 'S';
buf[3] = 'M';
buf[4] = 0x01;
buf[15] = 0x02;
coolshot_write_packet( camera, buf );
/* read ACK */
coolshot_read_packet( camera, buf );
/* read data */
coolshot_read_packet( camera, buf );
/* send ACK */
coolshot_ack( camera );
packet_size = 128;
return( GP_OK );
}
/* ?set baud? */
int coolshot_sb( Camera *camera, int speed ) {
char buf[16];
gp_port_settings settings;
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_sb");
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* speed: %i", speed);
memset( buf, 0, sizeof( buf ));
buf[0] = COOLSHOT_PKT;
buf[2] = 'S';
buf[3] = 'B';
buf[4] = 0x01;
buf[15] = 0x02;
gp_port_settings_get (camera->port, &settings);
switch (speed) {
case 9600:
buf[4] = '1';
settings.serial.speed = 9600;
break;
case -1:
case 19200:
buf[4] = '2';
settings.serial.speed = 19200;
break;
case 28800:
buf[4] = '3';
settings.serial.speed = 28800;
break;
case 38400:
buf[4] = '4';
settings.serial.speed = 38400;
break;
case 57600:
buf[4] = '5';
settings.serial.speed = 57600;
break;
case 0: /* Default speed */
case 115200:
buf[4] = '6';
settings.serial.speed = 115200;
break;
default:
return (GP_ERROR_IO_SERIAL_SPEED);
}
coolshot_enq( camera );
/* set speed */
coolshot_write_packet( camera, buf );
/* read ack */
coolshot_read_packet( camera, buf );
/* read OK */
coolshot_read_packet( camera, buf );
/* ack the OK */
coolshot_ack( camera );
CHECK (gp_port_settings_set (camera->port, settings));
GP_SYSTEM_SLEEP(10);
return (GP_OK);
}
int coolshot_fs( Camera *camera, int number ) {
char buf[16];
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_fs");
memset( buf, 0, sizeof( buf ));
buf[0] = COOLSHOT_PKT;
buf[2] = 'F';
buf[3] = 'S';
buf[7] = number;
buf[15] = 0x02;
coolshot_enq( camera );
coolshot_write_packet( camera, buf );
/* read ACK */
coolshot_read_packet( camera, buf );
/* read data */
coolshot_read_packet( camera, buf );
/* send ACK */
coolshot_ack( camera );
return( GP_OK );
}
int coolshot_sp( Camera *camera ) {
char buf[16];
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_sp");
memset( buf, 0, sizeof( buf ));
buf[0] = COOLSHOT_PKT;
buf[2] = 'S';
buf[3] = 'P';
buf[4] = 0x02;
buf[15] = 0x02;
coolshot_enq( camera );
coolshot_write_packet( camera, buf );
/* read ACK */
coolshot_read_packet( camera, buf );
packet_size = 500;
return( GP_OK );
}
int coolshot_file_count (Camera *camera) {
char buf[16];
int count = 0;
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_file_count");
memset( buf, 0, sizeof( buf ));
buf[0] = COOLSHOT_PKT;
buf[2] = 'R';
buf[3] = 'N';
buf[5] = 0x01;
buf[15] = 0x02;
coolshot_enq( camera );
/* request count */
coolshot_write_packet( camera, buf );
/* read ack */
coolshot_read_packet( camera, buf );
/* read data packet */
coolshot_read_packet( camera, buf );
count = buf[7];
usleep( COOL_SLEEP );
coolshot_ack( camera );
return( count );
}
int coolshot_request_image( Camera *camera, char *buf, int *len, int number ) {
char packet[16];
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_request_image");
memset( packet, 0, sizeof( packet ));
packet[0] = COOLSHOT_PKT;
packet[2] = 'R';
packet[3] = 'D';
packet[7] = number;
packet[15] = 0x02;
/* fixme */
coolshot_fs( camera, number );
coolshot_sp( camera );
coolshot_enq( camera );
/* request image */
coolshot_write_packet( camera, packet );
/* read ack */
coolshot_read_packet( camera, packet );
/* read OK */
coolshot_read_packet( camera, packet );
/* read data */
coolshot_download_image( camera, buf, len, 0 );
return( GP_OK );
}
int coolshot_request_thumbnail( Camera *camera, char *buf, int *len, int number ) {
char packet[16];
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_request_thumbnail");
memset( packet, 0, sizeof( packet ));
packet[0] = COOLSHOT_PKT;
packet[2] = 'R';
packet[3] = 'M';
packet[7] = number;
packet[15] = 0x02;
/* fixme */
coolshot_fs( camera, number );
/*
coolshot_sp( camera );
*/
coolshot_enq( camera );
/* request image */
coolshot_write_packet( camera, packet );
/* read ack */
coolshot_read_packet( camera, packet );
/* read OK */
coolshot_read_packet( camera, packet );
/* read data */
coolshot_download_image( camera, buf, len, 0 );
return( GP_OK );
}
int coolshot_check_checksum( char *packet, int length ) {
int checksum = 0;
int p_csum = 0;
int x;
unsigned char *ptr;
ptr = (unsigned char *)packet + 2;
for( x = 2; x < (length - 4 ); x++ ) {
checksum += *(ptr++);
/* checksum += (unsigned char)packet[x]; */
}
checksum &= 0xffff; /* 16 bit checksum */
p_csum = (unsigned char)packet[length - 4];
p_csum = p_csum << 8;
p_csum += (unsigned char)packet[length - 3];
if ( checksum == p_csum ) {
return( GP_OK );
} else {
return( GP_ERROR );
}
}
int coolshot_download_image( Camera *camera, char *buf, int *len, int thumbnail ) {
char packet[1024];
int data_len;
int bytes_read = 0;
int last_good = 0;
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_download_image");
memset( packet, 0, sizeof( packet ));
packet[2] = '0';
packet[3] = '0';
coolshot_ack( camera );
coolshot_read_packet( camera, packet );
data_len = (unsigned char)packet[6] * 256;
data_len += (unsigned char)packet[7];
/* fixme, get rid of hardcoded length */
if ( coolshot_check_checksum( packet, 8 + packet_size + 4 ) == GP_OK ) {
coolshot_ack( camera );
last_good = 1;
} else {
/*
coolshot_nak( camera );
*/
last_good = 0;
}
while( strncmp( packet + 2, "DT", 2 ) == 0 ) {
/* process packet */
if ( last_good ) {
data_len = (unsigned char)packet[6] * 256;
data_len += (unsigned char)packet[7];
memcpy( buf + bytes_read, packet + 8, data_len );
bytes_read += data_len;
}
coolshot_read_packet( camera, packet );
data_len = (unsigned char)packet[6] * 256;
data_len += (unsigned char)packet[7];
/* fixme, get rid of hardcoded length */
if ( coolshot_check_checksum( packet, 8 + packet_size + 4 ) == GP_OK) {
coolshot_ack( camera );
last_good = 1;
} else {
/*
coolshot_nak( camera );
*/
last_good = 0;
}
}
coolshot_ack( camera );
*len = bytes_read;
return( GP_OK );
}
int coolshot_write_packet (Camera *camera, char *packet) {
int x, ret, r, checksum=0, length;
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_write_packet");
if ( packet[0] == COOLSHOT_PKT ) {
/* fixme */
length = 16;
for ( x = 2 ; x < 12; x++ ) {
checksum += (unsigned char)packet[x];
}
packet[length - 4] = (checksum >> 8 ) & 0xff;
packet[length - 3] = checksum & 0xff;
} else if (( packet[0] == COOLSHOT_ENQ ) ||
( packet[0] == COOLSHOT_ACK ) ||
( packet[0] == COOLSHOT_NAK )) {
length = 1;
} else {
length = 0;
/* fixme */
return( -1 );
}
for (r = 0; r < RETRIES; r++) {
ret = gp_port_write (camera->port, packet, length);
if (ret == GP_ERROR_IO_TIMEOUT)
continue;
return (ret);
}
return (GP_ERROR_IO_TIMEOUT);
}
int coolshot_read_packet (Camera *camera, char *packet) {
int r = 0, x = 0, ret, done, length=0;
int blocksize, bytes_read;
char buf[4096];
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_read_packet");
read_packet_again:
buf[0] = 0;
packet[0] = 0;
if (r > 0)
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* reading again...");
done = 0;
blocksize = 1;
for (r = 0; r < RETRIES; r++) {
bytes_read = gp_port_read (camera->port, packet, blocksize);
if (bytes_read == GP_ERROR_IO_TIMEOUT)
continue;
if (bytes_read < 0)
return (bytes_read);
if ( packet[0] == COOLSHOT_ENQ ) {
usleep( COOL_SLEEP );
coolshot_ack( camera );
coolshot_read_packet( camera, packet );
return( GP_OK );
}
if (( packet[0] == COOLSHOT_ACK ) ||
( packet[0] == COOLSHOT_DONE )) {
return( GP_OK );
}
if ( packet[0] != COOLSHOT_PKT ) {
return( GP_ERROR );
}
bytes_read = gp_port_read (camera->port, packet + 1, 3 );
if (bytes_read == GP_ERROR_IO_TIMEOUT)
continue;
if (bytes_read < 0)
return (bytes_read);
/* Determine the packet type */
if (( strncmp( packet + 2, "OK", 2 ) == 0 ) ||
( strncmp( packet + 2, "DE", 2 ) == 0 ) ||
( 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) {
/* fixme */
/*
coolshot_nak (camera);
*/
goto read_packet_again;
}
if (ret < 0)
return (ret);
return( GP_OK );
} else if ( strncmp( packet + 2, "DT", 2 ) == 0 ) {
/* read in packet number and length */
ret = gp_port_read (camera->port, packet + 4, 4 );
/* fixme, error detection */
length = (unsigned char)packet[6] * 256;
length += (unsigned char)packet[7];
if (( packet_size == 128 ) ||
( length == 128 )) {
length = 128;
} else {
length = 500;
}
length += 4;
ret = gp_port_read (camera->port, packet + 8, length );
/* fixme, error detection */
x = 0;
while(( ret == GP_ERROR_IO_TIMEOUT ) &&
( x < RETRIES )) {
x++;
ret = gp_port_read (camera->port, packet + 8, length );
}
return( GP_OK );
}
if (done) break;
}
return (GP_ERROR_IO_TIMEOUT);
}
int coolshot_ack (Camera *camera)
{
int ret, r = 0;
char buf[16];
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_ack");
buf[0] = COOLSHOT_ACK;
for (r = 0; r < RETRIES; r++) {
ret = coolshot_write_packet (camera, buf);
if (ret == GP_ERROR_IO_TIMEOUT)
continue;
if (ret == GP_OK)
return (ret);
}
return (GP_ERROR_IO_TIMEOUT);
}
int coolshot_nak (Camera *camera)
{
int ret, r = 0;
char buf[16];
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_nak");
buf[0] = COOLSHOT_NAK;
for (r = 0; r < RETRIES; r++) {
ret = coolshot_write_packet (camera, buf);
if (ret == GP_ERROR_IO_TIMEOUT)
continue;
if (ret == GP_OK)
return (ret);
}
return (GP_ERROR_IO_TIMEOUT);
}
int coolshot_enq (Camera *camera)
{
int ret, r = 0;
char buf[16];
gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_enq");
buf[0] = COOLSHOT_ENQ;
for (r = 0; r < RETRIES; r++) {
ret = coolshot_write_packet (camera, buf);
if (ret == GP_ERROR_IO_TIMEOUT)
continue;
if (ret != GP_OK)
return (ret);
ret = coolshot_read_packet (camera, buf);
if (ret == GP_ERROR_IO_TIMEOUT)
continue;
if (ret != GP_OK)
return (ret);
if (buf[0] == COOLSHOT_ACK)
return (GP_OK);
else
return (GP_ERROR_CORRUPTED_DATA);
}
return (GP_ERROR_IO_TIMEOUT);
}

View File

@@ -0,0 +1,51 @@
/****************************************************************/
/* library.h - Gphoto2 library for accessing the Panasonic */
/* Coolshot KXL-600A & KXL-601A digital cameras. */
/* */
/* Copyright (C) 2001 Chris Pinkham */
/* */
/* Author: Chris Pinkham <cpinkham@infi.net> */
/* */
/* This program is free software; you can redistribute it */
/* and/or modify it under the terms of the GNU General Public */
/* License as published by the Free Software Foundation; either */
/* version 2 of the License, or (at your option) any later */
/* version. */
/* */
/* This program is distributed in the hope that it will be */
/* useful, but WITHOUT ANY WARRANTY; without even the implied */
/* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR */
/* PURPOSE. See the GNU General Public License for more */
/* details. */
/* */
/* You should have received a copy of the GNU General Public */
/* License along with this program; if not, write to the Free */
/* Software Foundation, Inc., 59 Temple Place, Suite 330, */
/* Boston, MA 02111-1307, USA. */
/****************************************************************/
#define RETRIES 10
#define COOLSHOT_DONE 0x00
#define COOLSHOT_PKT 0x01
#define COOLSHOT_ENQ 0x05
#define COOLSHOT_ACK 0x06
#define COOLSHOT_NAK 0x15
#define CHECK(result) {int res; res = result; if (res != GP_OK) return (res);}
int coolshot_sm (Camera *camera);
int coolshot_sb (Camera *camera, int speed);
int coolshot_fs (Camera *camera, int number);
int coolshot_sp (Camera *camera);
int coolshot_ack (Camera *camera);
int coolshot_nak (Camera *camera);
int coolshot_enq (Camera *camera);
int coolshot_write_packet (Camera *camera, char *packet);
int coolshot_read_packet (Camera *camera, char *packet);
int coolshot_file_count (Camera *camera);
int coolshot_check_checksum( char *packet, int length );
int coolshot_request_image (Camera *camera, char *buf, int *len, int number);
int coolshot_request_thumbnail (Camera *camera, char *buf, int *len, int number);
int coolshot_download_image (Camera *camera, char *buf, int *len, int thumbnail);

View File

@@ -179,6 +179,7 @@ camlibs/minolta/Makefile
camlibs/minolta/dimagev/Makefile
camlibs/panasonic/Makefile
camlibs/panasonic/l859/Makefile
camlibs/panasonic/coolshot/Makefile
camlibs/polaroid/Makefile
camlibs/samsung/Makefile
camlibs/sierra/Makefile