 void loop() {
   // put your main code here, to run repeatedly:
   char* gpsbuffer;
+  gpsSerial.listen();
 // Initialize buffer for gps data
-  Serial.println("Try to communicate");
+/*  Serial.println("Try to communicate");
+  Serial.print("Buffer size: ");
   Serial.println(gpsSerial.available());
- 	if (gpsSerial.available() > 0&&gpsSerial.peek()=='$'){
-   gpsbuffer=dynamic_array_Serial(gpsSerial,100);
+  Serial.print("First byte in buffer: ");
+  Serial.println(gpsSerial.peek());
+  Serial.println(gpsSerial.available());*/
+  //Serial.println(gpsSerial.read());
+  //Serial.println("Waiting for buffer to be filled");
+ //	if (gpsSerial.available() > 0){
+   gpsbuffer=dynamic_array_Serial(gpsSerial,100,'$','*');
+   Serial.println("Succeed in loading buffer with data");
    Serial.println(array_length);
    //Serial.print(gpsbuffer[0]);
    /* while (!(gpsSerial.findUntil("$GPRMC,",'*'))){

  while(src.available()>0){//Cant go into this loop
    char temp=src.read();
    delay(20);
    if(temp!='*'){
      max_array[array_length-1]=temp;
      array_length++;
      //Serial.println(max_array[array_length-1]);

   
    //gpsbuffer[i]=" ";
  }
  Serial.println();
 //	}
 /* else{
    Serial.println("Fail to communicate!");
  }
 */
  //Serial.println();
//	For Testing only
  array_length=1;
  //Serial.println("Flushing serial");
  //gpsSerial.flush();
  free(gpsbuffer);
  delay(1000);//Waiting for bytes to fill IO buffer
  

}
char* dynamic_array_Serial(SoftwareSerial src,int max_length,char start_char,char terminator){
  src.listen();
  while(src.available()<=0);//Waiting for bytes to fill buffer
  while(src.read()!=start_char);//Waiting for the start char
  extern int array_length;
  Serial.println("Successful");
  //Serial.println(array_length); Testing
