summaryrefslogtreecommitdiff
path: root/debug/comm/arduino_comm/arduino_comm.ino
blob: 4a2b205835ecc936ac7e5549bd1464ff6290b525 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
String tlocd = "";
String locd = "";
bool readloc = false;
unsigned long datatime = 0;

void setup() {
  Serial1.begin(19200);
  Serial.begin(19200); 
}

void loop() {
  if(Serial1.available()){
    datatime = millis(); 

    byte byteRead = Serial1.read();
    
    if(byteRead == 's'){
      tlocd = ""; 
      readloc = true;
    }
    else if(byteRead == 'e'){
      readloc = false;
      locd = tlocd;
    }
    else if(readloc == true){
      tlocd += (char)byteRead;
    }
  }
  else{
    if(millis() - datatime > 5000){
      Serial.println("Err no data recieved for 5 sec");  
      locd = "999";
    }
  }
  Serial.println(locd);
  delay(134);
}