]> Joshua Wise's Git repositories - fpgaboy.git/blobdiff - binwire.c
Merge andrew:/afs/andrew/usr/czl/public/FPGABoy
[fpgaboy.git] / binwire.c
index 3f19ca285b9b3df248953a9792599548c3718f1c..cef0924294a27630901af44fcb23142dc829f843 100644 (file)
--- a/binwire.c
+++ b/binwire.c
@@ -7,10 +7,13 @@
 
 void dowrite(char *s, int len)
 {
-  int i;
-  for (i=0; i<len; i++)
+  int i = 0;
+  while (i < len)
   {
-    write(1, s+i, 1);
+    int cs = ((len-i) > 1) ? 1 : (len-i);
+    
+    write(1, s+i, cs);
+    i += cs;
   }
 }
 
@@ -87,14 +90,22 @@ void main(int argc, char **argv)
   while ((sz = read(rfd, buf+3, 255)) > 0)
   {
     int rv;
+    char abuf[5];
     buf[0] = 0x1B;
     buf[1] = 'D';
     buf[2] = sz+1;
+    abuf[0] = 0x1B;
+    abuf[1] = 'A';
+    abuf[2] = (tc >> 16) & 0xFF;
+    abuf[3] = (tc >> 8) & 0xFF;
+    abuf[4] = tc & 0xFF;
     tc += sz;
     retry:
+    dowrite(abuf, 5);
+    rv = expect("A", 1);
     dowrite(buf, sz + 3);
     fprintf(stderr, "Data sent (%d)\n", tc);
-    rv = expect("D", 1);
+    rv |= expect("D", 1);
     expect_no_chars();
     if (rv)
     {
This page took 0.024365 seconds and 4 git commands to generate.