added canon lib\!\!
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@753 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
356
camlibs/canon/Makefile
Normal file
356
camlibs/canon/Makefile
Normal file
@@ -0,0 +1,356 @@
|
||||
# Generated automatically from Makefile.in by configure.
|
||||
# Makefile.in generated automatically by automake 1.4 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = /bin/sh
|
||||
|
||||
srcdir = .
|
||||
top_srcdir = ../..
|
||||
prefix = /usr/local
|
||||
exec_prefix = ${prefix}
|
||||
|
||||
bindir = ${exec_prefix}/bin
|
||||
sbindir = ${exec_prefix}/sbin
|
||||
libexecdir = ${exec_prefix}/libexec
|
||||
datadir = ${prefix}/share
|
||||
sysconfdir = ${prefix}/etc
|
||||
sharedstatedir = ${prefix}/com
|
||||
localstatedir = ${prefix}/var
|
||||
libdir = ${exec_prefix}/lib
|
||||
infodir = ${prefix}/info
|
||||
mandir = ${prefix}/man
|
||||
includedir = ${prefix}/include
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/gphoto2
|
||||
pkglibdir = $(libdir)/gphoto2
|
||||
pkgincludedir = $(includedir)/gphoto2
|
||||
|
||||
top_builddir = ../..
|
||||
|
||||
ACLOCAL = aclocal
|
||||
AUTOCONF = autoconf
|
||||
AUTOMAKE = automake
|
||||
AUTOHEADER = autoheader
|
||||
|
||||
INSTALL = /usr/bin/install -c
|
||||
INSTALL_PROGRAM = ${INSTALL} $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_DATA = ${INSTALL} -m 644
|
||||
INSTALL_SCRIPT = ${INSTALL_PROGRAM}
|
||||
transform = s,x,x,
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
host_alias = i586-pc-linux-gnu
|
||||
host_triplet = i586-pc-linux-gnu
|
||||
AS = @AS@
|
||||
CC = gcc
|
||||
CPP = gcc -E
|
||||
DLLTOOL = @DLLTOOL@
|
||||
LD = /usr/bin/ld
|
||||
LIBGPHOTO2_INCLUDEDIR = -I${includedir}
|
||||
LIBGPHOTO2_LIBDIR = -L${libdir}
|
||||
LIBGPHOTO2_LIBS = -lgphoto2
|
||||
LIBGPHOTO2_VERSION = 1.90
|
||||
LIBGPIO_CONFIG = /usr/bin/gpio-config
|
||||
LIBS = -ldl -L/usr/local/lib -lgpio
|
||||
LIBTOOL = $(SHELL) $(top_builddir)/libtool
|
||||
LN_S = ln -s
|
||||
MAINT = #
|
||||
MAKEINFO = makeinfo
|
||||
NM = /usr/bin/nm -B
|
||||
OBJDUMP = @OBJDUMP@
|
||||
PACKAGE = gphoto2
|
||||
RANLIB = ranlib
|
||||
SUBDIRS_CAMLIBS =
|
||||
VERSION = 1.90
|
||||
|
||||
camlibdir = $(prefix)/lib/gphoto2
|
||||
camlib_LTLIBRARIES = libgphoto2_canon.la
|
||||
|
||||
CFLAGS = -g -O2 -I/usr/local/include/gpio `gtk-config --cflags` `gpio-config --cflags` -g -Wall
|
||||
LDFLAGS = -g `gpio-config --libs`
|
||||
INCLUDES = -I$(top_srcdir)/include
|
||||
|
||||
libgphoto2_canon_la_SOURCES = canon.c canon.h psa50.c psa50.h serial.c serial.h crc.c crc.h util.c util.h
|
||||
|
||||
|
||||
libgphoto_canon_la_LDFLAGS = -version-info 0:0:0 `gpio-config --libs`
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../../config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
LTLIBRARIES = $(camlib_LTLIBRARIES)
|
||||
|
||||
|
||||
DEFS = -DHAVE_CONFIG_H -I. -I$(srcdir) -I../..
|
||||
CPPFLAGS =
|
||||
libgphoto2_canon_la_LDFLAGS =
|
||||
libgphoto2_canon_la_LIBADD =
|
||||
libgphoto2_canon_la_OBJECTS = canon.lo psa50.lo serial.lo crc.lo \
|
||||
util.lo
|
||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
DIST_COMMON = README Makefile.am Makefile.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
GZIP_ENV = --best
|
||||
DEP_FILES = .deps/canon.P .deps/crc.P .deps/psa50.P .deps/serial.P \
|
||||
.deps/util.P
|
||||
SOURCES = $(libgphoto2_canon_la_SOURCES)
|
||||
OBJECTS = $(libgphoto2_canon_la_OBJECTS)
|
||||
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .S .c .lo .o .s
|
||||
$(srcdir)/Makefile.in: # Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu camlibs/canon/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
|
||||
mostlyclean-camlibLTLIBRARIES:
|
||||
|
||||
clean-camlibLTLIBRARIES:
|
||||
-test -z "$(camlib_LTLIBRARIES)" || rm -f $(camlib_LTLIBRARIES)
|
||||
|
||||
distclean-camlibLTLIBRARIES:
|
||||
|
||||
maintainer-clean-camlibLTLIBRARIES:
|
||||
|
||||
install-camlibLTLIBRARIES: $(camlib_LTLIBRARIES)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkinstalldirs) $(DESTDIR)$(camlibdir)
|
||||
@list='$(camlib_LTLIBRARIES)'; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(camlibdir)/$$p"; \
|
||||
$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(camlibdir)/$$p; \
|
||||
else :; fi; \
|
||||
done
|
||||
|
||||
uninstall-camlibLTLIBRARIES:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
list='$(camlib_LTLIBRARIES)'; for p in $$list; do \
|
||||
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(camlibdir)/$$p; \
|
||||
done
|
||||
|
||||
.s.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.S.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.o core *.core
|
||||
|
||||
clean-compile:
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
maintainer-clean-compile:
|
||||
|
||||
.s.lo:
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
|
||||
|
||||
.S.lo:
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
distclean-libtool:
|
||||
|
||||
maintainer-clean-libtool:
|
||||
|
||||
libgphoto2_canon.la: $(libgphoto2_canon_la_OBJECTS) $(libgphoto2_canon_la_DEPENDENCIES)
|
||||
$(LINK) -rpath $(camlibdir) $(libgphoto2_canon_la_LDFLAGS) $(libgphoto2_canon_la_OBJECTS) $(libgphoto2_canon_la_LIBADD) $(LIBS)
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
here=`pwd` && cd $(srcdir) \
|
||||
&& mkid -f$$here/ID $$unique $(LISP)
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|
||||
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
clean-tags:
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID
|
||||
|
||||
maintainer-clean-tags:
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = camlibs/canon
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
here=`cd $(top_builddir) && pwd`; \
|
||||
top_distdir=`cd $(top_distdir) && pwd`; \
|
||||
distdir=`cd $(distdir) && pwd`; \
|
||||
cd $(top_srcdir) \
|
||||
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu camlibs/canon/Makefile
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
|
||||
|
||||
-include $(DEP_FILES)
|
||||
|
||||
mostlyclean-depend:
|
||||
|
||||
clean-depend:
|
||||
|
||||
distclean-depend:
|
||||
-rm -rf .deps
|
||||
|
||||
maintainer-clean-depend:
|
||||
|
||||
%.o: %.c
|
||||
@echo '$(COMPILE) -c $<'; \
|
||||
$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-cp .deps/$(*F).pp .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm .deps/$(*F).pp
|
||||
|
||||
%.lo: %.c
|
||||
@echo '$(LTCOMPILE) -c $<'; \
|
||||
$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
|
||||
< .deps/$(*F).pp > .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm -f .deps/$(*F).pp
|
||||
info-am:
|
||||
info: info-am
|
||||
dvi-am:
|
||||
dvi: dvi-am
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
installcheck-am:
|
||||
installcheck: installcheck-am
|
||||
install-exec-am:
|
||||
install-exec: install-exec-am
|
||||
|
||||
install-data-am: install-camlibLTLIBRARIES
|
||||
install-data: install-data-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-am
|
||||
uninstall-am: uninstall-camlibLTLIBRARIES
|
||||
uninstall: uninstall-am
|
||||
all-am: Makefile $(LTLIBRARIES)
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs:
|
||||
$(mkinstalldirs) $(DESTDIR)$(camlibdir)
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
mostlyclean-am: mostlyclean-camlibLTLIBRARIES mostlyclean-compile \
|
||||
mostlyclean-libtool mostlyclean-tags mostlyclean-depend \
|
||||
mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
clean-am: clean-camlibLTLIBRARIES clean-compile clean-libtool \
|
||||
clean-tags clean-depend clean-generic mostlyclean-am
|
||||
|
||||
clean: clean-am
|
||||
|
||||
distclean-am: distclean-camlibLTLIBRARIES distclean-compile \
|
||||
distclean-libtool distclean-tags distclean-depend \
|
||||
distclean-generic clean-am
|
||||
-rm -f libtool
|
||||
|
||||
distclean: distclean-am
|
||||
|
||||
maintainer-clean-am: maintainer-clean-camlibLTLIBRARIES \
|
||||
maintainer-clean-compile maintainer-clean-libtool \
|
||||
maintainer-clean-tags maintainer-clean-depend \
|
||||
maintainer-clean-generic distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
|
||||
.PHONY: mostlyclean-camlibLTLIBRARIES distclean-camlibLTLIBRARIES \
|
||||
clean-camlibLTLIBRARIES maintainer-clean-camlibLTLIBRARIES \
|
||||
uninstall-camlibLTLIBRARIES install-camlibLTLIBRARIES \
|
||||
mostlyclean-compile distclean-compile clean-compile \
|
||||
maintainer-clean-compile mostlyclean-libtool distclean-libtool \
|
||||
clean-libtool maintainer-clean-libtool tags mostlyclean-tags \
|
||||
distclean-tags clean-tags maintainer-clean-tags distdir \
|
||||
mostlyclean-depend distclean-depend clean-depend \
|
||||
maintainer-clean-depend info-am info dvi-am dvi check check-am \
|
||||
installcheck-am installcheck install-exec-am install-exec \
|
||||
install-data-am install-data install-am install uninstall-am uninstall \
|
||||
all-redirect all-am all installdirs mostlyclean-generic \
|
||||
distclean-generic clean-generic maintainer-clean-generic clean \
|
||||
mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
11
camlibs/canon/Makefile.am
Normal file
11
camlibs/canon/Makefile.am
Normal file
@@ -0,0 +1,11 @@
|
||||
camlibdir = $(prefix)/lib/gphoto2
|
||||
camlib_LTLIBRARIES = libgphoto2_canon.la
|
||||
|
||||
CFLAGS = @CFLAGS@ `gtk-config --cflags` `gpio-config --cflags` -g -Wall
|
||||
LDFLAGS = @LDFLAGS@ -g `gpio-config --libs`
|
||||
INCLUDES = -I$(top_srcdir)/include
|
||||
|
||||
libgphoto2_canon_la_SOURCES = canon.c canon.h psa50.c psa50.h serial.c serial.h \
|
||||
crc.c crc.h util.c util.h
|
||||
|
||||
libgphoto_canon_la_LDFLAGS = -version-info 0:0:0 `gpio-config --libs`
|
||||
356
camlibs/canon/Makefile.in
Normal file
356
camlibs/canon/Makefile.in
Normal file
@@ -0,0 +1,356 @@
|
||||
# Makefile.in generated automatically by automake 1.4 from Makefile.am
|
||||
|
||||
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
|
||||
DESTDIR =
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
|
||||
top_builddir = ../..
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
transform = @program_transform_name@
|
||||
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
host_alias = @host_alias@
|
||||
host_triplet = @host@
|
||||
AS = @AS@
|
||||
CC = @CC@
|
||||
CPP = @CPP@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
LD = @LD@
|
||||
LIBGPHOTO2_INCLUDEDIR = @LIBGPHOTO2_INCLUDEDIR@
|
||||
LIBGPHOTO2_LIBDIR = @LIBGPHOTO2_LIBDIR@
|
||||
LIBGPHOTO2_LIBS = @LIBGPHOTO2_LIBS@
|
||||
LIBGPHOTO2_VERSION = @LIBGPHOTO2_VERSION@
|
||||
LIBGPIO_CONFIG = @LIBGPIO_CONFIG@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LN_S = @LN_S@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
NM = @NM@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
PACKAGE = @PACKAGE@
|
||||
RANLIB = @RANLIB@
|
||||
SUBDIRS_CAMLIBS = @SUBDIRS_CAMLIBS@
|
||||
VERSION = @VERSION@
|
||||
|
||||
camlibdir = $(prefix)/lib/gphoto2
|
||||
camlib_LTLIBRARIES = libgphoto2_canon.la
|
||||
|
||||
CFLAGS = @CFLAGS@ `gtk-config --cflags` `gpio-config --cflags` -g -Wall
|
||||
LDFLAGS = @LDFLAGS@ -g `gpio-config --libs`
|
||||
INCLUDES = -I$(top_srcdir)/include
|
||||
|
||||
libgphoto2_canon_la_SOURCES = canon.c canon.h psa50.c psa50.h serial.c serial.h crc.c crc.h util.c util.h
|
||||
|
||||
|
||||
libgphoto_canon_la_LDFLAGS = -version-info 0:0:0 `gpio-config --libs`
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../../config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
LTLIBRARIES = $(camlib_LTLIBRARIES)
|
||||
|
||||
|
||||
DEFS = @DEFS@ -I. -I$(srcdir) -I../..
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
libgphoto2_canon_la_LDFLAGS =
|
||||
libgphoto2_canon_la_LIBADD =
|
||||
libgphoto2_canon_la_OBJECTS = canon.lo psa50.lo serial.lo crc.lo \
|
||||
util.lo
|
||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
|
||||
DIST_COMMON = README Makefile.am Makefile.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = tar
|
||||
GZIP_ENV = --best
|
||||
DEP_FILES = .deps/canon.P .deps/crc.P .deps/psa50.P .deps/serial.P \
|
||||
.deps/util.P
|
||||
SOURCES = $(libgphoto2_canon_la_SOURCES)
|
||||
OBJECTS = $(libgphoto2_canon_la_OBJECTS)
|
||||
|
||||
all: all-redirect
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .S .c .lo .o .s
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu camlibs/canon/Makefile
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
|
||||
mostlyclean-camlibLTLIBRARIES:
|
||||
|
||||
clean-camlibLTLIBRARIES:
|
||||
-test -z "$(camlib_LTLIBRARIES)" || rm -f $(camlib_LTLIBRARIES)
|
||||
|
||||
distclean-camlibLTLIBRARIES:
|
||||
|
||||
maintainer-clean-camlibLTLIBRARIES:
|
||||
|
||||
install-camlibLTLIBRARIES: $(camlib_LTLIBRARIES)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkinstalldirs) $(DESTDIR)$(camlibdir)
|
||||
@list='$(camlib_LTLIBRARIES)'; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(camlibdir)/$$p"; \
|
||||
$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(camlibdir)/$$p; \
|
||||
else :; fi; \
|
||||
done
|
||||
|
||||
uninstall-camlibLTLIBRARIES:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
list='$(camlib_LTLIBRARIES)'; for p in $$list; do \
|
||||
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(camlibdir)/$$p; \
|
||||
done
|
||||
|
||||
.s.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
.S.o:
|
||||
$(COMPILE) -c $<
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.o core *.core
|
||||
|
||||
clean-compile:
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
maintainer-clean-compile:
|
||||
|
||||
.s.lo:
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
|
||||
|
||||
.S.lo:
|
||||
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
distclean-libtool:
|
||||
|
||||
maintainer-clean-libtool:
|
||||
|
||||
libgphoto2_canon.la: $(libgphoto2_canon_la_OBJECTS) $(libgphoto2_canon_la_DEPENDENCIES)
|
||||
$(LINK) -rpath $(camlibdir) $(libgphoto2_canon_la_LDFLAGS) $(libgphoto2_canon_la_OBJECTS) $(libgphoto2_canon_la_LIBADD) $(LIBS)
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
here=`pwd` && cd $(srcdir) \
|
||||
&& mkid -f$$here/ID $$unique $(LISP)
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS)'; \
|
||||
unique=`for i in $$list; do echo $$i; done | \
|
||||
awk ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|
||||
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
|
||||
|
||||
mostlyclean-tags:
|
||||
|
||||
clean-tags:
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID
|
||||
|
||||
maintainer-clean-tags:
|
||||
|
||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
||||
|
||||
subdir = camlibs/canon
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
here=`cd $(top_builddir) && pwd`; \
|
||||
top_distdir=`cd $(top_distdir) && pwd`; \
|
||||
distdir=`cd $(distdir) && pwd`; \
|
||||
cd $(top_srcdir) \
|
||||
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu camlibs/canon/Makefile
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$/$$file $(distdir)/$$file; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
|
||||
|
||||
-include $(DEP_FILES)
|
||||
|
||||
mostlyclean-depend:
|
||||
|
||||
clean-depend:
|
||||
|
||||
distclean-depend:
|
||||
-rm -rf .deps
|
||||
|
||||
maintainer-clean-depend:
|
||||
|
||||
%.o: %.c
|
||||
@echo '$(COMPILE) -c $<'; \
|
||||
$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-cp .deps/$(*F).pp .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm .deps/$(*F).pp
|
||||
|
||||
%.lo: %.c
|
||||
@echo '$(LTCOMPILE) -c $<'; \
|
||||
$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
|
||||
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
|
||||
< .deps/$(*F).pp > .deps/$(*F).P; \
|
||||
tr ' ' '\012' < .deps/$(*F).pp \
|
||||
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
|
||||
>> .deps/$(*F).P; \
|
||||
rm -f .deps/$(*F).pp
|
||||
info-am:
|
||||
info: info-am
|
||||
dvi-am:
|
||||
dvi: dvi-am
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
installcheck-am:
|
||||
installcheck: installcheck-am
|
||||
install-exec-am:
|
||||
install-exec: install-exec-am
|
||||
|
||||
install-data-am: install-camlibLTLIBRARIES
|
||||
install-data: install-data-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
install: install-am
|
||||
uninstall-am: uninstall-camlibLTLIBRARIES
|
||||
uninstall: uninstall-am
|
||||
all-am: Makefile $(LTLIBRARIES)
|
||||
all-redirect: all-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
||||
installdirs:
|
||||
$(mkinstalldirs) $(DESTDIR)$(camlibdir)
|
||||
|
||||
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
||||
|
||||
maintainer-clean-generic:
|
||||
mostlyclean-am: mostlyclean-camlibLTLIBRARIES mostlyclean-compile \
|
||||
mostlyclean-libtool mostlyclean-tags mostlyclean-depend \
|
||||
mostlyclean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
clean-am: clean-camlibLTLIBRARIES clean-compile clean-libtool \
|
||||
clean-tags clean-depend clean-generic mostlyclean-am
|
||||
|
||||
clean: clean-am
|
||||
|
||||
distclean-am: distclean-camlibLTLIBRARIES distclean-compile \
|
||||
distclean-libtool distclean-tags distclean-depend \
|
||||
distclean-generic clean-am
|
||||
-rm -f libtool
|
||||
|
||||
distclean: distclean-am
|
||||
|
||||
maintainer-clean-am: maintainer-clean-camlibLTLIBRARIES \
|
||||
maintainer-clean-compile maintainer-clean-libtool \
|
||||
maintainer-clean-tags maintainer-clean-depend \
|
||||
maintainer-clean-generic distclean-am
|
||||
@echo "This command is intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
|
||||
.PHONY: mostlyclean-camlibLTLIBRARIES distclean-camlibLTLIBRARIES \
|
||||
clean-camlibLTLIBRARIES maintainer-clean-camlibLTLIBRARIES \
|
||||
uninstall-camlibLTLIBRARIES install-camlibLTLIBRARIES \
|
||||
mostlyclean-compile distclean-compile clean-compile \
|
||||
maintainer-clean-compile mostlyclean-libtool distclean-libtool \
|
||||
clean-libtool maintainer-clean-libtool tags mostlyclean-tags \
|
||||
distclean-tags clean-tags maintainer-clean-tags distdir \
|
||||
mostlyclean-depend distclean-depend clean-depend \
|
||||
maintainer-clean-depend info-am info dvi-am dvi check check-am \
|
||||
installcheck-am installcheck install-exec-am install-exec \
|
||||
install-data-am install-data install-am install uninstall-am uninstall \
|
||||
all-redirect all-am all installdirs mostlyclean-generic \
|
||||
distclean-generic clean-generic maintainer-clean-generic clean \
|
||||
mostlyclean distclean maintainer-clean
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
957
camlibs/canon/Protocol
Normal file
957
camlibs/canon/Protocol
Normal file
@@ -0,0 +1,957 @@
|
||||
(read/print this document with a non-proportional font such as courier)
|
||||
|
||||
============================================
|
||||
====== Canon Powershot Series ======
|
||||
==== Transfer Protocol Specifications =====
|
||||
============================================
|
||||
|
||||
* About this document
|
||||
|
||||
The following document is an overview of the Canon Powershot serial
|
||||
and USB transfer protocols. It should be a valid reference for models
|
||||
ranging from Powershot A5 to S20.
|
||||
|
||||
No information present in this document was obtained from Canon.
|
||||
Everything is the result of observations and logical analysis. It is
|
||||
by no means guaranteed to be accurate, nor even right. Nevertheless, a
|
||||
lot of people have managed to communicate with their Powershot cameras
|
||||
using these commands, so they cannot be completely wrong either !
|
||||
|
||||
An implementation of this communication protocol was made for the
|
||||
GPhoto digital camera software, available at www.gphoto.org.
|
||||
|
||||
* Contributors:
|
||||
|
||||
This document was written thanks to the efforts of:
|
||||
|
||||
Wolfgang G. Reissnegger, Werner Almesberger, Philippe Marzouk, Mikael
|
||||
Nyström, Edouard Lafargue.
|
||||
|
||||
|
||||
* Copyright :
|
||||
|
||||
The Canon Protocol information. Copyright (c) 2000 by its respective
|
||||
authors (see the Contrinutors section).
|
||||
|
||||
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., 675 Mass Ave, Cambridge, MA 02139,
|
||||
USA.
|
||||
|
||||
* To Do :
|
||||
|
||||
(send updates to Edouard.Lafargue@bigfoot.com or to the
|
||||
gphoto-devel mailing-list)
|
||||
|
||||
- Serial:
|
||||
|
||||
Update get_directory description to match what was discovered in USB.
|
||||
Describe the structure of the initial ID packet.
|
||||
Find out what the real meaning of the "fffb" command is.
|
||||
Describe error recovery protocol.
|
||||
Describe format of low batt condition.
|
||||
Find out the rest of the commands that were discovered in USB:
|
||||
- Make dir
|
||||
- Delete dir
|
||||
- Change attribute
|
||||
- etc.
|
||||
Describe File upload.
|
||||
Describe each command in detail.
|
||||
|
||||
- USB:
|
||||
|
||||
Describe the generic get_directory reply packet with the location of
|
||||
the error code offset.
|
||||
|
||||
- General:
|
||||
|
||||
Rewrite this document in XML (LinuxDoc).
|
||||
|
||||
* Changelog:
|
||||
|
||||
09 May 2000: first version with both USB and serial protocols
|
||||
described in the same document.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
=========================================================================
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
============================================
|
||||
== Serial Protocol ==
|
||||
=== Specifications ===
|
||||
============================================
|
||||
|
||||
|
||||
Introduction
|
||||
============
|
||||
|
||||
We have chosen to describe the Canon Serial Protocol as successive
|
||||
layers. I used OSI-like names but the protocol is not really a network
|
||||
protocol.
|
||||
|
||||
a. Data link layer:
|
||||
Responsible for framing, escaping and checksuming messages
|
||||
|
||||
b. Transport (packet) layer:
|
||||
Responsible for dividing messages into packets of known length.
|
||||
This layer also handles handshaking, retries, etc.
|
||||
|
||||
c. Session (message) layer:
|
||||
Last layer, carrying whole messages, such as download requests,
|
||||
image data, and such information.
|
||||
|
||||
Currently, all these layers are documented, but we still lack
|
||||
information on how to handle protocol retries, and errors in general.
|
||||
|
||||
|
||||
Data link layer
|
||||
=====================
|
||||
|
||||
The following figure illustrates the lower layers of the protocol
|
||||
used by some Canon PowerShot cameras:
|
||||
|
||||
[ Upper layers ] Example: payload "00 C0 01"
|
||||
| ^
|
||||
| | 00 C0 01
|
||||
<CRC>
|
||||
| | 00 C0 01 12 34 (fictious CRC)
|
||||
<Escaping>
|
||||
| | 00 7E E0 01 12 34
|
||||
<Framing>
|
||||
| | C0 00 7E E0 01 12 34 C1
|
||||
v |
|
||||
[ Wire format ]
|
||||
|
||||
The upper layers are described later in this file.
|
||||
|
||||
|
||||
0) Serial timing
|
||||
----------------
|
||||
|
||||
Initialization: PC sends sequences of "U" bytes at 9600 bps until the
|
||||
camera responds by sending its ID. Each sequence has a length of 2-8
|
||||
bytes. The interval to wait between sequences is 0.9-1.04 sec
|
||||
(measured for 8 bytes).
|
||||
|
||||
When the camera sends its ID, the computer can ask it to change to a
|
||||
higher speed. The speed can go up to 115200 bps.
|
||||
|
||||
Afterwards, a one/two seconds command timeout should be set.
|
||||
E.g. retrieving a directory with 1200 files takes several
|
||||
seconds. Opening a large capacity flash card takes time as well.
|
||||
|
||||
|
||||
1) Framing
|
||||
----------
|
||||
|
||||
Each message begins with the byte C0 and ends with the byte C1. The
|
||||
length of a message including the framing bytes and any escape bytes
|
||||
(see below) never exceeds 1024 bytes.
|
||||
|
||||
|
||||
2) Escaping
|
||||
-----------
|
||||
|
||||
The value 7E is used to XOR the following byte with the value 0x20. This
|
||||
is used for the following three combinations:
|
||||
7E 5E -> 7E
|
||||
7E E0 -> C0
|
||||
7E E1 -> C1
|
||||
|
||||
|
||||
3) CRC
|
||||
------
|
||||
|
||||
The last two bytes of a message (without framing and escaping) contain
|
||||
a 16-bit "CCITT" CRC in little-endian order. The CRC is calculated
|
||||
over the entire message, without framing and escaping, and without
|
||||
including the CRC bytes. The CRC generator [1] is initialized to a
|
||||
length-dependent value. The algorithim for the initial value is not
|
||||
known. However, a table of values emitted by the camera has been
|
||||
compiled and is in crc.c:crc_init. It is indexed by the length,
|
||||
i.e. the number of bytes over which the CRC is taken.
|
||||
|
||||
|
||||
[1] Assuming the use of
|
||||
http://www.cse.fau.edu/~sam/course/dc_htm/src_dir/crc_att.c,
|
||||
generator polynom 0102010 (octal), the initial value of "crc" is
|
||||
the CRC generator's initial value (in the original code always
|
||||
zero).
|
||||
|
||||
|
||||
|
||||
Transport layer
|
||||
=====================
|
||||
|
||||
Communication is done through messages, which may be split into
|
||||
several fragments, which are then sent as individual packets. Packets
|
||||
are framed as described earlier in this file.
|
||||
|
||||
|
||||
Packet level
|
||||
------------
|
||||
|
||||
Each packet consists of the following two-byte header:
|
||||
|
||||
<sequence> <ptype>
|
||||
|
||||
There are two sequence numbers: the message sequence number <mseq> and
|
||||
the fragment sequence number <fseq>. They are counted independently
|
||||
and start at zero. <mseq> is reset at the beginning of a session,
|
||||
while <fseq> is reset at the beginning of each message.
|
||||
|
||||
The following packet types are known:
|
||||
00 Message fragment
|
||||
03 Speed message from computer
|
||||
04 EOT
|
||||
05 ACK
|
||||
06 Compatibility?
|
||||
|
||||
A packet with type 03 is sent once, early in the initialization for
|
||||
the computer to ask the camera to switch to a higher speed.
|
||||
|
||||
Each message ends with an EOT packet, which is then confirmed by an
|
||||
ACK packet.
|
||||
|
||||
|
||||
EOT has the following format:
|
||||
xx 04 xx 00 00 00
|
||||
| |
|
||||
| indication of the message length. Known values:
|
||||
<mseq> 00 empty message (no fragments)
|
||||
01 short message (one fragment)
|
||||
ff maximum length data packet, more to follow
|
||||
else data packet, at end (observed values: 0f, 7f)
|
||||
|
||||
ACK has the following format:
|
||||
xx 05 xx 00 00 00
|
||||
| |
|
||||
| error code
|
||||
<mseq> 00 No error, acknowledged
|
||||
01 Not acknowledged
|
||||
FF retransmit last sequence
|
||||
else other values not known
|
||||
|
||||
|
||||
A packet with type 06 is sent once, as the first packet coming from
|
||||
the camera. It contains a length, just like a normal message fragment,
|
||||
but the message structure is different.
|
||||
|
||||
An empty message can be used to test if the camera is still responding.
|
||||
If yes, it will respond with an ACK. Example:
|
||||
PC->CAM xx 04 00 00 00 00
|
||||
CAM->PC xx 05 00 00 00 00
|
||||
|
||||
|
||||
Message fragment level
|
||||
----------------------
|
||||
|
||||
Message fragments have the following structure:
|
||||
|
||||
xx 00 xx xx ...
|
||||
| | | |
|
||||
| | | fragment data
|
||||
| | data length, MSB
|
||||
| data length, LSB
|
||||
<fseq>
|
||||
|
||||
The data length is the length (in bytes) of the fragment data that
|
||||
follows the length. Fragment data is simply concatenated to form the
|
||||
complete message.
|
||||
|
||||
|
||||
Session (message) Layer
|
||||
=======================
|
||||
|
||||
All messages (except the one with type 03) have the following structure:
|
||||
|
||||
00 02 00 00 xx 00 00 xx xx xx 00 00 ...
|
||||
| | | | |
|
||||
| | | | message payload
|
||||
| | | message length, MSB
|
||||
| | message length, LSB
|
||||
| direction code <dir>
|
||||
message type <mtype>
|
||||
|
||||
The message length is the length of the entire message, including the
|
||||
header shown above.
|
||||
|
||||
|
||||
|
||||
The first four bytes of the message payload <fffb> seem to depend on
|
||||
the message type. The following combinations have been sighted:
|
||||
|
||||
<mtype> <dir> <fffb> Operation
|
||||
|
||||
01 12 14 f7 8a 00 Identify camera request
|
||||
01 22 14 f7 8a 00 Identify camera response
|
||||
01 11 6a 08 79 04 Download image request
|
||||
01 11 aa 06 79 04 Download "thumbnail" request (see below)
|
||||
01 21 6a 08 79 04 Image data
|
||||
01 21 aa 06 79 04 "Thumbnail" data
|
||||
03 12 78 f3 64 01 Get Date
|
||||
04 12 08 d3 9d 00 Set date
|
||||
05 12 fc d2 9d 00 Change Owner name
|
||||
09 11 d8 f7 8a 00 Disk info request
|
||||
09 21 d8 f7 8a 00 Disk info response
|
||||
0a 11 dc f7 8a 00 Get disk(s) request
|
||||
0a 21 dc f7 8a 00 Get disk(s) response
|
||||
0a 12 70 f6 8a 00 Power Supply Status
|
||||
0a 22 70 f6 8a 00 Power Supply Status response
|
||||
0b 11 94 f6 8a 00 List without date request
|
||||
0b 21 94 f6 8a 00 List without date response
|
||||
0b 11 a8 f6 8a 00 List with date request
|
||||
0b 21 a8 f6 8a 00 List with date response
|
||||
0d 11 8c f4 7b 00 Delete image request
|
||||
0d 21 8c f4 7b 00 Delete image response
|
||||
0e 11 -- -- -- -- Set file attributes.
|
||||
|
||||
Important note : it seems that the "fffb" part can be set to 0 in
|
||||
every case, and the commands will still work. The exact meaning of
|
||||
this part of the packet is unknwown. It is probably used as a unique
|
||||
ID for each transaction and can be chosen at random each time.
|
||||
|
||||
|
||||
Identify camera
|
||||
---------------
|
||||
|
||||
The identify camera request has no data.
|
||||
|
||||
The identify camera response has the following structure:
|
||||
00 00 00 00 00 02 00 00 00 00 00 01 <camera_name> 00 (more 00s)
|
||||
|
||||
On the S10, the response has the following structure:
|
||||
00 00 00 00 00 04 00 00 00 00 00 01 and then:
|
||||
<firmware rev> (32 bit word) (offset: 0x08)
|
||||
<model name> (C string) (offset: 12 / 0x0c)
|
||||
<owner name> (C string) (offset: 44 / 0x2c)
|
||||
|
||||
Firmware version: 04 03 02 01 is version 1.2.3.4
|
||||
01 00 00 01 is version 1.0.0.1
|
||||
|
||||
Example (full packet): for a PowerShot S10 with firmware 1.0.0.0
|
||||
|
||||
RECV: (98 bytes)
|
||||
00000000: 00 00 5C 00 02 00 00 00 01 00 00 22 5C 00 00 00 - ..\........"\...
|
||||
00000010: 14 F7 8A 00 00 00 00 00 00 04 00 00 00 00 00 01 - ................
|
||||
00000020: 43 61 6E 6F 6E 20 50 6F 77 65 72 53 68 6F 74 20 - Canon PowerShot
|
||||
00000030: 53 31 30 00 00 00 00 00 00 00 00 00 00 00 00 00 - S10.............
|
||||
00000040: 45 64 6F 75 61 72 64 20 4C 61 66 61 72 67 75 65 - Edouard Lafargue
|
||||
00000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - ................
|
||||
00000060: 9C EA - ..
|
||||
|
||||
|
||||
Get Power Status
|
||||
----------------
|
||||
|
||||
Offsets in the payload:
|
||||
|
||||
0x04 contains a byte with power status: 0x6=good, 0x4=bad
|
||||
0x07 contains a byte with powertype: 0x10=ac-adaptor, 0x30=battery
|
||||
|
||||
Example (full packet):
|
||||
RECV: (30 bytes)
|
||||
00000000: 00 00 18 00 02 00 00 00 0A 00 00 22 18 00 00 00 - ..........."....
|
||||
00000010: 70 F6 8A 00 00 00 00 00 06 00 00 30 B5 5A - p..........0.Z
|
||||
|
||||
|
||||
|
||||
Change Owner Name
|
||||
----------------
|
||||
|
||||
The name (payload) can be 30 characters max.
|
||||
|
||||
|
||||
Set Date
|
||||
--------
|
||||
|
||||
The payload of this message is 4 bytes, it must be the same unix
|
||||
format as in the directory with date request, for example the
|
||||
01/01/2000 is 80 43 6D 38.
|
||||
|
||||
|
||||
Get disk(s)
|
||||
-----------
|
||||
|
||||
The get disk(s) request has no data.
|
||||
|
||||
The get disk response has the following structure:
|
||||
00 00 00 00 <disk_name> 00
|
||||
|
||||
Disk name example: "C:"
|
||||
|
||||
|
||||
Disk info
|
||||
---------
|
||||
|
||||
Disk info requests have the following structure:
|
||||
<root_name> 00
|
||||
|
||||
Disk info responses have the following structure:
|
||||
00 00 00 00 xx xx xx xx xx xx xx xx
|
||||
| |
|
||||
| Free space (in bytes)
|
||||
Total capacity (in bytes)
|
||||
|
||||
Root name example: "C:\" (The trailing slash is required.)
|
||||
|
||||
|
||||
List (show directory contents)
|
||||
------------------------------
|
||||
|
||||
Note: It seems that directory listing as described in the USB part is
|
||||
more accurate, when it comes to the meaning of the first byte (
|
||||
"date/withtout date").
|
||||
|
||||
List requests have the following structure:
|
||||
xx <directory_name> 00 00 00
|
||||
|
|
||||
00 if with date, 02 if without date
|
||||
|
||||
Directory name example: "C:\PWRSHOT", "D:", or "D:\.", but not
|
||||
"D:\" (trailing slash), or "D:\.\FOO" (dot not allowed in path ?)
|
||||
|
||||
List responses have the following structure:
|
||||
Failure:
|
||||
00 00 00 00 01 00 00 00 00 00 00 00
|
||||
|
||||
Success:
|
||||
00 00 00 00 xx 80 00 00 00 00 00 00 00 00 00 00
|
||||
|
|
||||
01 if last message, 00 if more
|
||||
<directory_name> 00
|
||||
<type> 00 <size> <date> <entry_name> 00
|
||||
...
|
||||
<type> 00 <size> <date> <entry_name> 00 (many 00s)
|
||||
|
||||
<type> is one byte containing the file attributes:
|
||||
File attributes:
|
||||
bit0 (1= write protected, 0=NOT write protected)
|
||||
bit4 (1=directory contains item but not recursived entered)
|
||||
(NOT used with the attrib command)
|
||||
bit5 (1=NOT downloaded, 0=downloaded)
|
||||
(must be manually switched)
|
||||
bit7 (1=recurively entered directory)
|
||||
(NOT used with the attrib command)
|
||||
|
||||
|
||||
<size> is the size in bytes. Directory size is always 0.
|
||||
|
||||
Entry name example: "AUT_1201.JPG" or "MISC"
|
||||
|
||||
The date is a four bytes Unix-style date. The list without date responses
|
||||
also contains the four data bytes, but sets them to zero.
|
||||
|
||||
Note: it's unclear if the list with/without date commands differ in any
|
||||
other way than the inclusion of the date.
|
||||
|
||||
If the directory is so large that additional messages are needed, they
|
||||
have the following structure:
|
||||
00 00 00 00 xx <entry>
|
||||
|
|
||||
1 if last message, 00 if more
|
||||
|
||||
The boundary between messages is always chosen such that the terminating
|
||||
00 of an entry is the last byte in the earlier message.
|
||||
|
||||
|
||||
Download and Data
|
||||
-----------------
|
||||
|
||||
Download requests have the following structure:
|
||||
00 00 00 00 00 xx 00 00 <name> 00
|
||||
|
|
||||
Length of name (including terminating \0)
|
||||
|
||||
Data messages have the following structure:
|
||||
00 00 00 00 xx xx xx xx xx xx xx xx xx xx xx xx xx 00 00 00 ...
|
||||
| | | | |
|
||||
| | | | data
|
||||
| | | 00 if more, 01 at end
|
||||
| | data size in this message
|
||||
| current offset
|
||||
total length
|
||||
|
||||
All lengths are measured in bytes.
|
||||
|
||||
The camera only sends the 10813 first bytes from the image for the thumbnail
|
||||
download request. However it is not a valid thumbnail image, the first part
|
||||
is the Exif header, the second part is the thumbnail itself between a FF D8
|
||||
and a FF D9, the remaining is the beginning of the picture.
|
||||
|
||||
|
||||
The camera always sends 8 messages then waits for an ACK from the computer,
|
||||
if the computer has not received everything, it sends an ACK with an error
|
||||
value asking to retransmit one of the eight packet sent. These error values
|
||||
are not yet known.
|
||||
|
||||
|
||||
Switch Camera off
|
||||
-----------------
|
||||
|
||||
In order to switch the camera off, you need to send the following
|
||||
characters (directly, without extra framing) :
|
||||
|
||||
C0 00 02 55 2C C1
|
||||
C0 00 04 01 00 00 00 24 C6 C1
|
||||
|
||||
|
||||
Low Battery warning
|
||||
-------------------
|
||||
|
||||
If the camera batteries run too low during a transfer and the camera
|
||||
needs to switch itself off, it will send a special packet just before
|
||||
going down. You can see how it is handled in psa50.c
|
||||
|
||||
|
||||
|
||||
===============================================
|
||||
=
|
||||
= USB Interface
|
||||
=
|
||||
===============================================
|
||||
|
||||
Nota:
|
||||
When mentioning word, 32bit word little_endian is implied.
|
||||
|
||||
References to usb11.pdf (Chaper 9.3 page 199):
|
||||
http://www.usb.org/developers/data/usbspec.zip (1.8Mb)
|
||||
|
||||
bmRequestType is 0xC0 during read and 0x40 during write.
|
||||
bRequest is 0x4 if length of data is >1, 0x0c otherwise (length > 1 ? 0x04 : 0x0C)
|
||||
wValue differs between operations.
|
||||
wIndex is always 0x00
|
||||
wLength is simply the length of data
|
||||
|
||||
In linux sending/reciving commands is using usb_control_msg (in usb.c).
|
||||
|
||||
usb11.pdf name | usb.c name)
|
||||
--------------------------------
|
||||
bmRequestType | requesttype
|
||||
bRequest | request
|
||||
wValue | value
|
||||
wIndex | index
|
||||
wLength | length
|
||||
|
||||
================================================================================
|
||||
Init of camera:
|
||||
================================================================================
|
||||
|
||||
1. Control_transfer_read requesttype=0xC0 value=0x55 length=1
|
||||
|
||||
Camera responds with following data (single char):
|
||||
"A" = Camera was already active
|
||||
"C" = Camera was woken up
|
||||
"I" = Unknown (some kind of error)
|
||||
"E" = Unknown (some kind of error)
|
||||
|
||||
2. Control_transfer_read requesttype=0xC0 value=0x1 length=0x58
|
||||
|
||||
The first 0x48 bytes can be trashed, save the last 0x10 byte and us it as
|
||||
data in next step.
|
||||
Example:
|
||||
00000000 18 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000040 01 00 02 00 43 30 A9 04-00 08 00 00 FF FF FF FF ....C0..........
|
||||
00000050 00 FD 00 00 00 FD 00 00 ........
|
||||
|
||||
3. Control_transfer_write requesttype=0x40 value=0x11 length=0x10 data=[from step 2]
|
||||
|
||||
4. PC sign should now appear on the LCD
|
||||
|
||||
5. Receive 0x44 bytes from bulk_in and throw it away.
|
||||
Example:
|
||||
00000000 04 00 00 00 02 03 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000040 00 00 00 00 ....
|
||||
|
||||
================================================================================
|
||||
USB Commands
|
||||
================================================================================
|
||||
|
||||
1. Structure of a command block
|
||||
|
||||
Example:
|
||||
|
||||
* Command block sent in general: (Example:Disk info request)
|
||||
0000000: 14 00 00 00 01 02 00 00-00 00 00 00 00 00 00 00 ................
|
||||
0000010: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
0000020: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
0000030: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
0000040: 02 00 00 00 09 00 00 11-14 00 00 00 78 56 34 12 ............xV4.
|
||||
0000050: 44 3A 5C 00 D:\.
|
||||
|
||||
USB arguments:
|
||||
- value is always 0x10
|
||||
- length is TOTAL length (0x54 in example above)
|
||||
|
||||
* Generic format of block sent:
|
||||
|
||||
0000000: xx xx xx xx yy yy yy yy - 00 00 00 00 00 00 00 00
|
||||
0000010: 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00
|
||||
0000020: 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00
|
||||
0000030: 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00
|
||||
0000040: 02 00 00 00 UU 00 00 VV - xx xx xx xx SS SS SS SS
|
||||
0000050: ... (payload/arguments)
|
||||
|
||||
xx xx xx xx : Length (word)
|
||||
yy yy yy yy : cmd3 (word)
|
||||
UU : cmd1 (byte)
|
||||
VV : cmd2 (byte)
|
||||
xx xx xx xx : Length (again)
|
||||
SS SS SS SS : serial number (word)
|
||||
|
||||
- 'length' is the length of the block, excluding the first 0x40 bytes
|
||||
in block, and is never less than 0x10.
|
||||
- cmd1 and cmd2 are a single byte
|
||||
- cmd3 is a word
|
||||
- Serial number is a word, sent back in command reply.
|
||||
|
||||
2. Summary of available (known) commands:
|
||||
|
||||
cmd1 | cmd2 | cmd3 | Argument(eg.) Response Length | Operation
|
||||
-----------------------------------------------------------------------------------------------
|
||||
0x01 0x11 0x202 | 0x00000000 0x00001400 "D:\DCIM\100CANON\IMG_0100.JPG" 0x00 L | Get picture
|
||||
0x01 0x11 0x202 | 0x00000001 0x00001400 "D:\DCIM\100CANON\IMG_0100.JPG" 0x00 L | Get thumbnail
|
||||
0x01 0x12 0x201 | none 0x9c | Identify camera request
|
||||
0x03 0x12 0x201 | none 0x60 | Get time
|
||||
0x04 0x12 0x201 | 0x390873f0 0x00000000 0x00000000 0x54 | Set time (0x390873f0) (UNIX-type)
|
||||
0x05 0x11 0x201 | "D:\DCIM" 0x00 0x54 | Make directory
|
||||
0x05 0x12 0x201 | "Donald Duck" 0x00 0x54 | Change owner
|
||||
0x06 0x11 0x201 | "D:\DCIM" 0x00 0x54 | Remove directory
|
||||
0x09 0x11 0x201 | "D:\" 0x00 0x5c | Disk info request
|
||||
0x0A 0x11 0x202 | none L | Flash device identification
|
||||
0x0A 0x12 0x201 | none 0x58 | Power supply status
|
||||
0x0b 0x11 0x202 | 0x1 "D:\DCIM" 0x00 0x00 0x00 L | Get directory (0x1 = max depth of recursion)
|
||||
0x0d 0x11 0x201 | "D:\DCIM\100CANON" 0x00 "IMG_0002.JPG" 0x00 0x54 | Delete file
|
||||
0x0E 0x11 0x201 | 0x00000021 "D:\DCIM\100CANON" 0x00 "IMG_0002.JPG" 0x00 0x54 | Set file attribute
|
||||
|
||||
L means that the program reads 0x40 from bulk in, checks for a word at
|
||||
position 0x6 for the length (0xd1fcf in this case), and then reads the
|
||||
rest in 0x1400 buffers. (long bulk in read)
|
||||
|
||||
00000000 00 00 00 00 02 03 CF 1F-0D 00 00 00 00 00 00 00 ................
|
||||
00000010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
|
||||
****
|
||||
** Disk Info Request:
|
||||
****
|
||||
|
||||
* Argument structure:
|
||||
|
||||
Null-terminated string containing the name of the disk.
|
||||
|
||||
* Camera response block:
|
||||
|
||||
Data received via bulk in after a command block: (Disk info request)
|
||||
0000000: 00 00 00 00 01 03 00 00 00 00 00 00 00 00 00 00 ................
|
||||
0000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
|
||||
0000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
|
||||
0000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
|
||||
0000040: 02 00 00 00 09 00 00 21 1C 00 00 00 78 56 34 12 .......!....xV4.
|
||||
0000050: 00 00 00 00 00 80 E8 03 00 A0 AF 03 ............
|
||||
|
||||
First 0x40 bytes is throwable.
|
||||
0x54 contains a word with totalbytes on flash.
|
||||
0x58 contains a word with bytes free.
|
||||
|
||||
****
|
||||
** Delete directory
|
||||
****
|
||||
Data received via bulk in after a command block: (Delete directory)
|
||||
00000000 00 00 00 00 01 03 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000040 02 00 00 00 06 00 00 21-14 00 00 00 78 56 34 12 .......!....xV4.
|
||||
00000050 00 00 00 00 ....
|
||||
|
||||
****
|
||||
** Make directory
|
||||
****
|
||||
Data received via bulk in after a command block: (Make directory)
|
||||
00000000 00 00 00 00 01 03 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000040 02 00 00 00 05 00 00 21-14 00 00 00 78 56 34 12 .......!....xV4.
|
||||
00000050 00 00 00 00 ....
|
||||
|
||||
|
||||
****
|
||||
** Get time
|
||||
****
|
||||
|
||||
Data received via bulk_in after a command block: (Get time)
|
||||
00000000 00 00 00 00 01 03 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000040 02 00 00 00 03 00 00 22-20 00 00 00 78 56 34 12 ......." ...xV4.
|
||||
00000050 00 00 00 00 8D 1D 12 39-00 00 00 00 00 00 00 00 .......9........
|
||||
|
||||
First 0x40 bytes is throwable.
|
||||
0x54 contains a UNIX time
|
||||
|
||||
****
|
||||
** Power supply status
|
||||
****
|
||||
|
||||
Data received via bulk_in after a command block: (Power supply status)
|
||||
00000000 00 00 00 00 01 03 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000040 02 00 00 00 0A 00 00 22-18 00 00 00 78 56 34 12 ......."....xV4.
|
||||
00000050 00 00 00 00 06 00 00 10- ........
|
||||
|
||||
First 0x40 bytes is throwable.
|
||||
0x54 contains a byte with power status: 0x6=good, 0x4=bad
|
||||
0x57 contains a byte with powertype: 0x10=ac-adaptor, 0x30=battery
|
||||
|
||||
****
|
||||
** Identify Camera request
|
||||
****
|
||||
|
||||
Data received via bulk_in after a command block: (Identify camera request)
|
||||
00000000 00 00 00 00 01 03 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000040 02 00 00 00 01 00 00 22-5C 00 00 00 78 56 34 12 ......."\...xV4.
|
||||
00000050 00 00 00 00 00 04 00 00-01 00 00 01 43 61 6E 6F ............Cano
|
||||
00000060 6E 20 50 6F 77 65 72 53-68 6F 74 20 53 32 30 00 n PowerShot S20.
|
||||
00000070 00 00 00 00 00 00 00 00-00 00 00 00 44 6F 6E 61 ............Dona
|
||||
00000080 6C 64 20 44 75 63 6B 00-00 00 00 00 00 00 00 00 ld Duck.........
|
||||
00000090 00 00 00 00 00 00 00 00-00 00 00 00 ............
|
||||
|
||||
First 0x40 bytes is throwable (as usual)
|
||||
At 0x5c a string with camera type exist
|
||||
At 0x7c a string with owner name exist.
|
||||
0x58-0x5b is firmware version (04 03 02 01 is version 1.2.3.4; 01 00 00 01 is version 1.0.0.1)
|
||||
Data at 0x54-0x57 has unknown purpose.
|
||||
|
||||
****
|
||||
** Flash device identification
|
||||
****
|
||||
|
||||
Data received via a long_bulk_in_read: (Flash device identification)
|
||||
00000000 44 3A 00 00 D:..
|
||||
|
||||
****
|
||||
** Set File Attribute
|
||||
****
|
||||
|
||||
Data received via bulk_in after a command block: (Set file attribute)
|
||||
00000000 00 00 00 00 01 03 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000040 02 00 00 00 0E 00 00 21-14 00 00 00 78 56 34 12 .......!....xV4.
|
||||
00000050 00 00 00 00 ....
|
||||
|
||||
Data received via bulk_in after a command block: (Set file attribute) (file did not exist).
|
||||
00000000 00 00 00 00 01 03 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000040 02 00 00 00 0E 00 00 21-14 00 00 00 78 56 34 12 .......!....xV4.
|
||||
00000050 22 00 00 02 "...
|
||||
|
||||
|
||||
File attributes:
|
||||
bit0 (1= write protected, 0=NOT write protected)
|
||||
bit4 (1=directory contains item but not recursived entered)
|
||||
(NOT used with the attrib command)
|
||||
bit5 (1=NOT downloaded, 0=downloaded)
|
||||
(must be manually switched)
|
||||
bit7 (1=recurively entered directory)
|
||||
(NOT used with the attrib command)
|
||||
|
||||
Example: 0x21 file is NOT downloaded but deleteprotected
|
||||
|
||||
|
||||
****
|
||||
** Delete file
|
||||
****
|
||||
|
||||
Data received via bulk_in after a command block: (Delete file) (file did not exist).
|
||||
00000000 00 00 00 00 01 03 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000040 02 00 00 00 0D 00 00 21-14 00 00 00 78 56 34 12 .......!....xV4.
|
||||
00000050 22 00 00 02 "...
|
||||
|
||||
Data received via bulk_in after a command block: (Delete file) (file was protected)
|
||||
00000000 00 00 00 00 01 03 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000040 02 00 00 00 0D 00 00 21-14 00 00 00 78 56 34 12 .......!....xV4.
|
||||
00000050 29 00 00 02 )...
|
||||
|
||||
Data received via bulk_in after a command block: (Delete file) (successful)
|
||||
00000000 00 00 00 00 01 03 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000040 02 00 00 00 0D 00 00 21-14 00 00 00 78 56 34 12 .......!....xV4.
|
||||
00000050 00 00 00 00 ....
|
||||
|
||||
|
||||
****
|
||||
** Change Owner
|
||||
****
|
||||
|
||||
Data received via bulk_in after a command block: (Change owner) (no errorcodes)
|
||||
00000000 00 00 00 00 01 03 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000040 02 00 00 00 05 00 00 22-14 00 00 00 78 56 34 12 ......."....xV4.
|
||||
00000050 00 00 00 00 ....
|
||||
|
||||
****
|
||||
** Directory Listing
|
||||
****
|
||||
|
||||
Errorcodes:
|
||||
0x02000022 File not found
|
||||
0x00000000 No errors
|
||||
0x02000086 Path not found
|
||||
0x02000029 File was protected
|
||||
|
||||
File attributes:
|
||||
bit1 (1=deleteprotected, 0=NOT deleteprotected)
|
||||
bit4 (1=directory contains item but not recursived entered) (NOT used with the attrib command)
|
||||
bit5 (1=NOT downloaded, 0=downloaded) (must be manually switched)
|
||||
bit8 (1=recurively entered directory) (NOT used with the attrib command)
|
||||
|
||||
Example: 0x21 file is NOT downloaded but deleteprotected
|
||||
|
||||
Directory handling:
|
||||
Thu May 4 00:11:40 2000 D:\DCIM\100CANON\IMG_0001.JPG 778435
|
||||
Thu May 4 00:28:32 2000 D:\DCIM\100CANON\IMG_0002.JPG 44409
|
||||
Thu May 4 00:28:32 2000 D:\DCIM\CANONMSC\100.CTG 2634
|
||||
Thu May 4 00:28:32 2000 D:\DCIM\CANONMSC\D.CTG 383
|
||||
|
||||
Directory contents: "D:" (recurse =0x0)
|
||||
00000000 80 00 00 00 00 00 00 00-00 00 44 3A 00 10 00 00 ..........D:....
|
||||
00000010 00 00 00 C6 B5 10 39 44-43 49 4D 00 00 00 00 00 ......9DCIM.....
|
||||
00000020 00 00 00 00 00 00 00 .......
|
||||
|
||||
Directory contents: "D:" (recurse =0x1)
|
||||
00000000 80 00 00 00 00 00 00 00-00 00 44 3A 00 80 00 00 ..........D:....
|
||||
00000010 00 00 00 36 C0 10 39 2E-5C 44 43 49 4D 00 10 00 ...6..9.\DCIM...
|
||||
00000020 00 00 00 00 36 C0 10 39-31 30 30 43 41 4E 4F 4E ....6..9100CANON
|
||||
00000030 00 10 00 00 00 00 00 CC-B5 10 39 43 41 4E 4F 4E ..........9CANON
|
||||
00000040 4D 53 43 00 80 00 00 00-00 00 00 00 00 00 2E 2E MSC.............
|
||||
00000050 00 00 00 00 00 00 00 00-00 00 00 00 ............
|
||||
|
||||
Directory contents: "D:" (recurse =0x2)
|
||||
00000000 80 00 00 00 00 00 00 00-00 00 44 3A 00 80 00 00 ..........D:....
|
||||
00000010 00 00 00 36 C0 10 39 2E-5C 44 43 49 4D 00 80 00 ...6..9.\DCIM...
|
||||
00000020 00 00 00 00 3C C0 10 39-2E 5C 31 30 30 43 41 4E ....<..9.\100CAN
|
||||
00000030 4F 4E 00 20 00 C3 E0 0B-00 3C C0 10 39 49 4D 47 ON. .....<..9IMG
|
||||
00000040 5F 30 30 30 31 2E 4A 50-47 00 20 00 79 AD 00 00 _0001.JPG. .y...
|
||||
00000050 30 C4 10 39 49 4D 47 5F-30 30 30 32 2E 4A 50 47 0..9IMG_0002.JPG
|
||||
00000060 00 80 00 00 00 00 00 00-00 00 00 2E 2E 00 80 00 ................
|
||||
00000070 00 00 00 00 30 C4 10 39-2E 5C 43 41 4E 4F 4E 4D ....0..9.\CANONM
|
||||
00000080 53 43 00 20 00 4A 0A 00-00 30 C4 10 39 31 30 30 SC. .J...0..9100
|
||||
00000090 2E 43 54 47 00 20 00 7F-01 00 00 30 C4 10 39 44 .CTG. ....0..9D
|
||||
000000A0 2E 43 54 47 00 80 00 00-00 00 00 00 00 00 00 2E .CTG............
|
||||
000000B0 2E 00 80 00 00 00 00 00-00 00 00 00 2E 2E 00 00 ................
|
||||
000000C0 00 00 00 00 00 00 00 00-00 00 ..........
|
||||
|
||||
Directory contents:
|
||||
attribute 0x00 size date "name" 0x00
|
||||
attribute is a byte describe little earlier in this document
|
||||
(0 in attribute, date, length and name means end of direntry, ".." in name means "leave directory".
|
||||
size is a word (filesize in byte)
|
||||
time is a word (UNIX time)
|
||||
|
||||
|
||||
****
|
||||
** Upload (a little bit special):
|
||||
****
|
||||
|
||||
Control_transfer_write
|
||||
requesttype=0x40
|
||||
value=0x10
|
||||
length=0x40
|
||||
data=0x00000000 0x0203 0x40+len1[explained later] [0x00 repeated 0x38]
|
||||
|
||||
Example:
|
||||
00000000 00 00 00 00 03 02 7A 14-00 00 00 00 00 00 00 00 ......z.........
|
||||
00000010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
|
||||
bulk_in_read [0x40 bytes]
|
||||
Example:
|
||||
00000000 00 00 00 00 03 03 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
|
||||
bulk_write [data below]
|
||||
|
||||
len1[explained later] 0x00 0x00 0x00000403 0x00000000 0x00000000
|
||||
[0x00 repeated 0x30 times]
|
||||
0x00000002 0x03 0x00 0x00 0x11 len1 0x00 0x00 serial (this line looks very similar to "ordinary" commands)
|
||||
0x00000002 offs len2 filename 0x00 datablock
|
||||
|
||||
bulk_in_read [0x5c bytes]
|
||||
|
||||
This is repeated until the whole file is transmitted:
|
||||
|
||||
- offs is a word that starts at 0 and increments with blocksize each time.
|
||||
|
||||
- len1 is the length of the "bulk_write_data" block above, minus 0x40 (the
|
||||
first length and padded zeros is not counted as in all other commands).
|
||||
len1 is typically 0x143A using a standard 0x1400 (ms-windows) block
|
||||
using the filename below (29 chars), last block is shorter.
|
||||
|
||||
- len2 is length of datablock (0x1400 is used in ms-windows), last
|
||||
block is shorter serial is a random word that is returned as a reply.
|
||||
|
||||
- filname is "D:\DCIM\100CANON\IMG_0002.JPG" for example (file cannot
|
||||
be created in nonexisting directory.)
|
||||
|
||||
- datablock is the datablock itself (the fragment of the JPG file).
|
||||
|
||||
Example of beginning of a block (first one):
|
||||
00000000 3A 14 00 00 03 04 00 00-00 00 00 00 00 00 00 00 :...............
|
||||
00000010 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000020 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000030 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
|
||||
00000040 02 00 00 00 03 00 00 11-3A 14 00 00 78 56 34 12 ........:...xV4.
|
||||
00000050 02 00 00 00 00 00 00 00-00 14 00 00 44 3A 5C 44 ............D:\D
|
||||
00000060 43 49 4D 5C 31 30 30 43-41 4E 4F 4E 5C 49 4D 47 CIM\100CANON\IMG
|
||||
00000070 5F 30 30 30 32 2E 4A 50-47 00 FF D8 FF E1 17 FE _0002.JPG.......
|
||||
00000080 45 78 69 66 00 00 49 49-2A 00 08 00 00 00 09 00 Exif..II*.......
|
||||
00000090 0F 01 02 00 06 00 00 00-7A 00 00 00 10 01 02 00 ........z.......
|
||||
114
camlibs/canon/README
Normal file
114
camlibs/canon/README
Normal file
@@ -0,0 +1,114 @@
|
||||
This driver is for the Canon PowerShot series. It works with the
|
||||
following models:
|
||||
|
||||
- Powershot A5
|
||||
- Powershot A5 Zoom
|
||||
- Powershot A50
|
||||
- Powershot S10
|
||||
- Powershot S20
|
||||
|
||||
It doesn't work with the PowerShot 350. However, the PS350 uses a
|
||||
vaguely similar protocol, so some parts of the sources can probably be
|
||||
shared.
|
||||
|
||||
The driver caches a lot of information. If the camera status changes
|
||||
during a session or if the driver gets stuck for some other reason,
|
||||
the caches can be manually flushed using "Configure camera".
|
||||
|
||||
|
||||
Change history
|
||||
==============
|
||||
|
||||
Version 6 (19-MAY-2000)
|
||||
---------
|
||||
|
||||
- Included USB support in the driver
|
||||
- More options in the configuration file
|
||||
- Debug output can be mostly disabled
|
||||
- The driver now sets the "downloaded" bit on downloaded images
|
||||
|
||||
Version 5 (09-MAY-2000)
|
||||
---------
|
||||
|
||||
- Support for full-speed transfers (115200)
|
||||
- Most protocol commands are implemented, or at least discovered (see
|
||||
the 'Protocol' file)
|
||||
- USB protocol description
|
||||
- Get/Set owner name
|
||||
- Get date
|
||||
- Get firmware rev.
|
||||
- Get battery status
|
||||
- Use libgpio for serial transfers
|
||||
- More reliable error recovery
|
||||
- Better configuration dialog
|
||||
- Support for all current powershot models (A5 to S20)
|
||||
- Low battery condition detection
|
||||
|
||||
|
||||
Version 4 (3-SEP-1999)
|
||||
---------
|
||||
|
||||
- changed uint16_t to unsigned short and removed inclusion of stdint.h, for
|
||||
compatibility :-(
|
||||
|
||||
|
||||
Version 3 (1-SEP-1999)
|
||||
---------
|
||||
|
||||
- lowered number of tries when initializing from 50 to 10 (50 was for
|
||||
experiments)
|
||||
- increased camera ID buffer to be large enough for PS350 responses
|
||||
- serial input is now flushed before testing or attempting synchronization
|
||||
- directories are now sorted alphabetically, implicitly ordering images by
|
||||
date
|
||||
- fixed a few memory leaks in directory handling
|
||||
- added arbitrary file download to Configure/Configure Camera (experimental;
|
||||
very fragile)
|
||||
|
||||
|
||||
Version 2 (29-AUG-1999)
|
||||
---------
|
||||
|
||||
- integrated into gphoto-2.3.5 (from CVS)
|
||||
- added support for large directories (listing occupies > 1 message)
|
||||
- receive timeout is now raised from 1 to 10 seconds after first response
|
||||
- renamed a50_select_disk to a50_disk_info. It now returns disk capacity
|
||||
and available space.
|
||||
- completed CRC table
|
||||
- properly integrated into gPhoto
|
||||
- lots of cleanups
|
||||
|
||||
|
||||
Version 1 (27-AUG-1999)
|
||||
---------
|
||||
|
||||
- a little bit of code cleanup, added a50.h, doc/, full recursive download
|
||||
in canon.c, and fixed a few documentation bugs, adjusted send/receive
|
||||
buffers
|
||||
- a50_send_msg incremented seq_tx when skipping retransissions while waiting
|
||||
for ACK
|
||||
|
||||
|
||||
Version 0 (27-AUG-1999)
|
||||
---------
|
||||
|
||||
- initial release which demonstrates most functions in a way that's
|
||||
completely useless for gPhoto
|
||||
|
||||
|
||||
To do
|
||||
=====
|
||||
|
||||
- code structure is still pretty ugly. Things that absolutely need fixing:
|
||||
- command codes and fffbs are spread all over the place
|
||||
- "ping" (empty message) should probably be merged into normal message
|
||||
handling; perhaps also 03 message -> wait_for_ack can be merged too
|
||||
- psa50.c must not invoke GUI functions
|
||||
- change many fprintf(stderr,... to GUI calls or callbacks
|
||||
- improve error handling: distinguish between severe and harmless errors
|
||||
(e.g. duplicate EOT vs. ten timeouts in a row)
|
||||
- find out how error recovery works (need traces)
|
||||
- get traces for other operations:
|
||||
- idle period/restart (keepalive ?)
|
||||
- upload file, create directory
|
||||
- find out how to avoid blocking gPhoto during transfer
|
||||
1408
camlibs/canon/canon.c
Normal file
1408
camlibs/canon/canon.c
Normal file
File diff suppressed because it is too large
Load Diff
49
camlibs/canon/canon.h
Normal file
49
camlibs/canon/canon.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* File: canon.h
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _CANON_H
|
||||
#define _CANON_H
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* global info structure
|
||||
*
|
||||
* Not much here yet...
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* These are defines for packet command codes collected from several
|
||||
* sources. There's no guarantee, that they are correct...
|
||||
*
|
||||
* The same is true for the ident string offset
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#define CANON_IDENT_OFFSET 0x1a
|
||||
|
||||
#define CANON_CMD_ACK 0x04
|
||||
#define CANON_CMD_PING 0x10
|
||||
|
||||
#define CANON_PCK_SOT 0x05
|
||||
#define CANON_PCK_EOT 0x04
|
||||
#define CANON_PCK_CMD 0x00
|
||||
#define CANON_PCK_IDENT 0x06
|
||||
|
||||
#endif /* _CANON_H */
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* End of file: canon.h
|
||||
*
|
||||
****************************************************************************/
|
||||
233
camlibs/canon/crc.c
Normal file
233
camlibs/canon/crc.c
Normal file
@@ -0,0 +1,233 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "crc.h"
|
||||
|
||||
|
||||
/*
|
||||
* CRC 0102010
|
||||
*/
|
||||
static unsigned short crc_table[256] = {
|
||||
0x0, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
|
||||
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
|
||||
0x1081, 0x108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
|
||||
0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
|
||||
0x2102, 0x308b, 0x210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
|
||||
0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
|
||||
0x3183, 0x200a, 0x1291, 0x318, 0x77a7, 0x662e, 0x54b5, 0x453c,
|
||||
0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
|
||||
0x4204, 0x538d, 0x6116, 0x709f, 0x420, 0x15a9, 0x2732, 0x36bb,
|
||||
0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
|
||||
0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x528, 0x37b3, 0x263a,
|
||||
0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
|
||||
0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x630, 0x17b9,
|
||||
0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
|
||||
0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x738,
|
||||
0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
|
||||
0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
|
||||
0x840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
|
||||
0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
|
||||
0x18c1, 0x948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
|
||||
0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
|
||||
0x2942, 0x38cb, 0xa50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
|
||||
0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
|
||||
0x39c3, 0x284a, 0x1ad1, 0xb58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
|
||||
0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
|
||||
0x4a44, 0x5bcd, 0x6956, 0x78df, 0xc60, 0x1de9, 0x2f72, 0x3efb,
|
||||
0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
|
||||
0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0xd68, 0x3ff3, 0x2e7a,
|
||||
0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
|
||||
0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0xe70, 0x1ff9,
|
||||
0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
|
||||
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0xf78,
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Initial CRC values. Determined by looking at CRCs sent by the camera.
|
||||
*/
|
||||
|
||||
static int crc_init[1024] = {
|
||||
-1, -1, -1, -1, -1, 0x83a4, 0x5b70, 0x724e,
|
||||
0x0ee6, 0x5969, 0x7b6c, 0x647f, 0x8e90, 0x07ad, 0x5af0, 0xfa5f,
|
||||
0x77aa, 0xc2b3, 0x5003, 0x59f5, 0xe76c, 0xad67, 0xe2af, 0x4632,
|
||||
0xd983, 0xb9a8, 0x8cfb, 0x7c8f, 0xbf08, 0x1c9d, 0xb35b, 0x2f51,
|
||||
0xec49, 0xd0dc, 0xae31, 0xac9c, 0x11be, 0xf886, 0xbe88, 0x948c,
|
||||
0xca17, 0xb48b, 0xc726, 0xed56, 0xc7cd, 0x0656, 0xa9e1, 0x44eb,
|
||||
0x10a1, 0xef97, 0x16ef, 0x91f1, 0x9f42, 0x5cac, 0x9639, 0x6f35,
|
||||
0x9c2b, 0x2d9f, 0x326b, 0x3f84, 0xb859, 0x75ea, 0x9291, 0xe771,
|
||||
0xb067, 0x0b62, 0xf53c, 0x6c55, 0xe418, 0xc154, 0xaf30, 0xa58d,
|
||||
0x4827, 0xbc6d, 0x61ae, 0x77c5, 0xadb3, 0x36af, 0xdbc0, 0xea8a,
|
||||
0x23ba, 0x6785, 0x6ca3, 0x1218, 0x46b5, 0x5e83, 0xa91b, 0xbeeb,
|
||||
0xf78c, 0xcc77, 0xe4ed, 0x3454, 0x30e2, 0xa6a6, 0x7b14, 0x1c7f,
|
||||
0x515b, 0x09e4, 0x631e, 0xd7e7, 0xad46, 0xc3af, 0x4412, 0xe9a1,
|
||||
0x1089, 0xc797, 0x5c56, 0x6c39, 0x8818, 0xbfcb, 0xdf9d, 0x97ce,
|
||||
0x9024, 0x4253, 0x98c7, 0xe1db, 0x2a01, 0x941c, 0x5a17, 0x1d5f,
|
||||
0x794a, 0x525d, 0x17d7, 0xa1e0, 0x0563, 0x84d2, 0x1507, 0x61c2,
|
||||
0x1bc5, 0xd32c, 0x4602, 0xe983, 0x3289, 0xdd84, 0x9eec, 0xfabd,
|
||||
0x95aa, 0xe406, 0xdf54, 0x5ece, 0xe41b, 0xc254, 0xb703, 0x5715,
|
||||
0x7782, 0xeab3, 0x1aba, 0xa43d, 0xf036, 0x4e00, 0xab0b, 0xbec9,
|
||||
0xd58c, 0xd664, 0x2657, 0xa2d0, 0x2d50, 0xfd6b, 0x7bdd, 0xd57f,
|
||||
0x2564, 0x89e3, 0x4cda, 0x6129, 0xf0c5, 0xbd00, 0x04bf, 0x50c3,
|
||||
0x99f5, 0xdbca, 0xe08a, 0x7310, 0x58f7, 0xed7d, 0xeccd, 0x54dc,
|
||||
0xa6b1, 0x6c14, 0xa518, 0xdd27, 0x3dec, 0xc07b, 0x8821, 0x86cb,
|
||||
0x1c25, 0x0b5b, 0xcc3c, 0xafed, 0x788d, 0x9d4c, 0x428e, 0x45c7,
|
||||
0x34b0, 0xd4e2, 0xb075, 0x1962, 0x640e, 0xff90, 0x90ff, 0x9953,
|
||||
0x7dca, 0xf219, 0x7122, 0x7ad5, 0xd56e, 0x3464, 0x00e2, 0x2d87,
|
||||
0x2a6b, 0xfe1c, 0x14ee, 0x80d3, 0x3443, 0x27e2, 0x1fc1, 0xf768,
|
||||
0x2877, 0xf23e, 0x5622, 0x4893, 0x086d, 0xe20f, 0xe632, 0xfb76,
|
||||
0x56bb, 0xd193, 0xe920, 0x9189, 0xe742, 0x8367, 0x9870, 0x56db,
|
||||
0xb193, 0xf773, 0x3377, 0x2b95, 0x080d, 0x820f, 0xf861, 0x5988,
|
||||
0x9a6c, 0x5af9, 0xf35f, 0x3f33, 0x0f59, 0xee78, 0xf1fe, 0x8e11,
|
||||
0x86ad, 0x7a25, 0x256e, 0x83e3, 0x1c70, 0x5e5b, 0x711b, 0x43d5,
|
||||
0x16d6, 0xa8f1, 0x5cfa, 0xc039, 0xca21, 0x828b, 0x7c61, 0x5108,
|
||||
0x5ae4, 0xee5f, 0xd6fe, 0xbc57, 0x5bae, 0xac4e, 0xc3be, 0x5512,
|
||||
0x60a0, 0x71d4, 0x8cd5, 0x528f, 0xc5d7, 0x0c74, 0xdb4b, 0x618a,
|
||||
0x53c5, 0x87c6, 0x1934, 0x320e, 0x5a84, 0x8e5f, 0xc8ad, 0x1ea9,
|
||||
0x9779, 0x2724, 0xd9c1, 0xfba8, 0x88bb, 0x1ccb, 0xe55b, 0x8a45,
|
||||
0xf2e9, 0x8122, 0xcd52, 0xc9fc, 0x47b8, 0x5b92, 0x904e, 0x2853,
|
||||
0xd63e, 0x7c57, 0x6708, 0xe1a3, 0x5201, 0x4bd7, 0x545e, 0x24b1,
|
||||
0x54f2, 0x88b1, 0x16cb, 0xb5f1, 0xb537, 0x7337, 0x7ff7, 0xdf3b,
|
||||
0x31ce, 0x82b7, 0x4061, 0xbae5, 0xd9c8, 0xf2a8, 0xc022, 0xd121,
|
||||
0x5b20, 0x224e, 0x9b94, 0xaae8, 0x55d8, 0xaaa0, 0x1dd8, 0xfe4a,
|
||||
0x42ee, 0x25c7, 0x2ae3, 0x761c, 0x7ca2, 0x9208, 0x7e71, 0x512a,
|
||||
0x78e4, 0xf44c, 0x1444, 0x2ad3, 0x461c, 0xf783, 0xc377, 0x9c12,
|
||||
0x149f, 0xf1d3, 0xa311, 0xe441, 0x9854, 0x72db, 0x9be6, 0xd8e8,
|
||||
0xdab9, 0x9b9b, 0xa5e8, 0x2d27, 0x8a6b, 0xdce9, 0xfbfd, 0xddbb,
|
||||
0xa1ec, 0x0963, 0xe41e, 0xc754, 0x9f56, 0x48ac, 0x376d, 0x11d1,
|
||||
0x9786, 0xd824, 0x16b9, 0xc7f1, 0x3a56, 0x420c, 0xc7c7, 0x0c56,
|
||||
0xf94b, 0x7b99, 0x917f, 0x1142, 0x0486, 0x69c3, 0x5a4d, 0x475f,
|
||||
0xbc92, 0x9eae, 0xb8bd, 0x91ea, 0x8442, 0x8507, 0xc816, 0xa5a9,
|
||||
0x6c27, 0x9618, 0x4e35, 0x9e0b, 0x1dbd, 0x9b4a, 0x74e8, 0x9880,
|
||||
0xa6db, 0x0614, 0xebe1, 0x40ab, 0x70e5, 0xb5c4, 0x8037, 0xd043,
|
||||
0x3131, 0x7db7, 0x8f19, 0x86bc, 0x6b25, 0xac6f, 0xe2be, 0x5732,
|
||||
0x5082, 0xd8f5, 0xc7b9, 0x7256, 0x16e6, 0x98f1, 0xd7db, 0x9146,
|
||||
0x2842, 0xc73e, 0xf556, 0x0655, 0xaae1, 0x5cd8, 0xe239, 0xd032,
|
||||
0x4031, 0xeae5, 0x4cba, 0x0129, 0xee96, 0x1ffe, 0xc868, 0xdba9,
|
||||
0x838a, 0x7570, 0x0891, 0x1e0f, 0x3179, 0x35b7, 0xdbf3, 0xd98a,
|
||||
0xb0a8, 0xc462, 0xb165, 0x0173, 0xb496, 0xda26, 0x049b, 0x74c3,
|
||||
0xb380, 0xf451, 0x0944, 0xc31e, 0xf512, 0x4255, 0x9ec7, 0xd1bd,
|
||||
0xc720, 0xeb56, 0xf7ab, 0xeb77, 0xd6ab, 0xe957, 0xe689, 0x4076,
|
||||
0xade5, 0x60af, 0x7ed4, 0xf42a, 0x7244, 0x04e6, 0x09c3, 0x441e,
|
||||
0xe5a1, 0x7045, 0x15c4, 0xa2c2, 0x3f50, 0x6c59, 0xe818, 0xa198,
|
||||
0x7d63, 0x5b19, 0x1b4e, 0x582c, 0x367d, 0x09c0, 0x471e, 0xfd92,
|
||||
0x82dd, 0x2a61, 0xf41c, 0x4444, 0xbfa1, 0xb59d, 0xd937, 0x0da8,
|
||||
0x0f5a, 0xed78, 0xe9cd, 0x7c89, 0xb908, 0x2cfb, 0x5e7a, 0x501b,
|
||||
0x41f5, 0x26f4, 0x01d0, 0x1796, 0xe0e0, 0x1910, 0x160e, 0x70f1,
|
||||
0xa1c4, 0x2163, 0xaea7, 0x3a9c, 0x880c, 0xabcb, 0x7ec9, 0xe92a,
|
||||
0x9b89, 0xb7e8, 0xbc15, 0x19ae, 0xa80e, 0xa3fa, 0x0f41, 0xf678,
|
||||
0x3066, 0x22a6, 0x7394, 0xdcf7, 0xe5fd, 0x2c45, 0xe07a, 0x8310,
|
||||
0xef70, 0xf1ef, 0x9f11, 0x0fac, 0x1b78, 0x6e2c, 0x8d3a, 0xb59e,
|
||||
0xda37, 0x159b, 0xfdc2, 0xd2dd, 0xbf13, 0x079d, 0x6af0, 0x717e,
|
||||
0x26d5, 0x20d0, 0x15b6, 0xd0c2, 0xb031, 0x5d62, 0x5028, 0x72f5,
|
||||
0xb5e6, 0xa237, 0xca50, 0xf38b, 0xeb33, 0x92ab, 0xdd71, 0x6bec,
|
||||
0x656f, 0x9681, 0xd735, 0x7f46, 0x6e3b, 0x9a3a, 0x0cf9, 0x564b,
|
||||
0x2193, 0x5ea7, 0x8d1b, 0x949e, 0xd817, 0x25b9, 0x54e3, 0x99b1,
|
||||
0x9fca, 0xd4ac, 0xfe75, 0x7dee, 0xd619, 0x5b57, 0x554e, 0x3ca0,
|
||||
0x846a, 0xad07, 0x82af, 0x5861, 0x7b7d, 0x757f, 0x0791, 0x66f0,
|
||||
0x11b2, 0xf486, 0xde44, 0x46df, 0x3483, 0xe7e2, 0x2367, 0xba85,
|
||||
0xb9c8, 0xecfb, 0x62dc, 0x1df6, 0xd04a, 0x3831, 0x352e, 0x42f3,
|
||||
0x38c7, 0xc32e, 0xc512, 0xc974, 0xcfb8, 0x33de, 0x8295, 0x6261,
|
||||
0xa0f6, 0x1b72, 0x642c, 0xdd90, 0x8aec, 0x5be9, 0xeb4e, 0xefab,
|
||||
0x2aef, 0x7a1c, 0x1c6e, 0x405b, 0x80e5, 0x0243, 0x9ca5, 0xa39f,
|
||||
0x6a41, 0xc07e, 0x8d21, 0xae9e, 0x039c, 0x4bb4, 0x375e, 0x22d1,
|
||||
0x0494, 0x7bc3, 0xcb7f, 0xd49a, 0xc875, 0xc6a9, 0x6a47, 0xc67e,
|
||||
0xbd47, 0x43bf, 0x7cd6, 0xe608, 0xc176, 0x8d30, 0xbf9e, 0x8a9d,
|
||||
0x2ae9, 0x7c1c, 0x2c08, 0xad7a, 0xffaf, 0xafff, 0x6a8d, 0x0c7e,
|
||||
0xd14b, 0x3120, 0x6cb7, 0x0618, 0xe7e1, 0x2067, 0xa2b6, 0x4b50,
|
||||
0xd35e, 0x3402, 0x66e2, 0x03b2, 0x65b4, 0x4d81, 0x3238, 0x6c84,
|
||||
0x3518, 0x74f3, 0x8380, 0x7f70, 0x583b, 0x217d, 0xb0a7, 0xcb62,
|
||||
0xc99a, 0x21b8, 0x75a7, 0xdf91, 0x9bce, 0xf0e8, 0x9000, 0x6653,
|
||||
0xb2b2, 0xce40, 0xc3cf, 0x2412, 0xf7f2, 0xb277, 0x0b40, 0xd73c,
|
||||
0x7646, 0x26a2, 0x57d0, 0xb282, 0xfe40, 0x48ee, 0x756d, 0x1591,
|
||||
0xf7c2, 0x8277, 0x8061, 0x8643, 0x9425, 0x6317, 0xdee7, 0xe5df,
|
||||
0x0e45, 0xfa69, 0x41aa, 0x79f4, 0xec5d, 0xc4dc, 0x0f65, 0xd278,
|
||||
0x1a13, 0x0d3d, 0x9a5a, 0x6cf9, 0x4818, 0x836d, 0x9270, 0x0671,
|
||||
0x8ee1, 0x76ad, 0xcda2, 0x39fc, 0xf03f, 0x4700, 0xe392, 0x7323,
|
||||
0x6bf7, 0x7e6f, 0x4f2a, 0x891a, 0xb5da, 0x9e37, 0x21bd, 0x70a7,
|
||||
0xf7c4, 0x8477, 0xb007, 0x6b62, 0xeb6f, 0xceab, 0x28cf, 0x4a3e,
|
||||
0xb54f, 0x0b37, 0xa03c, 0xd172, 0x0820, 0xaf0f, 0x9a8d, 0xbbf9,
|
||||
0xcdd9, 0x42fc, 0x37c7, 0xbbd1, 0xe5d9, 0x0845, 0xca0f, 0xac8b,
|
||||
0x06be, 0x41e1, 0x32f4, 0xa084, 0x6972, 0xeb4d, 0xecab, 0x32dc,
|
||||
0x8884, 0x23cb, 0x1685, 0xfbf1, 0xd1bb, 0xc120, 0xdb30, 0x1a8a,
|
||||
0x943d, 0x7b17, 0x1f7f, 0x4968, 0xfb7c, 0x5cbb, 0x8139, 0xd652,
|
||||
0x1057, 0x1997, 0x910e, 0x6042, 0x93d4, 0xaa60, 0xddd8, 0xc2ec,
|
||||
0x0f03, 0xb478, 0x3426, 0x42e2, 0x29c7, 0x4a2f, 0xa44f, 0x8236,
|
||||
0xc161, 0x9a30, 0x06f9, 0x06e1, 0x1ee1, 0xdf79, 0x73ce, 0x86f7,
|
||||
0x2025, 0xe0b6, 0x4f10, 0xb31a, 0x6e51, 0xf03a, 0x4200, 0xcbc7,
|
||||
0x6c9a, 0x2b18, 0x850d, 0xc216, 0xf503, 0x5355, 0x17c6, 0xb0e0,
|
||||
0x8c62, 0xe58f, 0x5e45, 0x6f1b, 0xb22b, 0x5740, 0x2282, 0x5794,
|
||||
0xf682, 0xca66, 0xc58b, 0x5074, 0x2ef5, 0x4058, 0x83e5, 0x1a70,
|
||||
0x6e3d, 0x9c3a, 0x3c9f, 0xbb6a, 0x5ed9, 0xf31b, 0x7b33, 0x3b7f,
|
||||
0x631d, 0xd4e7, 0xb575, 0x3137, 0x7bb7, 0xbf7f, 0x6b9d, 0x146f,
|
||||
0x01d3, 0x1496, 0xf8d3, 0xeb88, 0x29ab, 0x262f, 0xdad0, 0xf29b,
|
||||
0xf322, 0x4233, 0xf8c7, 0xff88, 0x88ff, 0x58cb, 0xd17d, 0x0720,
|
||||
0xd7f0, 0xba46, 0x7ac8, 0xc86e, 0xdda9, 0xb3ec, 0x9851, 0x77db,
|
||||
0xb3b3, 0xc751, 0x9a56, 0x60f9, 0x28d4, 0x513e, 0x6ce4, 0x5518,
|
||||
0x6aa0, 0x217e, 0xb3a7, 0xd351, 0x3b02, 0x1e1d, 0x2379, 0xa485,
|
||||
0x4836, 0xad6d, 0xe8af, 0x1698, 0xe6f1, 0x3876, 0x722e, 0x6ee6,
|
||||
0x473a, 0xd992, 0xa8a8, 0x05fa, 0x1dd2, 0xf44a, 0x1244, 0x1ab5,
|
||||
0xab3d, 0x88c9, 0x6ecb, 0x6a3a, 0xbb7e, 0x4ad9, 0x524f, 0x05d7,
|
||||
0x30d2, 0x96a6, 0xf035, 0x4d00, 0xb338, 0x4c51, 0xea29, 0x80ba,
|
||||
0x5d43, 0x7128, 0x70d5, 0x85c4, 0x0b16, 0x813c, 0xd352, 0x3802,
|
||||
0x062e, 0xd1e1, 0x9b20, 0x1ee8, 0xd679, 0x3b57, 0x4b1d, 0x9e5e,
|
||||
0x48bd, 0x266d, 0x98d0, 0xf6db, 0x9366, 0x1860, 0x6e1f, 0xbe3a,
|
||||
0x268c, 0x79d0, 0xc85d, 0xeea9, 0x20fe, 0x3bb6, 0xaa1d, 0xa0d8,
|
||||
0x3572, 0x1ef3, 0xcd79, 0xe2fc, 0x1532, 0x54c2, 0xb8b1, 0x9dea,
|
||||
0xe48e, 0x5754, 0x3682, 0xf6c0, 0x8866, 0xc1cb, 0x3030, 0x74a6,
|
||||
0xd680, 0xc257, 0xb403, 0x4f26, 0x851a, -1, -1, -1
|
||||
};
|
||||
|
||||
|
||||
static unsigned short chksum(unsigned short init,unsigned n,
|
||||
const unsigned char *s)
|
||||
{
|
||||
unsigned short crc;
|
||||
|
||||
for (crc = init; n > 0; n--)
|
||||
crc = crc_table[(crc ^ *s++) & 0xff] ^ (crc >> 8);
|
||||
return crc;
|
||||
}
|
||||
|
||||
|
||||
static int find_init(int len)
|
||||
{
|
||||
return len < 1024 ? crc_init[len] : -1;
|
||||
}
|
||||
|
||||
|
||||
unsigned short canon_psa50_gen_crc(const unsigned char *pkt,int len)
|
||||
{
|
||||
int init;
|
||||
|
||||
init = find_init(len);
|
||||
if (init != -1) return chksum(init,len,pkt);
|
||||
fprintf(stderr,"FATAL ERROR: initial CRC value for length %d "
|
||||
"unknown\n",len);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
static int guess(const unsigned char *m,int len,int crc)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 0x10000; i++)
|
||||
if (chksum(i,len,m) == crc) return i;
|
||||
fprintf(stderr,"unable to guess initial CRC value\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
int canon_psa50_chk_crc(const unsigned char *pkt,int len,unsigned short crc)
|
||||
{
|
||||
unsigned short this;
|
||||
int init;
|
||||
|
||||
init = find_init(len);
|
||||
if (init != -1) return chksum(init,len,pkt) == crc;
|
||||
this = guess(pkt,len,crc);
|
||||
fprintf(stderr,"warning: CRC not checked (add len %d, value 0x%04x) #########################\n",
|
||||
len,this);
|
||||
return 1;
|
||||
}
|
||||
7
camlibs/canon/crc.h
Normal file
7
camlibs/canon/crc.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef CRC_H
|
||||
#define CRC_H
|
||||
|
||||
unsigned short canon_psa50_gen_crc(const unsigned char *pkt,int len);
|
||||
int canon_psa50_chk_crc(const unsigned char *pkt,int len,unsigned short crc);
|
||||
|
||||
#endif
|
||||
33
camlibs/canon/mkpatch
Normal file
33
camlibs/canon/mkpatch
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
cd ../..
|
||||
ref=${1:-gphoto.ref}
|
||||
work=${2:-gphoto.work}
|
||||
[ -d $ref ] || { echo $ref/ is missing; exit; }
|
||||
[ -d $work ] || { echo $work/ is missing; exit; }
|
||||
for n in `awk '$1 !~ /^#/ {print$1}' <<EOF
|
||||
#--- gphoto -------------------------------------------------------------------
|
||||
Makefile.am
|
||||
configure.in
|
||||
#--- gphoto/canon -------------------------------------------------------------
|
||||
canon/README
|
||||
canon/Protocol
|
||||
canon/Makefile.am
|
||||
canon/canon.c
|
||||
canon/canon.h
|
||||
canon/psa50.c
|
||||
canon/psa50.h
|
||||
canon/crc.c
|
||||
canon/crc.h
|
||||
canon/serial.c
|
||||
canon/serial.h
|
||||
canon/util.c
|
||||
canon/util.h
|
||||
canon/mkpatch
|
||||
#--- gphoto/src ---------------------------------------------------------------
|
||||
src/Makefile.am
|
||||
src/cameras.h
|
||||
`; do
|
||||
s=$ref/$n
|
||||
if [ ! -f $s ]; then s=/dev/null; fi
|
||||
diff -u $s $work/$n
|
||||
done
|
||||
339
camlibs/canon/ps350/COPYING
Normal file
339
camlibs/canon/ps350/COPYING
Normal file
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
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.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
20
camlibs/canon/ps350/README
Normal file
20
camlibs/canon/ps350/README
Normal file
@@ -0,0 +1,20 @@
|
||||
Contents:
|
||||
|
||||
ps350proto.txt Description of the PS 350 protocol
|
||||
|
||||
pd350chk.c C program to calculate checksum of PS 350 packets
|
||||
|
||||
notes.txt Some other notes
|
||||
|
||||
ps350init Script to initialize the PS350 and get it to 115200 at
|
||||
once. Needs system-dependent modifications!
|
||||
camera* Files used by ps350init
|
||||
SerialIn Sample camera-returned data, created in /tmp by ps350init
|
||||
|
||||
renamejpg.c C program that automatically renames PS350 AUT/THM
|
||||
files (given as arguments) to a `recording-time' format
|
||||
that is much easier to interpret than the original
|
||||
name, like
|
||||
AUT_0365.JPG => aut_19990626-124040.jpg
|
||||
If the destination name already exists, names with
|
||||
appended `-2', `-3' etc. are tried.
|
||||
BIN
camlibs/canon/ps350/SerialIn
Normal file
BIN
camlibs/canon/ps350/SerialIn
Normal file
Binary file not shown.
BIN
camlibs/canon/ps350/compu1
Normal file
BIN
camlibs/canon/ps350/compu1
Normal file
Binary file not shown.
BIN
camlibs/canon/ps350/compu3
Normal file
BIN
camlibs/canon/ps350/compu3
Normal file
Binary file not shown.
BIN
camlibs/canon/ps350/compu3c
Normal file
BIN
camlibs/canon/ps350/compu3c
Normal file
Binary file not shown.
1
camlibs/canon/ps350/compu3d
Normal file
1
camlibs/canon/ps350/compu3d
Normal file
@@ -0,0 +1 @@
|
||||
B
|
||||
1
camlibs/canon/ps350/compu3e-4
Normal file
1
camlibs/canon/ps350/compu3e-4
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
1
camlibs/canon/ps350/compu3f
Normal file
1
camlibs/canon/ps350/compu3f
Normal file
@@ -0,0 +1 @@
|
||||
S
|
||||
BIN
camlibs/canon/ps350/compu5
Normal file
BIN
camlibs/canon/ps350/compu5
Normal file
Binary file not shown.
BIN
camlibs/canon/ps350/compu6
Normal file
BIN
camlibs/canon/ps350/compu6
Normal file
Binary file not shown.
13
camlibs/canon/ps350/notes.txt
Normal file
13
camlibs/canon/ps350/notes.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
Some notes about a driver for the PS 350/A5/...
|
||||
|
||||
|
||||
- When I use the M$Win driver on my 486DX50 laptop, it gets to 115200 but
|
||||
then has much problems getting even one thumbnail. It would be nice to
|
||||
be able to force the speed to lower bitrates. Or: default 115200 unless
|
||||
otherwise indicated (trying all possible speeds as the M$Win driver does
|
||||
is quite useless IMO).
|
||||
|
||||
- I don't know if gphoto already does this, but I'd like a program that
|
||||
just copies all images off the camera without user intervention. Maybe
|
||||
a few simple commandline options, no GUI.
|
||||
157
camlibs/canon/ps350/ps350chk.c
Normal file
157
camlibs/canon/ps350/ps350chk.c
Normal file
@@ -0,0 +1,157 @@
|
||||
/* Canon PowerShot 350 Checksum Calculation
|
||||
|
||||
Copyright (C) 1999 J.A. Bezemer
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
/* This is really simple. It only took quite some time to figure out
|
||||
its simplicity ;-)
|
||||
|
||||
The `electronic' structure is this:
|
||||
|
||||
In
|
||||
--->X<----------------------------------------------------------------.
|
||||
| |
|
||||
+--------------------+---------------------------. |
|
||||
| | | |
|
||||
| v v |
|
||||
`->T-->T-->T-->T-->T-X>T-->T-->T-->T-->T-->T-->T-X>T-->T-->T-->T--'
|
||||
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
|
||||
|
||||
The three X's are XOR gates; T's are 1-bit memory elements and the rest
|
||||
are wires with arrows indicating the direction of the logic signals.
|
||||
Bits are fed into the input (`In') LSBit first. When all bytes are
|
||||
fed in, the T's hold the checksum (bit numbers 15 through 0 as
|
||||
indicated). Only the 296 `real data' bytes are fed in (thus excluding
|
||||
the 0xC0 header) and initialization is 0x0000.
|
||||
|
||||
In other words: this is just a standard CRC-CCITT algorithm. But I
|
||||
only saw that when I drew the schematic. There are quite a few
|
||||
programs available that calculate this CRC, but I didn't understand
|
||||
most of them, so I wrote my own version for some experiments. (And most
|
||||
implementations that I've seen didn't have a clear copyright...)
|
||||
|
||||
I implemented the 16-stage shift register in a `long' variable
|
||||
that is shifted and XOR'd when necessary.
|
||||
|
||||
Note that this is only a sample implementation that is probably very
|
||||
slow. However, it should be fast enough to use it with 300-byte
|
||||
packets at 115200 baud.
|
||||
|
||||
This program uses hard-coded data for easy experimentation. Two sample
|
||||
packets are provided. Of course, this must be made into a proper
|
||||
function to be usable.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void
|
||||
main (void)
|
||||
{
|
||||
long datalen = 296; /* number of data bytes. Always 296. */
|
||||
|
||||
char data[] =
|
||||
{0x05, 0x03, 0x04, 0x00, 0x01,
|
||||
/* this is a EOT packet, count=5. The checksum is "87 3F" (LSByte-first!) */
|
||||
|
||||
/* a few 0's to fill up the packet (far too much 0's actually, but that's
|
||||
no problem) */
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
|
||||
/* from a serial snoop: jut some arbitrary packet from a JPG download. */
|
||||
/* rename this to `data' and the original `data' to `data1' to try it. */
|
||||
char data1[] =
|
||||
{
|
||||
/* 0x3f1e *//* 0xC0, */ 0x05,
|
||||
/* 0x3f20 */ 0x10, 0x24, 0x81, 0x4d, 0xf6, 0xa7, 0x52, 0xbd,
|
||||
/* 0x3f28 */ 0x83, 0xec, 0xe9, 0x88, 0xbc, 0xcc, 0x0f, 0x90,
|
||||
/* 0x3f30 */ 0xf4, 0x99, 0x97, 0xb0, 0xf6, 0xae, 0xa3, 0x9b,
|
||||
/* 0x3f38 */ 0x99, 0x98, 0xb6, 0xf7, 0xfb, 0x55, 0x8b, 0xbe,
|
||||
/* 0x3f40 */ 0x23, 0x68, 0xf3, 0xc7, 0xad, 0x72, 0xe6, 0xf2,
|
||||
/* 0x3f48 */ 0x1b, 0x88, 0xdf, 0x9c, 0x1e, 0xb4, 0xa3, 0x1d,
|
||||
/* 0x3f50 */ 0x59, 0xac, 0xe5, 0xa9, 0xdd, 0xe8, 0x97, 0x65,
|
||||
/* 0x3f58 */ 0x63, 0xd9, 0xe6, 0x7c, 0xb8, 0xad, 0x2b, 0x8b,
|
||||
/* 0x3f60 */ 0xce, 0x3f, 0xa5, 0x73, 0x3d, 0xcd, 0x8c, 0xc9,
|
||||
/* 0x3f68 */ 0x65, 0xbb, 0xfb, 0x3f, 0x99, 0x1d, 0xc4, 0xa0,
|
||||
/* 0x3f70 */ 0x15, 0x3c, 0x29, 0xf4, 0xc7, 0xbf, 0xbd, 0x32,
|
||||
/* 0x3f78 */ 0xfa, 0xd6, 0xf6, 0xde, 0x29, 0x0f, 0xf6, 0x9d,
|
||||
/* 0x3f80 */ 0xe4, 0xbf, 0x7b, 0xfd, 0x58, 0x27, 0xa2, 0xb3,
|
||||
/* 0x3f88 */ 0x7f, 0x7b, 0xfd, 0x9f, 0xd6, 0xb7, 0x80, 0x4a,
|
||||
/* 0x3f90 */ 0x71, 0xb6, 0xa8, 0xdd, 0xd1, 0xe0, 0x31, 0xe8,
|
||||
/* 0x3f98 */ 0x0c, 0xc3, 0xed, 0xb7, 0x33, 0xc2, 0x0b, 0x71,
|
||||
/* 0x3fa0 */ 0xbb, 0xe6, 0xff, 0x00, 0x67, 0x83, 0xd6, 0x9d,
|
||||
/* 0x3fa8 */ 0xb0, 0xde, 0x68, 0xcf, 0x25, 0xd5, 0xbd, 0xf5,
|
||||
/* 0x3fb0 */ 0x85, 0xc4, 0xaa, 0x53, 0x6c, 0x9b, 0xb3, 0x1f,
|
||||
/* 0x3fb8 */ 0xd7, 0x35, 0xc9, 0x3d, 0x64, 0xf5, 0x34, 0x53,
|
||||
/* 0x3fc0 */ 0x56, 0x5a, 0x1c, 0xb4, 0x30, 0x6a, 0x37, 0x1c,
|
||||
/* 0x3fc8 */ 0x0d, 0x52, 0xfa, 0x3c, 0x7f, 0x7f, 0x23, 0xbb,
|
||||
/* 0x3fd0 */ 0x8f, 0xef, 0x7f, 0xb2, 0x7f, 0xef, 0xaa, 0x82,
|
||||
/* 0x3fd8 */ 0xe1, 0x6f, 0xfc, 0xdb, 0x88, 0x5f, 0x52, 0xbb,
|
||||
/* 0x3fe0 */ 0xf9, 0x37, 0x7c, 0xcc, 0x4e, 0x1b, 0x0e, 0x57,
|
||||
/* 0x3fe8 */ 0xfb, 0xde, 0xd5, 0xe8, 0x9c, 0x7e, 0xd2, 0x1d,
|
||||
/* 0x3ff0 */ 0x8e, 0x46, 0x6b, 0xc9, 0x3e, 0x62, 0x64, 0xce,
|
||||
/* 0x3ff8 */ 0x17, 0xb9, 0xed, 0x5c, 0xaa, 0xdc, 0xb8, 0x47,
|
||||
/* 0x4000 */ 0x22, 0xba, 0x60, 0x8c, 0x31, 0x0e, 0xcc, 0xf4,
|
||||
/* 0x4008 */ 0x5d, 0x2e, 0xf0, 0x06, 0x45, 0xdd, 0xc7, 0x7a,
|
||||
/* 0x4010 */ 0xda, 0xbb, 0xbb, 0xc4, 0x13, 0x30, 0x2c, 0xc5,
|
||||
/* 0x4018 */ 0x57, 0x27, 0x00, 0xf1, 0x9e, 0x95, 0xc1, 0x34,
|
||||
/* 0x4020 */ 0x74, 0xa6, 0x32, 0xea, 0xfa, 0xca, 0x4d, 0x21,
|
||||
/* 0x4028 */ 0x55, 0x65, 0x5f, 0x33, 0x04, 0x00, 0x47, 0x5e,
|
||||
/* 0x4030 */ 0x63, 0xcf, 0x24, 0x7b, 0x51, 0xa8, 0x6b, 0x16,
|
||||
/* 0x4038 */ 0xf7, 0x31, 0x4b, 0x1d, 0xad, 0xc2, 0x33, 0x37,
|
||||
/* 0x4040 */ 0x98, 0xa7, 0x2c, 0x07, 0x58, 0x9c, 0x77, 0x6e,
|
||||
/* 0x4048 */ 0xc7, 0xc1};
|
||||
/* note: last 3 bytes are chksum and trailer */
|
||||
|
||||
char bits[] =
|
||||
{1, 2, 4, 8, 16, 32, 64, 128};
|
||||
long chksum = 0;
|
||||
long i, j;
|
||||
int inputbit, lastbit, xorbit;
|
||||
|
||||
/* calculate checksum */
|
||||
for (i = 0; i < datalen; i++)
|
||||
for (j = 0; j <= 7; j++)
|
||||
{
|
||||
lastbit = chksum & 0x0001; /* remember if last bit was 1 */
|
||||
chksum >>= 1; /* shift 1 place */
|
||||
inputbit = data[i] & bits[j] ? 1 : 0; /* the In bit */
|
||||
xorbit = inputbit ^ lastbit; /* output of upper XOR gate */
|
||||
if (xorbit) /* XOR if needed */
|
||||
chksum ^= 0x8408;
|
||||
}
|
||||
|
||||
/* display checksum */
|
||||
printf ("Checksum: 0x%lX\n", chksum);
|
||||
}
|
||||
50
camlibs/canon/ps350/ps350init
Executable file
50
camlibs/canon/ps350/ps350init
Executable file
@@ -0,0 +1,50 @@
|
||||
#! /bin/sh
|
||||
|
||||
# The tty to use
|
||||
tty=/dev/ttyS1
|
||||
|
||||
# Make the tty completely `raw' -- even more than `stty raw' does.
|
||||
# Works For Me [tm] on a Debian 2.1 system (kernel 2.0.36)
|
||||
stty sane < "$tty"
|
||||
stty -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok echonl -echoctl -echoke < "$tty"
|
||||
stty intr undef quit undef erase undef kill undef eof undef eol undef eol2 undef start undef stop undef susp undef rprnt undef werase undef lnext undef flush undef < "$tty"
|
||||
|
||||
stty 9600 < "$tty"
|
||||
|
||||
# Capture incoming signals to a file
|
||||
cat < "$tty" > /tmp/SerialIn &
|
||||
catpid=$!
|
||||
|
||||
cat compu1 > "$tty"
|
||||
sleep 1s
|
||||
# This lets camera answer
|
||||
|
||||
cat compu3 > "$tty"
|
||||
sleep 1s
|
||||
|
||||
# Imitate a serial break
|
||||
stty 50 < "$tty"
|
||||
cat compu3c > "$tty"
|
||||
sleep 1s
|
||||
|
||||
stty 9600 < "$tty"
|
||||
|
||||
cat compu3d > "$tty"
|
||||
sleep 1s
|
||||
cat compu3e-4 > "$tty"
|
||||
sleep 1s
|
||||
|
||||
stty 115200 < "$tty"
|
||||
|
||||
cat compu3c > "$tty"
|
||||
sleep 1s
|
||||
cat compu3f > "$tty"
|
||||
sleep 1s
|
||||
|
||||
cat compu5 > "$tty"
|
||||
sleep 1s
|
||||
|
||||
cat compu6 > "$tty"
|
||||
sleep 2s
|
||||
|
||||
kill $catpid
|
||||
740
camlibs/canon/ps350/ps350proto.txt
Normal file
740
camlibs/canon/ps350/ps350proto.txt
Normal file
@@ -0,0 +1,740 @@
|
||||
|
||||
Canon Powershot 350 / A5 Protocol Notes
|
||||
|
||||
J.A. Bezemer
|
||||
5 July 1999
|
||||
|
||||
|
||||
|
||||
GENERAL
|
||||
=======
|
||||
|
||||
This document tries to describe the protocol that is observed in the
|
||||
serial communication between the Canon Powershot 350 and A5 (Zoom) cameras
|
||||
and a computer (or any other device equipped with a serial port). Only RX,
|
||||
TX and GND pins are used, with speeds of up to 115200 baud.
|
||||
|
||||
Please read this document at least twice before complaining you don't
|
||||
understand anything at all.
|
||||
|
||||
This document is likely to contain errors. USE THIS DOCUMENT AT YOUR OWN
|
||||
RISK. NO WARRANTY WHATSOEVER.
|
||||
|
||||
This document is copyright (C) 1999 J.A. Bezemer. It may be modified/
|
||||
distributed according to the terms of the GNU General Public License. More
|
||||
details in the file COPYING, or on the GNU website (http://www.gnu.org).
|
||||
|
||||
|
||||
At this moment, this document only describes the protocol of the PS 350.
|
||||
The A5 protocol is believed to be very similar to the 350 protocol.
|
||||
Please inform me if there are notable differences in the A5 protocol.
|
||||
|
||||
|
||||
PACKETS
|
||||
=======
|
||||
|
||||
After (and also during) initialization, communication between camera and
|
||||
computer is organized in 300-byte packets. All packets start with 0xC0 and
|
||||
end with 0xC1. The last two bytes are a checksum, so one packet looks like
|
||||
this:
|
||||
|
||||
0xC0 ---296 data bytes--- ---2 byte checksum--- 0xC1
|
||||
|
||||
|
||||
The method of checksumming is a 16-bit CRC calculation. The file
|
||||
ps350chk.c contains more info and a sample implementation.
|
||||
|
||||
A packet contains a `length' field which indicates the length of the
|
||||
valid data in the packet. Non-valid extra bytes are sent as 0x00, but I
|
||||
don't know if that specific value is required.
|
||||
|
||||
|
||||
COMMUNICATION STRUCTURE
|
||||
=======================
|
||||
|
||||
The communication is organized as follows:
|
||||
|
||||
1. Computer sends command (always 1 packet)
|
||||
2. Camera sends reply (1 or more packets)
|
||||
3. Camera sends End-Of-Transmission packet
|
||||
4. Computer sends ACKnowledge packet
|
||||
|
||||
A `command-counter' is used that is incremented with each command.
|
||||
Computer and camera seem to increment the counter independently; there may
|
||||
be a possibility of getting out-of-sync (this may be corrected with a
|
||||
"ping" command, see below). It is an 8-bit value that warps from 255 to 0
|
||||
(assumption!).
|
||||
|
||||
This `count' is transmitted in every first packet of steps 1 through 4
|
||||
(i.e. not in the "extra" packets of a "long" camera-reply), except steps 1
|
||||
and 2 of a "ping" command.
|
||||
|
||||
|
||||
PACKET STRUCTURES
|
||||
=================
|
||||
|
||||
In the following, a large number of packets will be described. The 0xC0
|
||||
header byte will be omitted. In the diagrams, all numbers are in hex,
|
||||
unless otherwise stated. Multi-byte values are transmitted LSByte-first.
|
||||
|
||||
|
||||
"ping" command (sent by computer)
|
||||
--------------
|
||||
|
||||
00 10 0C 00 | 00 00 00 00 | 31 00 01 60 | 0C 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
<--------------------0C bytes---------------------->
|
||||
|
||||
`len' is length of this packet; `totlen' is total length of complete
|
||||
packet sequence. totlen != len only in multi-packet replies from camera.
|
||||
|
||||
The length starts counting from the 5th byte of the "real" data (the 0xC0
|
||||
excluded).
|
||||
|
||||
`comm' is the command number (at least, that's what I call it).
|
||||
|
||||
Note that there are a lot of 0x00 bytes, a checksum and 0xC1 trailer after
|
||||
the bytes specified above (always 300 bytes in a packet).
|
||||
|
||||
The "ping" command and reply are identical in all cases (no command count
|
||||
number).
|
||||
|
||||
This command is sent every few seconds when the system is otherwise idle.
|
||||
If there is no reply, the camera is assumed to be disconnected or turned
|
||||
off (possibly due to empty batteries).
|
||||
|
||||
|
||||
"ping" reply (sent by camera)
|
||||
------------
|
||||
|
||||
00 10 30 00 | 01 00 00 00 | 09 00 03 00 | 30 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
00 00 00 00 | 00 00 00 00 | 00 00 00 00 | 00 00 00 00
|
||||
04 00 03 00 | 00 00 00 00 | 00 00 00 00 | 00 00 00 00
|
||||
00 00 00 00
|
||||
|
||||
Normally the `comm' bytes are equal in command and reply, except here.
|
||||
|
||||
The 5th byte is 00 in computer packets and 01 in camera packets.
|
||||
|
||||
|
||||
EOT packet (sent by camera)
|
||||
----------
|
||||
|
||||
xx 03 04 00 | 01 00 00 00
|
||||
count <len->
|
||||
|
||||
|
||||
ACK packet (sent by computer)
|
||||
----------
|
||||
|
||||
xx 04 04 00 | 00 00 00 00
|
||||
count <len->
|
||||
|
||||
|
||||
"unknown1" command ("get settings"???)
|
||||
------------------
|
||||
|
||||
00 10 10 00 | 00 00 00 00 | 1E 00 01 60 | 10 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
xx 00 00 00
|
||||
count
|
||||
|
||||
The M$Win driver sends this when count=07.
|
||||
|
||||
|
||||
"unknown1" reply
|
||||
----------------
|
||||
|
||||
00 10 18 00 | 01 00 00 00 | 1E 00 02 60 | 18 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
xx 00 00 00 | 00 00 00 00 | 00 00 00 00
|
||||
count
|
||||
|
||||
After this, the usual EOT/ACK packets follow.
|
||||
|
||||
|
||||
"get disks" command
|
||||
-------------------
|
||||
|
||||
00 10 14 00 | 00 00 00 00 | 18 00 01 60 | 14 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
xx 00 00 00 | 1E 00 00 00
|
||||
count
|
||||
|
||||
The M$Win driver sends this when count=08.
|
||||
|
||||
|
||||
"get disks" reply
|
||||
-----------------
|
||||
|
||||
00 10 23 00 | 01 00 00 00 | 18 00 22 A0 | 23 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
xx 00 00 00 | 00 00 00 00 | 52 45 4D 4F | 56 41 42 4C
|
||||
count R E M O V A B L
|
||||
45 5F 31 3A | 2F 00 00
|
||||
E _ 1 : /
|
||||
|
||||
Normally, a string is 0-terminated. I think the second terminating zero
|
||||
indicates the end of a (possible) list of strings.
|
||||
|
||||
After this, the usual EOT/ACK packets follow. I won't indicate this again
|
||||
below.
|
||||
|
||||
|
||||
"use disk" command
|
||||
------------------
|
||||
|
||||
00 10 21 00 | 00 00 00 00 | 14 00 21 A0 | 21 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
xx 00 00 00 | 52 45 4D 4F | 56 41 42 4C | 45 5F 31 3A
|
||||
count R E M O V A B L E _ 1 :
|
||||
00 00 00 00 | 00
|
||||
|
||||
I don't know what those extra 00's mean.
|
||||
|
||||
The M$Win driver sends this when count=09.
|
||||
|
||||
|
||||
"use disk" reply
|
||||
----------------
|
||||
|
||||
00 10 1C 00 | 01 00 00 00 | 14 00 02 60 | 1C 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
xx 00 00 00 | 00 00 00 00 | 00 60 1E 00 | 00 xx xx 00
|
||||
count ??????
|
||||
|
||||
`?????' is different each time.
|
||||
|
||||
|
||||
"name for dir" command
|
||||
----------------------
|
||||
|
||||
00 10 xx xx | 00 00 00 00 | 02 00 21 A0 | xx xx xx xx
|
||||
<len-> comm <---totlen--->
|
||||
xx 00 00 00 | xx xx xx... ...xx 00
|
||||
count dirname (string) termination
|
||||
|
||||
E.g. "REMOVABLE_1:\DC97" has len=0x22
|
||||
|
||||
|
||||
"name for dir" reply for existing directory
|
||||
--------------------
|
||||
|
||||
00 10 18 00 | 01 00 00 00 | 02 00 02 60 | 18 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
xx 00 00 00 | 00 00 00 00 | xx xx xx xx
|
||||
count <---sector--->
|
||||
|
||||
I call the returned number `sector' because I don't know what it is ;-)
|
||||
This `sector' is used in further communications.
|
||||
|
||||
|
||||
"name for dir" reply for non-existing (maybe also empty??) directory
|
||||
--------------------
|
||||
|
||||
00 10 18 00 | 01 00 00 00 | 02 00 02 60 | 18 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
xx 00 00 00 | 02 00 00 20 | 02 00 00 20
|
||||
count |
|
||||
|
|
||||
This 0x02 may indicate that something is wrong. But I only have one
|
||||
occurrence, so I'm not sure.
|
||||
|
||||
|
||||
"forget dir" command
|
||||
--------------------
|
||||
|
||||
00 10 14 00 | 00 00 00 00 | 03 00 01 60 | 14 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
xx 00 00 00 | xx xx xx xx
|
||||
count <---sector--->
|
||||
|
||||
This command is used after a "name for dir" to check for dir existence and
|
||||
also after a full dir download.
|
||||
|
||||
sector is the number that was sent in the "name for dir" reply. In case of
|
||||
a non-existent dir, sector is here 00 00 00 00.
|
||||
|
||||
|
||||
"forget dir" reply
|
||||
------------------
|
||||
|
||||
00 10 14 00 | 01 00 00 00 | 03 00 02 60 | 14 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
xx 00 00 00 | 00 00 00 00
|
||||
count
|
||||
|
||||
|
||||
"prepare for dir download" command
|
||||
----------------------------------
|
||||
|
||||
00 10 14 00 | 00 00 00 00 | 04 00 01 60 | 14 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
xx 00 00 00 | xx xx xx xx
|
||||
count <---sector--->
|
||||
|
||||
This command is sent to indicate that a dir download will follow.
|
||||
|
||||
(I speak of "download" because I see the camera as "information server".)
|
||||
|
||||
|
||||
"prepare for dir download" reply
|
||||
--------------------------------
|
||||
|
||||
00 10 14 00 | 01 00 00 00 | 04 00 02 60 | 14 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
xx 00 00 00 | 00 00 00 00
|
||||
count
|
||||
|
||||
|
||||
"dir download" command
|
||||
----------------------
|
||||
|
||||
00 10 1C 00 | 00 00 00 00 | 2A 00 81 A0 | 1C 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
xx 00 00 00 | xx xx xx xx | E8 03 00 00 | 00 00 00 00
|
||||
count <---sector--->
|
||||
|
||||
I don't know what the E8 03 means, but it's there always.
|
||||
|
||||
|
||||
"dir download" reply
|
||||
--------------------
|
||||
This is possibly a multi-packet sequence. The first (or only) packet:
|
||||
|
||||
00 10 xx xx | 01 00 00 00 | 2A 00 42 A0 | xx xx xx xx
|
||||
num <len-> comm <---totlen--->
|
||||
xx 00 00 00 | 00 00 00 00 | xx xx xx xx | xx... ...xx
|
||||
count <#files> <----dir data-------- - -
|
||||
|
||||
All next packets (if any):
|
||||
|
||||
xx 10 xx xx | xx xx... ...xx
|
||||
num <len-> <----dir data---- - -
|
||||
|
||||
(The following applies to all "sequenced packets":)
|
||||
|
||||
num is the serial number of the packet in the sequence. The first packet
|
||||
has num=00, second 01, etc.
|
||||
|
||||
len is the number of valid data bytes in every individual packet, _always_
|
||||
starting with the fifth byte (0xC0 header excluded). totlen is the sum of
|
||||
all len's in the sequence.
|
||||
|
||||
Note that there's no need for len to be 300-8=292=0x0124. Notably
|
||||
directory entries are not split across packets, so there's always some
|
||||
empty space at the end of directory-download packets.
|
||||
|
||||
The MSBit of len is 1 in all not-last packets, and 0 only in the last
|
||||
packet. So the first packet may have a len=12 81 (LSByte first)=0x8112.
|
||||
|
||||
The EOT packet following a multi-packet sequence has non-zero values for
|
||||
bytes 5,6,7,8. I don't know what they mean. But the ACK packet is still
|
||||
`normal', so there shouldn't be a problem.
|
||||
|
||||
(This is only for "dir download":)
|
||||
|
||||
#files is the number of files in the directory; I don't know if that
|
||||
includes erased files. See below for more on the directory entries.
|
||||
|
||||
The dir data is not terminated (unlike 0-terminated strings).
|
||||
|
||||
After a dir download, a "forget dir" command follows.
|
||||
|
||||
|
||||
"name for file" command
|
||||
-----------------------
|
||||
|
||||
00 10 xx xx | 00 00 00 00 | 01 00 41 A0 | xx xx xx xx
|
||||
<len-> comm <---totlen--->
|
||||
xx 00 00 00 | 01 00 00 00 | xx xx... ...xx 00
|
||||
count filename (string) termination
|
||||
|
||||
E.g. "REMOVABLE_1:\DC97\CTG_0001\THM_0073.JPG" has len=0x3C
|
||||
|
||||
|
||||
"name for file" reply for existing file
|
||||
---------------------
|
||||
|
||||
00 10 18 00 | 01 00 00 00 | 01 00 02 60 | 18 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
xx 00 00 00 | 00 00 00 00 | xx xx xx xx
|
||||
count <---sector--->
|
||||
|
||||
I don't know what is returned for a non-existing file.
|
||||
|
||||
|
||||
"prepare for file download" command
|
||||
-----------------------------------
|
||||
|
||||
00 10 14 00 | 00 00 00 00 | 17 00 01 60 | 14 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
xx 00 00 00 | xx xx xx xx
|
||||
count <---sector--->
|
||||
|
||||
sector as returned in the "name for file" reply.
|
||||
|
||||
|
||||
"prepare for file download" reply
|
||||
---------------------------------
|
||||
|
||||
00 10 18 00 | 01 00 00 00 | 17 00 02 60 | 18 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
xx 00 00 00 | 00 00 00 00 | xx xx xx xx
|
||||
count <--file len-->
|
||||
|
||||
`file len' is the length of the file that is to be downloaded.
|
||||
|
||||
|
||||
"file download" command
|
||||
-----------------------
|
||||
|
||||
00 10 18 00 | 00 00 00 00 | 12 00 01 60 | 18 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
xx 00 00 00 | xx xx xx xx | xx xx xx xx
|
||||
count <---sector---> <-len2Bdownl->
|
||||
|
||||
`len2Bdownl' is the length of the piece of the file that should be sent to
|
||||
the computer in the reply packet-sequence. The M$Win driver limits this to
|
||||
0x245C (which (if I'm correct) nicely fills up 0x20 packets). If the reply
|
||||
packet-sequence has been received, another identical "file download"
|
||||
command is sent, and transmission will continue. The last "file download"
|
||||
command should have a len2Bdownl that exactly matches the length of the
|
||||
remainder of the file.
|
||||
|
||||
Note that the "start point for download" is not specified; the camera
|
||||
remembers this.
|
||||
|
||||
|
||||
"file download" reply
|
||||
---------------------
|
||||
This is possibly a multi-packet sequence. The first (or only) packet:
|
||||
|
||||
00 10 xx xx | 01 00 00 00 | 12 00 C2 A0 | xx xx xx xx
|
||||
num <len-> comm <---totlen--->
|
||||
xx 00 00 00 | 00 00 00 00 | xx xx xx xx | xx xx xx xx
|
||||
count <---sector---> <---offset--->
|
||||
xx xx xx xx | xx 00 00 00 | xx xx... ...xx
|
||||
<-len2Bdownl-> last <----file data--- - -
|
||||
|
||||
All next packets have same structure as those of "dir download" reply
|
||||
(see above). Everything mentioned there for "sequenced packets" applies
|
||||
here as well.
|
||||
|
||||
This packet format is repeated for every "resumed download".
|
||||
|
||||
`offset' is the number of bytes of the file that have been transmitted
|
||||
before this sequence (so starts at 0 at the first sequence).
|
||||
|
||||
`last' is 0x01 only in the last sequence, and 0x00 in non-last sequences.
|
||||
|
||||
Like dirs, the file data is not terminated (unlike 0-terminated strings).
|
||||
|
||||
After a completed file download, a "forget file" command follows.
|
||||
|
||||
|
||||
"forget file" command
|
||||
---------------------
|
||||
|
||||
00 10 14 00 | 00 00 00 00 | 11 00 01 60 | 14 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
xx 00 00 00 | xx xx xx xx
|
||||
count <---sector--->
|
||||
|
||||
|
||||
"forget file" reply
|
||||
-------------------
|
||||
|
||||
00 10 14 00 | 01 00 00 00 | 11 00 02 60 | 14 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
xx 00 00 00 | 00 00 00 00
|
||||
count
|
||||
|
||||
|
||||
"turn off" command
|
||||
------------------
|
||||
|
||||
00 01 00 00
|
||||
<len->
|
||||
|
||||
This tells the camera to turn itself off. This seems the only way of
|
||||
getting out of the computer-controlled mode. The M$Win driver issues this
|
||||
command upon exitting it.
|
||||
|
||||
|
||||
"turn off" reply
|
||||
----------------
|
||||
|
||||
00 10 10 00 | 01 00 00 00 | 39 00 02 60 | 10 00 00 00
|
||||
<len-> comm <---totlen--->
|
||||
00 00 00 00
|
||||
(count)
|
||||
|
||||
count seems to be 0x00 in all cases.
|
||||
|
||||
After this, a regular EOT packet (with the correct `count' number) is
|
||||
sent, after which the camera turns itself off. The computer does not send
|
||||
an ACK packet.
|
||||
|
||||
|
||||
Other packets
|
||||
-------------
|
||||
|
||||
There are also packets for file/all-files deletion, getting battery status
|
||||
and getting/setting owner's name, but I don't have information on these at
|
||||
this moment.
|
||||
|
||||
|
||||
INITIALIZATION
|
||||
==============
|
||||
|
||||
Below is the initialization procedure that the M$Win driver uses. Most
|
||||
numbers are in hex.
|
||||
|
||||
Connection check:
|
||||
|
||||
1. Speed = 9600 baud
|
||||
2. Computer sends 00 53 55 55 55 55
|
||||
3. Camera returns "identicifation" reply packet:
|
||||
|
||||
00 06 64 00 | 62 00 44 43 | 49 44 5C 00 | 00 00 01 00
|
||||
<len->
|
||||
00 01 00 01 | EA 04 01 01 | 00 00 00 00 | 4D 6F 64 65
|
||||
count? M o d e
|
||||
6C 4E 61 6D | 65 3D 50 6F | 77 65 72 53 | 68 6F 74 20
|
||||
l N a m e = P o w e r S h o t
|
||||
33 35 30 20 | 20 2C 46 69 | 72 6D 77 61 | 72 65 20 76
|
||||
3 5 0 , F i r m w a r e v
|
||||
65 72 73 69 | 6F 6E 3D 30 | 31 3A 30 32 | 2C 4D 61 6E
|
||||
e r s i o n = 0 1 : 0 2 , M a n
|
||||
75 66 61 63 | 74 75 72 65 | 72 3D 43 61 | 6E 6F 6E 20
|
||||
u f a c t u r e r = C a n o n
|
||||
49 6E 63 2E | 20 20 20 00
|
||||
I n c .
|
||||
|
||||
4. Camera sends regular EOT packet with count=00
|
||||
5. Computer sends ACK
|
||||
|
||||
Try possible speeds:
|
||||
|
||||
6. Computer sends serial break signal; a 00 at 50 baud also works
|
||||
7. Camera answers with serial break
|
||||
8. Speed = 9600
|
||||
9. Computer sends 42 00 (42 0x = speed change)
|
||||
10. Speed = 9600
|
||||
11. Computer sends 00 53
|
||||
12. Computer sends "ping" packet
|
||||
13. Camera returns "ping" reply
|
||||
14. Camera sends EOT packet with count=01
|
||||
15. Computer sends ACK packet with count=01
|
||||
|
||||
16. Computer sends serial break signal
|
||||
17. Camera answers with serial break
|
||||
18. Speed = 9600
|
||||
19. Computer sends 42 01
|
||||
20. Speed = 19200
|
||||
21. Computer sends 00 53
|
||||
22. Computer sends "ping" packet
|
||||
23. Camera returns "ping" reply
|
||||
24. Camera sends EOT packet with count=02
|
||||
25. Computer sends ACK packet with count=02
|
||||
|
||||
26. Computer sends serial break signal
|
||||
27. Camera answers with serial break
|
||||
28. Speed = 9600
|
||||
29. Computer sends 42 02
|
||||
30. Speed = 38400
|
||||
31. Computer sends 00 53
|
||||
32. Computer sends "ping" packet
|
||||
33. Camera returns "ping" reply
|
||||
34. Camera sends EOT packet with count=03
|
||||
35. Computer sends ACK packet with count=03
|
||||
|
||||
36. Computer sends serial break signal
|
||||
37. Camera answers with serial break
|
||||
38. Speed = 9600
|
||||
39. Computer sends 42 03
|
||||
40. Speed = 57600
|
||||
41. Computer sends 00 53
|
||||
42. Computer sends "ping" packet
|
||||
43. Camera returns "ping" reply
|
||||
44. Camera sends EOT packet with count=04
|
||||
45. Computer sends ACK packet with count=04
|
||||
|
||||
46. Computer sends serial break signal
|
||||
47. Camera answers with serial break
|
||||
48. Speed = 9600
|
||||
49. Computer sends 42 04
|
||||
50. Speed = 115200
|
||||
51. Computer sends 00 53
|
||||
52. Computer sends "ping" packet
|
||||
53. Camera returns "ping" reply
|
||||
54. Camera sends EOT packet with count=05
|
||||
55. Computer sends ACK packet with count=05
|
||||
|
||||
Resume communication at chosen speed:
|
||||
|
||||
56. Computer sends serial break signal
|
||||
57. Camera answers with serial break
|
||||
58. Speed = 9600
|
||||
59. Computer sends 42 04
|
||||
60. Speed = 115200
|
||||
61. Computer sends 00 53
|
||||
62. Computer sends "ping" packet
|
||||
63. Camera returns "ping" reply
|
||||
64. Camera sends EOT packet with count=06
|
||||
65. Computer sends ACK packet with count=06
|
||||
|
||||
After this, communication is as described in the next section.
|
||||
|
||||
It's not needed to try all speeds. The following sequence has been tried
|
||||
succesfully: 1, 2, 3, 4, 5, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65 (but
|
||||
then 64 and 65 with count=01).
|
||||
|
||||
|
||||
MORE COMMUNICATION
|
||||
==================
|
||||
|
||||
After initialization, the following communication takes place:
|
||||
|
||||
66. Computer sends "unknown1" command (see above), camera returns reply,
|
||||
EOT, ACK (count=07)
|
||||
67. Computer sends "get disks" command, camera returns reply, EOT, ACK
|
||||
(count=08)
|
||||
68. Computer sends "use disk" command, camera returns reply, EOT, ACK
|
||||
(count=09)
|
||||
69. Computer sends "name for dir" command to check if "REMOVABLE_1:\DC97"
|
||||
is present, camera returns reply (`exists'), EOT, ACK (count=0A)
|
||||
70. Computer sends "forget dir" command, camera returns reply, EOT, ACK
|
||||
(count=0B)
|
||||
71. Computer sends "name for dir" command to check if
|
||||
"REMOVABLE_1:\PWRSHOT" is present, camera returns reply (`does not
|
||||
exist'), EOT, ACK (count=0C)
|
||||
72. Computer sends "forget dir" command, camera returns reply, EOT, ACK
|
||||
(count=0D)
|
||||
73. Computer sends "name for dir" command for download of
|
||||
"REMOVABLE_1:\DC97", camera returns reply, EOT, ACK (count=0E)
|
||||
74. Computer sends "prepare for dir download" command, camera returns
|
||||
reply, EOT, ACK (count=0F)
|
||||
75. Computer sends "dir download" command, camera returns reply, EOT, ACK
|
||||
(count=10)
|
||||
The dir info returns
|
||||
.
|
||||
..
|
||||
CTG_0000
|
||||
CTG_0001
|
||||
and possibly more CTG's. These CTG's are `catalogs'; there may only be
|
||||
a limited number of files in a CTG subdir, and a new subdir is added
|
||||
when needed.
|
||||
76. Computer sends "forget dir" command, camera returns reply, EOT, ACK
|
||||
(count=11)
|
||||
|
||||
Now the computer gets each CTG_* directory with "name for dir", "prepare
|
||||
for dir download", "dir download" and "forget dir" commands. Dir names are
|
||||
"REMOVABLE_1:\DC97\CTG_0000" etc.
|
||||
|
||||
In the CTG directories, there are two files for each picture: a thumbnail
|
||||
file (e.g. THM_0021.JPG) and a `real picture' file (e.g. AUT_0021.JPG).
|
||||
|
||||
The M$Win driver first gets up to 9 thumbnail files (more don't fit in the
|
||||
driver's window), using commands "name for file", "prepare for file
|
||||
download", "file download" and "forget file". Sample file name:
|
||||
"REMOVABLE_1:\DC97\CTG_0001\THM_0073.JPG"
|
||||
|
||||
More thumbnails are loaded when a scroll button is pressed. During `idle
|
||||
time', "ping" packets are sent every second.
|
||||
|
||||
When a picture is selected, the `Aquire' button initiates a communication
|
||||
just like a thumbnail download, only there may be repeated "file
|
||||
download" commands. And in the file name it's "AUT" instead of "THM".
|
||||
|
||||
When the driver is exitted, a "turn off" command is sent.
|
||||
|
||||
|
||||
DIRECTORY ENTRIES
|
||||
=================
|
||||
|
||||
The directory information (as sent over the serial link) has 21=0x15 bytes
|
||||
of information per file. Example entry (numbers in hex):
|
||||
|
||||
20 2A 08 00 00 AA 28 3B 37 54 48 4D 5F 30 30 37 33 2E 4A 50 47
|
||||
type <--size---> <--time---> T H M _ 0 0 7 3 . J P G
|
||||
<---------------name-------------->
|
||||
|
||||
type is 0x20 for a regular file, 0x10 for a directory.
|
||||
|
||||
size is the file size in bytes, also returned in the "prepare for file
|
||||
download" reply.
|
||||
|
||||
time is the standard UNIX time_t-format time of file/dir creation.
|
||||
|
||||
name seems to be left-aligned; e.g. a ".." directory entry has in the name
|
||||
field ".." followed by ten 00-bytes.
|
||||
|
||||
Erased files have 0xE5 as first byte of the file name.
|
||||
|
||||
Directories have a size 00 00 00 00.
|
||||
|
||||
On the Compact Flash memory card, there is a normal FAT12 filesystem. The
|
||||
CF card behaves like a hard disk (has a partition table), of which
|
||||
the first (and only) partition spans the entire disk=memory. The PCMCIA
|
||||
kernel modules recognize it as an `ide' card.
|
||||
|
||||
|
||||
JPG FILE
|
||||
========
|
||||
|
||||
The header of all JPG files has some interesting fields. Example:
|
||||
|
||||
|
||||
FF D8 FF E0 | 00 10 4A 46 | 49 46 00 01 | 02 01 00 B4
|
||||
J F I F
|
||||
00 B4 00 00 | FF E0 00 A0 | 49 49 1A 00 | 00 00 48 45
|
||||
H E
|
||||
41 50 4A 50 | 47 4D 02 00 | 01 00 00 00 | 00 00 00 00
|
||||
A P J P G M
|
||||
00 00 44 F8 | 4F 37 00 00 | 00 00 00 00 | 00 00 43 61
|
||||
<-----time------> C a
|
||||
6E 6F 6E 20 | 49 6E 63 2E | 20 20 20 00 | 50 6F 77 65
|
||||
n o n I n c . P o w e
|
||||
72 53 68 6F | 74 20 33 35 | 30 20 20 00 | 46 69 72 6D
|
||||
r S h o t 3 5 0 F i r m
|
||||
77 61 72 65 | 20 76 65 72 | 73 69 6F 6E | 20 31 2E 30
|
||||
w a r e v e r s i o n 1 . 0
|
||||
32 00 01 00 | 0B 08 16 00 | 00 00 00 00 | 00 00 16 00
|
||||
2
|
||||
00 00 02 00 | 0A 08 1E 00 | 00 00 00 00 | 00 00 04 30
|
||||
|
||||
|
||||
The time field is exactly the same as in the directory.
|
||||
|
||||
Except for the time field, this piece of the header (and possibly more)
|
||||
seems to be identical for all JPG files (THM_* and AUT_*).
|
||||
|
||||
THM and AUT files are numbered, starting from {THM,AUT}_0000.JPG when the
|
||||
camera is new (and possibly when the batteries have been out a few days)
|
||||
and incremented for each picture. Incrementing is normally not interrupted
|
||||
by a CF card swap (i.e. if you place a new card after AUT_0168, then
|
||||
AUT_0169 will be the first picture on the new card). However, I have seen
|
||||
one occurrence of the same file name on two cards. The "right" method of
|
||||
ordering the files is by using the `time' field that is returned in the
|
||||
directory info. (Note that the time of AUT and THM files may be a few
|
||||
seconds apart.)
|
||||
|
||||
|
||||
For the PS 350, the THM files are 80 x 60 and AUT 640 x 480 pixels. There
|
||||
are three quality modes for the AUT files (recording-time choice), "Fine",
|
||||
"Normal" and "Economy", which correspond to JPEG quality factors of about
|
||||
90%, 75% and 50%. THM files are about 2.5 kB and AUT files about 150 kB,
|
||||
70 kB and 32 kB depending on the quality mode.
|
||||
|
||||
|
||||
CONTACT INFORMATION
|
||||
===================
|
||||
|
||||
I'm reachable preferably as <costar@panic.et.tudelft.nl>. If that
|
||||
shouldn't work, try <J.A.Bezemer@ITS.TUDelft.NL> or else <mcbzmr@dds.nl>.
|
||||
In the latter case, please indicate that you're trying to send a message
|
||||
to me (and not to my brother ;-)
|
||||
|
||||
75
camlibs/canon/ps350/renamejpg.c
Normal file
75
camlibs/canon/ps350/renamejpg.c
Normal file
@@ -0,0 +1,75 @@
|
||||
/* RenameJPG Copyright (C) 1999 J.A. Bezemer GPL'd */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void main (int argc, char **argv)
|
||||
{
|
||||
FILE *jpgfile;
|
||||
time_t time;
|
||||
struct tm *temptm;
|
||||
unsigned char buffer[4];
|
||||
char timestring[200];
|
||||
char tempstring[300];
|
||||
char newname[300];
|
||||
int i;
|
||||
struct stat statbuf;
|
||||
struct stat statbuf2;
|
||||
int newnamecounter;
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
fprintf (stderr, "Usage: renamejpg [filename(s)]\n\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (i=1; i<argc; i++)
|
||||
{
|
||||
if ((jpgfile = fopen (argv[i], "rb")) == NULL)
|
||||
{
|
||||
fprintf (stderr, "File could not be opened. Aborted.\n\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
fseek(jpgfile, 0x32, SEEK_SET);
|
||||
fread(buffer, 1, 4, jpgfile);
|
||||
|
||||
time= (((time_t) buffer[0]) )
|
||||
| (((time_t) buffer[1]) << 8 )
|
||||
| (((time_t) buffer[2]) << 16 )
|
||||
| (((time_t) buffer[3]) << 24 );
|
||||
|
||||
temptm=gmtime(&time);
|
||||
|
||||
strftime(timestring, 200, "%Y%m%d-%H%M%S", temptm);
|
||||
|
||||
fstat (fileno (jpgfile), &statbuf);
|
||||
|
||||
if (statbuf.st_size < 4000)
|
||||
/* thumbnail */
|
||||
snprintf(tempstring, 200, "thm_%s", timestring);
|
||||
else
|
||||
/* other jpg */
|
||||
snprintf(tempstring, 200, "aut_%s", timestring);
|
||||
|
||||
snprintf(newname, 200, "%s.jpg", tempstring);
|
||||
newnamecounter=1;
|
||||
|
||||
/* check if file exists. Will hang if all names are used... */
|
||||
while (stat(newname, &statbuf2)==0)
|
||||
{
|
||||
newnamecounter++;
|
||||
snprintf(newname, 200, "%s-%d.jpg", tempstring, newnamecounter);
|
||||
}
|
||||
|
||||
printf("File %s, size %ld, %s -> %s\n", argv[i], statbuf.st_size,
|
||||
timestring, newname);
|
||||
|
||||
fclose(jpgfile);
|
||||
|
||||
rename(argv[i], newname);
|
||||
}
|
||||
}
|
||||
1554
camlibs/canon/psa50.c
Normal file
1554
camlibs/canon/psa50.c
Normal file
File diff suppressed because it is too large
Load Diff
123
camlibs/canon/psa50.h
Normal file
123
camlibs/canon/psa50.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* psa50.h - Canon PowerShot A50 "native" operations.
|
||||
*
|
||||
* Written 1999 by Wolfgang G. Reissnegger and Werner Almesberger
|
||||
*/
|
||||
|
||||
#ifndef PSA50_H
|
||||
#define PSA50_H
|
||||
|
||||
/* Globals for error handling */
|
||||
#define NOERROR 0
|
||||
#define ERROR_RECEIVED 1
|
||||
#define ERROR_ADDRESSED 2
|
||||
#define FATAL_ERROR 3
|
||||
#define ERROR_LOWBATT 4
|
||||
|
||||
int receive_error;
|
||||
|
||||
/* Battery status values: */
|
||||
#define CAMERA_ON_AC 16
|
||||
#define CAMERA_ON_BATTERY 48
|
||||
#define CAMERA_POWER_OK 6
|
||||
#define CAMERA_POWER_BAD 4
|
||||
|
||||
/* @@@ change this to canon_dir when merging with other models */
|
||||
struct psa50_dir {
|
||||
const char *name; /* NULL if at end */
|
||||
unsigned int size;
|
||||
time_t date;
|
||||
char attrs; /* File attributes, see "Protocols" for details */
|
||||
int is_file;
|
||||
void *user; /* user-specific data */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Various Powershot camera types
|
||||
*/
|
||||
typedef enum {
|
||||
CANON_PS_A5,
|
||||
CANON_PS_A5_ZOOM,
|
||||
CANON_PS_A50,
|
||||
CANON_PS_S10,
|
||||
CANON_PS_S20,
|
||||
CANON_PS_A70
|
||||
} canonCamModel;
|
||||
|
||||
|
||||
struct canon_info
|
||||
{
|
||||
canonCamModel model;
|
||||
int speed; /* The speed we're using for this camera */
|
||||
char ident[32]; /* Model ID string given by the camera */
|
||||
char owner[32]; /* Owner name */
|
||||
char firmwrev[4]; /* Firmware revision */
|
||||
};
|
||||
|
||||
|
||||
extern struct canon_info camera;
|
||||
extern char psa50_id[]; /* ditto @@@ */
|
||||
int A5;
|
||||
|
||||
/*
|
||||
* Our driver now supports both USB and serial communications
|
||||
*/
|
||||
#define CANON_SERIAL_RS232 0
|
||||
#define CANON_USB 1
|
||||
int canon_comm_method;
|
||||
|
||||
|
||||
typedef unsigned long u32;
|
||||
#ifndef byteswap32
|
||||
#ifdef __sparc
|
||||
#define byteswap32(val) ({ u32 x = val; x = (x << 24) | ((x << 8) & 0xff0000) | ((x >> 8) & 0xff00) | (x >> 24); x; })
|
||||
#else
|
||||
#define byteswap32(val) val
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* All functions returning a pointer have malloc'ed the data. The caller must
|
||||
* free() it when done.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Switches the camera on, detects the model and sets its speed
|
||||
*/
|
||||
int psa50_ready(void);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
char *psa50_get_disk(void);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
int psa50_get_battery(int *pwr_status, int *pwr_source);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
int psa50_disk_info(const char *name,int *capacity,int *available);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
struct psa50_dir *psa50_list_directory(const char *name);
|
||||
void psa50_free_dir(struct psa50_dir *list);
|
||||
unsigned char *psa50_get_file(const char *name,int *length);
|
||||
unsigned char *psa50_get_thumbnail(const char *name,int *length);
|
||||
int psa50_set_file_attributes(const char *file, const char *dir, char attrs);
|
||||
int psa50_delete_file(const char *name, const char *dir);
|
||||
int psa50_end(void);
|
||||
int psa50_off(void);
|
||||
int psa50_sync_time(void);
|
||||
time_t psa50_get_time(void);
|
||||
int psa50_get_owner_name(void);
|
||||
int psa50_set_owner_name(const char *name);
|
||||
void psa50_error_type(void);
|
||||
|
||||
#endif
|
||||
316
camlibs/canon/serial.c
Normal file
316
camlibs/canon/serial.c
Normal file
@@ -0,0 +1,316 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* File: serial.c
|
||||
*
|
||||
* Serial communication layer.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* include files
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <termios.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <gphoto2.h>
|
||||
|
||||
#include "util.h"
|
||||
#include "psa50.h"
|
||||
|
||||
|
||||
/**** new stuff ********/
|
||||
#include <gpio/gpio.h>
|
||||
extern struct Model *Camera;
|
||||
int gpio_usb_find_device(int idvendor, int idproduct, struct usb_device **device);
|
||||
int gpio_usb_msg_write(gpio_device *dev, int value, char *bytes, int size);
|
||||
int gpio_usb_msg_read(gpio_device *dev, int value, char *bytes, int size);
|
||||
int gpio_usb_read(gpio_device *dev, char *bytes, int size);
|
||||
int gpio_usb_write(gpio_device *dev, char *bytes, int size);
|
||||
/******* new stuff *********/
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* static global storage area
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
gpio_device *iodev;
|
||||
gpio_device_settings settings;
|
||||
|
||||
|
||||
void serial_flush_input(void)
|
||||
{
|
||||
}
|
||||
|
||||
void serial_flush_output(void)
|
||||
{
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* canon_serial_change_speed
|
||||
*
|
||||
* change the speed of the communication.
|
||||
*
|
||||
* speed - the new speed
|
||||
*
|
||||
* Returns 1 on success.
|
||||
* Returns 0 on any error.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int canon_serial_change_speed(int speed)
|
||||
{
|
||||
/* set speed */
|
||||
gpio_get_settings(iodev, &settings);
|
||||
settings.serial.speed = speed;
|
||||
gpio_set_settings(iodev, settings);
|
||||
|
||||
usleep(70000);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* canon_serial_get_cts
|
||||
*
|
||||
* Gets the status of the CTS (Clear To Send) line on the serial port.
|
||||
*
|
||||
* CTS is "1" when the camera is ON, and "0" when it is OFF.
|
||||
*
|
||||
* Returns 1 on CTS high.
|
||||
* Returns 0 on CTS low.
|
||||
*
|
||||
****************************************************************************/
|
||||
int canon_serial_get_cts(void)
|
||||
{
|
||||
return gpio_get_pin(iodev,PIN_CTS);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* canon_serial_init
|
||||
*
|
||||
* Initializes the given serial or USB device.
|
||||
*
|
||||
* devname - the name of the device to open
|
||||
*
|
||||
* Returns 0 on success.
|
||||
* Returns -1 on any error.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int canon_serial_init(const char *devname)
|
||||
{
|
||||
#ifdef GPIO_USB
|
||||
char msg[65536];
|
||||
char mem;
|
||||
char buffer[65536];
|
||||
gpio_device_settings settings;
|
||||
struct usb_device *udev;
|
||||
#endif
|
||||
|
||||
debug_message("Initializing the camera.\n");
|
||||
|
||||
switch (canon_comm_method) {
|
||||
case CANON_USB:
|
||||
#ifdef GPIO_USB
|
||||
|
||||
if (gpio_usb_find_device(Camera->idVendor,
|
||||
Camera->idProduct, &udev)) {
|
||||
printf("found '%s' @ %d/%d\n", Camera->name,
|
||||
udev->bus->busnum, udev->devicenum);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Found no camera!\n");
|
||||
exit(1);
|
||||
}
|
||||
iodev = gpio_new(GPIO_DEVICE_USB);
|
||||
if (!iodev)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
settings.usb.udev = udev;
|
||||
|
||||
settings.usb.inep = 0x81;
|
||||
settings.usb.outep = 0x02;
|
||||
settings.usb.config = 1;
|
||||
settings.usb.interface = 0;
|
||||
settings.usb.altsetting = 0;
|
||||
|
||||
/* canon_send = canon_usb_send;
|
||||
canon_read = canon_usb_read; */
|
||||
|
||||
gpio_set_settings(iodev, settings);
|
||||
if (gpio_open(iodev) < 0) {
|
||||
fprintf(stderr,"Camera used by other USB device!\n");
|
||||
exit(1);
|
||||
/* return -1; */
|
||||
}
|
||||
|
||||
gpio_usb_msg_read(iodev,0x55,msg,1);
|
||||
// fprintf(stderr,"%c\n",msg[0]);
|
||||
gpio_usb_msg_read(iodev,0x1,msg,0x58);
|
||||
gpio_usb_msg_write(iodev,0x11,msg+0x48,0x10);
|
||||
gpio_read(iodev, buffer, 0x44);
|
||||
// fprintf(stderr,"Antal b: %x\n",buffer[0]);
|
||||
if (buffer[0]==0x54)
|
||||
gpio_read(iodev, buffer, 0x40);
|
||||
return 0;
|
||||
/* #else
|
||||
return -1;*/
|
||||
#else
|
||||
fprintf(stderr,"This computer does not support USB, please try to select 'RS-232'\n"
|
||||
" in the configuration panel (Configure/Configure camera...).\n");
|
||||
return -1;
|
||||
#endif
|
||||
break;
|
||||
case CANON_SERIAL_RS232:
|
||||
default:
|
||||
|
||||
if (!devname)
|
||||
{
|
||||
fprintf(stderr, "INVALID device string (NULL)\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
debug_message("canon_init_serial(): Using serial port on %s\n", devname);
|
||||
|
||||
iodev = gpio_new(GPIO_DEVICE_SERIAL);
|
||||
|
||||
strcpy(settings.serial.port, devname);
|
||||
settings.serial.speed = 9600;
|
||||
settings.serial.bits = 8;
|
||||
settings.serial.parity = 0;
|
||||
settings.serial.stopbits = 1;
|
||||
|
||||
gpio_set_settings(iodev, settings); /* Sets the serial device name */
|
||||
if ( gpio_open(iodev) == GPIO_ERROR) { /* open the device */
|
||||
perror("Unable to open the serial port");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* canon_serial_restore
|
||||
*
|
||||
* Restores the saved settings for the serial device
|
||||
*
|
||||
* Returns 0 on success.
|
||||
* Returns -1 on any error.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int canon_serial_restore()
|
||||
{
|
||||
|
||||
gpio_close(iodev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* canon_serial_send
|
||||
*
|
||||
* Send the given buffer with given length over the serial line.
|
||||
*
|
||||
* buf - the raw data buffer to send
|
||||
* len - the length of the buffer
|
||||
* sleep - time in usec to wait between characters
|
||||
*
|
||||
* Returns 0 on success, -1 on error.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int canon_serial_send(const unsigned char *buf, int len, int sleep)
|
||||
{
|
||||
int i;
|
||||
dump_hex("canon_serial_send()", buf, len);
|
||||
|
||||
if (sleep>0) {
|
||||
for(i=0;i<len;i++) {
|
||||
gpio_write(iodev,buf,1);
|
||||
buf++;
|
||||
usleep(sleep);
|
||||
}
|
||||
}
|
||||
else {
|
||||
gpio_write(iodev,buf,len);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the timeout, in miliseconds.
|
||||
*/
|
||||
void serial_set_timeout(int to)
|
||||
{
|
||||
gpio_set_timeout(iodev,to);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* canon_serial_get_byte
|
||||
*
|
||||
* Get the next byte from the serial line.
|
||||
* Actually the fucntion reads chunks of data and keeps them in a cache.
|
||||
* Only one byte per call will be returned.
|
||||
*
|
||||
* Returns the byte on success, -1 on error.
|
||||
*
|
||||
****************************************************************************/
|
||||
int canon_serial_get_byte()
|
||||
{
|
||||
static unsigned char cache[512];
|
||||
static unsigned char *cachep = cache;
|
||||
static unsigned char *cachee = cache;
|
||||
int recv;
|
||||
|
||||
/* if still data in cache, get it */
|
||||
if (cachep < cachee)
|
||||
{
|
||||
return (int) *cachep++;
|
||||
}
|
||||
|
||||
|
||||
recv = gpio_read(iodev, cache, 1);
|
||||
if (recv == GPIO_ERROR || recv == GPIO_TIMEOUT)
|
||||
return -1;
|
||||
cachep = cache;
|
||||
cachee = cache + recv;
|
||||
|
||||
if (recv)
|
||||
{
|
||||
return (int) *cachep++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* End of file: serial.c
|
||||
*
|
||||
****************************************************************************/
|
||||
33
camlibs/canon/serial.h
Normal file
33
camlibs/canon/serial.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* File: serial.h
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _SERIAL_H
|
||||
#define _SERIAL_H
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* prototypes
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int canon_serial_change_speed(int speed);
|
||||
int canon_serial_init(const char *devname);
|
||||
int canon_serial_restore();
|
||||
int canon_serial_send(const unsigned char *buf, int len, int sleep);
|
||||
int canon_serial_get_byte();
|
||||
int canon_serial_get_cts(void);
|
||||
|
||||
void serial_flush_input(void);
|
||||
void serial_flush_output(void);
|
||||
void serial_set_timeout(int to);
|
||||
|
||||
#endif /* _SERIAL_H */
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* End of file: serial.h
|
||||
*
|
||||
****************************************************************************/
|
||||
124
camlibs/canon/util.c
Normal file
124
camlibs/canon/util.c
Normal file
@@ -0,0 +1,124 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* File: util.c
|
||||
*
|
||||
* Utility functions for the gPhoto Canon PowerShot A5(Z)/A50 driver.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* include files
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* dump_hex
|
||||
*
|
||||
* Dumps a memory area as hex on the screen.
|
||||
*
|
||||
* msg - Info message for the dump
|
||||
* buf - the memory buffer to dump
|
||||
* len - length of the buffer
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
extern int canon_debug_driver;
|
||||
|
||||
#define NIBBLE(_i) (((_i) < 10) ? '0' + (_i) : 'A' + (_i) - 10)
|
||||
|
||||
void dump_hex(const char *msg, const unsigned char *buf, int len)
|
||||
{
|
||||
int i;
|
||||
int nlocal;
|
||||
const unsigned char *pc;
|
||||
char *out;
|
||||
const unsigned char *start;
|
||||
char c;
|
||||
char line[100];
|
||||
|
||||
if (canon_debug_driver > 8) { // Only printout with max. debug level (9)
|
||||
start = buf;
|
||||
|
||||
#if 0
|
||||
if (len > 160)
|
||||
{
|
||||
fprintf(stderr,"dump n:%d --> 160\n", len);
|
||||
len = 160;
|
||||
}
|
||||
#endif
|
||||
|
||||
fprintf(stderr,"%s: (%d bytes)\n", msg, len);
|
||||
while (len > 0)
|
||||
{
|
||||
sprintf(line, "%08x: ", buf - start);
|
||||
out = line + 10;
|
||||
|
||||
for (i = 0, pc = buf, nlocal = len; i < 16; i++, pc++)
|
||||
{
|
||||
if (nlocal > 0)
|
||||
{
|
||||
c = *pc;
|
||||
|
||||
*out++ = NIBBLE((c >> 4) & 0xF);
|
||||
*out++ = NIBBLE(c & 0xF);
|
||||
|
||||
nlocal--;
|
||||
}
|
||||
else
|
||||
{
|
||||
*out++ = ' ';
|
||||
*out++ = ' ';
|
||||
} /* end else */
|
||||
|
||||
*out++ = ' ';
|
||||
} /* end for */
|
||||
|
||||
*out++ = '-';
|
||||
*out++ = ' ';
|
||||
|
||||
for (i = 0, pc = buf, nlocal = len;
|
||||
(i < 16) && (nlocal > 0);
|
||||
i++, pc++, nlocal--)
|
||||
{
|
||||
c = *pc;
|
||||
|
||||
if ((c < ' ') || (c >= 126))
|
||||
{
|
||||
c = '.';
|
||||
}
|
||||
|
||||
*out++ = c;
|
||||
} /* end for */
|
||||
|
||||
*out++ = 0;
|
||||
|
||||
fprintf(stderr,"%s\n", line);
|
||||
|
||||
buf += 16;
|
||||
len -= 16;
|
||||
} /* end while */
|
||||
} /* end 'if debug' */
|
||||
} /* end dump */
|
||||
|
||||
void debug_message(const char * msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
|
||||
if (canon_debug_driver) {
|
||||
va_start(ap, msg);
|
||||
vfprintf(stderr,msg, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* End of file: util.c
|
||||
*
|
||||
****************************************************************************/
|
||||
26
camlibs/canon/util.h
Normal file
26
camlibs/canon/util.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/****************************************************************************
|
||||
*
|
||||
* File: util.h
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _CANON_UTIL_H
|
||||
#define _CANON_UTIL_H
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* prototypes
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void dump_hex(const char *msg, const unsigned char *buf, int len);
|
||||
void debug_message(const char * msg, ...);
|
||||
|
||||
|
||||
#endif /* _CANON_UTIL_H */
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* End of file: util.h
|
||||
*
|
||||
****************************************************************************/
|
||||
Reference in New Issue
Block a user