summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorBernhard Tittelbach <xro@realraum.at>2012-05-19 20:48:31 +0000
committerBernhard Tittelbach <xro@realraum.at>2012-05-19 20:48:31 +0000
commit6ad3af1f3b01c5c5e78f91fbb71f77d034fad7c1 (patch)
tree65c6e11c8dfbffba26bac9c25a492b418a1fb1c1 /tools
parentmoved hid70dongle usbhid pc interface (diff)
attempt to open several usb device ids
git-svn-id: https://svn.spreadspace.org/mur.sat@444 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'tools')
-rw-r--r--tools/atmega324u_usbhid/rawhid_testinterface.c23
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);