Subversion Repositories NaviCtrl

Compare Revisions

Ignore whitespace Rev 495 → Rev 496

/trunk/uart1.c
189,7 → 189,7
UART_VersionInfo_t UART_VersionInfo;
NaviData_t NaviData;
Data3D_t Data3D;
WPL_Store_t WPL_Store;
 
u16 Echo; // 2 bytes recieved will be sent back as echo
 
u32 UART1_DebugData_Timer = 0;
525,29 → 525,11
break;
 
case 'i':// Store WP List to file
 
memcpy((u8*)&WPL_Store, SerialMsg.pData, sizeof(WPL_Store));
WPL_Store.Name[11] = 0; // make sure the string is terminated
 
memcpy((u8*)&WPL_Store, SerialMsg.pData, sizeof(WPL_Store_t));
WPL_Store.Name[11] = 0; // make sure the name string is terminated
WPL_Answer.Index = WPL_Store.Index; // echo Index
WPL_Answer.Status = WPL_ERROR; // set bad state by default
 
if(WPL_Store.Index != 0) // valid index
{
if(WPL_Store.Type == WPL_STORE_TYPE_REL)
{
if(PointList_Move(1, &(NaviData.HomePosition)))
{
WPL_Answer.Status = PointList_SaveToFile(&WPL_Store);
}
}
else
{
WPL_Answer.Status = PointList_SaveToFile(&WPL_Store);
}
}
WPL_Answer.Status = PointList_SaveToFile(&WPL_Store);
UART1_Request_WPLStore = TRUE;
 
break;
 
 
/trunk/waypoints.c
61,7 → 61,11
#include "waypoints.h"
#include "uart1.h"
#include "fat16.h"
#include "spi_slave.h"
 
 
WPL_Store_t WPL_Store;
 
// the waypoints list
#define MAX_LIST_LEN 101
 
360,10 → 364,17
File_t *fp;
s8 wpline[LINE_MAX];
u8 retval = WPL_ERROR;
// user absolute path, i.e. leading /
sprintf(wpline, "/list_%03d.wpl", pWPL_Store->Index);
 
// user absolute path, i.e. leading /
if(pWPL_Store->Index == 0)
{
sprintf(wpline, "/default.wpl");
}
else
{
sprintf(wpline, "/WPL/list_%03d.wpl", pWPL_Store->Index);
}
UART1_PutString("\n\r Save WPL...");
 
if(Fat16_IsValid())
480,7 → 491,8
u8 PointList_ReadFromFile(WPL_Store_t * pWPL_Store)
{
File_t *fp;
s8 wpline[LINE_MAX], retval = 0;
s8 wpline[LINE_MAX];
u8 retval = WPL_ERROR;
s8 *name, *value;
u8 i;
490,7 → 502,14
u8 WPNumber = 0;
 
// user absolute path, i.e. leading /
sprintf(wpline, "/list_%03d.wpl", pWPL_Store->Index);
if(pWPL_Store->Index == 0) // index 0 looks for a default WPL file in the root
{
sprintf(wpline, "/default.wpl");
}
else
{
sprintf(wpline, "/WPL/list_%03d.wpl", pWPL_Store->Index);
}
 
UART1_PutString("\n\r Read ");
UART1_PutString(wpline);
502,7 → 521,7
if(fp == NULL)
{
UART1_PutString("ERROR: Reading waypoint file!\r\n");
return(0);
return(retval);
}
// clear point list first
PointList_Clear();
647,8 → 666,9
{
if((u8)atoi(value) != WP_FILE_VERSION_COMPATIBLE)
{
PointList_Clear();
UART1_PutString("Bad file version!\r\n");
return(0);
return(WPL_ERROR);
}
}
else if (strcmp(name, "NAME") == 0)
675,8 → 695,22
} // EOF loop over all lines
fclose_(fp);
NaviData.WaypointNumber = WPCount;
UART1_PutString("ok\r\n");
retval = 1;
// if the WPS data are relative to home position
if(pWPL_Store->Type == WPL_STORE_TYPE_REL)
{ // try to shift the wp list
if(PointList_Move(1, &(NaviData.HomePosition))) retval = WPL_OK;
else
{
PointList_Clear(); // to avoid wrong absolute positions
UART1_PutString("no reference position!\r\n");
}
}
else
{ // nothing to do
retval = WPL_OK;
}
if(retval == WPL_OK) UART1_PutString("ok\r\n");
} // EOF if(Fat16_IsValid())
else UART1_PutString("no file system found!\r\n");
return(retval);
/trunk/waypoints.h
37,6 → 37,8
s8 Name[12];
} __attribute__((packed)) WPL_Store_t;
 
extern WPL_Store_t WPL_Store;
 
// Init List, return TRUE on success
u8 PointList_Init(void);
// Clear List, return TRUE on success