新手入门
- 积分
- 15
- 金钱
- 15
- 注册时间
- 2016-8-6
- 在线时间
- 2 小时
|
1金钱
FATFS fs; // Work area (file system object) for logical drive
FIL fsrc; // file objects
UINT br; // File R/W count
FRESULT res;
DWORD Offset;
char Have;
// char DataBuffer[51];
char DataBuffer[50*8];
unsigned short RecordLen;
//程序实际只执行了下面蓝色部分
f_mount( &fs,"0:",1); //注册到文件系统0区
fsrc.fs=&fs;
res = f_open(&fsrc, path, FA_OPEN_EXISTING | FA_READ);
if (res==FR_NOT_READY)
Show_Str(0,208,lcddev.width,16,(u8*)"TF卡还没有准备好。",16,1);
while(res==FR_NOT_READY)
{
res = f_open(&fsrc, path, FA_OPEN_EXISTING | FA_READ);
}
if(!res)
{
Offset=index * RLength;
res = f_lseek(&fsrc,Offset);//将文件写指针指向文件开始
RecordLen=RLength;
res = f_read(&fsrc, DataBuffer,RecordLen, &br);
Have= br==0;
pBucketData->PulseType=255;
pSecRecord->PulseType=255;
if (br>0)
{
ConertData(pBucketData,DataBuffer);
pBucketData->PosIndex=index;
}
else
{
pBucketData->PosIndex=-1;
pSecRecord->PosIndex=-1;
return FALSE;
}
if (pBucketData->PulseType>0)
{
Offset=(index+1) * RLength;
res = f_lseek(&fsrc,Offset);
res = f_read(&fsrc, DataBuffer,RecordLen, &br);
if (br>0)
{
ConertData(pSecRecord,DataBuffer);
if (strcmp( pBucketData->WellName ,pSecRecord->WellName)!=0)
pSecRecord->PulseType=255;
pSecRecord->PosIndex=index+1;
}
else
{
pSecRecord->PosIndex=-1;
}
}
f_close(&fsrc);
if (res || Have)
return FALSE; // error or eof
else
return TRUE;
}
else
{
pBucketData->PulseType=255;
pSecRecord->PulseType=255;
pBucketData->PosIndex=-1;
pSecRecord->PosIndex=-1;
}
f_mount(0, 0,1); //卸载文件系统
程序实际只执行了下面蓝色部分;但是只要程序执行过这个过程,在显示中文前通过W25QXX_Read获取显示的字符中文编码,获取编码就不正常;开发重新复位运行又能正常显示,不知道是不是FATFS文件操作与W25QXX_Read存在什么冲突。
|
|