On 03/04/2014 10:37 PM, Phil Dibowitz wrote:
> On 03/04/2014 12:11 PM, Scott Talbert wrote:
>> On Tue, 4 Mar 2014, Phil Dibowitz wrote:
>>
>>>> Just for kicks, have you tried running with debug turned off?
>>>
>>> Yup... on this thing I've done most of my work wiht debug turned off and 
>>> then
>>> verified with debug on to get more info (to avoid these sorts of
>>> race-condition issues).
>>
>> Maybe try commenting out the printf's we're doing during config reads and 
>> writes (in the callback)?
> 
> Yeah, I did removed all those to ensure that the PRI change was actually
> working for the 885 dump.
> 
> Ugh... I'll find some time to do more digging.

Ok, sick of waiting for crap to compile/run/etc. on my hold G4, I borrowed a
macbook pro.

And all of the things just worked without any crazy hidapi hackery, or
ignoring certain ACKs. So I'm going to merge the attached patch... it's far
more simple than previous ones, and works on both OSX and Linux.

I commented on the PR for hidapi - it's unclear to me of the problems are bad
hardware, old OSX, old USB, or what... but it works on modern stuff, so I'm
going to stop wasting time. :)

-- 
Phil Dibowitz                             p...@ipom.com
Open Source software and tech docs        Insanity Palace of Metallica
http://www.phildev.net/                   http://www.ipom.com/

"Be who you are and say what you feel, because those who mind don't matter
 and those who matter don't mind."
 - Dr. Seuss

commit 522238e78aeb0ae42dc3533c3412bd79a8746290
Author: Phil Dibowitz <p...@ipom.com>
Date:   Sun Dec 1 23:10:48 2013 -0800

    Various MacOSX fixes
    
    libconcord/configure.ac
    libconcord/Makefile.am
    * Start using pkg-config to find zlib - on OSX, some header files
      are in strange places
    
    libconcord/INSTALL.mac
    * Added homebrew version of instructions
    * Tweaked instructions for pkg-config change
    
    libconcord/libhidapi.cpp
    * Do not call hid_exit() in ShutdownUSB() or we can never re-grab
      the remote after a reset - instead use atexit() from InitUSB
    
    libconcord/hid.h
    * Update the default read timeout to 1s - required on my old mac,
      but probably not a mac issue in general.
    
    Signed-off-by: Phil Dibowitz <p...@ipom.com>

diff --git a/libconcord/INSTALL.mac b/libconcord/INSTALL.mac
index 10d215a..3010ed7 100644
--- a/libconcord/INSTALL.mac
+++ b/libconcord/INSTALL.mac
@@ -4,18 +4,31 @@
 
 You'll need the Xcode tools installed before you can do anything.
 
-You'll need to install pkgconfig. I used the Mac package here:
+From there, there's two different ways to get the requirements: (1) homebrew
+or (2) a combination of macpkg + compiling software yourself. Using homebrew
+is highly recommended.
+
+OPTION 1: HOMEBREW
+
+Install Homebrew from: http://brew.sh/
+
+Tell Homebrew to install all the requirements:
+
+  brew install libusb libusb-compat pkgconfig autoconf automake libtool libzip
+
+OPTION 2: MANUAL PACKAGE INSTALLATION
+
+First, install pkgconfig. The Mac package here is pre-built and tested:
 
 http://macpkg.sourceforge.net/
 
 You will then need to set the following in your environment for everything
 else to go smoothly:
-
   export PATH=$PATH:/opt/pkgconfig/bin
   export PKG_CONFIG=/opt/pkgconfig/bin/pkg-config
   export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig
 
-You must install libusb-1.0. It's fairly straight forward to install, it should
+Next, install libusb-1.0. It's fairly straight forward to install, it should
 be:
    ./configure --prefix=/usr
    make
@@ -24,39 +37,57 @@ be:
 If you get errors about -System while building libusb, upgrade your version of
 Xcode.
 
-You must install libusb-0.1-compat as well. It requires libusb-1.0, so install
-that first. It is also straight forward:
+You must install libusb-0.1-compat as well. This requires libusb-1.0 (it's not
+an alternative). It is also straight forward:
    ./configure --prefix=/usr
    make
    sudo make install
 
-You must install hidapi (there's a few similarly named projects, you want:
-https://github.com/signal11/hidapi). Grab the source from git (NOT a release),
-and do:
-   ./bootstrap
+Finally, you will need to install libzip, which again is straight forward:
    ./configure --prefix=/usr
    make
    sudo make install
 
-Finally, you will need to install libzip, which again is straight forward:
+1. INSTALL HIDAPI (an additional pre-req)
+
+This has to be installed manually, so even if you are using homebrew, you
+still have to do this one from scratch (since you need fixes from 'git' that
+are not yet in a release). There's a few similarly named projects, you want:
+   https://github.com/signal11/hidapi
+
+Grab the source from git (NOT a release), and do:
+   ./bootstrap
    ./configure --prefix=/usr
    make
    sudo make install
- 
 
-1. BUILD THE LIBRARY
+2. BUILD LIBCONCORD
 
    As a normal user...
-     A. ***IF**** You are building from CVS, run "autoreconf --install"
+     A. ****IF**** You are building from git run "autoreconf --install"
+        Note that if you compiled the depenencies by hand, you proably
+        need to do this instead:
+          aclocal -I /opt/pkgconfig/share/aclocal
+          autoheader
+          automake
+          autoconf
      B. Run "./configure"
      C. Run "make"
 
 Various options, such as '--prefix' are available to the configure script to
 help you choose where software gets installed and how it is built.
 
-2. INSTALL THE SOFTWARE
+3. INSTALL THE SOFTWARE
 
 As root, simply run "make install"
 
 
+==== UNINSTALLATION ====
+
+Due to a bug in libtool on OSX, 'make uninstall' won't actually remove
+everything from your system. You will need to do:
+    sudo rm -f /usr/lib/libconcord*
+
+Assuming you installed with a prefix of /usr
+
 vim:textwidth=78:
diff --git a/libconcord/Makefile.am b/libconcord/Makefile.am
index 50a6fd3..93206d9 100644
--- a/libconcord/Makefile.am
+++ b/libconcord/Makefile.am
@@ -8,6 +8,7 @@ libconcord_la_SOURCES = remote.cpp remote_z.cpp libconcord.cpp binaryfile.cpp \
 include_HEADERS = libconcord.h
 libconcord_la_CPPFLAGS = -Wall
 libconcord_la_LDFLAGS = -version-info 3:0:0 $(LIBCONCORD_LDFLAGS) -lzip
+libconcord_la_CXXFLAGS = $(ZIP_CFLAGS)
 UDEVROOT ?= /
 UDEVLIBDIR ?= $(UDEVROOT)/lib
 
@@ -60,8 +61,8 @@ install_consolekit: consolekit install_udev_common
 newmimedir = $(datadir)/mime/packages
 newmime_DATA = libconcord.xml
 
-EXTRA_DIST =                           \
-	$(mime_DATA)                    \
+EXTRA_DIST = \
+	$(mime_DATA) \
 	$(newmime_DATA)
 
 install-data-hook:
diff --git a/libconcord/configure.ac b/libconcord/configure.ac
index 48a453f..cc5898b 100644
--- a/libconcord/configure.ac
+++ b/libconcord/configure.ac
@@ -74,12 +74,7 @@ then
   fi
   AC_MSG_ERROR([$errorstr])
 fi
-AC_CHECK_HEADER(zip.h, [], [a=0])
-AC_CHECK_LIB(zip, zip_open, [], [a=0])
-if test $a == 0
-then
-    AC_MSG_ERROR([Error, libzip is missing!])
-fi
+PKG_CHECK_MODULES([ZIP], [libzip])
 AC_CONFIG_FILES([
     Makefile
 ])
diff --git a/libconcord/hid.h b/libconcord/hid.h
index 62bb369..a499d94 100644
--- a/libconcord/hid.h
+++ b/libconcord/hid.h
@@ -38,6 +38,6 @@ void ShutdownUSB();
 int FindRemote(THIDINFO &hid_info);
 
 int HID_WriteReport(const uint8_t *data);
-int HID_ReadReport(uint8_t *data, unsigned int timeout = 500);
+int HID_ReadReport(uint8_t *data, unsigned int timeout = 1000);
 
 #endif
diff --git a/libconcord/libhidapi.cpp b/libconcord/libhidapi.cpp
index 9acdbc7..3e8ace1 100644
--- a/libconcord/libhidapi.cpp
+++ b/libconcord/libhidapi.cpp
@@ -51,6 +51,12 @@ hid_device *h_dev;
 int InitUSB()
 {
     hid_init();
+    /*
+     * Note we do NOT call hid_exit() in ShutdownUSB, because you can
+     * never reinitialize libhidapi - and on a reset, we need
+     * to come back and do more stuff. So we set it up as an atexit()
+     */
+    atexit((void(*)())hid_exit);
     return 0;
 }
 
@@ -59,7 +65,6 @@ void ShutdownUSB()
     if (h_dev) {
         hid_close(h_dev);
     }
-    hid_exit();
 }
 
 bool is_harmony(struct hid_device_info *dev)

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
concordance-devel mailing list
concordance-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/concordance-devel

Reply via email to