/trunk/uart1.c |
---|
177,6 → 177,13 |
"Used_Sats " |
}; |
typedef struct |
{ |
u8 Index; |
u8 Status; |
} __attribute__((packed)) WPL_Answer_t; |
WPL_Answer_t WPL_Answer; |
DebugOut_t DebugOut; |
ExternControl_t ExternControl; |
UART_VersionInfo_t UART_VersionInfo; |
518,26 → 525,29 |
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 |
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 |
{ |
memcpy((u8*)&WPL_Store, SerialMsg.pData, sizeof(WPL_Store)); |
WPL_Store.Name[11] = 0; // make sure the string is terminated |
WPL_Store.reserved[0] = 0; |
if(WPL_Store.Index != 0) |
if(WPL_Store.Type == WPL_STORE_TYPE_REL) |
{ |
if(WPL_Store.Type == WPL_STORE_TYPE_REL) |
{ |
if(PointList_Move(1, &(GPSData.Position))) |
{ |
WPL_Store.reserved[0] = PointList_SaveToFile(WPL_Store.Index, WPL_Store.Name); |
} |
if(PointList_Move(1, &(NaviData.HomePosition))) |
{ |
WPL_Answer.Status = PointList_SaveToFile(&WPL_Store); |
} |
else |
{ |
WPL_Store.reserved[0] = PointList_SaveToFile(WPL_Store.Index, WPL_Store.Name); |
} |
} |
UART1_Request_WPLStore = TRUE; |
else |
{ |
WPL_Answer.Status = PointList_SaveToFile(&WPL_Store); |
} |
} |
UART1_Request_WPLStore = TRUE; |
break; |
1042,7 → 1052,12 |
} |
else if(UART1_Request_WPLStore) |
{ |
MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'I', NC_ADDRESS, 2,(u8 *)&(WPL_Store.Index), 1, (u8 *)&(WPL_Store.reserved[0]), 1 ); |
/* |
s8 txt[50]; |
sprintf(txt, "\r\nWPL Overwride = %d, Type = %d, Index = %d, Status = %d\r\n", WPL_Store.OverwriteFile, WPL_Store.Type, WPL_Answer.Index, WPL_Answer.Status); |
UART1_PutString(txt); |
*/ |
MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'I', NC_ADDRESS, 1,(u8 *)&(WPL_Answer), sizeof(WPL_Answer_t)); |
UART1_Request_WPLStore = FALSE; |
} |
else if((((NMEA_Interval > 0) && CheckDelay(NMEA_Timer))) && (UART1_tx_buffer.Locked == FALSE)) |
/trunk/uart1.h |
---|
6,6 → 6,7 |
#define UART_MKGPS 2 |
#include "ubx.h" |
#include "waypoints.h" |
#define NC_ERROR0_SPI_RX 0x01 |
#define NC_ERROR0_COMPASS_RX 0x02 |
87,15 → 88,6 |
s16 Compass; // angle between north and head of the MK |
} __attribute__((packed)) Attitude_t; |
#define WPL_STORE_TYPE_REL 0 |
#define WPL_STORE_TYPE_ABS 1 |
typedef struct |
{ |
u8 Index; |
u8 Type; |
u8 reserved[8]; |
s8 Name[12]; |
} __attribute__((packed)) WPL_Store_t; |
typedef struct |
{ |
166,6 → 158,8 |
extern u8 UART1_Request_SendFollowMe; |
extern u8 LastTransmittedFCStatusFlags2; |
extern WPL_Store_t WPL_Store; |
extern u32 NMEA_Interval;// in ms |
#endif //_UART1_H |
/trunk/waypoints.c |
---|
355,22 → 355,27 |
#define LINE_MAX 70 |
#define WP_FILE_VERSION_COMPATIBLE 3 |
// save actual point list to SD card |
u8 PointList_SaveToFile(u8 place, s8 * name) |
u8 PointList_SaveToFile(WPL_Store_t * pWPL_Store) |
{ |
File_t *fp; |
s8 wpline[LINE_MAX], retval = 0; |
s8 wpline[LINE_MAX]; |
u8 retval = WPL_ERROR; |
// user absolute path, i.e. leading / |
sprintf(wpline, "/list_%03d.wpl", pWPL_Store->Index); |
sprintf(wpline, "/list_%03d.wpl", place); |
UART1_PutString("\n\r Write "); |
UART1_PutString(wpline); |
UART1_PutString("..."); |
UART1_PutString("\n\r Save WPL..."); |
if(Fat16_IsValid()) |
{ // check if wpl file is existing |
if(fexist_(wpline)) |
{ //file is existent |
if(!(pWPL_Store->OverwriteFile)) |
{ |
UART1_PutString("Error: file exist!\r\n"); |
return(WPL_FILEEXIST); |
} |
} |
fp = fopen_(wpline, 'w'); // try to open the file |
if(fp == NULL) |
{ |
379,8 → 384,10 |
} |
// Create general section and key entries |
fputs_("[General]\r\n", fp); |
sprintf(wpline, "Name=%s\r\n", name); |
sprintf(wpline, "Name=%s\r\n", pWPL_Store->Name); |
fputs_(wpline, fp); |
sprintf(wpline, "PositionType=%d\r\n", pWPL_Store->Type); |
fputs_(wpline, fp); |
sprintf(wpline, "FileVersion=%d\r\n", WP_FILE_VERSION_COMPATIBLE); |
fputs_(wpline, fp); |
sprintf(wpline, "NumberOfWaypoints=%d\r\n", PointCount); |
462,7 → 469,7 |
else |
{ |
UART1_PutString("ok\r\n"); |
retval = 1; |
retval = WPL_OK; |
} |
} // EOF if(Fat16_IsValid()) |
else UART1_PutString("no file system found!\r\n"); |
470,7 → 477,7 |
} |
// load actual point list from SD card |
u8 PointList_ReadFromFile(u8 place) |
u8 PointList_ReadFromFile(WPL_Store_t * pWPL_Store) |
{ |
File_t *fp; |
s8 wpline[LINE_MAX], retval = 0; |
483,7 → 490,7 |
u8 WPNumber = 0; |
// user absolute path, i.e. leading / |
sprintf(wpline, "/list_%03d.wpl", place); |
sprintf(wpline, "/list_%03d.wpl", pWPL_Store->Index); |
UART1_PutString("\n\r Read "); |
UART1_PutString(wpline); |
644,6 → 651,17 |
return(0); |
} |
} |
else if (strcmp(name, "NAME") == 0) |
{ |
u8 len = strlen(value); |
if(len > 11) |
value[11] = 0; |
memcpy(pWPL_Store->Name, value, 12); |
} |
else if (strcmp(name, "POSITIONTYPE") == 0) |
{ |
pWPL_Store->Type = (u8)atoi(value); |
} |
else |
{ |
UART1_PutString("Unknown key: "); |
/trunk/waypoints.h |
---|
24,6 → 24,19 |
u8 reserve[2]; // reserve |
} __attribute__((packed)) Point_t; |
#define WPL_STORE_TYPE_REL 0 |
#define WPL_STORE_TYPE_ABS 1 |
typedef struct |
{ |
u8 Index; |
u8 Type; // 0 = rel, 1 = abs |
u8 OverwriteFile; // 0 = no, 1 = yes |
u8 reserved[7]; |
s8 Name[12]; |
} __attribute__((packed)) WPL_Store_t; |
// Init List, return TRUE on success |
u8 PointList_Init(void); |
// Clear List, return TRUE on success |
45,9 → 58,12 |
// returns pointer to actual POI |
Point_t* PointList_GetPOI(void); |
// save actual point list to SD card |
u8 PointList_SaveToFile(u8 place, s8 * name); |
#define WPL_ERROR 0 |
#define WPL_OK 1 |
#define WPL_FILEEXIST 2 |
u8 PointList_SaveToFile(WPL_Store_t * pWPL_Store); |
// load actual point list from SD card |
u8 PointList_ReadFromFile(u8 place); |
u8 PointList_ReadFromFile(WPL_Store_t * pWPL_Store); |
// move actual point list to ref pos., the point in the list marked by RefIndex get the RefPos afterwards |
u8 PointList_Move(u8 RefIndex, GPS_Pos_t* pRefPos); |