📄 gpssimulator.c
字号:
#include "common.h"
#include <stdlib.h>
#include <stdio.h>
#include <minigui/common.h>
/*
* read the file
* para
* ft: the file of handle
**len: the lenght
*
*/
int getfilestr(FILE* ft,char* p,int len)
{
if(fgets(p,100,ft))
{
return 1;
}
else
{
return -1;
}
}
/*
*
*
*/
POINT parsestring(const char *str)
{
int len ;
POINT retval;
char * head = str;
len = strlen(str);
while(*head != ',')
{
++head;
}
if(!head)
{
retval.x = 0;
retval.y = 0;
return retval;
}
*head= '\0';
retval.x = atof(str)*3600*256;
retval.y = atof(head+1)*3600*256;
return retval;
}
/*
*
*
*/
uint8 getsimulatordata(POINT* gpssimdata,int len)
{
FILE * ft;
POINT reaxy;
char readfile[100];
ft = fopen("data/trace.txt","r");
if(!ft)
{
printf("can't open the file!\n");
// exit(0);
}
else
{
int i= 0;
while(getfilestr(ft,readfile,100))
{
reaxy = parsestring(readfile);
printf("x = %d,y = %d,i = %d\n",reaxy.x,reaxy.y,i);
gpssimdata[i] = reaxy;
++i;
if(i == 105)
{
break;
}
}
}
fclose(ft);
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -