Code:
	void handlelog(void)
{
unsigned char low=0,high=0;
unsigned int buffer=0,ui_i=0;
unsigned char text[400];
unsigned char sametext[14],reiptext[14];
switch (logstate)
    {
    case logoff:
    if(LOGSW==0)
        {
        logstate=logstart; 
        }
    break;
    
    case logstart:
    logstate=writeheader1;
    logtimer=6;
    break;
    
    case writeheader1:
    strcpyf(text,header1);
    for (ui_i=0;ui_i<strlen(text);ui_i++)
        {
        putchar(text[ui_i]);
        }
    logstate=writeheader2;
    break;
    
    case writeheader2:
    strcpyf(text,header2);
    for (ui_i=0;ui_i<strlen(text);ui_i++)
        {
        putchar(text[ui_i]);
        }
    logstate=writeheader3;
    break;
    
    case writeheader3:
    strcpyf(text,header3);
    for (ui_i=0;ui_i<strlen(text);ui_i++)
        {
        putchar(text[ui_i]);
        }
    if(LOGSW==0)
        {
        oldlatx=latx;
        oldlath=lath;
        oldlatl=latl;
        oldlongx=longx;
        oldlongh=longh;
        oldlongl=longl;
        logstate=writedata;
        }
    else
        {
        logstate=writecloser;
        }
    break;
    
    case writedata:
    /* Hier müssen noch die REIP Daten für das File generiert
    und an den SD CARD Reader übergeben werden
    */
    /*
    <Style id="720_50">
      <LineStyle>
        <color>ff800080</color>
        <width>5</width>
      </LineStyle>
    </Style>
    <Placemark>
      <name>720-50</name>
      <description>Reip 720, Deck 50</description>
    <styleUrl>#720_50</styleUrl>
      <LineString>
        <extrude>1</extrude>
        <tessellate>1</tessellate>
        <altitudeMode>clampToGround</altitudeMode>
        <coordinates>
        11.561936,49.023278,2357
          11.561935,49.023277,2357
          11.561930,49.023277,2357
          11.561927,49.023281,2357
        </coordinates>
    </LineString>
    </Placemark>
    */
    strcpyf(text,"<Style id=\"");
    high=reip/10;
    itoa(high,sametext),
    strcpyf(reiptext,"7");
    if(high<10){strcatf(reiptext,"0");}
    strcat(reiptext,sametext);
    strcatf(reiptext,"_");
    itoa(deck,sametext);
    strcat(reiptext,sametext);
    strcat(text,reiptext);
    strcatf(text,"\">\r\n");
    strcatf(text,"<LineStyle>\r\n<color>ff");
    buffer=reip*100;
    buffer/=157;
    high=buffer>>4;
    low=buffer&0x0F;
    if(high<10)
        {
        high+=0x30;
        }
    else
        {
        high+=0x37;
        }
    if(low<10)
        {
        low+=0x30;
        }
    else
        {
        low+=0x37;
        }
    sametext[0]=high;
    sametext[1]=low;
    sametext[2]='0';
    sametext[3]='0';
    buffer=256-buffer;
    high=buffer>>4;
    low=buffer&0x0F;
    if(high<10)
        {
        high+=0x30;
        }
    else
        {
        high+=0x37;
        }
    if(low<10)
        {
        low+=0x30;
        }
    else
        {
        low+=0x37;
        }
    sametext[4]=high;
    sametext[5]=low;
    sametext[8]=0;
    strcat(text,sametext);
    strcatf(text,"</color>\r\n<width>");
    low=deck/10;
    if(low<1){low=1;}
    itoa(low,sametext);
    strcat(text,sametext);
    strcatf(text,"</width>\r\n</LineStyle>\r\n</Style>\r\n<Placemark>\r\n<name>");
    strcat(text,reiptext);
    strcatf(text,"</name>\r\n<description>Reip 7"); //720, Deck 50</description>"
    buffer=reip/10;
    itoa(buffer,sametext);
    if(buffer<10){strcatf(text,"0");}
    strcat(text,sametext);
    strcatf(text,",");
    buffer=reip%10;
    itoa(buffer,sametext);
    strcat(text,sametext);
    strcatf(text," Deck ");
    itoa(deck,sametext);
    strcat(text,sametext);
    strcatf(text,"%</description>\r\n<styleUrl>#");
    strcat(text,reiptext);
    strcatf(text,"</styleUrl>\r\n<LineString>\r\n<extrude>1</extrude>\r\n<tessellate>1</tessellate>\r\n<altitudeMode>clampToGround</altitudeMode>\r\n<coordinates>\r\n");
    if(oldlongx=='W'){strcatf(text,"-");}
    itoa(oldlongh,sametext);
    strcat(text,sametext);
    strcatf(text,".");
    ltoa(oldlongl,sametext);
    if(oldlongl<100000){strcatf(text,"0");}
    if(oldlongl<10000){strcatf(text,"0");}
    if(oldlongl<1000){strcatf(text,"0");}
    if(oldlongl<100){strcatf(text,"0");}
    if(oldlongl<10){strcatf(text,"0");}
    strcat(text,sametext);
    strcatf(text,",");
    if(oldlatx=='S'){strcatf(text,"-");}
    itoa(oldlath,sametext);
    strcat(text,sametext);
    strcatf(text,".");
    ltoa(oldlatl,sametext);
    if(oldlatl<100000){strcatf(text,"0");}
    if(oldlatl<10000){strcatf(text,"0");}
    if(oldlatl<1000){strcatf(text,"0");}
    if(oldlatl<100){strcatf(text,"0");}
    if(oldlatl<10){strcatf(text,"0");}
    strcat(text,sametext);
    strcatf(text,",");
    buffer=height/10;
    itoa(buffer,sametext);
    strcat(text,sametext);
    strcatf(text,"\r\n");
    if(longx=='W'){strcatf(text,"-");}
    itoa(longh,sametext);
    strcat(text,sametext);
    strcatf(text,".");
    ltoa(longl,sametext);
    if(longl<100000){strcatf(text,"0");}
    if(longl<10000){strcatf(text,"0");}
    if(longl<1000){strcatf(text,"0");}
    if(longl<100){strcatf(text,"0");}
    if(longl<10){strcatf(text,"0");}
    strcat(text,sametext);
    strcatf(text,",");
    if(latx=='S'){strcatf(text,"-");}
    itoa(lath,sametext);
    strcat(text,sametext);
    strcatf(text,".");
    ltoa(latl,sametext);
    if(latl<100000){strcatf(text,"0");}
    if(latl<10000){strcatf(text,"0");}
    if(latl<1000){strcatf(text,"0");}
    if(latl<100){strcatf(text,"0");}
    if(latl<10){strcatf(text,"0");}
    strcat(text,sametext);
    strcatf(text,",");
    buffer=height/10;
    itoa(buffer,sametext);
    strcat(text,sametext);
    strcatf(text,"\r\n");
    strcatf(text,"</coordinates>\r\n</LineString>\r\n</Placemark>");
    for(ui_i=0;ui_i<strlen(text);ui_i++)
        {
        putchar(text[ui_i]);
        }
    //Prepare for next data record
    oldlatx=latx;
    oldlath=lath;
    oldlatl=latl;
    oldlongx=longx;
    oldlongh=longh;
    oldlongl=longl;
    if(LOGSW!=0)
        {
        logstate=writecloser;
        }
    break;
    
    case writecloser:
    strcpyf(text,closer);
    for (ui_i=0;ui_i<strlen(text);ui_i++)
        {
        putchar(text[ui_i]);
        }
    logstate=fileclosed;
    logtimer=32;
    break;
    }
}
 Ist sicher noch nicht optimal das Ganze, aber ein funktionierender Anfang.
						
Lesezeichen