   String daqString = String(daqTelemetry->systemRpm) + "," +
                      String(daqTelemetry->systemVoltage) + "," +
                      String(daqTelemetry->systemCurrent) + "," +
-                     outputDistance;
+                     String(outputDistance) + "," +
+                     logs + "," +
+                     (millis() / 1000.0 );
   Serial.println(daqString);
 }
 
-/**
-   TBD
-*/
-
+int update_watchdog_timer(){
+  watchdogTimer = watchdogTimer + ( millis() - lastTime );
+  lastTime = millis();
+  return watchdogTimer;
+}
 
 void loop() {
+  Serial.println(watchdogTimer);
   if (Serial.available() > 0) {
-    control_input();
-  }
-  //Solve serial buffer problem
+    process_code( retrieve_code() );
+  }
   daqTelemetry = daq();
   save_and_send(daqTelemetry);
+  
+ update_watchdog_timer();
+  if(watchdogEnabled == true){
+    if(watchdogTimer > timeoutTime){
+      process_code( recallCode );
+    }
+  }
+  Serial.print("freeMemory()=");
+  Serial.println(freeMemory());
+  logs = "Null";
   delete daqTelemetry;
-  //Serial.print("freeMemory()=");
-  //Serial.println(freeMemory());
-}
-
+}
+

#include "MemoryFree.h"
#include "DaqTelemetry.h"

//Defined as a global for memory 
DaqTelemetry *daqTelemetry;

//Motor
int enablePin = 13; //enable/disable motor
int revPin = 11; //seting fwd/rev
int brakePin = 12; //brake pin
int speedPin = 6; //speedPin
int voltagePin = A0; //ammeter voltage pin
int currentPin = A1; //ammeter current pin
int encoderPin = A5; //pin for motor controller

  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);


  //enabling the serial connection
  Serial.begin(9600);
}
