From 6ad3af1f3b01c5c5e78f91fbb71f77d034fad7c1 Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Sat, 19 May 2012 20:48:31 +0000 Subject: attempt to open several usb device ids git-svn-id: https://svn.spreadspace.org/mur.sat@444 7de4ea59-55d0-425e-a1af-a3118ea81d4c --- tools/atmega324u_usbhid/rawhid_testinterface.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'tools/atmega324u_usbhid') diff --git a/tools/atmega324u_usbhid/rawhid_testinterface.c b/tools/atmega324u_usbhid/rawhid_testinterface.c index 386fa9e..48246c3 100644 --- a/tools/atmega324u_usbhid/rawhid_testinterface.c +++ b/tools/atmega324u_usbhid/rawhid_testinterface.c @@ -4,6 +4,7 @@ #include #include #include +#include #if defined(OS_LINUX) || defined(OS_MACOSX) #include #include @@ -27,16 +28,23 @@ int mtime_diff(struct timeval high,struct timeval low) } #define BUF_LEN 64 +#define NUM_DEVICE_IDS 3 +uint16_t dev_ids[] = {0x0481, 0x0480, 0x0482}; int main (int argc, char *argv[]) { - int r, num; + int r, num, d; char buf[BUF_LEN]; // C-based example is 16C0:0480:FFAB:0200 unsigned int attemtps = 100; while(attemtps--) { - r = rawhid_open(1, 0x16C0, 0x0481, 0xFFAB, 0x0200); + for (d=0; d 0) + break; + } if (r > 0) break; else @@ -46,16 +54,9 @@ int main (int argc, char *argv[]) { printf("no rawhid device found\n"); return -1; - } + } printf("found rawhid device\n\n"); - //~ printf("Clearing Buffer\n"); - //~ sendstr("c"); // clear the buffer - //~ struct timeval start_time,stop_time; - //~ gettimeofday(&start_time,NULL); - //~ gettimeofday(&stop_time,NULL); - //~ while (mtime_diff(stop_time,start_time)<1000) { - // check if any Raw HID packet has arrived - + while (1) { num = rawhid_recv(0, buf, BUF_LEN, 250); -- cgit v1.2.3