summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolai Kondrashov <spbnick@gmail.com>2012-04-05 11:51:03 +0300
committerNikolai Kondrashov <spbnick@gmail.com>2012-04-05 11:52:14 +0300
commit43e1967e3fb618093af7e4e0fdf2e17d6c5763bb (patch)
tree3a93668f6443da34e113652784ae019ce7b484b1
parent81eab80f40fd6c0d7ffb3734e27480ea5617807a (diff)
downloadusbhid-dump-waltop.tar.gz
Add Waltop proprietary mode enablingwaltop
Add sending of Waltop proprietary mode-enabling feature set report before starting the stream dumping.
-rw-r--r--configure.ac2
-rw-r--r--include/uhd/iface.h16
-rw-r--r--lib/iface.c39
-rw-r--r--src/usbhid-dump.c4
4 files changed, 60 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 98ac558..1177745 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
-AC_INIT([usbhid-dump], [1.3])
+AC_INIT([usbhid-dump], [1.3-waltop])
AC_CONFIG_AUX_DIR([auxdir])
AM_INIT_AUTOMAKE([1.9 -Wall foreign])
AM_MAINTAINER_MODE
diff --git a/include/uhd/iface.h b/include/uhd/iface.h
index d6bd67d..c60fd40 100644
--- a/include/uhd/iface.h
+++ b/include/uhd/iface.h
@@ -149,6 +149,22 @@ extern enum libusb_error uhd_iface_set_protocol(
unsigned int timeout);
/**
+ * Set Waltop mode feature.
+ *
+ * @param iface The interface to set the feature report to.
+ * @param mode1 The first mode byte.
+ * @param mode2 The second mode byte.
+ * @param timeout The request timeout, ms.
+ *
+ * @return Libusb error code.
+ */
+extern enum libusb_error uhd_iface_set_waltop_mode(
+ const uhd_iface *iface,
+ uint8_t mode1,
+ uint8_t mode2,
+ unsigned int timeout);
+
+/**
* Clear halt condition on the input interrupt endpoint of an interface.
*
* @param iface The interface to clear halt condition on.
diff --git a/lib/iface.c b/lib/iface.c
index 7209188..0d68899 100644
--- a/lib/iface.c
+++ b/lib/iface.c
@@ -241,3 +241,42 @@ uhd_iface_set_protocol(const uhd_iface *iface,
}
+enum libusb_error
+uhd_iface_set_waltop_mode(const uhd_iface *iface,
+ uint8_t mode1,
+ uint8_t mode2,
+ unsigned int timeout)
+{
+ uint8_t report[] = {0x02, mode1, mode2};
+ int rc;
+
+ assert(uhd_iface_valid(iface));
+
+ rc = libusb_control_transfer(iface->dev->handle,
+ LIBUSB_REQUEST_TYPE_CLASS |
+ LIBUSB_RECIPIENT_INTERFACE |
+ LIBUSB_ENDPOINT_OUT,
+ /* Set_Report */
+ 0x09,
+ /* Feature report, ID 2 */
+ 0x0302,
+ /* Interface */
+ iface->number,
+ (unsigned char *)report, sizeof(report),
+ timeout);
+
+ if (rc < 0)
+ fprintf(stderr, "%s: %s\n", __FUNCTION__, libusb_strerror(rc));
+
+ /*
+ * Ignoring EPIPE, which means a STALL handshake, which is OK on
+ * control pipes and indicates request is not supported.
+ * See USB 2.0 spec, 8.4.5 Handshake Packets
+ */
+ if (rc < 0 && rc != LIBUSB_ERROR_PIPE)
+ return rc;
+
+ return LIBUSB_SUCCESS;
+}
+
+
diff --git a/src/usbhid-dump.c b/src/usbhid-dump.c
index 56a2956..5ff8b41 100644
--- a/src/usbhid-dump.c
+++ b/src/usbhid-dump.c
@@ -319,6 +319,10 @@ dump_iface_list_stream(libusb_context *ctx,
/* Set infinite idle duration */
LIBUSB_IFACE_GUARD(uhd_iface_set_idle(iface, 0, UHD_IO_TIMEOUT),
iface, "set infinite idle duration");
+
+ LIBUSB_IFACE_GUARD(uhd_iface_set_waltop_mode(iface, 0x10, 0x01,
+ timeout),
+ iface, "set waltop mode");
}
/* Calculate number of interfaces and thus transfers */