From 46f2c1134d276944fb74584a61d90cc363aee7eb Mon Sep 17 00:00:00 2001 From: Benjamin Dobell Date: Sun, 5 Dec 2010 00:25:04 +1100 Subject: Removed the "Heimdall" folder and moved its contents to the root directory. --- libusb-1.0/examples/.DS_Store | Bin 0 -> 6148 bytes libusb-1.0/examples/._.DS_Store | Bin 0 -> 4096 bytes libusb-1.0/examples/.deps/dpfp.Po | 1 + .../examples/.deps/dpfp_threaded-dpfp_threaded.Po | 1 + libusb-1.0/examples/.deps/lsusb.Po | 1 + libusb-1.0/examples/.deps/xusb.Po | 1 + libusb-1.0/examples/Makefile | 561 +++++++++++++ libusb-1.0/examples/Makefile.am | 23 + libusb-1.0/examples/Makefile.in | 561 +++++++++++++ libusb-1.0/examples/_lsusb_2008.vcproj | 321 ++++++++ libusb-1.0/examples/_xusb_2008.vcproj | 319 ++++++++ libusb-1.0/examples/dpfp.c | 508 ++++++++++++ libusb-1.0/examples/dpfp_threaded.c | 546 +++++++++++++ libusb-1.0/examples/lsusb.c | 64 ++ libusb-1.0/examples/xusb.c | 867 +++++++++++++++++++++ 15 files changed, 3774 insertions(+) create mode 100644 libusb-1.0/examples/.DS_Store create mode 100644 libusb-1.0/examples/._.DS_Store create mode 100644 libusb-1.0/examples/.deps/dpfp.Po create mode 100644 libusb-1.0/examples/.deps/dpfp_threaded-dpfp_threaded.Po create mode 100644 libusb-1.0/examples/.deps/lsusb.Po create mode 100644 libusb-1.0/examples/.deps/xusb.Po create mode 100644 libusb-1.0/examples/Makefile create mode 100644 libusb-1.0/examples/Makefile.am create mode 100644 libusb-1.0/examples/Makefile.in create mode 100644 libusb-1.0/examples/_lsusb_2008.vcproj create mode 100644 libusb-1.0/examples/_xusb_2008.vcproj create mode 100644 libusb-1.0/examples/dpfp.c create mode 100644 libusb-1.0/examples/dpfp_threaded.c create mode 100644 libusb-1.0/examples/lsusb.c create mode 100644 libusb-1.0/examples/xusb.c (limited to 'libusb-1.0/examples') diff --git a/libusb-1.0/examples/.DS_Store b/libusb-1.0/examples/.DS_Store new file mode 100644 index 0000000..de43283 Binary files /dev/null and b/libusb-1.0/examples/.DS_Store differ diff --git a/libusb-1.0/examples/._.DS_Store b/libusb-1.0/examples/._.DS_Store new file mode 100644 index 0000000..338bd7b Binary files /dev/null and b/libusb-1.0/examples/._.DS_Store differ diff --git a/libusb-1.0/examples/.deps/dpfp.Po b/libusb-1.0/examples/.deps/dpfp.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/libusb-1.0/examples/.deps/dpfp.Po @@ -0,0 +1 @@ +# dummy diff --git a/libusb-1.0/examples/.deps/dpfp_threaded-dpfp_threaded.Po b/libusb-1.0/examples/.deps/dpfp_threaded-dpfp_threaded.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/libusb-1.0/examples/.deps/dpfp_threaded-dpfp_threaded.Po @@ -0,0 +1 @@ +# dummy diff --git a/libusb-1.0/examples/.deps/lsusb.Po b/libusb-1.0/examples/.deps/lsusb.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/libusb-1.0/examples/.deps/lsusb.Po @@ -0,0 +1 @@ +# dummy diff --git a/libusb-1.0/examples/.deps/xusb.Po b/libusb-1.0/examples/.deps/xusb.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/libusb-1.0/examples/.deps/xusb.Po @@ -0,0 +1 @@ +# dummy diff --git a/libusb-1.0/examples/Makefile b/libusb-1.0/examples/Makefile new file mode 100644 index 0000000..bd4c858 --- /dev/null +++ b/libusb-1.0/examples/Makefile @@ -0,0 +1,561 @@ +# Makefile.in generated by automake 1.11 from Makefile.am. +# examples/Makefile. Generated from Makefile.in by configure. + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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. + + + + +pkgdatadir = $(datadir)/libusb +pkgincludedir = $(includedir)/libusb +pkglibdir = $(libdir)/libusb +pkglibexecdir = $(libexecdir)/libusb +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = i386-apple-darwin10.0.0 +host_triplet = i386-apple-darwin10.0.0 +noinst_PROGRAMS = xusb$(EXEEXT) lsusb$(EXEEXT) $(am__EXEEXT_1) \ + $(am__EXEEXT_2) +am__append_1 = dpfp +am__append_2 = dpfp_threaded +subdir = examples +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__EXEEXT_1 = dpfp$(EXEEXT) +am__EXEEXT_2 = dpfp_threaded$(EXEEXT) +PROGRAMS = $(noinst_PROGRAMS) +am__dpfp_SOURCES_DIST = dpfp.c +am_dpfp_OBJECTS = dpfp.$(OBJEXT) +dpfp_OBJECTS = $(am_dpfp_OBJECTS) +dpfp_DEPENDENCIES = ../libusb/libusb-1.0.la +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent +am__dpfp_threaded_SOURCES_DIST = dpfp_threaded.c +am_dpfp_threaded_OBJECTS = dpfp_threaded-dpfp_threaded.$(OBJEXT) +dpfp_threaded_OBJECTS = $(am_dpfp_threaded_OBJECTS) +dpfp_threaded_DEPENDENCIES = ../libusb/libusb-1.0.la +dpfp_threaded_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(dpfp_threaded_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +am_lsusb_OBJECTS = lsusb.$(OBJEXT) +lsusb_OBJECTS = $(am_lsusb_OBJECTS) +lsusb_DEPENDENCIES = ../libusb/libusb-1.0.la +am_xusb_OBJECTS = xusb.$(OBJEXT) +xusb_OBJECTS = $(am_xusb_OBJECTS) +xusb_DEPENDENCIES = ../libusb/libusb-1.0.la +DEFAULT_INCLUDES = -I. -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_$(V)) +am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_$(V)) +am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(dpfp_SOURCES) $(dpfp_threaded_SOURCES) $(lsusb_SOURCES) \ + $(xusb_SOURCES) +DIST_SOURCES = $(am__dpfp_SOURCES_DIST) \ + $(am__dpfp_threaded_SOURCES_DIST) $(lsusb_SOURCES) \ + $(xusb_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = ${SHELL} /Users/Ben/Desktop/heimdall-1.1.0/libusb-1.0/missing --run aclocal-1.11 +AMTAR = ${SHELL} /Users/Ben/Desktop/heimdall-1.1.0/libusb-1.0/missing --run tar +AM_CFLAGS = -std=gnu99 -fgnu89-inline -Wall -Wundef -Wunused -Wstrict-prototypes -Werror-implicit-function-declaration -Wno-pointer-sign -Wshadow +AM_DEFAULT_VERBOSITY = 0 +AM_LDFLAGS = -Wl,-framework,IOKit -Wl,-framework,CoreFoundation -Wl,-prebind -no-undefined -pthread +AR = ar +AUTOCONF = ${SHELL} /Users/Ben/Desktop/heimdall-1.1.0/libusb-1.0/missing --run autoconf +AUTOHEADER = ${SHELL} /Users/Ben/Desktop/heimdall-1.1.0/libusb-1.0/missing --run autoheader +AUTOMAKE = ${SHELL} /Users/Ben/Desktop/heimdall-1.1.0/libusb-1.0/missing --run automake-1.11 +AWK = gawk +CC = gcc +CCDEPMODE = depmode=gcc3 +CFLAGS = -g -O2 +CPP = gcc -E +CPPFLAGS = +CYGPATH_W = echo +DEFS = -DHAVE_CONFIG_H +DEPDIR = .deps +DLLTOOL = +DSYMUTIL = dsymutil +DUMPBIN = +ECHO_C = \c +ECHO_N = +ECHO_T = +EGREP = /usr/bin/grep -E +EXEEXT = +FGREP = /usr/bin/grep -F +GREP = /usr/bin/grep +INSTALL = /usr/bin/install -c +INSTALL_DATA = ${INSTALL} -m 644 +INSTALL_PROGRAM = ${INSTALL} +INSTALL_SCRIPT = ${INSTALL} +INSTALL_STRIP_PROGRAM = $(install_sh) -c -s +LD = /usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld +LDFLAGS = +LIBOBJS = +LIBS = +LIBTOOL = $(SHELL) $(top_builddir)/libtool +LIBUSB_VERSION_MAJOR = 1 +LIBUSB_VERSION_MICRO = 8 +LIBUSB_VERSION_MINOR = 0 +LIBUSB_VERSION_NANO = 10323 +LIPO = lipo +LN_S = ln -s +LTLIBOBJS = +MAINT = +MAKEINFO = ${SHELL} /Users/Ben/Desktop/heimdall-1.1.0/libusb-1.0/missing --run makeinfo +MKDIR_P = .././install-sh -c -d +NM = /usr/bin/nm +NMEDIT = nmedit +OBJDUMP = false +OBJEXT = o +OS_DARWIN = +OS_LINUX = +OS_WINDOWS = +OTOOL = otool +OTOOL64 = : +PACKAGE = libusb +PACKAGE_BUGREPORT = libusb-devel@lists.sourceforge.net +PACKAGE_NAME = libusb +PACKAGE_STRING = libusb 1.0.8 +PACKAGE_TARNAME = libusb +PACKAGE_URL = http://www.libusb.org/ +PACKAGE_VERSION = 1.0.8 +PATH_SEPARATOR = : +PC_LIBS_PRIVATE = -Wl,-framework,IOKit -Wl,-framework,CoreFoundation -Wl,-prebind -no-undefined -pthread +RANLIB = ranlib +RC = +SED = /opt/local/bin/gsed +SET_MAKE = +SHELL = /bin/sh +STRIP = strip +THREAD_CFLAGS = -pthread +VERSION = 1.0.8 +VISIBILITY_CFLAGS = -fvisibility=hidden +abs_builddir = /Users/Ben/Desktop/heimdall-1.1.0/libusb-1.0/examples +abs_srcdir = /Users/Ben/Desktop/heimdall-1.1.0/libusb-1.0/examples +abs_top_builddir = /Users/Ben/Desktop/heimdall-1.1.0/libusb-1.0 +abs_top_srcdir = /Users/Ben/Desktop/heimdall-1.1.0/libusb-1.0 +ac_ct_CC = gcc +ac_ct_DUMPBIN = +am__include = include +am__leading_dot = . +am__quote = +am__tar = ${AMTAR} chof - "$$tardir" +am__untar = ${AMTAR} xf - +bindir = ${exec_prefix}/bin +build = i386-apple-darwin10.0.0 +build_alias = +build_cpu = i386 +build_os = darwin10.0.0 +build_vendor = apple +builddir = . +datadir = ${datarootdir} +datarootdir = ${prefix}/share +docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} +dvidir = ${docdir} +exec_prefix = ${prefix} +host = i386-apple-darwin10.0.0 +host_alias = +host_cpu = i386 +host_os = darwin10.0.0 +host_vendor = apple +htmldir = ${docdir} +includedir = ${prefix}/include +infodir = ${datarootdir}/info +install_sh = ${SHELL} /Users/Ben/Desktop/heimdall-1.1.0/libusb-1.0/install-sh +libdir = ${exec_prefix}/lib +libexecdir = ${exec_prefix}/libexec +localedir = ${datarootdir}/locale +localstatedir = ${prefix}/var +lt_ECHO = /bin/echo +lt_age = 1 +lt_current = 1 +lt_revision = 0 +mandir = ${datarootdir}/man +mkdir_p = $(top_builddir)/./install-sh -c -d +oldincludedir = /usr/include +pdfdir = ${docdir} +prefix = /usr/local +program_transform_name = s,x,x, +psdir = ${docdir} +sbindir = ${exec_prefix}/sbin +sharedstatedir = ${prefix}/com +srcdir = . +sysconfdir = ${prefix}/etc +target_alias = +top_build_prefix = ../ +top_builddir = .. +top_srcdir = .. +INCLUDES = -I$(top_srcdir)/libusb +lsusb_SOURCES = lsusb.c +lsusb_LDADD = ../libusb/libusb-1.0.la -lusb-1.0 +xusb_SOURCES = xusb.c +xusb_LDADD = ../libusb/libusb-1.0.la -lusb-1.0 +dpfp_SOURCES = dpfp.c +dpfp_LDADD = ../libusb/libusb-1.0.la -lusb-1.0 +dpfp_threaded_SOURCES = dpfp_threaded.c +dpfp_threaded_CFLAGS = $(THREAD_CFLAGS) $(AM_CFLAGS) +dpfp_threaded_LDADD = ../libusb/libusb-1.0.la -lusb-1.0 +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu examples/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu examples/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +dpfp$(EXEEXT): $(dpfp_OBJECTS) $(dpfp_DEPENDENCIES) + @rm -f dpfp$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(dpfp_OBJECTS) $(dpfp_LDADD) $(LIBS) +dpfp_threaded$(EXEEXT): $(dpfp_threaded_OBJECTS) $(dpfp_threaded_DEPENDENCIES) + @rm -f dpfp_threaded$(EXEEXT) + $(AM_V_CCLD)$(dpfp_threaded_LINK) $(dpfp_threaded_OBJECTS) $(dpfp_threaded_LDADD) $(LIBS) +lsusb$(EXEEXT): $(lsusb_OBJECTS) $(lsusb_DEPENDENCIES) + @rm -f lsusb$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(lsusb_OBJECTS) $(lsusb_LDADD) $(LIBS) +xusb$(EXEEXT): $(xusb_OBJECTS) $(xusb_DEPENDENCIES) + @rm -f xusb$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(xusb_OBJECTS) $(xusb_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +include ./$(DEPDIR)/dpfp.Po +include ./$(DEPDIR)/dpfp_threaded-dpfp_threaded.Po +include ./$(DEPDIR)/lsusb.Po +include ./$(DEPDIR)/xusb.Po + +.c.o: + $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< + $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# $(AM_V_CC) \ +# source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c $< + +.c.obj: + $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` + $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +# $(AM_V_CC) \ +# source='$<' object='$@' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: + $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< + $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +# $(AM_V_CC) \ +# source='$<' object='$@' libtool=yes \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(LTCOMPILE) -c -o $@ $< + +dpfp_threaded-dpfp_threaded.o: dpfp_threaded.c + $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(dpfp_threaded_CFLAGS) $(CFLAGS) -MT dpfp_threaded-dpfp_threaded.o -MD -MP -MF $(DEPDIR)/dpfp_threaded-dpfp_threaded.Tpo -c -o dpfp_threaded-dpfp_threaded.o `test -f 'dpfp_threaded.c' || echo '$(srcdir)/'`dpfp_threaded.c + $(AM_V_at)$(am__mv) $(DEPDIR)/dpfp_threaded-dpfp_threaded.Tpo $(DEPDIR)/dpfp_threaded-dpfp_threaded.Po +# $(AM_V_CC) \ +# source='dpfp_threaded.c' object='dpfp_threaded-dpfp_threaded.o' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(dpfp_threaded_CFLAGS) $(CFLAGS) -c -o dpfp_threaded-dpfp_threaded.o `test -f 'dpfp_threaded.c' || echo '$(srcdir)/'`dpfp_threaded.c + +dpfp_threaded-dpfp_threaded.obj: dpfp_threaded.c + $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(dpfp_threaded_CFLAGS) $(CFLAGS) -MT dpfp_threaded-dpfp_threaded.obj -MD -MP -MF $(DEPDIR)/dpfp_threaded-dpfp_threaded.Tpo -c -o dpfp_threaded-dpfp_threaded.obj `if test -f 'dpfp_threaded.c'; then $(CYGPATH_W) 'dpfp_threaded.c'; else $(CYGPATH_W) '$(srcdir)/dpfp_threaded.c'; fi` + $(AM_V_at)$(am__mv) $(DEPDIR)/dpfp_threaded-dpfp_threaded.Tpo $(DEPDIR)/dpfp_threaded-dpfp_threaded.Po +# $(AM_V_CC) \ +# source='dpfp_threaded.c' object='dpfp_threaded-dpfp_threaded.obj' libtool=no \ +# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ +# $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(dpfp_threaded_CFLAGS) $(CFLAGS) -c -o dpfp_threaded-dpfp_threaded.obj `if test -f 'dpfp_threaded.c'; then $(CYGPATH_W) 'dpfp_threaded.c'; else $(CYGPATH_W) '$(srcdir)/dpfp_threaded.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstPROGRAMS ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am + + +# 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: diff --git a/libusb-1.0/examples/Makefile.am b/libusb-1.0/examples/Makefile.am new file mode 100644 index 0000000..e8a4516 --- /dev/null +++ b/libusb-1.0/examples/Makefile.am @@ -0,0 +1,23 @@ +INCLUDES = -I$(top_srcdir)/libusb +noinst_PROGRAMS = xusb lsusb + +lsusb_SOURCES = lsusb.c +lsusb_LDADD = ../libusb/libusb-1.0.la -lusb-1.0 + +xusb_SOURCES = xusb.c +xusb_LDADD = ../libusb/libusb-1.0.la -lusb-1.0 + +if HAVE_SIGACTION +dpfp_SOURCES = dpfp.c +dpfp_LDADD = ../libusb/libusb-1.0.la -lusb-1.0 +noinst_PROGRAMS += dpfp +endif + +if THREADS_POSIX +if HAVE_SIGACTION +dpfp_threaded_SOURCES = dpfp_threaded.c +dpfp_threaded_CFLAGS = $(THREAD_CFLAGS) $(AM_CFLAGS) +dpfp_threaded_LDADD = ../libusb/libusb-1.0.la -lusb-1.0 +noinst_PROGRAMS += dpfp_threaded +endif +endif diff --git a/libusb-1.0/examples/Makefile.in b/libusb-1.0/examples/Makefile.in new file mode 100644 index 0000000..57ce925 --- /dev/null +++ b/libusb-1.0/examples/Makefile.in @@ -0,0 +1,561 @@ +# Makefile.in generated by automake 1.11 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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. + +@SET_MAKE@ + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +noinst_PROGRAMS = xusb$(EXEEXT) lsusb$(EXEEXT) $(am__EXEEXT_1) \ + $(am__EXEEXT_2) +@HAVE_SIGACTION_TRUE@am__append_1 = dpfp +@HAVE_SIGACTION_TRUE@@THREADS_POSIX_TRUE@am__append_2 = dpfp_threaded +subdir = examples +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +@HAVE_SIGACTION_TRUE@am__EXEEXT_1 = dpfp$(EXEEXT) +@HAVE_SIGACTION_TRUE@@THREADS_POSIX_TRUE@am__EXEEXT_2 = dpfp_threaded$(EXEEXT) +PROGRAMS = $(noinst_PROGRAMS) +am__dpfp_SOURCES_DIST = dpfp.c +@HAVE_SIGACTION_TRUE@am_dpfp_OBJECTS = dpfp.$(OBJEXT) +dpfp_OBJECTS = $(am_dpfp_OBJECTS) +@HAVE_SIGACTION_TRUE@dpfp_DEPENDENCIES = ../libusb/libusb-1.0.la +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent +am__dpfp_threaded_SOURCES_DIST = dpfp_threaded.c +@HAVE_SIGACTION_TRUE@@THREADS_POSIX_TRUE@am_dpfp_threaded_OBJECTS = dpfp_threaded-dpfp_threaded.$(OBJEXT) +dpfp_threaded_OBJECTS = $(am_dpfp_threaded_OBJECTS) +@HAVE_SIGACTION_TRUE@@THREADS_POSIX_TRUE@dpfp_threaded_DEPENDENCIES = ../libusb/libusb-1.0.la +dpfp_threaded_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(dpfp_threaded_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +am_lsusb_OBJECTS = lsusb.$(OBJEXT) +lsusb_OBJECTS = $(am_lsusb_OBJECTS) +lsusb_DEPENDENCIES = ../libusb/libusb-1.0.la +am_xusb_OBJECTS = xusb.$(OBJEXT) +xusb_OBJECTS = $(am_xusb_OBJECTS) +xusb_DEPENDENCIES = ../libusb/libusb-1.0.la +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_$(V)) +am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_$(V)) +am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(dpfp_SOURCES) $(dpfp_threaded_SOURCES) $(lsusb_SOURCES) \ + $(xusb_SOURCES) +DIST_SOURCES = $(am__dpfp_SOURCES_DIST) \ + $(am__dpfp_threaded_SOURCES_DIST) $(lsusb_SOURCES) \ + $(xusb_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AM_LDFLAGS = @AM_LDFLAGS@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUSB_VERSION_MAJOR = @LIBUSB_VERSION_MAJOR@ +LIBUSB_VERSION_MICRO = @LIBUSB_VERSION_MICRO@ +LIBUSB_VERSION_MINOR = @LIBUSB_VERSION_MINOR@ +LIBUSB_VERSION_NANO = @LIBUSB_VERSION_NANO@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OS_DARWIN = @OS_DARWIN@ +OS_LINUX = @OS_LINUX@ +OS_WINDOWS = @OS_WINDOWS@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PC_LIBS_PRIVATE = @PC_LIBS_PRIVATE@ +RANLIB = @RANLIB@ +RC = @RC@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +THREAD_CFLAGS = @THREAD_CFLAGS@ +VERSION = @VERSION@ +VISIBILITY_CFLAGS = @VISIBILITY_CFLAGS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ +lt_age = @lt_age@ +lt_current = @lt_current@ +lt_revision = @lt_revision@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +INCLUDES = -I$(top_srcdir)/libusb +lsusb_SOURCES = lsusb.c +lsusb_LDADD = ../libusb/libusb-1.0.la -lusb-1.0 +xusb_SOURCES = xusb.c +xusb_LDADD = ../libusb/libusb-1.0.la -lusb-1.0 +@HAVE_SIGACTION_TRUE@dpfp_SOURCES = dpfp.c +@HAVE_SIGACTION_TRUE@dpfp_LDADD = ../libusb/libusb-1.0.la -lusb-1.0 +@HAVE_SIGACTION_TRUE@@THREADS_POSIX_TRUE@dpfp_threaded_SOURCES = dpfp_threaded.c +@HAVE_SIGACTION_TRUE@@THREADS_POSIX_TRUE@dpfp_threaded_CFLAGS = $(THREAD_CFLAGS) $(AM_CFLAGS) +@HAVE_SIGACTION_TRUE@@THREADS_POSIX_TRUE@dpfp_threaded_LDADD = ../libusb/libusb-1.0.la -lusb-1.0 +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu examples/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu examples/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +dpfp$(EXEEXT): $(dpfp_OBJECTS) $(dpfp_DEPENDENCIES) + @rm -f dpfp$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(dpfp_OBJECTS) $(dpfp_LDADD) $(LIBS) +dpfp_threaded$(EXEEXT): $(dpfp_threaded_OBJECTS) $(dpfp_threaded_DEPENDENCIES) + @rm -f dpfp_threaded$(EXEEXT) + $(AM_V_CCLD)$(dpfp_threaded_LINK) $(dpfp_threaded_OBJECTS) $(dpfp_threaded_LDADD) $(LIBS) +lsusb$(EXEEXT): $(lsusb_OBJECTS) $(lsusb_DEPENDENCIES) + @rm -f lsusb$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(lsusb_OBJECTS) $(lsusb_LDADD) $(LIBS) +xusb$(EXEEXT): $(xusb_OBJECTS) $(xusb_DEPENDENCIES) + @rm -f xusb$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(xusb_OBJECTS) $(xusb_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dpfp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dpfp_threaded-dpfp_threaded.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lsusb.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xusb.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +dpfp_threaded-dpfp_threaded.o: dpfp_threaded.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(dpfp_threaded_CFLAGS) $(CFLAGS) -MT dpfp_threaded-dpfp_threaded.o -MD -MP -MF $(DEPDIR)/dpfp_threaded-dpfp_threaded.Tpo -c -o dpfp_threaded-dpfp_threaded.o `test -f 'dpfp_threaded.c' || echo '$(srcdir)/'`dpfp_threaded.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dpfp_threaded-dpfp_threaded.Tpo $(DEPDIR)/dpfp_threaded-dpfp_threaded.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dpfp_threaded.c' object='dpfp_threaded-dpfp_threaded.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(dpfp_threaded_CFLAGS) $(CFLAGS) -c -o dpfp_threaded-dpfp_threaded.o `test -f 'dpfp_threaded.c' || echo '$(srcdir)/'`dpfp_threaded.c + +dpfp_threaded-dpfp_threaded.obj: dpfp_threaded.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(dpfp_threaded_CFLAGS) $(CFLAGS) -MT dpfp_threaded-dpfp_threaded.obj -MD -MP -MF $(DEPDIR)/dpfp_threaded-dpfp_threaded.Tpo -c -o dpfp_threaded-dpfp_threaded.obj `if test -f 'dpfp_threaded.c'; then $(CYGPATH_W) 'dpfp_threaded.c'; else $(CYGPATH_W) '$(srcdir)/dpfp_threaded.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dpfp_threaded-dpfp_threaded.Tpo $(DEPDIR)/dpfp_threaded-dpfp_threaded.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dpfp_threaded.c' object='dpfp_threaded-dpfp_threaded.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(dpfp_threaded_CFLAGS) $(CFLAGS) -c -o dpfp_threaded-dpfp_threaded.obj `if test -f 'dpfp_threaded.c'; then $(CYGPATH_W) 'dpfp_threaded.c'; else $(CYGPATH_W) '$(srcdir)/dpfp_threaded.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstPROGRAMS ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am + + +# 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: diff --git a/libusb-1.0/examples/_lsusb_2008.vcproj b/libusb-1.0/examples/_lsusb_2008.vcproj new file mode 100644 index 0000000..8fe7584 --- /dev/null +++ b/libusb-1.0/examples/_lsusb_2008.vcproj @@ -0,0 +1,321 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libusb-1.0/examples/_xusb_2008.vcproj b/libusb-1.0/examples/_xusb_2008.vcproj new file mode 100644 index 0000000..3c056a0 --- /dev/null +++ b/libusb-1.0/examples/_xusb_2008.vcproj @@ -0,0 +1,319 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libusb-1.0/examples/dpfp.c b/libusb-1.0/examples/dpfp.c new file mode 100644 index 0000000..07ffe4d --- /dev/null +++ b/libusb-1.0/examples/dpfp.c @@ -0,0 +1,508 @@ +/* + * libusb example program to manipulate U.are.U 4000B fingerprint scanner. + * Copyright (C) 2007 Daniel Drake + * + * Basic image capture program only, does not consider the powerup quirks or + * the fact that image encryption may be enabled. Not expected to work + * flawlessly all of the time. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include +#include +#include + +#include "libusb.h" + +#define EP_INTR (1 | LIBUSB_ENDPOINT_IN) +#define EP_DATA (2 | LIBUSB_ENDPOINT_IN) +#define CTRL_IN (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_IN) +#define CTRL_OUT (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT) +#define USB_RQ 0x04 +#define INTR_LENGTH 64 + +enum { + MODE_INIT = 0x00, + MODE_AWAIT_FINGER_ON = 0x10, + MODE_AWAIT_FINGER_OFF = 0x12, + MODE_CAPTURE = 0x20, + MODE_SHUT_UP = 0x30, + MODE_READY = 0x80, +}; + +static int next_state(void); + +enum { + STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_ON = 1, + STATE_AWAIT_IRQ_FINGER_DETECTED, + STATE_AWAIT_MODE_CHANGE_CAPTURE, + STATE_AWAIT_IMAGE, + STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_OFF, + STATE_AWAIT_IRQ_FINGER_REMOVED, +}; + +static int state = 0; +static struct libusb_device_handle *devh = NULL; +static unsigned char imgbuf[0x1b340]; +static unsigned char irqbuf[INTR_LENGTH]; +static struct libusb_transfer *img_transfer = NULL; +static struct libusb_transfer *irq_transfer = NULL; +static int img_idx = 0; +static int do_exit = 0; + +static int find_dpfp_device(void) +{ + devh = libusb_open_device_with_vid_pid(NULL, 0x05ba, 0x000a); + return devh ? 0 : -EIO; +} + +static int print_f0_data(void) +{ + unsigned char data[0x10]; + int r; + unsigned int i; + + r = libusb_control_transfer(devh, CTRL_IN, USB_RQ, 0xf0, 0, data, + sizeof(data), 0); + if (r < 0) { + fprintf(stderr, "F0 error %d\n", r); + return r; + } + if ((unsigned int) r < sizeof(data)) { + fprintf(stderr, "short read (%d)\n", r); + return -1; + } + + printf("F0 data:"); + for (i = 0; i < sizeof(data); i++) + printf("%02x ", data[i]); + printf("\n"); + return 0; +} + +static int get_hwstat(unsigned char *status) +{ + int r; + + r = libusb_control_transfer(devh, CTRL_IN, USB_RQ, 0x07, 0, status, 1, 0); + if (r < 0) { + fprintf(stderr, "read hwstat error %d\n", r); + return r; + } + if ((unsigned int) r < 1) { + fprintf(stderr, "short read (%d)\n", r); + return -1; + } + + printf("hwstat reads %02x\n", *status); + return 0; +} + +static int set_hwstat(unsigned char data) +{ + int r; + + printf("set hwstat to %02x\n", data); + r = libusb_control_transfer(devh, CTRL_OUT, USB_RQ, 0x07, 0, &data, 1, 0); + if (r < 0) { + fprintf(stderr, "set hwstat error %d\n", r); + return r; + } + if ((unsigned int) r < 1) { + fprintf(stderr, "short write (%d)", r); + return -1; + } + + return 0; +} + +static int set_mode(unsigned char data) +{ + int r; + printf("set mode %02x\n", data); + + r = libusb_control_transfer(devh, CTRL_OUT, USB_RQ, 0x4e, 0, &data, 1, 0); + if (r < 0) { + fprintf(stderr, "set mode error %d\n", r); + return r; + } + if ((unsigned int) r < 1) { + fprintf(stderr, "short write (%d)", r); + return -1; + } + + return 0; +} + +static void LIBUSB_CALL cb_mode_changed(struct libusb_transfer *transfer) +{ + if (transfer->status != LIBUSB_TRANSFER_COMPLETED) { + fprintf(stderr, "mode change transfer not completed!\n"); + do_exit = 2; + } + + printf("async cb_mode_changed length=%d actual_length=%d\n", + transfer->length, transfer->actual_length); + if (next_state() < 0) + do_exit = 2; +} + +static int set_mode_async(unsigned char data) +{ + unsigned char *buf = malloc(LIBUSB_CONTROL_SETUP_SIZE + 1); + struct libusb_transfer *transfer; + + if (!buf) + return -ENOMEM; + + transfer = libusb_alloc_transfer(0); + if (!transfer) { + free(buf); + return -ENOMEM; + } + + printf("async set mode %02x\n", data); + libusb_fill_control_setup(buf, CTRL_OUT, USB_RQ, 0x4e, 0, 1); + buf[LIBUSB_CONTROL_SETUP_SIZE] = data; + libusb_fill_control_transfer(transfer, devh, buf, cb_mode_changed, NULL, + 1000); + + transfer->flags = LIBUSB_TRANSFER_SHORT_NOT_OK + | LIBUSB_TRANSFER_FREE_BUFFER | LIBUSB_TRANSFER_FREE_TRANSFER; + return libusb_submit_transfer(transfer); +} + +static int do_sync_intr(unsigned char *data) +{ + int r; + int transferred; + + r = libusb_interrupt_transfer(devh, EP_INTR, data, INTR_LENGTH, + &transferred, 1000); + if (r < 0) { + fprintf(stderr, "intr error %d\n", r); + return r; + } + if (transferred < INTR_LENGTH) { + fprintf(stderr, "short read (%d)\n", r); + return -1; + } + + printf("recv interrupt %04x\n", *((uint16_t *) data)); + return 0; +} + +static int sync_intr(unsigned char type) +{ + int r; + unsigned char data[INTR_LENGTH]; + + while (1) { + r = do_sync_intr(data); + if (r < 0) + return r; + if (data[0] == type) + return 0; + } +} + +static int save_to_file(unsigned char *data) +{ + FILE *fd; + char filename[64]; + size_t ignore; + + sprintf(filename, "finger%d.pgm", img_idx++); + fd = fopen(filename, "w"); + if (!fd) + return -1; + + fputs("P5 384 289 255 ", fd); + ignore = fwrite(data + 64, 1, 384*289, fd); + fclose(fd); + printf("saved image to %s\n", filename); + return 0; +} + +static int next_state(void) +{ + int r = 0; + printf("old state: %d\n", state); + switch (state) { + case STATE_AWAIT_IRQ_FINGER_REMOVED: + state = STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_ON; + r = set_mode_async(MODE_AWAIT_FINGER_ON); + break; + case STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_ON: + state = STATE_AWAIT_IRQ_FINGER_DETECTED; + break; + case STATE_AWAIT_IRQ_FINGER_DETECTED: + state = STATE_AWAIT_MODE_CHANGE_CAPTURE; + r = set_mode_async(MODE_CAPTURE); + break; + case STATE_AWAIT_MODE_CHANGE_CAPTURE: + state = STATE_AWAIT_IMAGE; + break; + case STATE_AWAIT_IMAGE: + state = STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_OFF; + r = set_mode_async(MODE_AWAIT_FINGER_OFF); + break; + case STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_OFF: + state = STATE_AWAIT_IRQ_FINGER_REMOVED; + break; + default: + printf("unrecognised state %d\n", state); + } + if (r < 0) { + fprintf(stderr, "error detected changing state\n"); + return r; + } + + printf("new state: %d\n", state); + return 0; +} + +static void LIBUSB_CALL cb_irq(struct libusb_transfer *transfer) +{ + unsigned char irqtype = transfer->buffer[0]; + + if (transfer->status != LIBUSB_TRANSFER_COMPLETED) { + fprintf(stderr, "irq transfer status %d?\n", transfer->status); + do_exit = 2; + libusb_free_transfer(transfer); + irq_transfer = NULL; + return; + } + + printf("IRQ callback %02x\n", irqtype); + switch (state) { + case STATE_AWAIT_IRQ_FINGER_DETECTED: + if (irqtype == 0x01) { + if (next_state() < 0) { + do_exit = 2; + return; + } + } else { + printf("finger-on-sensor detected in wrong state!\n"); + } + break; + case STATE_AWAIT_IRQ_FINGER_REMOVED: + if (irqtype == 0x02) { + if (next_state() < 0) { + do_exit = 2; + return; + } + } else { + printf("finger-on-sensor detected in wrong state!\n"); + } + break; + } + if (libusb_submit_transfer(irq_transfer) < 0) + do_exit = 2; +} + +static void LIBUSB_CALL cb_img(struct libusb_transfer *transfer) +{ + if (transfer->status != LIBUSB_TRANSFER_COMPLETED) { + fprintf(stderr, "img transfer status %d?\n", transfer->status); + do_exit = 2; + libusb_free_transfer(transfer); + img_transfer = NULL; + return; + } + + printf("Image callback\n"); + save_to_file(imgbuf); + if (next_state() < 0) { + do_exit = 2; + return; + } + if (libusb_submit_transfer(img_transfer) < 0) + do_exit = 2; +} + +static int init_capture(void) +{ + int r; + + r = libusb_submit_transfer(irq_transfer); + if (r < 0) + return r; + + r = libusb_submit_transfer(img_transfer); + if (r < 0) { + libusb_cancel_transfer(irq_transfer); + while (irq_transfer) + if (libusb_handle_events(NULL) < 0) + break; + return r; + } + + /* start state machine */ + state = STATE_AWAIT_IRQ_FINGER_REMOVED; + return next_state(); +} + +static int do_init(void) +{ + unsigned char status; + int r; + + r = get_hwstat(&status); + if (r < 0) + return r; + + if (!(status & 0x80)) { + r = set_hwstat(status | 0x80); + if (r < 0) + return r; + r = get_hwstat(&status); + if (r < 0) + return r; + } + + status &= ~0x80; + r = set_hwstat(status); + if (r < 0) + return r; + + r = get_hwstat(&status); + if (r < 0) + return r; + + r = sync_intr(0x56); + if (r < 0) + return r; + + return 0; +} + +static int alloc_transfers(void) +{ + img_transfer = libusb_alloc_transfer(0); + if (!img_transfer) + return -ENOMEM; + + irq_transfer = libusb_alloc_transfer(0); + if (!irq_transfer) + return -ENOMEM; + + libusb_fill_bulk_transfer(img_transfer, devh, EP_DATA, imgbuf, + sizeof(imgbuf), cb_img, NULL, 0); + libusb_fill_interrupt_transfer(irq_transfer, devh, EP_INTR, irqbuf, + sizeof(irqbuf), cb_irq, NULL, 0); + + return 0; +} + +static void sighandler(int signum) +{ + do_exit = 1; +} + +int main(void) +{ + struct sigaction sigact; + int r = 1; + + r = libusb_init(NULL); + if (r < 0) { + fprintf(stderr, "failed to initialise libusb\n"); + exit(1); + } + + r = find_dpfp_device(); + if (r < 0) { + fprintf(stderr, "Could not find/open device\n"); + goto out; + } + + r = libusb_claim_interface(devh, 0); + if (r < 0) { + fprintf(stderr, "usb_claim_interface error %d\n", r); + goto out; + } + printf("claimed interface\n"); + + r = print_f0_data(); + if (r < 0) + goto out_release; + + r = do_init(); + if (r < 0) + goto out_deinit; + + /* async from here onwards */ + + r = alloc_transfers(); + if (r < 0) + goto out_deinit; + + r = init_capture(); + if (r < 0) + goto out_deinit; + + sigact.sa_handler = sighandler; + sigemptyset(&sigact.sa_mask); + sigact.sa_flags = 0; + sigaction(SIGINT, &sigact, NULL); + sigaction(SIGTERM, &sigact, NULL); + sigaction(SIGQUIT, &sigact, NULL); + + while (!do_exit) { + r = libusb_handle_events(NULL); + if (r < 0) + goto out_deinit; + } + + printf("shutting down...\n"); + + if (irq_transfer) { + r = libusb_cancel_transfer(irq_transfer); + if (r < 0) + goto out_deinit; + } + + if (img_transfer) { + r = libusb_cancel_transfer(img_transfer); + if (r < 0) + goto out_deinit; + } + + while (irq_transfer || img_transfer) + if (libusb_handle_events(NULL) < 0) + break; + + if (do_exit == 1) + r = 0; + else + r = 1; + +out_deinit: + libusb_free_transfer(img_transfer); + libusb_free_transfer(irq_transfer); + set_mode(0); + set_hwstat(0x80); +out_release: + libusb_release_interface(devh, 0); +out: + libusb_close(devh); + libusb_exit(NULL); + return r >= 0 ? r : -r; +} + diff --git a/libusb-1.0/examples/dpfp_threaded.c b/libusb-1.0/examples/dpfp_threaded.c new file mode 100644 index 0000000..7868015 --- /dev/null +++ b/libusb-1.0/examples/dpfp_threaded.c @@ -0,0 +1,546 @@ +/* + * libusb example program to manipulate U.are.U 4000B fingerprint scanner. + * Copyright (C) 2007 Daniel Drake + * + * Basic image capture program only, does not consider the powerup quirks or + * the fact that image encryption may be enabled. Not expected to work + * flawlessly all of the time. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include +#include +#include +#include + +#include "libusb.h" + +#define EP_INTR (1 | LIBUSB_ENDPOINT_IN) +#define EP_DATA (2 | LIBUSB_ENDPOINT_IN) +#define CTRL_IN (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_IN) +#define CTRL_OUT (LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT) +#define USB_RQ 0x04 +#define INTR_LENGTH 64 + +enum { + MODE_INIT = 0x00, + MODE_AWAIT_FINGER_ON = 0x10, + MODE_AWAIT_FINGER_OFF = 0x12, + MODE_CAPTURE = 0x20, + MODE_SHUT_UP = 0x30, + MODE_READY = 0x80, +}; + +static int next_state(void); + +enum { + STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_ON = 1, + STATE_AWAIT_IRQ_FINGER_DETECTED, + STATE_AWAIT_MODE_CHANGE_CAPTURE, + STATE_AWAIT_IMAGE, + STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_OFF, + STATE_AWAIT_IRQ_FINGER_REMOVED, +}; + +static int state = 0; +static struct libusb_device_handle *devh = NULL; +static unsigned char imgbuf[0x1b340]; +static unsigned char irqbuf[INTR_LENGTH]; +static struct libusb_transfer *img_transfer = NULL; +static struct libusb_transfer *irq_transfer = NULL; +static int img_idx = 0; +static int do_exit = 0; + +static pthread_t poll_thread; +static pthread_cond_t exit_cond = PTHREAD_COND_INITIALIZER; +static pthread_mutex_t exit_cond_lock = PTHREAD_MUTEX_INITIALIZER; + +static void request_exit(int code) +{ + do_exit = code; + pthread_cond_signal(&exit_cond); +} + +static void *poll_thread_main(void *arg) +{ + int r = 0; + printf("poll thread running\n"); + + while (!do_exit) { + struct timeval tv = { 1, 0 }; + r = libusb_handle_events_timeout(NULL, &tv); + if (r < 0) { + request_exit(2); + break; + } + } + + printf("poll thread shutting down\n"); + pthread_exit(NULL); +} + +static int find_dpfp_device(void) +{ + devh = libusb_open_device_with_vid_pid(NULL, 0x05ba, 0x000a); + return devh ? 0 : -EIO; +} + +static int print_f0_data(void) +{ + unsigned char data[0x10]; + int r; + unsigned int i; + + r = libusb_control_transfer(devh, CTRL_IN, USB_RQ, 0xf0, 0, data, + sizeof(data), 0); + if (r < 0) { + fprintf(stderr, "F0 error %d\n", r); + return r; + } + if ((unsigned int) r < sizeof(data)) { + fprintf(stderr, "short read (%d)\n", r); + return -1; + } + + printf("F0 data:"); + for (i = 0; i < sizeof(data); i++) + printf("%02x ", data[i]); + printf("\n"); + return 0; +} + +static int get_hwstat(unsigned char *status) +{ + int r; + + r = libusb_control_transfer(devh, CTRL_IN, USB_RQ, 0x07, 0, status, 1, 0); + if (r < 0) { + fprintf(stderr, "read hwstat error %d\n", r); + return r; + } + if ((unsigned int) r < 1) { + fprintf(stderr, "short read (%d)\n", r); + return -1; + } + + printf("hwstat reads %02x\n", *status); + return 0; +} + +static int set_hwstat(unsigned char data) +{ + int r; + + printf("set hwstat to %02x\n", data); + r = libusb_control_transfer(devh, CTRL_OUT, USB_RQ, 0x07, 0, &data, 1, 0); + if (r < 0) { + fprintf(stderr, "set hwstat error %d\n", r); + return r; + } + if ((unsigned int) r < 1) { + fprintf(stderr, "short write (%d)", r); + return -1; + } + + return 0; +} + +static int set_mode(unsigned char data) +{ + int r; + printf("set mode %02x\n", data); + + r = libusb_control_transfer(devh, CTRL_OUT, USB_RQ, 0x4e, 0, &data, 1, 0); + if (r < 0) { + fprintf(stderr, "set mode error %d\n", r); + return r; + } + if ((unsigned int) r < 1) { + fprintf(stderr, "short write (%d)", r); + return -1; + } + + return 0; +} + +static void LIBUSB_CALL cb_mode_changed(struct libusb_transfer *transfer) +{ + if (transfer->status != LIBUSB_TRANSFER_COMPLETED) { + fprintf(stderr, "mode change transfer not completed!\n"); + request_exit(2); + } + + printf("async cb_mode_changed length=%d actual_length=%d\n", + transfer->length, transfer->actual_length); + if (next_state() < 0) + request_exit(2); +} + +static int set_mode_async(unsigned char data) +{ + unsigned char *buf = malloc(LIBUSB_CONTROL_SETUP_SIZE + 1); + struct libusb_transfer *transfer; + + if (!buf) + return -ENOMEM; + + transfer = libusb_alloc_transfer(0); + if (!transfer) { + free(buf); + return -ENOMEM; + } + + printf("async set mode %02x\n", data); + libusb_fill_control_setup(buf, CTRL_OUT, USB_RQ, 0x4e, 0, 1); + buf[LIBUSB_CONTROL_SETUP_SIZE] = data; + libusb_fill_control_transfer(transfer, devh, buf, cb_mode_changed, NULL, + 1000); + + transfer->flags = LIBUSB_TRANSFER_SHORT_NOT_OK + | LIBUSB_TRANSFER_FREE_BUFFER | LIBUSB_TRANSFER_FREE_TRANSFER; + return libusb_submit_transfer(transfer); +} + +static int do_sync_intr(unsigned char *data) +{ + int r; + int transferred; + + r = libusb_interrupt_transfer(devh, EP_INTR, data, INTR_LENGTH, + &transferred, 1000); + if (r < 0) { + fprintf(stderr, "intr error %d\n", r); + return r; + } + if (transferred < INTR_LENGTH) { + fprintf(stderr, "short read (%d)\n", r); + return -1; + } + + printf("recv interrupt %04x\n", *((uint16_t *) data)); + return 0; +} + +static int sync_intr(unsigned char type) +{ + int r; + unsigned char data[INTR_LENGTH]; + + while (1) { + r = do_sync_intr(data); + if (r < 0) + return r; + if (data[0] == type) + return 0; + } +} + +static int save_to_file(unsigned char *data) +{ + FILE *fd; + char filename[64]; + size_t ignore; + + sprintf(filename, "finger%d.pgm", img_idx++); + fd = fopen(filename, "w"); + if (!fd) + return -1; + + fputs("P5 384 289 255 ", fd); + ignore = fwrite(data + 64, 1, 384*289, fd); + fclose(fd); + printf("saved image to %s\n", filename); + return 0; +} + +static int next_state(void) +{ + int r = 0; + printf("old state: %d\n", state); + switch (state) { + case STATE_AWAIT_IRQ_FINGER_REMOVED: + state = STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_ON; + r = set_mode_async(MODE_AWAIT_FINGER_ON); + break; + case STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_ON: + state = STATE_AWAIT_IRQ_FINGER_DETECTED; + break; + case STATE_AWAIT_IRQ_FINGER_DETECTED: + state = STATE_AWAIT_MODE_CHANGE_CAPTURE; + r = set_mode_async(MODE_CAPTURE); + break; + case STATE_AWAIT_MODE_CHANGE_CAPTURE: + state = STATE_AWAIT_IMAGE; + break; + case STATE_AWAIT_IMAGE: + state = STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_OFF; + r = set_mode_async(MODE_AWAIT_FINGER_OFF); + break; + case STATE_AWAIT_MODE_CHANGE_AWAIT_FINGER_OFF: + state = STATE_AWAIT_IRQ_FINGER_REMOVED; + break; + default: + printf("unrecognised state %d\n", state); + } + if (r < 0) { + fprintf(stderr, "error detected changing state\n"); + return r; + } + + printf("new state: %d\n", state); + return 0; +} + +static void LIBUSB_CALL cb_irq(struct libusb_transfer *transfer) +{ + unsigned char irqtype = transfer->buffer[0]; + + if (transfer->status != LIBUSB_TRANSFER_COMPLETED) { + fprintf(stderr, "irq transfer status %d?\n", transfer->status); + irq_transfer = NULL; + request_exit(2); + return; + } + + printf("IRQ callback %02x\n", irqtype); + switch (state) { + case STATE_AWAIT_IRQ_FINGER_DETECTED: + if (irqtype == 0x01) { + if (next_state() < 0) { + request_exit(2); + return; + } + } else { + printf("finger-on-sensor detected in wrong state!\n"); + } + break; + case STATE_AWAIT_IRQ_FINGER_REMOVED: + if (irqtype == 0x02) { + if (next_state() < 0) { + request_exit(2); + return; + } + } else { + printf("finger-on-sensor detected in wrong state!\n"); + } + break; + } + if (libusb_submit_transfer(irq_transfer) < 0) + request_exit(2); +} + +static void LIBUSB_CALL cb_img(struct libusb_transfer *transfer) +{ + if (transfer->status != LIBUSB_TRANSFER_COMPLETED) { + fprintf(stderr, "img transfer status %d?\n", transfer->status); + img_transfer = NULL; + request_exit(2); + return; + } + + printf("Image callback\n"); + save_to_file(imgbuf); + if (next_state() < 0) { + request_exit(2); + return; + } + if (libusb_submit_transfer(img_transfer) < 0) + request_exit(2); +} + +static int init_capture(void) +{ + int r; + + r = libusb_submit_transfer(irq_transfer); + if (r < 0) + return r; + + r = libusb_submit_transfer(img_transfer); + if (r < 0) { + libusb_cancel_transfer(irq_transfer); + while (irq_transfer) + if (libusb_handle_events(NULL) < 0) + break; + return r; + } + + /* start state machine */ + state = STATE_AWAIT_IRQ_FINGER_REMOVED; + return next_state(); +} + +static int do_init(void) +{ + unsigned char status; + int r; + + r = get_hwstat(&status); + if (r < 0) + return r; + + if (!(status & 0x80)) { + r = set_hwstat(status | 0x80); + if (r < 0) + return r; + r = get_hwstat(&status); + if (r < 0) + return r; + } + + status &= ~0x80; + r = set_hwstat(status); + if (r < 0) + return r; + + r = get_hwstat(&status); + if (r < 0) + return r; + + r = sync_intr(0x56); + if (r < 0) + return r; + + return 0; +} + +static int alloc_transfers(void) +{ + img_transfer = libusb_alloc_transfer(0); + if (!img_transfer) + return -ENOMEM; + + irq_transfer = libusb_alloc_transfer(0); + if (!irq_transfer) + return -ENOMEM; + + libusb_fill_bulk_transfer(img_transfer, devh, EP_DATA, imgbuf, + sizeof(imgbuf), cb_img, NULL, 0); + libusb_fill_interrupt_transfer(irq_transfer, devh, EP_INTR, irqbuf, + sizeof(irqbuf), cb_irq, NULL, 0); + + return 0; +} + +static void sighandler(int signum) +{ + request_exit(1); +} + +int main(void) +{ + struct sigaction sigact; + int r = 1; + + r = libusb_init(NULL); + if (r < 0) { + fprintf(stderr, "failed to initialise libusb\n"); + exit(1); + } + + r = find_dpfp_device(); + if (r < 0) { + fprintf(stderr, "Could not find/open device\n"); + goto out; + } + + r = libusb_claim_interface(devh, 0); + if (r < 0) { + fprintf(stderr, "usb_claim_interface error %d %s\n", r, strerror(-r)); + goto out; + } + printf("claimed interface\n"); + + r = print_f0_data(); + if (r < 0) + goto out_release; + + r = do_init(); + if (r < 0) + goto out_deinit; + + /* async from here onwards */ + + sigact.sa_handler = sighandler; + sigemptyset(&sigact.sa_mask); + sigact.sa_flags = 0; + sigaction(SIGINT, &sigact, NULL); + sigaction(SIGTERM, &sigact, NULL); + sigaction(SIGQUIT, &sigact, NULL); + + r = pthread_create(&poll_thread, NULL, poll_thread_main, NULL); + if (r) + goto out_deinit; + + r = alloc_transfers(); + if (r < 0) { + request_exit(1); + pthread_join(poll_thread, NULL); + goto out_deinit; + } + + r = init_capture(); + if (r < 0) { + request_exit(1); + pthread_join(poll_thread, NULL); + goto out_deinit; + } + + while (!do_exit) { + pthread_mutex_lock(&exit_cond_lock); + pthread_cond_wait(&exit_cond, &exit_cond_lock); + pthread_mutex_unlock(&exit_cond_lock); + } + + printf("shutting down...\n"); + pthread_join(poll_thread, NULL); + + r = libusb_cancel_transfer(irq_transfer); + if (r < 0) { + request_exit(1); + goto out_deinit; + } + + r = libusb_cancel_transfer(img_transfer); + if (r < 0) { + request_exit(1); + goto out_deinit; + } + + while (img_transfer || irq_transfer) + if (libusb_handle_events(NULL) < 0) + break; + + if (do_exit == 1) + r = 0; + else + r = 1; + +out_deinit: + libusb_free_transfer(img_transfer); + libusb_free_transfer(irq_transfer); + set_mode(0); + set_hwstat(0x80); +out_release: + libusb_release_interface(devh, 0); +out: + libusb_close(devh); + libusb_exit(NULL); + return r >= 0 ? r : -r; +} + diff --git a/libusb-1.0/examples/lsusb.c b/libusb-1.0/examples/lsusb.c new file mode 100644 index 0000000..e36e0c1 --- /dev/null +++ b/libusb-1.0/examples/lsusb.c @@ -0,0 +1,64 @@ +/* + * libusb example program to list devices on the bus + * Copyright (C) 2007 Daniel Drake + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include + +#include "libusb.h" + +static void print_devs(libusb_device **devs) +{ + libusb_device *dev; + int i = 0; + + while ((dev = devs[i++]) != NULL) { + struct libusb_device_descriptor desc; + int r = libusb_get_device_descriptor(dev, &desc); + if (r < 0) { + fprintf(stderr, "failed to get device descriptor"); + return; + } + + printf("%04x:%04x (bus %d, device %d)\n", + desc.idVendor, desc.idProduct, + libusb_get_bus_number(dev), libusb_get_device_address(dev)); + } +} + +int main(void) +{ + libusb_device **devs; + int r; + ssize_t cnt; + + r = libusb_init(NULL); + if (r < 0) + return r; + + cnt = libusb_get_device_list(NULL, &devs); + if (cnt < 0) + return (int) cnt; + + print_devs(devs); + libusb_free_device_list(devs, 1); + + libusb_exit(NULL); + return 0; +} + diff --git a/libusb-1.0/examples/xusb.c b/libusb-1.0/examples/xusb.c new file mode 100644 index 0000000..812e81f --- /dev/null +++ b/libusb-1.0/examples/xusb.c @@ -0,0 +1,867 @@ +/* + * xusb: libusb-winusb specific test program + * Copyright (c) 2009-2010 Pete Batard + * Based on lsusb, copyright (c) 2007 Daniel Drake + * With contributions to Mass Storage test by Alan Stern. + * + * This test program tries to access an USB device through WinUSB. + * To access your device, modify this source and add your VID/PID. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include +#include +#include +#include + +#include "libusb.h" + +#ifdef OS_WINDOWS +#define msleep(msecs) Sleep(msecs) +#else +#include +#define msleep(msecs) usleep(1000*msecs) +#endif + +#if !defined(_MSC_VER) || _MSC_VER<=1200 +#define sscanf_s sscanf +#endif + +#if !defined(bool) +#define bool int +#endif +#if !defined(true) +#define true (1 == 1) +#endif +#if !defined(false) +#define false (!true) +#endif + + +// Future versions of libusb will use usb_interface instead of interface +// in libusb_config_descriptor => catter for that +#define usb_interface interface + +// Global variables +bool binary_dump = false; +char binary_name[64]; + +inline static int perr(char const *format, ...) +{ + va_list args; + int r; + + va_start (args, format); + r = vfprintf(stderr, format, args); + va_end(args); + + return r; +} + +#define ERR_EXIT(errcode) do { perr(" %s\n", libusb_strerror(errcode)); return -1; } while (0) +#define CALL_CHECK(fcall) do { r=fcall; if (r < 0) ERR_EXIT(r); } while (0); +#define B(x) (((x)!=0)?1:0) +#define be_to_int32(buf) (((buf)[0]<<24)|((buf)[1]<<16)|((buf)[2]<<8)|(buf)[3]) + +#define RETRY_MAX 5 +#define REQUEST_SENSE_LENGTH 0x12 +#define INQUIRY_LENGTH 0x24 +#define READ_CAPACITY_LENGTH 0x08 + +// HID Class-Specific Requests values. See section 7.2 of the HID specifications +#define HID_GET_REPORT 0x01 +#define HID_GET_IDLE 0x02 +#define HID_GET_PROTOCOL 0x03 +#define HID_SET_REPORT 0x09 +#define HID_SET_IDLE 0x0A +#define HID_SET_PROTOCOL 0x0B +#define HID_REPORT_TYPE_INPUT 0x01 +#define HID_REPORT_TYPE_OUTPUT 0x02 +#define HID_REPORT_TYPE_FEATURE 0x03 + +// Mass Storage Requests values. See section 3 of the Bulk-Only Mass Storage Class specifications +#define BOMS_RESET 0xFF +#define BOMS_GET_MAX_LUN 0xFE + +// Section 5.1: Command Block Wrapper (CBW) +struct command_block_wrapper { + uint8_t dCBWSignature[4]; + uint32_t dCBWTag; + uint32_t dCBWDataTransferLength; + uint8_t bmCBWFlags; + uint8_t bCBWLUN; + uint8_t bCBWCBLength; + uint8_t CBWCB[16]; +}; + +// Section 5.2: Command Status Wrapper (CSW) +struct command_status_wrapper { + uint8_t dCSWSignature[4]; + uint32_t dCSWTag; + uint32_t dCSWDataResidue; + uint8_t bCSWStatus; +}; + +static uint8_t cdb_length[256] = { +// 0 1 2 3 4 5 6 7 8 9 A B C D E F + 06,06,06,06,06,06,06,06,06,06,06,06,06,06,06,06, // 0 + 06,06,06,06,06,06,06,06,06,06,06,06,06,06,06,06, // 1 + 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, // 2 + 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, // 3 + 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, // 4 + 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10, // 5 + 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, // 6 + 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, // 7 + 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, // 8 + 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, // 9 + 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, // A + 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, // B + 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, // C + 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, // D + 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, // E + 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00, // F +}; + +enum test_type { + USE_XBOX, + USE_KEY, + USE_JTAG, + USE_HID, +} test_mode; +uint16_t VID, PID; + +void display_buffer_hex(unsigned char *buffer, unsigned size) +{ + unsigned i; + + for (i=0; i sizeof(cbw.CBWCB))) { + perr("send_mass_storage_command: don't know how to handle this command (%02X, length %d)\n", + cdb[0], cdb_len); + return -1; + } + + memset(&cbw, 0, sizeof(cbw)); + cbw.dCBWSignature[0] = 'U'; + cbw.dCBWSignature[1] = 'S'; + cbw.dCBWSignature[2] = 'B'; + cbw.dCBWSignature[3] = 'C'; + *ret_tag = tag; + cbw.dCBWTag = tag++; + cbw.dCBWDataTransferLength = data_length; + cbw.bmCBWFlags = direction; + cbw.bCBWLUN = lun; + // Subclass is 1 or 6 => cdb_len + cbw.bCBWCBLength = cdb_len; + memcpy(cbw.CBWCB, cdb, cdb_len); + + i = 0; + do { + // The transfer length must always be exactly 31 bytes. + r = libusb_bulk_transfer(handle, endpoint, (unsigned char*)&cbw, 31, &size, 1000); + if (r == LIBUSB_ERROR_PIPE) { + libusb_clear_halt(handle, endpoint); + } + i++; + } while ((r == LIBUSB_ERROR_PIPE) && (i HID_REPORT_TYPE_FEATURE)) { + return 0; + } else { + return (record_size[type - HID_REPORT_TYPE_INPUT]+7)/8; + } +} + +int test_hid(libusb_device_handle *handle, uint8_t endpoint_in) +{ + int r, size, descriptor_size; + uint8_t hid_report_descriptor[256]; + uint8_t *report_buffer; + FILE *fd; + size_t junk; + + printf("\nReading HID Report Descriptors:\n"); + descriptor_size = libusb_control_transfer(handle, LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_STANDARD|LIBUSB_RECIPIENT_INTERFACE, + LIBUSB_REQUEST_GET_DESCRIPTOR, LIBUSB_DT_REPORT<<8, 0, hid_report_descriptor, 256, 1000); + if (descriptor_size < 0) { + printf("failed\n"); + return -1; + } else { + display_buffer_hex(hid_report_descriptor, descriptor_size); + if ((binary_dump) && ((fd = fopen(binary_name, "w")) != NULL)) { + junk = fwrite(hid_report_descriptor, 1, descriptor_size, fd); + fclose(fd); + } + size = get_hid_record_size(hid_report_descriptor, descriptor_size, HID_REPORT_TYPE_FEATURE); + } + + if (size <= 0) { + printf("\nSkipping Feature Report readout (None detected)\n"); + } else { + report_buffer = calloc(size, 1); + if (report_buffer == NULL) { + return -1; + } + + printf("\nReading Feature Report (length %d)...\n", size); + r = libusb_control_transfer(handle, LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE, + HID_GET_REPORT, (HID_REPORT_TYPE_FEATURE<<8)|0, 0, report_buffer, (uint16_t)size, 5000); + if (r >= 0) { + display_buffer_hex(report_buffer, size); + } else { + switch(r) { + case LIBUSB_ERROR_NOT_FOUND: + printf(" No Feature Report available for this device\n"); + break; + case LIBUSB_ERROR_PIPE: + printf(" Detected stall - resetting pipe...\n"); + libusb_clear_halt(handle, 0); + break; + default: + printf(" Error: %s\n", libusb_strerror(r)); + break; + } + } + free(report_buffer); + } + + size = get_hid_record_size(hid_report_descriptor, descriptor_size, HID_REPORT_TYPE_INPUT); + if (size <= 0) { + printf("\nSkipping Input Report readout (None detected)\n"); + } else { + report_buffer = calloc(size, 1); + if (report_buffer == NULL) { + return -1; + } + + printf("\nReading Input Report (length %d)...\n", size); + r = libusb_control_transfer(handle, LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE, + HID_GET_REPORT, (HID_REPORT_TYPE_INPUT<<8)|0x00, 0, report_buffer, (uint16_t)size, 5000); + if (r >= 0) { + display_buffer_hex(report_buffer, size); + } else { + switch(r) { + case LIBUSB_ERROR_TIMEOUT: + printf(" Timeout! Please make sure you act on the device within the 5 seconds allocated...\n"); + break; + case LIBUSB_ERROR_PIPE: + printf(" Detected stall - resetting pipe...\n"); + libusb_clear_halt(handle, 0); + break; + default: + printf(" Error: %s\n", libusb_strerror(r)); + break; + } + } + + // Attempt a bulk read from endpoint 0 (this should just return a raw input report) + printf("\nTesting interrupt read using endpoint %02X...\n", endpoint_in); + r = libusb_interrupt_transfer(handle, endpoint_in, report_buffer, size, &size, 5000); + if (r >= 0) { + display_buffer_hex(report_buffer, size); + } else { + printf(" %s\n", libusb_strerror(r)); + } + + free(report_buffer); + } + return 0; +} + +int test_device(uint16_t vid, uint16_t pid) +{ + libusb_device_handle *handle; + libusb_device *dev; + struct libusb_config_descriptor *conf_desc; + const struct libusb_endpoint_descriptor *endpoint; + int i, j, k, r; + int iface, nb_ifaces; +#ifdef OS_LINUX + // Attaching/detaching the kernel driver is only relevant for Linux + int iface_detached = -1; +#endif + bool test_scsi = false; + struct libusb_device_descriptor dev_desc; + char string[128]; + uint8_t string_index[3]; // indexes of the string descriptors + uint8_t endpoint_in = 0, endpoint_out = 0; // default IN and OUT endpoints + + printf("Opening device...\n"); + handle = libusb_open_device_with_vid_pid(NULL, vid, pid); + + if (handle == NULL) { + perr(" Failed.\n"); + return -1; + } + + dev = libusb_get_device(handle); + + printf("\nReading device descriptor:\n"); + CALL_CHECK(libusb_get_device_descriptor(dev, &dev_desc)); + printf(" length: %d\n", dev_desc.bLength); + printf(" device class: %d\n", dev_desc.bDeviceClass); + printf(" S/N: %d\n", dev_desc.iSerialNumber); + printf(" VID:PID: %04X:%04X\n", dev_desc.idVendor, dev_desc.idProduct); + printf(" bcdDevice: %04X\n", dev_desc.bcdDevice); + printf(" iMan:iProd:iSer: %d:%d:%d\n", dev_desc.iManufacturer, dev_desc.iProduct, dev_desc.iSerialNumber); + printf(" nb confs: %d\n", dev_desc.bNumConfigurations); + // Copy the string descriptors for easier parsing + string_index[0] = dev_desc.iManufacturer; + string_index[1] = dev_desc.iProduct; + string_index[2] = dev_desc.iSerialNumber; + + printf("\nReading configuration descriptors:\n"); + CALL_CHECK(libusb_get_config_descriptor(dev, 0, &conf_desc)); + nb_ifaces = conf_desc->bNumInterfaces; + printf(" nb interfaces: %d\n", nb_ifaces); + for (i=0; ibNumInterfaces; i++) { + for (j=0; jusb_interface[i].num_altsetting; j++) { + printf("interface[%d].altsetting[%d]: num endpoints = %d\n", + i, j, conf_desc->usb_interface[i].altsetting[j].bNumEndpoints); + printf(" Class.SubClass.Protocol: %02X.%02X.%02X\n", + conf_desc->usb_interface[i].altsetting[j].bInterfaceClass, + conf_desc->usb_interface[i].altsetting[j].bInterfaceSubClass, + conf_desc->usb_interface[i].altsetting[j].bInterfaceProtocol); + if ( (conf_desc->usb_interface[i].altsetting[j].bInterfaceClass == LIBUSB_CLASS_MASS_STORAGE) + && ( (conf_desc->usb_interface[i].altsetting[j].bInterfaceSubClass == 0x01) + || (conf_desc->usb_interface[i].altsetting[j].bInterfaceSubClass == 0x06) ) + && (conf_desc->usb_interface[i].altsetting[j].bInterfaceProtocol == 0x50) ) { + // Mass storage devices that can use basic SCSI commands + test_scsi = true; + } + for (k=0; kusb_interface[i].altsetting[j].bNumEndpoints; k++) { + endpoint = &conf_desc->usb_interface[i].altsetting[j].endpoint[k]; + printf(" endpoint[%d].address: %02X\n", k, endpoint->bEndpointAddress); + // Use the last IN/OUT endpoints found as default for testing + if (endpoint->bEndpointAddress & LIBUSB_ENDPOINT_IN) { + endpoint_in = endpoint->bEndpointAddress; + } else { + endpoint_out = endpoint->bEndpointAddress; + } + printf(" max packet size: %04X\n", endpoint->wMaxPacketSize); + printf(" polling interval: %02X\n", endpoint->bInterval); + } + } + } + libusb_free_config_descriptor(conf_desc); + + for (iface = 0; iface < nb_ifaces; iface++) + { + printf("\nClaiming interface %d...\n", iface); + r = libusb_claim_interface(handle, iface); +#ifdef OS_LINUX + if ((r != LIBUSB_SUCCESS) && (iface == 0)) { + // Maybe we need to detach the driver + perr(" Failed. Trying to detach driver...\n"); + libusb_detach_kernel_driver(handle, iface); + iface_detached = iface; + printf(" Claiming interface again...\n"); + r = libusb_claim_interface(handle, iface); + } +#endif + if (r != LIBUSB_SUCCESS) { + perr(" Failed.\n"); + } + } + + printf("\nReading string descriptors:\n"); + for (i=0; i<3; i++) { + if (string_index[i] == 0) { + continue; + } + if (libusb_get_string_descriptor_ascii(handle, string_index[i], string, 128) >= 0) { + printf(" String (0x%02X): \"%s\"\n", string_index[i], string); + } + } + + switch(test_mode) { + case USE_XBOX: + CALL_CHECK(display_xbox_status(handle)); + CALL_CHECK(set_xbox_actuators(handle, 128, 222)); + msleep(2000); + CALL_CHECK(set_xbox_actuators(handle, 0, 0)); + break; + case USE_HID: + test_hid(handle, endpoint_in); + break; + default: + break; + } + + if (test_scsi) { + CALL_CHECK(test_mass_storage(handle, endpoint_in, endpoint_out)); + } + + printf("\n"); + for (iface = 0; iface= 0) { + printf("Re-attaching kernel driver...\n"); + libusb_attach_kernel_driver(handle, iface_detached); + } +#endif + + printf("Closing device...\n"); + libusb_close(handle); + + return 0; +} + +int main(int argc, char** argv) +{ + bool show_help = false; + bool got_vidpid = false; + bool debug_mode = false; + const struct libusb_version* version; + int j, r; + size_t i, arglen; + unsigned tmp_vid, tmp_pid; + uint16_t endian_test = 0xBE00; + + // Default to HID, expecting VID:PID + VID = 0; + PID = 0; + test_mode = USE_HID; + + if (((uint8_t*)&endian_test)[0] == 0xBE) { + printf("Despite their natural superiority for end users, big endian\n" + "CPUs are not supported with this program, sorry.\n"); + return 0; + } + + if (argc >= 2) { + for (j = 1; j= 2) ) { + switch(argv[j][1]) { + case 'd': + debug_mode = true; + break; + case 'b': + strcat(binary_name, "raw.bin"); + if (j+1 < argc) { + strncpy(binary_name, argv[j+1], 64); + j++; + } + binary_dump = true; + break; + case 'i': + // IBM HID Optical mouse - 1 interface + if (!VID && !PID) { + VID = 0x04B3; + PID = 0x3108; + } + test_mode = USE_HID; + break; + case 'j': + // OLIMEX ARM-USB-TINY JTAG, 2 channel composite device - 2 interfaces + if (!VID && !PID) { + VID = 0x15BA; + PID = 0x0004; + } + test_mode = USE_JTAG; + break; + case 'k': + // Generic 2 GB USB Key (SCSI Transparent/Bulk Only) - 1 interface + if (!VID && !PID) { + VID = 0x0204; + PID = 0x6025; + } + test_mode = USE_KEY; + break; + // The following tests will force VID:PID if already provided + case 'l': + // Plantronics DSP 400, 2 channel HID composite device - 1 HID interface + VID = 0x047F; + PID = 0x0CA1; + test_mode = USE_HID; + break; + case 's': + // Microsoft Sidewinder Precision Pro Joystick - 1 HID interface + VID = 0x045E; + PID = 0x0008; + test_mode = USE_HID; + break; + case 'x': + // Microsoft XBox Controller Type S - 1 interface + VID = 0x045E; + PID = 0x0289; + test_mode = USE_XBOX; + break; + default: + show_help = true; + break; + } + } else { + for (i=0; i 7)) { + printf("usage: %s [-d] [-b [file]] [-h] [-i] [-j] [-k] [-l] [-s] [-x] [vid:pid]\n", argv[0]); + printf(" -h: display usage\n"); + printf(" -d: enable debug output (if library was compiled with debug enabled)\n"); + printf(" -b: dump raw HID report descriptor or Mass Storage first block to binary file\n"); + printf(" -i: test generic HID device (default)\n"); + printf(" -k: test generic Mass Storage USB device (using WinUSB)\n"); + printf(" -j: test FTDI based JTAG device (using WinUSB)\n"); + printf(" -l: test Plantronics Headset (using HID)\n"); + printf(" -s: test Microsoft Sidewinder Precision Pro (using HID)\n"); + printf(" -x: test Microsoft XBox Controller Type S (using WinUSB)\n"); + return 0; + } + + version = libusb_getversion(); + printf("Using libusb v%d.%d.%d.%d\n\n", version->major, version->minor, version->micro, version->nano); + r = libusb_init(NULL); + if (r < 0) + return r; + + // Warnings = 2, Debug = 4 + libusb_set_debug(NULL, debug_mode?4:2); + + test_device(VID, PID); + + libusb_exit(NULL); + + return 0; +} + -- cgit v1.2.3