 }
 int j = 0;
 int k = 0;
-int enable = 1;
+volatile int enable = 1;
 long led_on_time=0;
 void loop()
 {
   unsigned char c, dtr;
 	static unsigned char prev_dtr = 0;
-  delay(2000);
+
   //while(j <  20)
   //{
   if (Serial.available()) {
+    //Uart.flush();
+    enable = 0;
 	c = Serial.read();
+    if(c == '$' ) enable  =1;
+    if(c == '^') Uart.flush();
 	Uart.write(c);
 	digitalWrite(led_pin, led_on);
 	led_on_time = millis();
 	return;
 	}
-if(enable)
+if(enable == 1)
 {
+    delay(2000);
   uint16_t length = tx_packet.prepare2send();
   uint16_t i;
   for(i = 0; i < length; i++)
   {
     //Uart.print(tx_buffer1[i], BYTE);
+//    delayMicroseconds(10);
     Uart.write(tx_buffer1[i]);
 
   }

	}
  Serial.println("EOR");
//  tx_packet.push_back( (uint8_t) j+1);
}
    dtr = Serial.dtr();
	if (dtr && !prev_dtr) {

RxPacket rx_packet;

uVector myvector;
static uint8_t * tx_buffer1;

HardwareSerial Uart = HardwareSerial();
unsigned long baud = 9600;
