Commits

Alex Hixon  committed dc6c522

Try to get 2 bytes send/receive.

  • Participants
  • Parent commits b37620c

Comments (0)

Files changed (3)

             device.send (wireless.MessageType.MOVE_RUDDER, deg)
         elif act[0] == "e":
             device.send (wireless.MessageType.MOVE_ELEVATOR, deg)
+
+        print "HMM:", device.read_string()
         
         print "Return code:", wireless.get_response_code(device.response)
 except Exception, e:

File controller/controller.pde

 */
 void read(unsigned int *data, int block)
 {
-    int t = 0;
+    char vals[2];
+    int i = 0;
+    int temp = 0;
+    
     if (block) {
-        while ((t = Serial.read()) == -1) { ;; }
+        // FIXME: add timeout
+        while (TRUE) {
+          temp = Serial.read();
+          if (temp != -1) {
+            vals[i] = temp;
+            i++;
+          }
+          
+          if (i == 2) {
+            break;
+          }
+        }
     } else {
-        t = Serial.read();
+        vals[0] = Serial.read();
+        vals[1] = Serial.read();
     }
     
-    // since *data is unsigned, make sure no negatives
-    if (t < 0) {
-        t = 0;
-    }
-    *data = t;
+    
+    Serial.print ("HOLY DICK GOT ");
+    *data = (vals[0] << 8) + vals[1];
+    Serial.println (*data);
 }
 
 // send response via serial
                 //send (STATUS_SUCCESS);
                 break;
         }
+        
+        
     }
-}
+}
             self.device.write (chr(msg))
         else:
             a = struct.pack('<cI', chr(msg), args)
-            print a
+            print "Writing:", a
             self.device.write (a)
     
     @property