Bmag incl gps rettelse

Dependencies:   mbed WDT MODSERIAL BME280

Revision:
8:d6287c33b54a
Parent:
7:872984a67d5b
Child:
19:5d25cffef662
--- a/SPS/SPS.cpp	Wed Mar 15 13:56:53 2017 +0000
+++ b/SPS/SPS.cpp	Thu Mar 23 10:11:26 2017 +0000
@@ -6,13 +6,13 @@
     currentString = "";
     currentErrString = "";
     lastString = "";
-    headerString = "/tag identifier_id group_id date time zzz | s1 source_id interpreter_id data_line_version encoding source_firmware_version interpreter_firmware_version | latitude longitude gpsFixFlag mag_time mag_nt mag_sq checksum";
+    headerString = "/tag identifier_id group_id date time zzz | s1 source_id interpreter_id data_line_version encoding source_firmware_version interpreter_firmware_version | barcode latitude longitude gpsFixFlag batteryvoltage mag_time mag_nt mag_sq checksum";
     crc_tab16_init = 0;
     errStatus = true;
            
 };
 
-void SPS::UpdateCurrentString(string tag, string identifier_id, string group_id, string date, string time, string ZZZ,string s1, string source_id, string interpreter_id, string data_line_version, string source_firmware_version, string interpreter_firmware_version, string latitude, string longitude, bool gpsFixFlag, string mag_time, string mag_nt, string mag_sq, Serial * dbg){
+void SPS::UpdateCurrentString(string tag, string identifier_id, string group_id, string date, string time, string ZZZ,string s1, string source_id, string interpreter_id, string data_line_version, string source_firmware_version, string interpreter_firmware_version, string barcode, string latitude, string longitude, bool gpsFixFlag, string batteryvoltage, string mag_time, string mag_nt, string mag_sq, Serial * dbg){
 
     currentString = "";
     currentString.resize(256);
@@ -49,6 +49,8 @@
     addToCurrentString(SPACE);
     addToCurrentString(HEADEREND);
     addToCurrentString(SPACE);
+    addToCurrentString(barcode);
+    addToCurrentString(SPACE);
     addToCurrentString(latitude);
     addToCurrentString(SPACE);
     addToCurrentString(longitude);
@@ -62,16 +64,14 @@
     }
     
     addToCurrentString(SPACE);
+    addToCurrentString(batteryvoltage);
+    addToCurrentString(SPACE);
     addToCurrentString(mag_time);
     addToCurrentString(SPACE);
     addToCurrentString(mag_nt);
     addToCurrentString(SPACE);
     addToCurrentString(mag_sq);
     
-    //dbg->printf("CurrentStringBeforeChecksumCalc: ");
-    //dbg->printf(currentString.c_str());
-    //dbg->printf("\r\n");
-    
     //calculate checksum
     for(int i = 0; i < strlen(currentString.c_str()); i++){
         if(currentString[i] != '>' || currentString[i] != '<'){
@@ -86,8 +86,7 @@
     //append rest of string
     addToCurrentString(SPACE);
     addToCurrentString(checkSum);
-    addToCurrentString(LINESTOP);
- 
+    addToCurrentString(LINESTOP); 
 };
 
 //Updates current ERR string   
@@ -148,9 +147,7 @@
     //append rest of string
     addToCurrentErrString(SPACE);
     addToCurrentErrString(checkSum);
-    addToCurrentErrString(LINESTOP);    
-    
-    
+    addToCurrentErrString(LINESTOP);   
 };
 
 //Fills the array for calculation of the CRC-16 with values
@@ -222,10 +219,19 @@
 void SPS::addToCurrentString(string data){
     int currentStartIndex = strlen(currentString.c_str());
     char dataStrLen = 0;
+    int index = 0;
+    
     dataStrLen = strlen(data.c_str());
     
     for(int i = 0; i < dataStrLen; i++){
-        currentString[currentStartIndex+i] = data[i];               
+        
+        if((currentString[currentStartIndex+i] != '\r') || (currentString[currentStartIndex+i] != '\n')){
+            
+            currentString[currentStartIndex+i] = data[index];
+            index += 1;
+                  
+        }
+                     
     }                
 }