[hp34comm] fix key stroke reception code draft

Tue, 11 Oct 2016 21:49:43 +0200

author
David Douard <david.douard@logilab.fr>
date
Tue, 11 Oct 2016 21:49:43 +0200
changeset 16
c5e5bdc5ef49
parent 15
ec327bf8f224
child 17
162fe523c37d

[hp34comm] fix key stroke reception code

was not correct

src/hp34comm.cpp file | annotate | diff | comparison | revisions
--- a/src/hp34comm.cpp	Tue Oct 11 21:48:22 2016 +0200
+++ b/src/hp34comm.cpp	Tue Oct 11 21:49:43 2016 +0200
@@ -91,10 +91,6 @@
 	  ack = 1;
 	  wait_us(2);
 	  ack = 0;
-	  wait_us(2);
-	  ack = 1;
-	  wait_us(2);
-	  ack = 0;
 #endif
 	}
       else
@@ -125,14 +121,35 @@
       tx_len = 0xFF;
     }
     else if (tx_len == 0xFF) {
-      // got a cmd, expect a payload size
-      tx_len = val;
-      tx_ack = false;
+      if (val == 0x55) {
+	// packet was in fact a keystroke, tx_cmd is in fact the key
+	// stroke and no payload is expected 
+#ifdef DEBUG2
+      statetx = 1;
+#endif
+      pushCmd((TrState)Tx, tx_cmd, 0, (char*)buf);
+#ifdef DEBUG2
+      wait_us(2);
+      statetx = 0;
+#endif
+      reset();
+      } else {
+	// got a cmd, expect a payload size
+	tx_len = val;
+	tx_ack = false;
+      }
     }
     else if (tx_len == 0x55) {
       // packet was in fact a keystroke, tx_cmd is in fact the key
       // stroke and no payload is expected 
-      pushCmd((TrState)Tx, tx_cmd, 0, NULL);
+#ifdef DEBUG2
+      statetx = 1;
+#endif
+      pushCmd((TrState)Tx, tx_cmd, 0, (char*)buf);
+#ifdef DEBUG2
+      wait_us(2);
+      statetx = 0;
+#endif
       reset();
     }
     else if (tx_len > 0) {

mercurial