Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 435 → Rev 436

/FollowMe/trunk/fat16.c
1676,12 → 1676,14
int8_t *pbuff;
int16_t c = 0, bytecount;
 
if((!Partition.IsValid) || (file == NULL) || (string == NULL) || (length > 1)) return (0);
if( (!Partition.IsValid) || (file == NULL) || (string == NULL) || (length < 1) ) return (0);
 
pbuff = string;
bytecount = length;
while(bytecount > 1) // read the count-1 characters from the file to the string.
{
c = fgetc_(file); // read a character from the opened file.
 
switch(c)
{
case 0x0A:
/FollowMe/trunk/gps.c
3,7 → 3,7
#include "main.h"
#include "timer0.h"
 
#define GPS_TIMEOUT 1000 // of ne new gps data arrivw within that time an error ist set
#define GPS_TIMEOUT 1000 // if no new gps data arrive within that time an error is set
#define GPS_MINSATS 4
 
//------------------------------------------------------------
/FollowMe/trunk/gpx.c
105,7 → 105,7
retvalue = 1; // the document could be created on the drive.
doc->state = GPX_DOC_OPENED; // change document state to opened. At next a placemark has to be opened.
str = GPX_DOCUMENT_HEADER; // write the gpx-header to the document..
for(i= 0; i < sizeof(GPX_DOCUMENT_HEADER); i++)
for(i= 0; i < sizeof(GPX_DOCUMENT_HEADER)-1; i++)
{
c = (int8_t)pgm_read_byte(str++); // get byte from flash
fputc_(c, doc->file); // and write that to sd-card
150,7 → 150,7
if(doc->file != NULL)
{
str = GPX_DOCUMENT_FOOTER; // write the gpx-footer to the document.
for(i= 0; i < sizeof(GPX_DOCUMENT_FOOTER); i++)
for(i= 0; i < sizeof(GPX_DOCUMENT_FOOTER)-1; i++)
{
c = (int8_t)pgm_read_byte(str++); // get byte from flash
fputc_(c, doc->file); // and write that to sd-card
194,7 → 194,7
doc->state = GPX_DOC_TRACK_OPENED;
retvalue = 1;
str = GPX_TRACK_HEADER;
for(i= 0; i < sizeof(GPX_TRACK_HEADER); i++)
for(i= 0; i < sizeof(GPX_TRACK_HEADER)-1; i++)
{
c = (int8_t)pgm_read_byte(str++); // get byte from flash
fputc_(c, doc->file); // and write that to sd-card
227,7 → 227,7
{
doc->state = GPX_DOC_OPENED;
str = GPX_TRACK_FOOTER;
for(i= 0; i < sizeof(GPX_TRACK_FOOTER); i++)
for(i= 0; i < sizeof(GPX_TRACK_FOOTER)-1; i++)
{
c = (int8_t)pgm_read_byte(str++); // get byte from flash
fputc_(c, doc->file); // and write that to sd-card
261,7 → 261,7
{
doc->state = GPX_DOC_TRACKSEGMENT_OPENED;
str = GPX_TRACKSEGMENT_HEADER;
for(i = 0; i < sizeof(GPX_TRACKSEGMENT_HEADER); i++)
for(i = 0; i < sizeof(GPX_TRACKSEGMENT_HEADER)-1; i++)
{
c = (int8_t)pgm_read_byte(str++); // get byte from flash
fputc_(c, doc->file); // and write that to sd-card
296,7 → 296,7
{
doc->state = GPX_DOC_TRACK_OPENED;
str = GPX_TRACKSEGMENT_FOOTER;
for(i = 0; i < sizeof(GPX_TRACKSEGMENT_FOOTER); i++)
for(i = 0; i < sizeof(GPX_TRACKSEGMENT_FOOTER)-1; i++)
{
c = (int8_t)pgm_read_byte(str++); // get byte from flash
fputc_(c, doc->file); // and write that to sd-card
346,7 → 346,7
i16_1 = abs((int16_t)(GPSData.Position.Longitude/10000000L));
i16_2 = abs((int16_t)((GPSData.Position.Longitude%10000000L)/10000L));
i16_3 = abs((int16_t)(((GPSData.Position.Longitude%10000000L)%10000L)/10L));
sprintf(string, "<lon=\"%c%d.%.3d%.3d\" ",u8_1, i16_1, i16_2, i16_3);
sprintf(string, "lon=\"%c%d.%.3d%.3d\" >\r\n",u8_1, i16_1, i16_2, i16_3);
fputs_(string, doc->file);
 
// write <time> tag only at a resolution of one second
/FollowMe/trunk/gpx_header.h
10,7 → 10,7
const prog_char GPX_DOCUMENT_HEADER[] =
{
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\r\n"
"<gpx creator=\"NC\" version=\"1.0\" >\r\n"
"<gpx creator=\"FollowMe\" version=\"1.0\" >\r\n"
"\r\n"
"<metadata>\r\n"
"<link href=\"http://www.mikrokopter.de\">\r\n"
35,11 → 35,10
// Header of a track
//
//________________________________________________________________________________________________________________________________________
 
const prog_char GPX_TRACK_HEADER[] =
{
"<trk>\r\n"
"<name>Flight</name>\r\n"
"<name>FollowMe</name>\r\n"
};
 
//________________________________________________________________________________________________________________________________________
/FollowMe/trunk/kml.c
132,7 → 132,7
retvalue = 1; // the document could be created on the drive.
doc->state = KML_DOC_OPENED; // change document state to opened. At next a placemark has to be opened.
str = KML_DOCUMENT_HEADER; // write the KML-header to the document.
for(i= 0; i < sizeof(KML_DOCUMENT_HEADER); i++)
for(i= 0; i < sizeof(KML_DOCUMENT_HEADER)-1; i++)
{
c = (int8_t)pgm_read_byte(str++); // get byte from flash
fputc_(c, doc->file); // and write that to sd-card
176,7 → 176,7
if(doc->file != NULL)
{
str = KML_DOCUMENT_FOOTER; // write the KML- footer to the document.
for(i= 0; i < sizeof(KML_DOCUMENT_FOOTER); i++)
for(i= 0; i < sizeof(KML_DOCUMENT_FOOTER)-1; i++)
{
c = (int8_t)pgm_read_byte(str++); // get byte from flash
fputc_(c, doc->file); // and write that to sd-card
219,7 → 219,7
doc->state = KML_DOC_PLACEMARK_OPENED;
retvalue = 1;
str = KML_PLACEMARK_HEADER;
for(i= 0; i < sizeof(KML_PLACEMARK_HEADER); i++)
for(i= 0; i < sizeof(KML_PLACEMARK_HEADER)-1; i++)
{
c = (int8_t)pgm_read_byte(str++); // get byte from flash
fputc_(c, doc->file); // and write that to sd-card
252,7 → 252,7
{
doc->state = KML_DOC_OPENED;
str = KML_PLACEMARK_FOOTER;
for(i= 0; i < sizeof(KML_PLACEMARK_FOOTER); i++)
for(i= 0; i < sizeof(KML_PLACEMARK_FOOTER)-1; i++)
{
c = (int8_t)pgm_read_byte(str++); // get byte from flash
fputc_(c, doc->file); // and write that to sd-card
286,7 → 286,7
{
doc->state = KML_DOC_LINESTRING_OPENED;
str = KML_LINESTRING_HEADER;
for(i= 0; i < sizeof(KML_LINESTRING_HEADER); i++)
for(i= 0; i < sizeof(KML_LINESTRING_HEADER)-1; i++)
{
c = (int8_t)pgm_read_byte(str++); // get byte from flash
fputc_(c, doc->file); // and write that to sd-card
320,7 → 320,7
{
doc->state = KML_DOC_PLACEMARK_OPENED;
str = KML_LINESTRING_FOOTER;
for(i= 0; i < sizeof(KML_LINESTRING_FOOTER); i++)
for(i= 0; i < sizeof(KML_LINESTRING_FOOTER)-1; i++)
{
c = (int8_t)pgm_read_byte(str++); // get byte from flash
fputc_(c, doc->file); // and write that to sd-card
/FollowMe/trunk/kml_header.h
13,9 → 13,9
"<Document>\r\n"
"<name>Mikrokopter GPS logging</name>\r\n"
"\r\n"
"<Style id=\"MK_gps-style\">\r\n"
"<Style id=\"FM_gps-style\">\r\n"
"<LineStyle>\r\n"
"<color>ff0000ff</color>\r\n"
"<color>ff00ff00</color>\r\n"
"<width>2</width>\r\n"
"</LineStyle>\r\n"
"</Style>\r\n"
40,8 → 40,8
const prog_char KML_PLACEMARK_HEADER[] =
{
"<Placemark>\r\n"
"<name>Flight</name>\r\n"
"<styleUrl>#MK_gps-style</styleUrl>\r\n"
"<name>FollowMe</name>\r\n"
"<styleUrl>#FM_gps-style</styleUrl>\r\n"
};
 
//________________________________________________________________________________________________________________________________________
/FollowMe/trunk/logging.c
59,7 → 59,7
#include "timer0.h"
#include "uart1.h"
#include "kml.h"
//#include "gpx.h"
#include "gpx.h"
#include "ssc.h"
#include "settings.h"
#include "printf_P.h"
115,7 → 115,7
}
 
//----------------------------------------------------------------------------------------------------
/*int8_t* GenerateGPXLogFileName(void)
int8_t* GenerateGPXLogFileName(void)
{
static uint16_t filenum = 0; // file name counter
static int8_t filename[35];
137,7 → 137,7
return filename;
}
else return NULL;
}*/
}
 
 
//----------------------------------------------------------------------------------------------------
149,7 → 149,7
static uint16_t logtimer = 0, flushtimer = 0; // the log update timer
static KML_Document_t logfile; // the logfilehandle
 
// initialize if LogDelay os zero
// initialize if LogDelay is zero
if(!LogDelay)
{
switch(logfilestate)
265,7 → 265,6
}
 
//----------------------------------------------------------------------------------------------------
/*
// logs gps and state info to a gpx file
logfilestate_t Logging_GPX(uint16_t LogDelay)
{
386,7 → 385,6
 
return logfilestate;
}
*/
 
//----------------------------------------------------------------------------------------------------
// initialize logging
393,11 → 391,11
void Logging_Init(void)
{
LogCfg.KML_Interval = 500; //default
Settings_GetParamValue(PID_KML_LOGGING, (uint16_t*)&LogCfg.KML_Interval); // overwrite by settings value
Logging_KML(0); // initialize
//LogCfg.GPX_Interval = 1000; //default
//Settings_GetParamValue(PID_GPX_LOGGING, (uint16_t*)&LogCfg.GPX_Interval); // overwrite by settings value
//Logging_GPX(0); // initialize
Settings_GetParamValue(PID_KML_LOGGING, &(LogCfg.KML_Interval)); // overwrite by settings value
printf("\r\nKML Interval = %d", LogCfg.KML_Interval);
LogCfg.GPX_Interval = 1000; //default
Settings_GetParamValue(PID_GPX_LOGGING, &(LogCfg.GPX_Interval)); // overwrite by settings value
Logging_GPX(0); // initialize
}
 
//----------------------------------------------------------------------------------------------------
415,7 → 413,7
logtimer = SetDelay(10); // faster makes no sense
// call the logger handlers if no error has occured
if(logstate != LOGFILE_ERROR) logstate = Logging_KML(LogCfg.KML_Interval);
//if(logstate != LOGFILE_ERROR) logstate = Logging_GPX(LogCfg.GPX_Interval);
if(logstate != LOGFILE_ERROR) logstate = Logging_GPX(LogCfg.GPX_Interval);
 
// a logging error has occured
if(logstate == LOGFILE_ERROR)
/FollowMe/trunk/main.c
113,6 → 113,7
}
 
// state machine
DebugOut.Analog[9] = SysState;
switch(SysState)
{
case STATE_SEND_FOLLOWME:
/FollowMe/trunk/makefile
5,7 → 5,7
#-------------------------------------------------------------------
VERSION_MAJOR = 0
VERSION_MINOR = 1
VERSION_PATCH = 3
VERSION_PATCH = 4
 
VERSION_SERIAL_MAJOR = 10 # Serial Protocol Major Version
VERSION_SERIAL_MINOR = 0 # Serial Protocol Minor Version
76,7 → 76,7
 
##########################################################################################################
# List C source files here. (C dependencies are automatically generated.)
SRC = main.c uart0.c uart1.c printf_P.c timer0.c menu.c led.c ubx.c analog.c button.c crc16.c ssc.c sdc.c fat16.c gps.c settings.c logging.c kml.c gpx.c
SRC = main.c uart0.c uart1.c printf_P.c timer0.c menu.c led.c ubx.c analog.c button.c crc16.c ssc.c sdc.c fat16.c gps.c settings.c logging.c kml.c gpx.c
##########################################################################################################
 
 
/FollowMe/trunk/menu.c
11,6 → 11,7
#include "printf_P.h"
#include "ubx.h"
#include "timer0.h"
#include "main.h"
 
uint8_t MaxMenuItem = 3;
uint8_t MenuItem = 0;
58,6 → 59,24
if(MenuItem == MaxMenuItem) MenuItem = 0;
else MenuItem++;
}
/*
if(RemoteKeys & KEY4)
{
switch(SysState)
{
case STATE_IDLE:
SysState = STATE_SEND_FOLLOWME; // activate followme only of no error has occured
break;
 
case STATE_SEND_FOLLOWME:
SysState = STATE_IDLE;
break;
 
default:
SysState = STATE_IDLE;
break;
}
}*/
if((RemoteKeys & KEY1) && (RemoteKeys & KEY2)) MenuItem = 0;
 
LCD_Clear();
/FollowMe/trunk/settings.c
155,7 → 155,7
return;
}
// read all lines from file
while(fgets_(settingsline, LINE_MAX, fp) != 0)
while(fgets_(settingsline, LINE_MAX, fp) != NULL)
{
if ( // ignorelines starting with \r,\n,' ',';','#'
(settingsline[0] != '\n') &&
/FollowMe/trunk/uart0.c
17,7 → 17,7
#include "timer0.h"
#include "uart0.h"
#include "ubx.h"
#include "led.h"
#include "printf_P.h"
 
 
#define FC_ADDRESS 1
72,13 → 72,13
"Analog_Ch6 ",
"Analog_Ch7 ",
"UBat ",
"Speed_North ",
"Speed_East ", //10
"Speed_Top ",
"NumOfSats ",
"Pos.Longitude ",
"Pos.Latitude ",
"Pos.Altitude ", //15
"SysState ",
"Debug10 ", //10
"Debug11 ",
"Debug12 ",
"Debug13 ",
"Debug14 ",
"Debug15 ", //15
"Zellenzahl ",
"PowerOn ",
"Debug18 ",
/FollowMe/trunk/ubx.c
2,6 → 2,7
#include "ubx.h"
#include "timer0.h"
#include "uart0.h"
#include "printf_P.h"
 
 
// ------------------------------------------------------------------------------------------------
405,11 → 406,4
break;
 
}
DebugOut.Analog[9] = GPSData.Speed_North;
DebugOut.Analog[10] = GPSData.Speed_East;
DebugOut.Analog[11] = GPSData.Speed_Top;
DebugOut.Analog[12] = GPSData.NumOfSats;
DebugOut.Analog[13] = GPSData.Position.Longitude;
DebugOut.Analog[14] = GPSData.Position.Latitude;
DebugOut.Analog[15] = GPSData.Position.Altitude;
}