summaryrefslogtreecommitdiffstats
path: root/host/main.c
diff options
context:
space:
mode:
authorJames McKenzie <git@madingley.org>2015-08-03 10:34:07 +0100
committerJames McKenzie <git@madingley.org>2015-08-03 10:34:07 +0100
commit061430973e82995368d27ff9081391f9475da3c7 (patch)
tree62ac12e6cff789050ca17f00ac70d85de75e3efd /host/main.c
parent23e5d273ef3e11c8ad463c632daa5a52684bc5bb (diff)
downloadcandlestick-061430973e82995368d27ff9081391f9475da3c7.tar.gz
candlestick-061430973e82995368d27ff9081391f9475da3c7.tar.bz2
candlestick-061430973e82995368d27ff9081391f9475da3c7.zip
fish
Diffstat (limited to 'host/main.c')
-rw-r--r--host/main.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/host/main.c b/host/main.c
new file mode 100644
index 0000000..a779cc1
--- /dev/null
+++ b/host/main.c
@@ -0,0 +1,101 @@
+#include "project.h"
+
+
+
+static void poke(libusb_device_handle *devh)
+{
+uint32_t timeout=4000;
+char buf[128];
+int len;
+
+len= libusb_control_transfer( devh,
+ /* bmRequestType */ LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_INTERFACE,
+ /* bRequest */ 0x34,
+ /* wValue */ 0x1234,
+ /* wIndex */ 0x5678,
+ /* Data */ buf,
+ /* wLength */ sizeof(buf), timeout );
+
+
+
+
+if (len>=0)
+hexdump(">",buf,len);
+
+
+}
+
+
+
+static void poke_device(libusb_device *dev, struct libusb_device_descriptor *desc)
+{
+int ret;
+libusb_device_handle *devh;
+
+ret=libusb_open(dev, &devh);
+
+if (ret) {
+ warn("unable to open device: %i",ret);
+ return;
+}
+
+printf("poke\n");
+
+poke(devh);
+
+libusb_close(devh);
+
+}
+
+void probe_devices(libusb_context *ctx)
+{
+ libusb_device **list;
+ ssize_t num_devs;
+ ssize_t i;
+
+ num_devs = libusb_get_device_list(ctx, &list);
+ for (i = 0; i < num_devs; ++i) {
+ struct libusb_device_descriptor desc;
+ struct libusb_device *dev = list[i];
+
+ if (libusb_get_device_descriptor(dev, &desc))
+ continue;
+
+
+ if (desc.idVendor!=0x1d6b) continue;
+ if (desc.idProduct!=0x1932) continue;
+
+ poke_device(dev,&desc);
+
+ }
+ libusb_free_device_list(list, 0);
+}
+
+
+
+
+
+int main(int argc,char *argv)
+{
+ int ret;
+
+ libusb_context *ctx;
+
+
+ ret = libusb_init(&ctx);
+ if (ret)
+ errx(EX_IOERR, "unable to initialize libusb: %i", ret);
+
+
+ libusb_set_debug(ctx, 255);
+
+ probe_devices(ctx);
+
+ return 0;
+}
+
+
+
+
+
+