   long len;
 } CommandPacket;
 
-
+//Builtin functions
 void setup();
 void loop();
-void error(int error);
+//Table of Contents functions
+void start();
+void enroll(Command cmd, uint32_t param);
+//Utility functions
+void flash(uint32_t num,int time);
+//Error leaf function
+void error(uint32_t error);
+//Send packet functions
 CommandPacket* getCommand(Command cmd);
 void setParameter(CommandPacket* packet,uint16_t value);
 void fillChecksum(uint8_t* bytes,long len);
-CommandPacket* sendCommand(CommandPacket* packet);
+uint32_t sendCommand(CommandPacket* packet);
+//Read packet functions
+CommandPacket* readCommand();
+//Bytes read send
 void sendBytes(uint8_t* bytes,long len);
-CommandPacket* readCommand();
-void readBytes(uint8_t* bytes,long len);
+void recvBytes(uint8_t* bytes,long len);
 
 /**
  * Setups up the baudrate to be 9600 and

void loop()
{
  CommandPacket* led = getCommand(CMOS_LED);
  CommandPacket* res;
  while (true)
  {
    setParameter(led,1);
    res = sendCommand(led);
    //if (res->cmd == ACK)
    digitalWrite(ERROR_PIN, LOW);
    //else
    //  digitalWrite(ERROR_PIN, LOW);
    free(res);
    delay(5000);
    setParameter(led,0);
    res = sendCommand(led);
    //if (res->cmd == ACK)
      digitalWrite(ERROR_PIN, HIGH);
    //else
    //  digitalWrite(ERROR_PIN, HIGH);
    free(res);
    delay(5000);      
  }
}
/**
 * Flash arduino LED on error
 * error - number of times to flash
 */
void error(int error)
{
  Serial.end();
  int i = 0;
  while(true)
  {
    //Flash "error" number of times.
    for (i = 0; i < error; i++)
    {
      digitalWrite(ERROR_PIN, HIGH);
      delay(200);
      digitalWrite(ERROR_PIN, LOW);
      delay(200);
    }
    delay(1800);
  }
}


void sendBytes(uint8_t* bytes,long len) 
{
  fillChecksum(bytes,len);
  int i = 0;
  /*Serial.print("< ");
  for (i = 0; i < len; i++) {
    Serial.print(bytes[i],HEX);
    Serial.print(" ");
  }
  Serial.println();*/
  if (Serial.write(bytes,len) != len)
    error(10);
}
