datenformat vereinheitlicht
[svn42.git] / rf433rcv / pc / rawhid_test.c
index eaef389..2e0ac11 100644 (file)
@@ -17,7 +17,7 @@ static char get_keystroke(void);
 
 void sendstr(char * tosend)
 {
-  rawhid_send(0, tosend, strlen(tosend),100);
+  rawhid_send(0, tosend, strlen(tosend),1000);
 }
 
 int main (int argc, char *argv[])
@@ -40,13 +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, 1, 63, f);
-    for(i=len+1;i<64;i++)
-      buf[i]=0xff;
-    rawhid_send(0, buf, 64, 100); //fill the buffer
-    sendstr("s\x10"); // send 4 times
+    buf[0]='f'; 
+    size_t len;
+    while ( ( len = fread(buf+1, 1, 63, f)  ) )
+    {
+      
+      rawhid_send(0, buf, 64, 1000); //fill the buffer
+      printf("Sending Buffer %d bytes\n",len);
+      for(i=0;i<len+1;i++)
+      {
+        printf("%02x ",(unsigned char) buf[i]);
+      }  
+      printf("\n");
+    }
+    printf("Executing Send command\n");
+    sendstr("s\x20"); // send 32 times
     len = rawhid_recv(0, buf, 64, 255);
     for(i=0;i<len;i++)
     {
@@ -72,13 +82,13 @@ int main (int argc, char *argv[])
             } else {
               printf("0");
             }
-            printf(",");
+            // printf(",");
             buf[i/8]<<=1;
           }
       }
       // check if any input on stdin
       while ((c = get_keystroke()) >= 32) {
-        printf("\ngot key '%c', sending...\n", c);
+        fprintf(stderr,"\ngot key '%c', sending...\n", c);
         buf[0] = c;
         for (i=1; i<64; i++) {
           buf[i] = 0;