X-Git-Url: https://git.realraum.at/?a=blobdiff_plain;f=rf433rcv%2Fpc%2Frawhid_test.c;h=38f34015ccbe11323f5b4597f2e7d9f8ffb86170;hb=ac71234587241032871cfb0745471f011fcbb943;hp=3bccde495ab322f84c99806ecf3fcd003820a99b;hpb=02293cb00639b97ca422619ee15f5981a5b3ffd0;p=svn42.git diff --git a/rf433rcv/pc/rawhid_test.c b/rf433rcv/pc/rawhid_test.c index 3bccde4..38f3401 100644 --- a/rf433rcv/pc/rawhid_test.c +++ b/rf433rcv/pc/rawhid_test.c @@ -1,6 +1,7 @@ #include #include #include +#include #if defined(OS_LINUX) || defined(OS_MACOSX) #include @@ -14,12 +15,15 @@ static char get_keystroke(void); +void sendstr(char * tosend) +{ + rawhid_send(0, tosend, strlen(tosend),1000); +} int main (int argc, char *argv[]) { int i, r, num; char c, buf[64]; - // C-based example is 16C0:0480:FFAB:0200 r = rawhid_open(1, 0x16C0, 0x0480, 0xFFAB, 0x0200); if (r <= 0) { @@ -36,12 +40,23 @@ int main (int argc, char *argv[]) FILE * f = fopen (argv[1], "r"); if (!f) return -3; + printf("Clearing Buffer\n"); + sendstr("c"); // clear the buffer buf[0]='f'; - size_t len= fread(buf+1, 63, 1, f); - rawhid_send(0, buf, 1+len, 100); - buf[0]='s'; - buf[1]=4; - rawhid_send(0, buf, 2, 100); + while ( fread(buf+1, 1, 63, f) ) + { + + rawhid_send(0, buf, 64, 1000); //fill the buffer + printf("Sending Buffer\n"); + } + printf("Executing Send command\n"); + sendstr("s\x10"); // send 4 times + size_t len = rawhid_recv(0, buf, 64, 255); + for(i=0;i