diff options
Diffstat (limited to 'tools/atmega324u_usbhid/rawhid_testinterface.c')
-rw-r--r-- | tools/atmega324u_usbhid/rawhid_testinterface.c | 23 |
1 files changed, 12 insertions, 11 deletions
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 <string.h> #include <sys/time.h> #include <unistd.h> +#include <stdint.h> #if defined(OS_LINUX) || defined(OS_MACOSX) #include <sys/ioctl.h> #include <termios.h> @@ -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<NUM_DEVICE_IDS; d++) + { + r = rawhid_open(1, 0x16C0, dev_ids[d], 0xFFAB, 0x0200); + if (r > 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); |