summaryrefslogtreecommitdiff
path: root/software/hhd70dongle/pcusbhid/rawhid_testinterface.c
diff options
context:
space:
mode:
authorBernhard Tittelbach <xro@realraum.at>2012-05-19 20:48:29 +0000
committerBernhard Tittelbach <xro@realraum.at>2012-05-19 20:48:29 +0000
commit8ddbd3faab208bf46f907f86dba319f3153613de (patch)
treeee2a7425d61f31f9e798f6877a7eaac54097a213 /software/hhd70dongle/pcusbhid/rawhid_testinterface.c
parentclean reset (diff)
moved hid70dongle usbhid pc interface
git-svn-id: https://svn.spreadspace.org/mur.sat@443 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'software/hhd70dongle/pcusbhid/rawhid_testinterface.c')
-rw-r--r--software/hhd70dongle/pcusbhid/rawhid_testinterface.c75
1 files changed, 0 insertions, 75 deletions
diff --git a/software/hhd70dongle/pcusbhid/rawhid_testinterface.c b/software/hhd70dongle/pcusbhid/rawhid_testinterface.c
deleted file mode 100644
index 386fa9e..0000000
--- a/software/hhd70dongle/pcusbhid/rawhid_testinterface.c
+++ /dev/null
@@ -1,75 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <sys/time.h>
-#include <unistd.h>
-#if defined(OS_LINUX) || defined(OS_MACOSX)
-#include <sys/ioctl.h>
-#include <termios.h>
-#elif defined(OS_WINDOWS)
-#include <conio.h>
-#endif
-
-#include "hid.h"
-
-
-void sendstr(char * tosend)
-{
- rawhid_send(0, tosend, strlen(tosend),1000);
-}
-
-int mtime_diff(struct timeval high,struct timeval low)
-{
- int result=1000*(high.tv_sec-low.tv_sec);
- result+=high.tv_usec/1000-low.tv_usec/1000;
- return result;
-}
-
-#define BUF_LEN 64
-
-int main (int argc, char *argv[])
-{
- int r, num;
- 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);
- if (r > 0)
- break;
- else
- sleep(1.0);
- }
- if (r <= 0)
- {
- 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);
- if (num < 0)
- {
- printf("\nerror reading, device went offline\n");
- rawhid_close(0);
- return 0;
- }
- if (num > 0)
- {
- buf[num]='\0';
- printf("%s\n",buf);
- fflush(0);
- }
- }
-}