summaryrefslogtreecommitdiff
path: root/software/hhd70dongle/pcusbhid
diff options
context:
space:
mode:
Diffstat (limited to 'software/hhd70dongle/pcusbhid')
-rw-r--r--software/hhd70dongle/pcusbhid/Makefile7
-rw-r--r--software/hhd70dongle/pcusbhid/rawhid_testinterface.c9
-rw-r--r--software/hhd70dongle/pcusbhid/reset.c22
3 files changed, 31 insertions, 7 deletions
diff --git a/software/hhd70dongle/pcusbhid/Makefile b/software/hhd70dongle/pcusbhid/Makefile
index c6689ed..cd0f018 100644
--- a/software/hhd70dongle/pcusbhid/Makefile
+++ b/software/hhd70dongle/pcusbhid/Makefile
@@ -35,8 +35,7 @@ endif
OBJS = $(PROG).o hid.o
-
-all: $(TARGET)
+all: $(TARGET) reset
$(PROG): $(OBJS)
$(CC) -o $(PROG) $(OBJS) $(LIBS)
@@ -53,6 +52,10 @@ $(PROG).dmg: $(PROG)
hid.o: hid_$(OS).c hid.h
$(CC) $(CFLAGS) -c -o $@ $<
+reset: reset.o hid.o
+ $(CC) -o $@ $+ $(LIBS)
+ $(STRIP) $@
+
reset.o: reset.c
$(CC) $(CFLAGS) -c -o $@ $<
diff --git a/software/hhd70dongle/pcusbhid/rawhid_testinterface.c b/software/hhd70dongle/pcusbhid/rawhid_testinterface.c
index 8f19c4f..1d47daa 100644
--- a/software/hhd70dongle/pcusbhid/rawhid_testinterface.c
+++ b/software/hhd70dongle/pcusbhid/rawhid_testinterface.c
@@ -59,18 +59,17 @@ int main (int argc, char *argv[])
while (1)
{
- num = rawhid_recv(0, buf, BUF_LEN, 220);
+ num = rawhid_recv(0, buf, BUF_LEN, 250);
if (num < 0)
{
printf("\nerror reading, device went offline\n");
rawhid_close(0);
return 0;
}
- else if (num == 0)
+ if (num > 0)
{
- sleep(1.0);
+ buf[num]='\0';
+ printf("%s\n",buf);
}
- buf[num]='\0';
- printf("%s\n",buf);
}
}
diff --git a/software/hhd70dongle/pcusbhid/reset.c b/software/hhd70dongle/pcusbhid/reset.c
new file mode 100644
index 0000000..7955b1b
--- /dev/null
+++ b/software/hhd70dongle/pcusbhid/reset.c
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <string.h>
+
+#include "hid.h"
+
+
+void sendstr(char * tosend)
+{
+ rawhid_send(0, tosend, strlen(tosend),1000);
+}
+
+int main (int argc, char *argv[])
+{
+ // C-based example is 16C0:0480:FFAB:0200
+ int r = rawhid_open(1, 0x16C0, 0x0481, 0xFFAB, 0x0200);
+ if (r <= 0) {
+ printf("no rawhid device found\n");
+ return -1;
+ }
+ sendstr("r"); // clear the buffer
+ return 0;
+}