James Heavey / 3875_Individualproject

Dependents:   3875_DISSERTATION

Revision:
8:92167bd3eb44
Parent:
7:b4fc73882a2a
Child:
9:074ce6197b51
--- a/m3pi.cpp	Wed Jul 05 13:02:24 2017 +0000
+++ b/m3pi.cpp	Wed Jul 05 14:39:33 2017 +0000
@@ -43,13 +43,15 @@
 
 void m3pi::get_raw_values(unsigned int *values)
 {
+    while (_serial->readable() ) {  // flush buffer
+     _serial->getc();   
+    }
+    
     char vals[10];                     // array to receive 10 byte return message
     _serial->putc(0x86);                // send command
 
-    int n=0;
-    while ( _serial->readable() ) {     // keep looping while data on rx line
-        vals[n] = _serial->getc();      // read into array
-        n++;                            // increment index
+    for (int i=0; i < 10; i++) {
+        vals[i] =  _serial->getc();   
     }
 
     for(int i=0; i<5; i++) {            // construct the 2-byte values