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); |