UART_Send_Str("Start to read data....\r\n");
i=0;
linelength=0;
readflag=1;
while(readflag==1)
{
len=znFAT_ReadData(&fileinfo,i,1,&readBuf);
if(readBuf==0x0D)
{
linebufTemp[i]=readBuf;
readflag=0;
for(i=0;i<linelength;i++)
{
if(linebufTemp[i]=='X')
{
xreadflag=1;
xnpos=i;
}
if(linebufTemp[i]=='Y')
{
yreadflag=1;
ynpos=i;
}
}
if(xreadflag==1 && yreadflag==1)
{
for(i=xnpos+1;i<ynpos;i++)
{
xstring[j]=linebufTemp[i];
j++;
}
xstring[j]='\0';
j=0;
for(i=ynpos+1;i<linelength+1;i++)
{
ystring[j]=linebufTemp[i];
j++;
}
ystring[j]='\0';
j=0;
UART_Send_Str("xstring and ystring is below:---");
UART_Send_Enter();
UART_Send_Str(xstring);
UART_Send_Enter();
UART_Send_Str(ystring);
UART_Send_Enter();
xnew=atof(xstring);
if(xnew<0)
{
UART_Send_StrNum("Have read data xnew(Bytes):",xnew*(-1)*1000+100);
UART_Send_Enter();
}
else if(xnew>0)
{
UART_Send_StrNum("Have read data xnew(Bytes):",xnew*1000+100);
UART_Send_Enter();
}
}
else if(xreadflag==1 && yreadflag==0)
{
}
else if(xreadflag==0 && yreadflag==1)
{
}
}
else
{
linelength=linelength+1;
linebufTemp[i]=readBuf;
i++;
}
}
UART_Send_Str("Data is below:\r\n");
UART_Send_Str(linebufTemp);
UART_Send_Enter();
UART_Send_StrNum("Have read data linebufTemp(Bytes):",linelength);
znFAT_Close_File(&fileinfo);
}
else
{
UART_Send_StrNum("Fail to open file, Err Code:",res);
}
znFAT_Flush_FS();
while(1);
return 0;
}