Can we parse into a XML file with Arduino

Dear All,

Acrually, I am collecting data and saving it into an EEPROM.
The data is a set of pisition

  • Course
  • Longitude
  • Latitude
  • Altitude
  • Time
  • Spped
  • Stat

I have not test this code yet, but I will past it

Each minutes the a set of GPS coordinate is save into the EEPROM
Each 5 minutes, the 5 sets of coordinate is set to a sevrer . It should send all sets once, this is to avoid 5 connections.
And I am looking how the send the 5 sets in once

Before, how it works,
the void GetGPS() funtion is collection the GPS cordinate each minutes. And exh minute the mask in incremented of 0x0100 (the 1 is representing the inute) . So, at the fift minute, the mask variable is egual at 0x0500;

byte mask = 0x0000;
define EPROM_INC x0100 // THis is the incrementation

char stat[2];
char lon[15];
char lat[15];
char alt[15];
char time[15];
char vel[15];
char coords[74];
char courseid[6];

// THIS IS CALL EACH 5 MIN:
void SendDATA(void){

  Serial.println(F("Data is going to be collected form EEPROM"));
  // Read and get the pos record from the EEPROM

  // HERE I AM MAKING A LOOP STARTING FROM 0x000 and going to the "mask" VALUE. USUAL , IT SHOULD BE 0x0500
  for(byte xmask = 0x0000; xmask <= mask ; xmask = xmask + EPROM_INC){
    courseid = readEEPROM(rom, xmask+EPROM_COU); // READ THE EPROM AT 0x0008, then READ THE EPROM AT 0x0108, then READ THE EERPOM at 0x0208, etc
    lon = readEEPROM(rom, xmask+EPROM_LON); // READ THE EPROM AT 0x0018, then READ THE EPROM AT 0x0118, then READ THE EERPOM at 0x0218, etc
    lat = readEEPROM(rom, xmask+EPROM_LAT); // READ THE EPROM AT 0x0028, then READ THE EPROM AT 0x0128, then READ THE EERPOM at 0x0228, etc
    alt = readEEPROM(rom, xmask+EPROM_ALT); // READ THE EPROM AT 0x0038, then READ THE EPROM AT 0x0138, then READ THE EERPOM at 0x0238, etc
    time = readEEPROM(rom, xmask+EPROM_TIM); // READ THE EPROM AT 0x0048, then READ THE EPROM AT 0x0148, then READ THE EERPOM at 0x0248, etc
    vel = readEEPROM(rom, xmask+EPROM_VEL); // READ THE EPROM AT 0x0058, then READ THE EPROM AT 0x0158, then READ THE EERPOM at 0x0258, etc
    sta = readEEPROM(rom, xmask+EPROM_STA); // READ THE EPROM AT 0x0068, then READ THE EPROM AT 0x0168, then READ THE EERPOM at 0x0268, etc


 sprintf(coords, "g=%s,%s,%s,%s,%s,%s,%s",course_id,lon,lat,alt,tim,vel,_stat);


    Serial.println(F("\n"));
    
    // HERE I WOULD LIKE TO PARSE THE VARIABLE coords INTO XML FORMAT, AND EACH NEW LOOP, IT ADD TO THE END OF XML THE NEW VALUE


   // THIS SEND THE FUTURE XML FORMAT TO THE REMOTE SERVER. TJHE FORTH PARAMETER IS THE DATA TO SEND
if(inet.httpPOST(host, port, path, coords, "Result", 0)){
         // Check if there is collected data then send
         #ifdef DEBUG
           Serial.println(F("Data sent"));
         #endif
         //Read EEPROM
      }else{
         #ifdef DEBUG
           Serial.println(F("Data not sent"));
           // Save in EEPROM
         #endif
         #ifdef LED  
           blinkLed(redGPRS,5, MSEC);
         #endif
         
      }
  }

In the above code, I know there is an issue. the functon readEEPROM() return a char and I do not know to do in the way that for example, vel take the value of the return char value

vel = readEEPROM(rom, xmask+EPROM_VEL)

May be should I use sprintf, as I did with coords?

But for now my main worries is how to parse into XML file to send once, to a remote server, the 5 sets of coordinates.

I hope I provided you enough information and it clear for you.
… and many thank for your help. Feel you free to ask me aditionnal information

Cheers

// HERE I WOULD LIKE TO PARSE THE VARIABLE coords INTO XML FORMAT, AND EACH NEW LOOP, IT ADD TO THE END OF XML THE NEW VALUE

You seem to have a misunderstanding of what parse means. Parsing is the process of reading data that is in some known format (such as XML) and extracting the parts of interest. You aren't reading data in some known format, with a need to parse it.

You have data that you want to output in a known format. That is NOT parsing.

In the above code, I know there is an issue. the functon readEEPROM() return a char

No, it doesn't. It returns a pointer to an array of chars. Not the same thing at all.

and I do not know to do in the way that for example, vel take the value of the return char value

atoi(), atof(), strtol(), and strtoul() come to mind.

May be should I use sprintf, as I did with coords?

No.

But for now my main worries is how to parse into XML file

Nothing to worry about. You don't parse INTO XML format. You write the data in XML format. Not the same thing at all, and not at all hard. You simply need to write the appropriate start and end tags manually, with the data in between.

Since the XML output is all text, there is no good reason to convert the strings that you get from EEPROM to ints, floats, etc. and then convert them back to strings for output.

I’m not sure which EEPROM you’re using, but the integral EEPROM storage is relatively small. If you’re storing 256 bytes per minute over five minutes, is it actually going to fit in the EEPROM?

Is it really necessary to use EEPROM storage to buffer it? You don’t seem to be buffering a huge amount of data and it seems like the sort of data that could be represented in a sufficiently compact format to hold it all in RAM.

You seem to have a misunderstanding of what parse means

You are right. Sorry. I do not want to parse, but create an XML format

In the above code, I know there is an issue. the functon readEEPROM() return a char

I will not continue this Post with this issue. I am going to create a new Post for this problem.

You simply need to write the appropriate start and end tags manually

Ok then there is no library or some things else.

So I am still a bit worries because coords has a lenth of 87 (char coords[87];) If I want to add to coords 5 set of coordinate, I have to extent the length to 435 If I have to add the xml format, I have to extent the length to xxx. It's a lot, no? It will take a lot of memory? My sketch code have 25000, and the maximum of arduino is 32000.

No my question, is better to use the function

if(inet.httpPOST(host, port, path, coords, "Result", 0)){}else{}

for each set of cordinate. The each minute it collect a GPS it will send it.

Or it better to have a large lenth of coords, and send a 5 sets ina XML format?