This is the first commit of the Minolta Dimage V camera library. This is
a new work, owing very little to my previous gphoto 0.4.x Minolta Dimage V driver. It support image capture, download, and deletion. This does not support any other model of Minolta camera to the best of my knowledge, only the now-discontinued Dimage V. The C files are divided by function; the primary file is dimagev.c, with subroutines of varying types divided into the rest. For example, packet.c contains functions pertaining to the packet communication used by the camera. git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@1121 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
340
camlibs/minolta/dimagev/COPYING
Normal file
340
camlibs/minolta/dimagev/COPYING
Normal file
@@ -0,0 +1,340 @@
|
||||
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
|
||||
|
||||
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.
|
||||
9
camlibs/minolta/dimagev/Makefile.am
Normal file
9
camlibs/minolta/dimagev/Makefile.am
Normal file
@@ -0,0 +1,9 @@
|
||||
camlibdir = $(prefix)/lib/gphoto2
|
||||
camlib_LTLIBRARIES = libgphoto2_dimagev.la
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/include
|
||||
|
||||
libgphoto2_dimagev_la_SOURCES = dimagev.c dimagev.h packet.c data.c status.c \
|
||||
info.c capture.c util.c
|
||||
|
||||
libgphoto2_dimagev_la_LDFLAGS = -version-info 0:0:0
|
||||
353
camlibs/minolta/dimagev/Makefile.in
Normal file
353
camlibs/minolta/dimagev/Makefile.in
Normal file
@@ -0,0 +1,353 @@
|
||||
# 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@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
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@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
PACKAGE = @PACKAGE@
|
||||
RANLIB = @RANLIB@
|
||||
SUBDIRS_CAMLIBS = @SUBDIRS_CAMLIBS@
|
||||
VERSION = @VERSION@
|
||||
|
||||
camlibdir = $(prefix)/lib/gphoto2
|
||||
camlib_LTLIBRARIES = libgphoto2_dimagev.la
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/include
|
||||
|
||||
libgphoto2_dimagev_la_SOURCES = dimagev.c dimagev.h packet.c data.c status.c info.c capture.c util.c
|
||||
|
||||
|
||||
libgphoto2_dimagev_la_LDFLAGS = -version-info 0:0:0
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = ../../../config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
LTLIBRARIES = $(camlib_LTLIBRARIES)
|
||||
|
||||
|
||||
DEFS = @DEFS@ -I. -I$(srcdir) -I../../..
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
libgphoto2_dimagev_la_LIBADD =
|
||||
libgphoto2_dimagev_la_OBJECTS = dimagev.lo packet.lo data.lo status.lo \
|
||||
info.lo capture.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 COPYING Makefile.am Makefile.in
|
||||
|
||||
|
||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
TAR = gtar
|
||||
GZIP_ENV = --best
|
||||
DEP_FILES = .deps/capture.P .deps/data.P .deps/dimagev.P .deps/info.P \
|
||||
.deps/packet.P .deps/status.P .deps/util.P
|
||||
SOURCES = $(libgphoto2_dimagev_la_SOURCES)
|
||||
OBJECTS = $(libgphoto2_dimagev_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/minolta/dimagev/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_dimagev.la: $(libgphoto2_dimagev_la_OBJECTS) $(libgphoto2_dimagev_la_DEPENDENCIES)
|
||||
$(LINK) -rpath $(camlibdir) $(libgphoto2_dimagev_la_LDFLAGS) $(libgphoto2_dimagev_la_OBJECTS) $(libgphoto2_dimagev_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/minolta/dimagev
|
||||
|
||||
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/minolta/dimagev/Makefile
|
||||
@for file in $(DISTFILES); do \
|
||||
d=$(srcdir); \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pr $$d/$$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:
|
||||
22
camlibs/minolta/dimagev/README
Normal file
22
camlibs/minolta/dimagev/README
Normal file
@@ -0,0 +1,22 @@
|
||||
This is a fresh driver for the Minolta DImage V camera, which has since been
|
||||
discontinued. This driver contains no code form my earlier efforts.
|
||||
|
||||
The assistance of Minolta was very helpful in writing this driver; I was given
|
||||
a copy of the specification and told that I could "share it with the Linux
|
||||
community". I am interpreting this "sharing" as the GNU GPL. Minolta takes no
|
||||
respondsibility for the information they provided me, which is perfectly fair.
|
||||
Please see the file COPYING for more information.
|
||||
|
||||
This library is far from complete. There are plenty of places where better
|
||||
sanity checking could be done, such as ensuring that the media is write-enabled
|
||||
before trying to capture an image. I will continue to work on it until I buy a
|
||||
newer camera.
|
||||
|
||||
Notes on specific functions:
|
||||
The capture function takes a picture, downloads it, and then deletes it.
|
||||
This image is always named dv00000.jpg, since that holds with the naming
|
||||
convention for the rest of the pictures, and simultaneously cannot be a
|
||||
valid name for an image retrieved from the camera.
|
||||
|
||||
|
||||
--Gus Hartmann
|
||||
137
camlibs/minolta/dimagev/capture.c
Normal file
137
camlibs/minolta/dimagev/capture.c
Normal file
@@ -0,0 +1,137 @@
|
||||
#include "dimagev.h"
|
||||
|
||||
int dimagev_shutter(dimagev_t *dimagev) {
|
||||
dimagev_packet *p, *raw;
|
||||
unsigned char char_buffer;
|
||||
|
||||
/* This function just flips the shutter. The image is always stored last. */
|
||||
|
||||
dimagev->data->play_rec_mode = 1;
|
||||
dimagev_host_mode(dimagev, 1);
|
||||
|
||||
sleep(1);
|
||||
|
||||
/* Check the device. */
|
||||
if ( dimagev->dev == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::device not valid\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
/* Let's say hello and get the current status. */
|
||||
if ( ( p = dimagev_make_packet(DIMAGEV_SHUTTER, 1, 0)) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_shutter::unable to allocate packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( gpio_write(dimagev->dev, p->buffer, p->length) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_shutter::unable to write packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
} else if ( gpio_read(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_shutter::no response from camera");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
free(p);
|
||||
|
||||
switch ( char_buffer ) {
|
||||
case DIMAGEV_ACK:
|
||||
/* Sleep for a few seconds while the image is written to flash. */
|
||||
sleep(5);
|
||||
break;
|
||||
case DIMAGEV_NAK:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::camera did not acknowledge transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
case DIMAGEV_CAN:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::camera cancels transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
default:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::camera responded with unknown value %x\n", char_buffer);
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ( p = dimagev_read_packet(dimagev) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::unable to read packet\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( dimagev->debug != 0 ) {
|
||||
dimagev_dump_packet(p);
|
||||
}
|
||||
|
||||
if ( ( raw = dimagev_strip_packet(p) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::unable to strip data packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( raw->buffer[0] != 0 ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::camera returned error code");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
char_buffer = DIMAGEV_EOT;
|
||||
if ( gpio_write(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_shutter::unable to send EOT");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( gpio_read(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_shutter::no response from camera");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
switch ( char_buffer ) {
|
||||
case DIMAGEV_ACK:
|
||||
break;
|
||||
case DIMAGEV_NAK:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::camera did not acknowledge transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
case DIMAGEV_CAN:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::camera cancels transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
default:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::camera responded with unknown value %x", char_buffer);
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
dimagev->data->play_rec_mode = 0;
|
||||
dimagev_host_mode(dimagev, 0);
|
||||
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
234
camlibs/minolta/dimagev/data.c
Normal file
234
camlibs/minolta/dimagev/data.c
Normal file
@@ -0,0 +1,234 @@
|
||||
#include "dimagev.h"
|
||||
|
||||
/* This is the parent function, who calls most of the functions below.
|
||||
It returns GP_ERROR if it cannot get the camera data, and GP_OK otherwise.
|
||||
The subroutines will print out more detained information should they fail. */
|
||||
int dimagev_get_camera_data(dimagev_t *dimagev) {
|
||||
dimagev_packet *p, *raw;
|
||||
unsigned char char_buffer;
|
||||
|
||||
/* Check the device. */
|
||||
if ( dimagev->dev == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_data::device not valid\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
/* Let's say hello and get the current status. */
|
||||
if ( ( p = dimagev_make_packet(DIMAGEV_GET_DATA, 1, 0)) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_get_camera_data::unable to allocate packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( gpio_write(dimagev->dev, p->buffer, p->length) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_get_camera_data::unable to write packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
} else if ( gpio_read(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_get_camera_data::no response from camera");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
free(p);
|
||||
|
||||
switch ( char_buffer ) {
|
||||
case DIMAGEV_ACK:
|
||||
break;
|
||||
case DIMAGEV_NAK:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_data::camera did not acknowledge transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
case DIMAGEV_CAN:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_data::camera cancels transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
default:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_data::camera responded with unknown value %x\n", char_buffer);
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ( p = dimagev_read_packet(dimagev) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_data::unable to read packet\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
char_buffer = DIMAGEV_EOT;
|
||||
if ( gpio_write(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_get_camera_data::unable to send EOT");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( gpio_read(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_get_camera_data::no response from camera");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
switch ( char_buffer ) {
|
||||
case DIMAGEV_ACK:
|
||||
break;
|
||||
case DIMAGEV_NAK:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_data::camera did not acknowledge transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
case DIMAGEV_CAN:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_data::camera cancels transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
default:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_data::camera responded with unknown value %x\n", char_buffer);
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( dimagev->debug != 0 ) {
|
||||
dimagev_dump_packet(p);
|
||||
}
|
||||
|
||||
if ( ( raw = dimagev_strip_packet(p) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_data::unable to strip data packet\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( ( dimagev->data = dimagev_import_camera_data(raw->buffer)) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_data::unable to read camera data\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
/* Sure it *should* get freed automagically, but why take the risk? */
|
||||
free(p);
|
||||
free(raw);
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
dimagev_data_t *dimagev_import_camera_data(unsigned char *raw_data) {
|
||||
dimagev_data_t *processed_data;
|
||||
|
||||
if ( raw_data == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( ( processed_data = malloc(sizeof(dimagev_data_t)) ) == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* They really pack those bit fields. */
|
||||
processed_data->host_mode = ( raw_data[0] & 0x80) >> 7;
|
||||
processed_data->exposure_valid = (raw_data[0] & 0x40 ) >> 6;
|
||||
processed_data->date_valid = (raw_data[0] & 0x20 ) >> 5;
|
||||
processed_data->self_timer_mode = (raw_data[0] & 0x10 ) >> 4;
|
||||
processed_data->flash_mode = ( raw_data[0] & 0x0C ) >> 2;
|
||||
processed_data->quality_setting = ( raw_data[0] & 0x02 ) >> 1;
|
||||
processed_data->play_rec_mode = (raw_data[0] & 0x01 );
|
||||
processed_data->year = dimagev_bcd_to_decimal(raw_data[1]);
|
||||
processed_data->month = dimagev_bcd_to_decimal(raw_data[2]);
|
||||
processed_data->day = dimagev_bcd_to_decimal(raw_data[3]);
|
||||
processed_data->hour = dimagev_bcd_to_decimal(raw_data[4]);
|
||||
processed_data->minute = dimagev_bcd_to_decimal(raw_data[5]);
|
||||
processed_data->second = dimagev_bcd_to_decimal(raw_data[6]);
|
||||
processed_data->exposure_correction = raw_data[7];
|
||||
processed_data->valid = ( raw_data[8] & 0x80) >> 7;
|
||||
processed_data->id_number = ( raw_data[8] & 0x7F);
|
||||
|
||||
return processed_data;
|
||||
}
|
||||
|
||||
unsigned char *dimagev_export_camera_data(dimagev_data_t *good_data) {
|
||||
unsigned char *export_data;
|
||||
|
||||
if ( ( export_data = malloc(9) ) == NULL ) {
|
||||
perror("dimagev_export_camera_data::unable to allocate buffer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
export_data[0] = 0;
|
||||
export_data[0] = export_data[0] | ( ( ( good_data->host_mode ) << 7 ) & 0x80 );
|
||||
export_data[0] = export_data[0] | ( ( ( good_data->exposure_valid ) << 6 ) & 0x40 );
|
||||
export_data[0] = export_data[0] | ( ( ( good_data->date_valid ) << 5 ) & 0x20 );
|
||||
export_data[0] = export_data[0] | ( ( ( good_data->self_timer_mode ) << 4 ) & 0x10 );
|
||||
export_data[0] = export_data[0] | ( ( ( good_data->flash_mode ) << 2 ) & 0x0C );
|
||||
export_data[0] = export_data[0] | ( ( ( good_data->quality_setting ) << 1 ) & 0x02 );
|
||||
export_data[0] = export_data[0] | ( ( ( good_data->play_rec_mode )) & 0x01 );
|
||||
export_data[1] = 0;
|
||||
export_data[1] = dimagev_decimal_to_bcd(good_data->year);
|
||||
export_data[2] = 0;
|
||||
export_data[2] = dimagev_decimal_to_bcd(good_data->month);
|
||||
export_data[3] = 0;
|
||||
export_data[3] = dimagev_decimal_to_bcd(good_data->day);
|
||||
export_data[4] = 0;
|
||||
export_data[4] = dimagev_decimal_to_bcd(good_data->hour);
|
||||
export_data[5] = 0;
|
||||
export_data[5] = dimagev_decimal_to_bcd(good_data->minute);
|
||||
export_data[6] = 0;
|
||||
export_data[6] = dimagev_decimal_to_bcd(good_data->second);
|
||||
export_data[7] = 0;
|
||||
export_data[7] = good_data->exposure_correction;
|
||||
export_data[8] = 0;
|
||||
export_data[8] = export_data[8] & ( ( ( good_data->valid ) << 7 ) & 0x80 );
|
||||
export_data[8] = export_data[8] & ( ( ( good_data->id_number ) ) & 0x7F );
|
||||
|
||||
return export_data;
|
||||
}
|
||||
|
||||
void dimagev_dump_camera_data(dimagev_data_t *data) {
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "========= Begin Camera Data =========");
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Host mode: %s ( %d )", data->host_mode ? "Host mode" : "Camera mode", data->host_mode);
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Exposure valid: %s ( %d )", data->exposure_valid ? "Valid" : "Not Valid", data->exposure_valid);
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Exposure correction: %d", (signed char)data->exposure_correction);
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Date valid: %s ( %d )", data->date_valid ? "Valid" : "Not Valid", data->exposure_valid);
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Self timer mode: %s ( %d )", data->self_timer_mode ? "Yes" : "No", data->self_timer_mode);
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Flash mode: ");
|
||||
|
||||
switch ( data->flash_mode ) {
|
||||
case 0:
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "\tAuto ( 0 )");
|
||||
break;
|
||||
case 1:
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "\tForce Flash ( 1 )");
|
||||
break;
|
||||
case 2:
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "\tProhibit Flash ( 2 )");
|
||||
break;
|
||||
default:
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "\tInvalid mode for flash ( %d )", data->flash_mode);
|
||||
break;
|
||||
}
|
||||
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Quality mode: %s ( %d )", data->quality_setting ? "High" : "Low", data->quality_setting);
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Play or Record mode: %s ( %d )", data->play_rec_mode ? "Record" : "Play", data->play_rec_mode);
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Date: %02d/%02d/%02d %d:%d:%d", data->year, data->month, data->day, data->hour, data->minute, data->second);
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Card ID Valid: %s ( %d )", data->valid ? "Valid" : "Invalid", data->valid);
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Card ID Data: %02x", data->id_number);
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "========== End Camera Data ==========");
|
||||
|
||||
return;
|
||||
}
|
||||
458
camlibs/minolta/dimagev/dimagev.c
Normal file
458
camlibs/minolta/dimagev/dimagev.c
Normal file
@@ -0,0 +1,458 @@
|
||||
#include "dimagev.h"
|
||||
|
||||
int camera_id (CameraText *id) {
|
||||
|
||||
strcpy(id->text, "minolta-dimagev");
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int camera_abilities (CameraAbilitiesList *list) {
|
||||
|
||||
CameraAbilities *a;
|
||||
|
||||
a = gp_abilities_new();
|
||||
|
||||
strcpy(a->model, "Minolta Dimage V");
|
||||
a->port = GP_PORT_SERIAL;
|
||||
a->speed[0] = 38400;
|
||||
a->speed[1] = 0;
|
||||
a->capture = 1;
|
||||
a->config = 1;
|
||||
a->file_delete = 1;
|
||||
a->file_preview = 1;
|
||||
a->file_put = 1;
|
||||
|
||||
gp_abilities_list_append(list, a);
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int camera_init (Camera *camera, CameraInit *init) {
|
||||
dimagev_t *dimagev = NULL;
|
||||
|
||||
/* First, set up all the function pointers */
|
||||
camera->functions->id = camera_id;
|
||||
camera->functions->abilities = camera_abilities;
|
||||
camera->functions->init = camera_init;
|
||||
camera->functions->exit = camera_exit;
|
||||
camera->functions->folder_list = camera_folder_list;
|
||||
camera->functions->file_list = camera_file_list;
|
||||
camera->functions->file_get = camera_file_get;
|
||||
camera->functions->file_get_preview = camera_file_get_preview;
|
||||
camera->functions->file_put = NULL;
|
||||
camera->functions->file_delete = camera_file_delete;
|
||||
/* camera->functions->config_get = camera_config_get;*/
|
||||
/* camera->functions->config_set = camera_config_set;*/
|
||||
camera->functions->capture = camera_capture;
|
||||
camera->functions->summary = camera_summary;
|
||||
camera->functions->manual = camera_manual;
|
||||
camera->functions->about = camera_about;
|
||||
|
||||
if ( camera->debug != 0 ) {
|
||||
printf("dimagev: initializing the camera\n");
|
||||
}
|
||||
|
||||
if ( ( dimagev = (dimagev_t*) malloc(sizeof(dimagev_t))) == NULL ) {
|
||||
if ( camera->debug != 0 ) {
|
||||
perror("camera_init::unable to allocate dimagev_t");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
camera->camlib_data = dimagev;
|
||||
dimagev->debug = camera->debug;
|
||||
|
||||
/* Now open a port. */
|
||||
if ( ( dimagev->dev = gpio_new(GPIO_DEVICE_SERIAL) ) == NULL ) {
|
||||
if ( camera->debug != 0 ) {
|
||||
perror("camera_init::unable to allocate gpio_dev");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
gpio_set_timeout(dimagev->dev, 5000);
|
||||
|
||||
/* The current max for a path is set to 64. Best to avoide overruns. */
|
||||
strncpy(dimagev->settings.serial.port, init->port.path, 64);
|
||||
dimagev->settings.serial.speed = 38400;
|
||||
dimagev->settings.serial.bits = 8;
|
||||
dimagev->settings.serial.parity = 0;
|
||||
dimagev->settings.serial.stopbits = 1;
|
||||
|
||||
if ( ( dimagev->fs = gp_filesystem_new()) == NULL ) {
|
||||
if ( camera->debug != 0 ) {
|
||||
perror("camera_init::unable to allocate filesystem");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
gpio_set_settings(dimagev->dev, dimagev->settings);
|
||||
gpio_open(dimagev->dev);
|
||||
|
||||
if ( dimagev_get_camera_data(dimagev) == GP_ERROR ) {
|
||||
if ( camera->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "camera_init::unable to get current camera status");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
int camera_exit (Camera *camera) {
|
||||
dimagev_t *dimagev;
|
||||
|
||||
dimagev = camera->camlib_data;
|
||||
|
||||
/* Set the camera back into a normal mode. */
|
||||
|
||||
if ( ( dimagev == NULL ) || ( dimagev->data == NULL ) ) {
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
dimagev_host_mode(dimagev, 0);
|
||||
|
||||
if ( dimagev->dev != NULL ) {
|
||||
gpio_close(dimagev->dev);
|
||||
gpio_free(dimagev->dev);
|
||||
}
|
||||
|
||||
if ( dimagev->fs != NULL ) {
|
||||
gp_filesystem_free(dimagev->fs);
|
||||
}
|
||||
|
||||
if ( dimagev->data != NULL ) {
|
||||
free(dimagev->data);
|
||||
}
|
||||
|
||||
if ( dimagev->status != NULL ) {
|
||||
free(dimagev->status);
|
||||
}
|
||||
|
||||
if ( dimagev->info != NULL ) {
|
||||
free(dimagev->info);
|
||||
}
|
||||
|
||||
free(dimagev);
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int camera_folder_list (Camera *camera, CameraList *list, char *folder) {
|
||||
/* Taking yet another lead from the Panasonic drivers, I'll just */
|
||||
/* return okay, since folders aren't supported on the Minolta Dimage V. */
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
int camera_file_list (Camera *camera, CameraList *list, char *folder) {
|
||||
dimagev_t *dimagev;
|
||||
int i=0;
|
||||
|
||||
dimagev = camera->camlib_data;
|
||||
|
||||
if ( dimagev_get_camera_status(dimagev) != GP_OK ) {
|
||||
if ( camera->debug != 0 ) {
|
||||
perror("camera_file_list::unable to get camera status");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( camera->debug != 0 ) {
|
||||
dimagev_dump_camera_status(dimagev->status);
|
||||
}
|
||||
|
||||
gp_filesystem_populate(dimagev->fs, "/", DIMAGEV_FILENAME_FMT, dimagev->status->number_images);
|
||||
|
||||
for ( i = 0 ; i < dimagev->status->number_images ; i++ ) {
|
||||
gp_list_append(list, gp_filesystem_name(dimagev->fs, "/", i), GP_LIST_FILE);
|
||||
}
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int camera_file_get (Camera *camera, CameraFile *file, char *folder, char *filename) {
|
||||
dimagev_t *dimagev;
|
||||
int file_number=0;
|
||||
|
||||
dimagev = camera->camlib_data;
|
||||
|
||||
file_number = gp_filesystem_number(dimagev->fs, folder, filename);
|
||||
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "file number is %d", file_number);
|
||||
}
|
||||
|
||||
if ( dimagev_get_picture(dimagev, file_number + 1, file) == GP_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "camera_file_get::unable to retireve image file");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
snprintf(file->type, 63, "image/jpg");
|
||||
snprintf(file->name, 63, "%s", filename);
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
int camera_file_get_preview (Camera *camera, CameraFile *file,
|
||||
char *folder, char *filename) {
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int camera_file_put (Camera *camera, CameraFile *file, char *folder) {
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int camera_file_delete (Camera *camera, char *folder, char *filename) {
|
||||
dimagev_t *dimagev;
|
||||
int file_number=0;
|
||||
|
||||
dimagev = camera->camlib_data;
|
||||
|
||||
file_number = gp_filesystem_number(dimagev->fs, folder, filename);
|
||||
|
||||
return dimagev_delete_picture(dimagev, (file_number + 1 ));
|
||||
}
|
||||
|
||||
int camera_config_get (Camera *camera, CameraWidget *window) {
|
||||
printf("Getting config.\n");
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int camera_config_set (Camera *camera, CameraSetting *conf, int count) {
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int camera_capture (Camera *camera, CameraFile *file, CameraCaptureInfo *info) {
|
||||
|
||||
dimagev_t *dimagev;
|
||||
|
||||
dimagev=camera->camlib_data;
|
||||
|
||||
if ( dimagev_shutter(dimagev) == GP_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "camera_capture::unable to open shutter");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
/* Now check how many pictures are taken, and return the last one. */
|
||||
if ( dimagev_get_camera_status(dimagev) ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "camera_capture::unable to get camera status");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( dimagev_get_picture(dimagev, ( dimagev->status->number_images ), file ) == GP_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "camera_capture::unable to retrieve new image");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
/* The Dimage V *always* uses EXIF/JPEG. */
|
||||
snprintf(file->type, 63, "image/jpg");
|
||||
/* Always name the image 0, for predictablity reasons. */
|
||||
snprintf(file->name, 63, DIMAGEV_FILENAME_FMT, 0);
|
||||
|
||||
/* Now delete it. */
|
||||
|
||||
if ( dimagev_delete_picture(dimagev, dimagev->status->number_images ) == GP_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "camera_capture::unable to delete new image");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
int camera_summary (Camera *camera, CameraText *summary) {
|
||||
dimagev_t *dimagev;
|
||||
int i = 0, count = 0;
|
||||
|
||||
dimagev = camera->camlib_data;
|
||||
|
||||
if ( dimagev_get_camera_status(dimagev) != GP_OK ) {
|
||||
if ( camera->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "camera_summary::unable to get camera status");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( dimagev_get_camera_data(dimagev) != GP_OK ) {
|
||||
if ( camera->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "camera_summary::unable to get camera data");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( dimagev_get_camera_info(dimagev) != GP_OK ) {
|
||||
if ( camera->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "camera_summary::unable to get camera info");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( camera->debug != 0 ) {
|
||||
dimagev_dump_camera_status(dimagev->status);
|
||||
dimagev_dump_camera_data(dimagev->data);
|
||||
dimagev_dump_camera_info(dimagev->info);
|
||||
}
|
||||
|
||||
/* Now put all of the information into a reasonably formatted string. */
|
||||
i = 0;
|
||||
/* First the stuff from the dimagev_info_t */
|
||||
i = snprintf(summary->text, 32766, "\t\tGeneral Information\nModel:\t\t\t%s Dimage V (%s)\nHardware Revision:\t%s\nFirmware Revision:\t%s\n\n", dimagev->info->vendor, dimagev->info->model, dimagev->info->hardware_rev, dimagev->info->firmware_rev);
|
||||
|
||||
if ( i > 0 ) {
|
||||
count += i;
|
||||
}
|
||||
|
||||
/* Now the stuff from dimagev_data_t */
|
||||
i = snprintf(&(summary->text[count]), 32766 - count, "\t\tCurrent Information\n"
|
||||
"Host Mode:\t\t%s\n"
|
||||
"Exposure Correction:\t%s\n"
|
||||
"Exposure Data:\t\t%d\n"
|
||||
"Date Valid:\t\t%s\n"
|
||||
"Date:\t\t\t%d/%02d/%02d %02d:%02d:%02d\n"
|
||||
"Self Timer Set:\t\t%s\n"
|
||||
"Quality Setting:\t%s\n"
|
||||
"Play/Record Mode:\t%s\n"
|
||||
"Card ID Valid:\t\t%s\n"
|
||||
"Card ID:\t\t%d\n"
|
||||
"Flash Mode:\t\t",
|
||||
|
||||
( dimagev->data->host_mode ? "Remote" : "Local" ),
|
||||
( dimagev->data->exposure_valid ? "Yes" : "No" ),
|
||||
(signed char)dimagev->data->exposure_correction,
|
||||
( dimagev->data->date_valid ? "Yes" : "No" ),
|
||||
( dimagev->data->year < 70 ? 2000 + dimagev->data->year : 1900 + dimagev->data->year ),
|
||||
dimagev->data->month, dimagev->data->day, dimagev->data->hour,
|
||||
dimagev->data->minute, dimagev->data->second,
|
||||
( dimagev->data->self_timer_mode ? "Yes" : "No"),
|
||||
( dimagev->data->quality_setting ? "Fine" : "Standard" ),
|
||||
( dimagev->data->play_rec_mode ? "Record" : "Play" ),
|
||||
( dimagev->data->valid ? "Yes" : "No"),
|
||||
dimagev->data->id_number );
|
||||
|
||||
if ( i > 0 ) {
|
||||
count += i;
|
||||
}
|
||||
|
||||
/* Flash is a special case, a switch is needed. */
|
||||
switch ( dimagev->data->flash_mode ) {
|
||||
case 0:
|
||||
i = snprintf(&(summary->text[count]), 32766 - count, "Automatic\n");
|
||||
break;
|
||||
case 1:
|
||||
i = snprintf(&(summary->text[count]), 32766 - count, "Force Flash\n");
|
||||
break;
|
||||
case 2:
|
||||
i = snprintf(&(summary->text[count]), 32766 - count, "Prohibit Flash\n");
|
||||
break;
|
||||
default:
|
||||
i = snprintf(&(summary->text[count]), 32766 - count, "Invalid Value ( %d )\n", dimagev->data->flash_mode);
|
||||
break;
|
||||
}
|
||||
|
||||
if ( i > 0 ) {
|
||||
count += i;
|
||||
}
|
||||
|
||||
/* Now for the information in dimagev_status_t */
|
||||
i = snprintf(&(summary->text[count]), 32766 - count,
|
||||
"Battery Level:\t\t%s\n"
|
||||
"Number of Images:\t%d\n"
|
||||
"Minimum Capacity Left:\t%d\n"
|
||||
"Busy:\t\t\t%s\n"
|
||||
"Flash Charging:\t\t%s\n"
|
||||
"Lens Status:\t\t"
|
||||
,
|
||||
( dimagev->status->battery_level ? "Not Full" : "Full" ),
|
||||
dimagev->status->number_images,
|
||||
dimagev->status->minimum_images_can_take,
|
||||
( dimagev->status->busy ? "Busy" : "Idle" ),
|
||||
( dimagev->status->flash_charging ? "Charging" : "Ready" )
|
||||
|
||||
);
|
||||
|
||||
if ( i > 0 ) {
|
||||
count += i;
|
||||
}
|
||||
|
||||
/* Lens status is another switch. */
|
||||
switch ( dimagev->status->lens_status ) {
|
||||
case 0:
|
||||
i = snprintf(&(summary->text[count]), 32766 - count, "Normal\n");
|
||||
break;
|
||||
case 1: case 2:
|
||||
i = snprintf(&(summary->text[count]), 32766 - count, "Lens direction does not match flash light\n");
|
||||
break;
|
||||
case 3:
|
||||
i = snprintf(&(summary->text[count]), 32766 - count, "Lens is not connected\n");
|
||||
break;
|
||||
default:
|
||||
i = snprintf(&(summary->text[count]), 32766 - count, "Bad value for lens status %d\n", dimagev->status->lens_status);
|
||||
break;
|
||||
}
|
||||
|
||||
if ( i > 0 ) {
|
||||
count += i;
|
||||
}
|
||||
|
||||
/* Card status is another switch. */
|
||||
i = snprintf(&(summary->text[count]), 32766 - count, "Card Status:\t\t");
|
||||
if ( i > 0 ) {
|
||||
count += i;
|
||||
}
|
||||
|
||||
switch ( dimagev->status->card_status ) {
|
||||
case 0:
|
||||
i = snprintf(&(summary->text[count]), 32766 - count, "Normal\n");
|
||||
break;
|
||||
case 1:
|
||||
i = snprintf(&(summary->text[count]), 32766 - count, "Full\n");
|
||||
break;
|
||||
case 2:
|
||||
i = snprintf(&(summary->text[count]), 32766 - count, "Write-protected\n");
|
||||
break;
|
||||
case 3:
|
||||
i = snprintf(&(summary->text[count]), 32766 - count, "Unsuitable card\n");
|
||||
break;
|
||||
default:
|
||||
i = snprintf(&(summary->text[count]), 32766 - count, "Bade value for card status %d\n", dimagev->status->card_status);
|
||||
break;
|
||||
}
|
||||
|
||||
if ( i > 0 ) {
|
||||
count += i;
|
||||
}
|
||||
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int camera_manual (Camera *camera, CameraText *manual) {
|
||||
|
||||
strcpy(manual->text, "Manual not available.");
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int camera_about (Camera *camera, CameraText *about) {
|
||||
|
||||
strcpy(about->text,
|
||||
"Minolta Dimage V
|
||||
Gus Hartmann <gphoto@gus-the-cat.org>
|
||||
Simple library for a simple camera.
|
||||
Special thanks to Minolta for the spec.");
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
121
camlibs/minolta/dimagev/dimagev.h
Normal file
121
camlibs/minolta/dimagev/dimagev.h
Normal file
@@ -0,0 +1,121 @@
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <gphoto2.h>
|
||||
#include <gpio.h>
|
||||
|
||||
/* These are the repsonse codes. */
|
||||
#define DIMAGEV_STX 0x02
|
||||
#define DIMAGEV_ETX 0x03
|
||||
#define DIMAGEV_EOT 0x04
|
||||
#define DIMAGEV_ACK 0x06
|
||||
#define DIMAGEV_NAK 0x15
|
||||
#define DIMAGEV_CAN 0x18
|
||||
|
||||
/* These are the commands. */
|
||||
#define DIMAGEV_INQUIRY "\x01"
|
||||
#define DIMAGEV_DRIVE_READY "\x02"
|
||||
#define DIMAGEV_GET_DIR "\x03"
|
||||
#define DIMAGEV_GET_IMAGE "\x04"
|
||||
#define DIMAGEV_ERASE_IMAGE "\x05"
|
||||
#define DIMAGEV_ERASE_ALL "\x06"
|
||||
#define DIMAGEV_GET_STATUS "\x07"
|
||||
#define DIMAGEV_SET_DATA "\x08"
|
||||
#define DIMAGEV_GET_DATA "\x09"
|
||||
#define DIMAGEV_SHUTTER "\x0a"
|
||||
#define DIMAGEV_FORMAT "\x0b"
|
||||
#define DIMAGEV_DIAG "\x0c"
|
||||
#define DIMAGEV_GET_THUMB "\x0d"
|
||||
#define DIMAGEV_SET_IMAGE "\x0e"
|
||||
|
||||
#define DIMAGEV_FILENAME_FMT "dv%05i.jpg"
|
||||
|
||||
typedef struct {
|
||||
unsigned int length;
|
||||
unsigned char buffer[1024];
|
||||
} dimagev_packet;
|
||||
|
||||
typedef struct {
|
||||
unsigned char vendor[8];
|
||||
unsigned char model[8];
|
||||
unsigned char hardware_rev[4];
|
||||
unsigned char firmware_rev[4];
|
||||
unsigned char have_storage;
|
||||
} dimagev_info_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned char battery_level;
|
||||
unsigned int number_images;
|
||||
unsigned int minimum_images_can_take;
|
||||
unsigned char busy;
|
||||
unsigned char flash_charging;
|
||||
unsigned char lens_status;
|
||||
unsigned char card_status;
|
||||
unsigned char id_number;
|
||||
} dimagev_status_t;
|
||||
|
||||
typedef struct {
|
||||
unsigned char host_mode;
|
||||
unsigned char exposure_valid;
|
||||
unsigned char date_valid;
|
||||
unsigned char self_timer_mode;
|
||||
unsigned char flash_mode;
|
||||
unsigned char quality_setting;
|
||||
unsigned char play_rec_mode;
|
||||
unsigned char year;
|
||||
unsigned char month;
|
||||
unsigned char day;
|
||||
unsigned char hour;
|
||||
unsigned char minute;
|
||||
unsigned char second;
|
||||
unsigned char exposure_correction;
|
||||
unsigned char valid;
|
||||
unsigned char id_number;
|
||||
} dimagev_data_t;
|
||||
|
||||
typedef struct {
|
||||
int size;
|
||||
int debug;
|
||||
gpio_device *dev;
|
||||
gpio_device_settings settings;
|
||||
dimagev_data_t *data;
|
||||
dimagev_status_t *status;
|
||||
dimagev_info_t *info;
|
||||
CameraFilesystem *fs;
|
||||
} dimagev_t;
|
||||
|
||||
/* These functions are in packet.c */
|
||||
dimagev_packet *dimagev_make_packet(unsigned char *buffer, unsigned int length, unsigned int seq);
|
||||
dimagev_packet *dimagev_read_packet(dimagev_t *dimagev);
|
||||
int dimagev_verify_packet(dimagev_packet *p);
|
||||
dimagev_packet *dimagev_strip_packet(dimagev_packet *p);
|
||||
void dimagev_dump_packet(dimagev_packet *p);
|
||||
unsigned char dimagev_decimal_to_bcd(unsigned char decimal);
|
||||
unsigned char dimagev_bcd_to_decimal(unsigned char bcd);
|
||||
int dimagev_packet_sequence(dimagev_packet *p);
|
||||
|
||||
/* These functions are in data.c */
|
||||
int dimagev_get_camera_data(dimagev_t *dimagev);
|
||||
dimagev_data_t *dimagev_import_camera_data(unsigned char *raw_data);
|
||||
unsigned char *dimagev_export_camera_data(dimagev_data_t *good_data);
|
||||
void dimagev_dump_camera_data(dimagev_data_t *data);
|
||||
|
||||
/* These functions are in status.c */
|
||||
int dimagev_get_camera_status(dimagev_t *dimagev);
|
||||
dimagev_status_t *dimagev_import_camera_status(unsigned char *raw_data);
|
||||
void dimagev_dump_camera_status(dimagev_status_t *status);
|
||||
|
||||
/* These functions are in info.c */
|
||||
int dimagev_get_camera_info(dimagev_t *dimagev);
|
||||
dimagev_info_t *dimagev_import_camera_info(unsigned char *raw_data);
|
||||
void dimagev_dump_camera_info(dimagev_info_t *info);
|
||||
|
||||
/* These functions are in capture.c */
|
||||
int dimagev_shutter(dimagev_t *dimagev);
|
||||
|
||||
/* These functions are in util.c */
|
||||
int dimagev_host_mode(dimagev_t *dimagev, int newmode);
|
||||
int dimagev_get_picture(dimagev_t *dimagev, int file_number, CameraFile *file);
|
||||
int dimagev_delete_picture(dimagev_t *dimagev, int file_number);
|
||||
int dimagev_delete_all(dimagev_t *dimagev);
|
||||
174
camlibs/minolta/dimagev/info.c
Normal file
174
camlibs/minolta/dimagev/info.c
Normal file
@@ -0,0 +1,174 @@
|
||||
#include "dimagev.h"
|
||||
|
||||
/* This is the parent function, who calls most of the functions below.
|
||||
It returns GP_ERROR if it cannot get the camera data, and GP_OK otherwise.
|
||||
The subroutines will print out more detained information should they fail. */
|
||||
int dimagev_get_camera_info(dimagev_t *dimagev) {
|
||||
dimagev_packet *p, *raw;
|
||||
unsigned char char_buffer;
|
||||
|
||||
/* Check the device. */
|
||||
if ( dimagev->dev == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::device not valid\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
/* Make sure that the old info struct is fred, and allocate a new one. */
|
||||
if ( dimagev->info != NULL ) {
|
||||
free(dimagev->info);
|
||||
}
|
||||
|
||||
/* Let's say hello and get the current status. */
|
||||
if ( ( p = dimagev_make_packet(DIMAGEV_INQUIRY, 1, 0)) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_get_camera_info::unable to allocate packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( gpio_write(dimagev->dev, p->buffer, p->length) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_get_camera_info::unable to write packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
} else if ( gpio_read(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_get_camera_info::no response from camera");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
free(p);
|
||||
|
||||
switch ( char_buffer ) {
|
||||
case DIMAGEV_ACK:
|
||||
break;
|
||||
case DIMAGEV_NAK:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::camera did not acknowledge transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
case DIMAGEV_CAN:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::camera cancels transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
default:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::camera responded with unknown value %x\n", char_buffer);
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ( p = dimagev_read_packet(dimagev) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::unable to read packet\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
char_buffer = DIMAGEV_EOT;
|
||||
if ( gpio_write(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_get_camera_info::unable to send EOT");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( gpio_read(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_get_camera_info::no response from camera");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
switch ( char_buffer ) {
|
||||
case DIMAGEV_ACK:
|
||||
break;
|
||||
case DIMAGEV_NAK:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::camera did not acknowledge transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
case DIMAGEV_CAN:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::camera cancels transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
default:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::camera responded with unknown value %x\n", char_buffer);
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( dimagev->debug != 0 ) {
|
||||
dimagev_dump_packet(p);
|
||||
}
|
||||
|
||||
if ( ( raw = dimagev_strip_packet(p) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::unable to strip data packet\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( ( dimagev->info = dimagev_import_camera_info(raw->buffer) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::unable to read camera info\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/* Sure it *should* get fred automagically, but why take the risk? */
|
||||
free(p);
|
||||
free(raw);
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
dimagev_info_t *dimagev_import_camera_info(unsigned char *raw_data) {
|
||||
dimagev_info_t *info;
|
||||
|
||||
if ( ( info = malloc(sizeof(dimagev_info_t)) ) == NULL ) {
|
||||
perror("dimagev_import_camera_info::unable to allocate dimagev_info_t");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(info->vendor, &(raw_data[0]), 8);
|
||||
info->vendor[7]=0;
|
||||
memcpy(info->model, &(raw_data[8]), 8);
|
||||
info->model[7]=0;
|
||||
memcpy(info->hardware_rev, &(raw_data[16]), 4);
|
||||
info->hardware_rev[3]=0;
|
||||
memcpy(info->firmware_rev, &(raw_data[20]), 4);
|
||||
info->firmware_rev[3]=0;
|
||||
info->have_storage = raw_data[24];
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
void dimagev_dump_camera_info(dimagev_info_t *info) {
|
||||
if ( info == NULL ) {
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_dump_camera_info::unable to read NULL simagev_info_t");
|
||||
return;
|
||||
}
|
||||
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "========= Begin Camera Info =========");
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Vendor: %s", info->vendor);
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Model: %s", info->model);
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Hardware Revision: %s", info->hardware_rev);
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Firmware Revision: %s", info->firmware_rev);
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "========== End Camera Info ==========");
|
||||
|
||||
return;
|
||||
}
|
||||
168
camlibs/minolta/dimagev/packet.c
Normal file
168
camlibs/minolta/dimagev/packet.c
Normal file
@@ -0,0 +1,168 @@
|
||||
#include "dimagev.h"
|
||||
|
||||
dimagev_packet *dimagev_make_packet(unsigned char *buffer, unsigned int length, unsigned int seq) {
|
||||
unsigned int i=0, checksum=0;
|
||||
dimagev_packet *p;
|
||||
|
||||
if ( ( p = calloc(1, sizeof(dimagev_packet) ) ) == NULL ) {
|
||||
perror("dimagev_make_packet::unable to allocate packet");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p->length = length + 7;
|
||||
|
||||
p->buffer[0] = DIMAGEV_STX;
|
||||
p->buffer[1] = seq & 0x000000ff;
|
||||
p->buffer[2] = ( p->length & 0x0000ff00) >> 8;
|
||||
p->buffer[3] = p->length & 0x000000ff;
|
||||
|
||||
memcpy(&(p->buffer[4]), buffer, length);
|
||||
|
||||
/* Now the footer. */
|
||||
for (i=0 ; i < p->length - 3 ; i++ )
|
||||
{
|
||||
checksum += p->buffer[i];
|
||||
}
|
||||
p->buffer[(p->length - 3)] = (checksum & 0x0000ff00) >> 8;
|
||||
p->buffer[(p->length - 2)] = checksum & 0x000000ff;
|
||||
p->buffer[(p->length - 1)] = DIMAGEV_ETX;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/* dimagev_verify_packet(): return 1 if valid packet, 0 otherwise. */
|
||||
int dimagev_verify_packet(dimagev_packet *p) {
|
||||
int i=0;
|
||||
unsigned short correct_checksum=0, current_checksum=0;
|
||||
|
||||
/* All packets must start with DIMAGEV_STX and end with DIMAGEV_ETX. It's an easy check. */
|
||||
if ( ( p->buffer[0] != DIMAGEV_STX ) || ( p->buffer[(p->length - 1)] != DIMAGEV_ETX ) ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
correct_checksum = (p->buffer[(p->length - 3)] * 256) + p->buffer[(p->length - 2)];
|
||||
|
||||
for ( i = 0 ; i < ( p->length - 3 ) ; i++ ) {
|
||||
current_checksum += p->buffer[i];
|
||||
}
|
||||
|
||||
if ( current_checksum != correct_checksum ) {
|
||||
fprintf(stderr, "dimagev_verify_packet::checksum bytes were %02x%02x, checksum was %d, should be %d\n", p->buffer[( p->length - 3) ], p->buffer[ ( p->length -2 ) ], current_checksum, correct_checksum);
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
dimagev_packet *dimagev_read_packet(dimagev_t *dimagev) {
|
||||
dimagev_packet *p;
|
||||
unsigned char char_buffer;
|
||||
|
||||
if ( ( p = malloc(sizeof(dimagev_packet)) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_read_packet::unable to allocate packet");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( gpio_read(dimagev->dev, p->buffer, 4) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_read_packet::unable to read packet header");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p->length = ( p->buffer[2] * 256 ) + ( p->buffer[3] );
|
||||
|
||||
if ( gpio_read(dimagev->dev, &(p->buffer[4]), ( p->length - 4)) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_read_packet::unable to read packet body");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Now we *should* have a packet. Let's do a sanity check. */
|
||||
if ( dimagev_verify_packet(p) == 0 ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_read_packet::got an invalid packet");
|
||||
fprintf(stderr, "dimagev_read_packet::got an invalid packet\n");
|
||||
}
|
||||
free(p);
|
||||
|
||||
/* Send a NAK */
|
||||
char_buffer = DIMAGEV_NAK;
|
||||
if ( gpio_write(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_read_packet::unable to send NAK");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Who likes recursion? */
|
||||
return ( p = dimagev_read_packet(dimagev));
|
||||
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
void dimagev_dump_packet(dimagev_packet *p) {
|
||||
int i=0;
|
||||
|
||||
printf("Packet length is %d\n", p->length);
|
||||
|
||||
for ( i = 0 ; i < p->length ; i++ ) {
|
||||
printf("%02x ", p->buffer[i]);
|
||||
}
|
||||
printf("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
dimagev_packet *dimagev_strip_packet(dimagev_packet *p) {
|
||||
dimagev_packet *stripped;
|
||||
|
||||
/* All camera packets must start with DIMAGEV_STX and end with DIMAGEV_ETX. */
|
||||
/* Packets used as strings shouldn't have these. It's an easy check. */
|
||||
if ( ( p->buffer[0] != DIMAGEV_STX ) || ( p->buffer[(p->length - 1)] != DIMAGEV_ETX ) ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( ( stripped = malloc(sizeof(dimagev_packet)) ) == NULL ) {
|
||||
perror("dimagev_strip_packet::unable to allocate destination packet");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
stripped->length = ( p->length - 7 );
|
||||
|
||||
memcpy(stripped->buffer, &(p->buffer[4]), stripped->length);
|
||||
|
||||
return stripped;
|
||||
}
|
||||
|
||||
unsigned char dimagev_decimal_to_bcd(unsigned char decimal) {
|
||||
unsigned char bcd=0;
|
||||
int tensdigit=0;
|
||||
|
||||
if ( decimal > 99 ) {
|
||||
/* No good way to handle this. */
|
||||
return 0;
|
||||
} else {
|
||||
tensdigit = decimal / 10;
|
||||
bcd = tensdigit * 16;
|
||||
bcd += tensdigit % 10;
|
||||
return bcd;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char dimagev_bcd_to_decimal(unsigned char bcd) {
|
||||
if ( bcd > 99 ) {
|
||||
/* The highest value that we can handle in BCD */
|
||||
return 99;
|
||||
} else {
|
||||
return ((bcd/16)*10 + (bcd%16));
|
||||
}
|
||||
}
|
||||
|
||||
int dimagev_packet_sequence(dimagev_packet *p) {
|
||||
return p->buffer[1];
|
||||
}
|
||||
206
camlibs/minolta/dimagev/status.c
Normal file
206
camlibs/minolta/dimagev/status.c
Normal file
@@ -0,0 +1,206 @@
|
||||
#include "dimagev.h"
|
||||
|
||||
|
||||
/* This is the parent function, who calls most of the functions below.
|
||||
It returns GP_ERROR if it cannot get the camera data, and GP_OK otherwise.
|
||||
The subroutines will print out more detained information should they fail. */
|
||||
int dimagev_get_camera_status(dimagev_t *dimagev) {
|
||||
dimagev_packet *p, *raw;
|
||||
unsigned char char_buffer;
|
||||
|
||||
/* Check the device. */
|
||||
if ( dimagev->dev == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::device not valid");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
/* Let's say hello and get the current status. */
|
||||
if ( ( p = dimagev_make_packet(DIMAGEV_GET_STATUS, 1, 0)) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_get_camera_status::unable to allocate packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( gpio_write(dimagev->dev, p->buffer, p->length) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_get_camera_status::unable to write packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
} else if ( gpio_read(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_get_camera_status::no response from camera");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
free(p);
|
||||
|
||||
switch ( char_buffer ) {
|
||||
case DIMAGEV_ACK:
|
||||
break;
|
||||
case DIMAGEV_NAK:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::camera did not acknowledge transmission");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
case DIMAGEV_CAN:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::camera cancels transmission");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
default:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::camera responded with unknown value %x", char_buffer);
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ( p = dimagev_read_packet(dimagev) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::unable to read packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
char_buffer = DIMAGEV_EOT;
|
||||
if ( gpio_write(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_get_camera_status::unable to send EOT");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( gpio_read(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_get_camera_status::no response from camera");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
switch ( char_buffer ) {
|
||||
case DIMAGEV_ACK:
|
||||
break;
|
||||
case DIMAGEV_NAK:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::camera did not acknowledge transmission");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
case DIMAGEV_CAN:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::camera cancels transmission");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
default:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::camera responded with unknown value %x", char_buffer);
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( dimagev->debug != 0 ) {
|
||||
dimagev_dump_packet(p);
|
||||
}
|
||||
|
||||
if ( ( raw = dimagev_strip_packet(p) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::unable to strip data packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( ( dimagev->status = dimagev_import_camera_status(raw->buffer) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::unable to read camera status");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
dimagev_status_t *dimagev_import_camera_status(unsigned char *raw_data) {
|
||||
dimagev_status_t *processed_data;
|
||||
|
||||
if ( raw_data == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( ( processed_data = malloc(sizeof(dimagev_status_t)) ) == NULL ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
processed_data->battery_level = raw_data[0];
|
||||
processed_data->number_images = ( raw_data[1] * 256 ) + ( raw_data[2] );
|
||||
processed_data->minimum_images_can_take = ( raw_data[3] * 256 ) + ( raw_data[4] );
|
||||
processed_data->busy = ( raw_data[5] & 0x40 ) >> 6;
|
||||
processed_data->flash_charging = ( raw_data[5] & 0x10 ) >> 4;
|
||||
processed_data->lens_status = ( raw_data[5] & 0x0c ) >> 2 ;
|
||||
processed_data->card_status = ( raw_data[5] & 0x03 );
|
||||
processed_data->id_number = raw_data[6];
|
||||
|
||||
return processed_data;
|
||||
}
|
||||
|
||||
void dimagev_dump_camera_status(dimagev_status_t *status) {
|
||||
|
||||
if ( status == NULL ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "Unable to dump NULL status");
|
||||
return;
|
||||
}
|
||||
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "========= Begin Camera Status =========");
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Battery level: %d", status->battery_level);
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Number of images: %d", status->number_images);
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Minimum images remaining: %d", status->minimum_images_can_take);
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Busy: %s ( %d )", status->busy ? "Busy" : "Not Busy", status->busy);
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Flash charging: %s ( %d )", status->flash_charging ? "Charging" : "Ready", status->flash_charging);
|
||||
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Lens status: ");
|
||||
switch ( status->lens_status ) {
|
||||
case 0:
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Normal ( 0 )");
|
||||
break;
|
||||
case 1: case 2:
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Lens direction does not match flash light ( %d )", status->lens_status );
|
||||
break;
|
||||
case 3:
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Lens is not attached ( 3 )");
|
||||
break;
|
||||
default:
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Bad value for lens status ( %d )", status->lens_status);
|
||||
break;
|
||||
}
|
||||
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Card status: ");
|
||||
switch ( status->card_status ) {
|
||||
case 0:
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Normal ( 0 )");
|
||||
break;
|
||||
case 1:
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Full ( 1 )");
|
||||
break;
|
||||
case 2:
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Write-protected ( 2 )");
|
||||
break;
|
||||
case 3:
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Card not valid for this camera ( 3 )");
|
||||
break;
|
||||
default:
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Invalid value for card status ( %d )\n", status->card_status);
|
||||
break;
|
||||
}
|
||||
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Card ID Data: %02x", status->id_number);
|
||||
gp_debug_printf(GP_DEBUG_LOW, "dimagev", "========== End Camera Status ==========");
|
||||
|
||||
return;
|
||||
}
|
||||
476
camlibs/minolta/dimagev/util.c
Normal file
476
camlibs/minolta/dimagev/util.c
Normal file
@@ -0,0 +1,476 @@
|
||||
#include "dimagev.h"
|
||||
|
||||
int dimagev_host_mode(dimagev_t *dimagev, int newmode) {
|
||||
dimagev_packet *p;
|
||||
unsigned char *export_data, char_buffer;
|
||||
|
||||
|
||||
if ( dimagev == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_capture::unable to use NULL dimagev_t");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
dimagev->data->host_mode = newmode;
|
||||
|
||||
if ( ( export_data = dimagev_export_camera_data(dimagev->data) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_capture::unable to export camera data");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( dimagev->debug != 0 ) {
|
||||
dimagev_dump_camera_data(dimagev->data);
|
||||
}
|
||||
|
||||
if ( ( p = dimagev_make_packet(DIMAGEV_SET_DATA, 1, 0) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_capture::unable to create set_data packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( gpio_write(dimagev->dev, p->buffer, p->length) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_capture::unable to send set_data packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
} else if ( gpio_read(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_get_camera_data::no response from camera");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
free(p);
|
||||
|
||||
switch ( char_buffer ) {
|
||||
case DIMAGEV_ACK:
|
||||
break;
|
||||
case DIMAGEV_NAK:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_capture::camera did not acknowledge transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
case DIMAGEV_CAN:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_capture::camera cancels transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
default:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_capture::camera responded with unknown value %x\n", char_buffer);
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ( p = dimagev_make_packet(export_data, 9, 1) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_capture::unable to create set_data packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( dimagev->debug != 0 ) {
|
||||
dimagev_dump_packet(p);
|
||||
}
|
||||
|
||||
if ( gpio_write(dimagev->dev, p->buffer, p->length) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_capture::unable to send data packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( gpio_read(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_get_camera_data::no response from camera");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
switch ( char_buffer ) {
|
||||
case DIMAGEV_ACK:
|
||||
break;
|
||||
case DIMAGEV_NAK:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_data::camera did not acknowledge transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
case DIMAGEV_CAN:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_data::camera cancels transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
default:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_data::camera responded with unknown value %x\n", char_buffer);
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
char_buffer = DIMAGEV_EOT;
|
||||
if ( gpio_write(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_get_camera_data::unable to send EOT");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( gpio_read(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_get_camera_data::no response from camera");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
switch ( char_buffer ) {
|
||||
case DIMAGEV_ACK:
|
||||
break;
|
||||
case DIMAGEV_NAK:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_data::camera did not acknowledge transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
case DIMAGEV_CAN:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_data::camera cancels transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
default:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_data::camera responded with unknown value %x\n", char_buffer);
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
int dimagev_get_picture(dimagev_t *dimagev, int file_number, CameraFile *file) {
|
||||
int length, total_packets, i;
|
||||
dimagev_packet *p, *r;
|
||||
unsigned char char_buffer, command_buffer[8];
|
||||
|
||||
if ( dimagev_host_mode(dimagev, 1) == GP_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to set host mode");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::file_number is %d", file_number);
|
||||
|
||||
/* Maybe check if it exists? Check the file type? */
|
||||
|
||||
/* First make the command packet. */
|
||||
command_buffer[0] = 0x04;
|
||||
command_buffer[1] = (unsigned char)( file_number / 256 );
|
||||
command_buffer[2] = (unsigned char)( file_number % 256 );
|
||||
if ( ( p = dimagev_make_packet(command_buffer, 3, 0) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to allocate command packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( gpio_write(dimagev->dev, p->buffer, p->length) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to send set_data packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
} else if ( gpio_read(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_get_picture::no response from camera");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
free(p);
|
||||
|
||||
switch ( char_buffer ) {
|
||||
case DIMAGEV_ACK:
|
||||
break;
|
||||
case DIMAGEV_NAK:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::camera did not acknowledge transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
case DIMAGEV_CAN:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::camera cancels transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
default:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::camera responded with unknown value %x\n", char_buffer);
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ( p = dimagev_read_packet(dimagev) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to read packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( ( r = dimagev_strip_packet(p) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to strip packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
free(p);
|
||||
|
||||
total_packets = r->buffer[0];
|
||||
length = ( r->length - 1 );
|
||||
|
||||
/* Allocate an extra byte just in case. */
|
||||
if ( ( file->data = malloc((993 * total_packets) + 1) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to allocate buffer for file");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
memcpy(file->data, &(r->buffer[1]), r->length );
|
||||
file->size += ( r->length - 2 );
|
||||
|
||||
free(r);
|
||||
|
||||
for ( i = 0 ; i < ( total_packets -1 ) ; i++ ) {
|
||||
|
||||
char_buffer=DIMAGEV_ACK;
|
||||
if ( gpio_write(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to send ACK");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( ( p = dimagev_read_packet(dimagev) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to read packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( ( r = dimagev_strip_packet(p) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to strip packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
free(p);
|
||||
|
||||
memcpy(&( file->data[ ( file->size + 1) ] ), r->buffer, r->length );
|
||||
file->size += r->length;
|
||||
|
||||
free(r);
|
||||
}
|
||||
|
||||
file->size++;
|
||||
|
||||
char_buffer=DIMAGEV_EOT;
|
||||
if ( gpio_write(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to send ACK");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( gpio_read(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_get_picture::no response from camera");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
switch ( char_buffer ) {
|
||||
case DIMAGEV_ACK:
|
||||
break;
|
||||
case DIMAGEV_NAK:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::camera did not acknowledge transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
case DIMAGEV_CAN:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::camera cancels transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
default:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::camera responded with unknown value %x\n", char_buffer);
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Now set the camera back into local mode. */
|
||||
if ( dimagev_host_mode(dimagev, 0) == GP_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to leave host mode");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
int dimagev_delete_picture(dimagev_t *dimagev, int file_number) {
|
||||
dimagev_packet *p, *raw;
|
||||
unsigned char char_buffer, command_buffer[8];
|
||||
|
||||
if ( dimagev == NULL ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::unable to use NULL dimagev_t");
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
dimagev_host_mode(dimagev, 1);
|
||||
|
||||
/* First make the command packet. */
|
||||
command_buffer[0] = 0x05;
|
||||
command_buffer[1] = (unsigned char)( file_number / 256 );
|
||||
command_buffer[2] = (unsigned char)( file_number % 256 );
|
||||
if ( ( p = dimagev_make_packet(command_buffer, 3, 0) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::unable to allocate command packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( gpio_write(dimagev->dev, p->buffer, p->length) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::unable to send set_data packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
} else if ( gpio_read(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_delete_picture::no response from camera");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
free(p);
|
||||
|
||||
switch ( char_buffer ) {
|
||||
case DIMAGEV_ACK:
|
||||
break;
|
||||
case DIMAGEV_NAK:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::camera did not acknowledge transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
case DIMAGEV_CAN:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::camera cancels transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
default:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::camera responded with unknown value %x\n", char_buffer);
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ( ( p = dimagev_read_packet(dimagev) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::unable to read packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( ( raw = dimagev_strip_packet(p) ) == NULL ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::unable to strip packet");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
free(p);
|
||||
|
||||
if ( raw->buffer[0] != 0 ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::delete returned error code");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
char_buffer=DIMAGEV_EOT;
|
||||
if ( gpio_write(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to send ACK");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
if ( gpio_read(dimagev->dev, &char_buffer, 1) == GPIO_ERROR ) {
|
||||
if ( dimagev->debug != 0 ) {
|
||||
perror("dimagev_delete_picture::no response from camera");
|
||||
}
|
||||
return GP_ERROR;
|
||||
}
|
||||
|
||||
switch ( char_buffer ) {
|
||||
case DIMAGEV_ACK:
|
||||
break;
|
||||
case DIMAGEV_NAK:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::camera did not acknowledge transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
case DIMAGEV_CAN:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::camera cancels transmission\n");
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
default:
|
||||
if ( dimagev->debug != 0 ) {
|
||||
gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::camera responded with unknown value %x\n", char_buffer);
|
||||
}
|
||||
return GP_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
dimagev_host_mode(dimagev, 0);
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
int dimagev_delete_all(dimagev_t *dimagev) {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user