初级会员

- 积分
- 87
- 金钱
- 87
- 注册时间
- 2014-8-31
- 在线时间
- 0 小时
|
5金钱
1.我的读取缓存区只能设置到328,多了就不跑了,请问是为什么?
2.我写进去24个字节的数,为啥读出来的多余24的时候是乱码,
if(myfs_init())
{
FRESULT rc,rw;
BYTE buffer[328];//="?ó?????ó?????ó?????ó????";
BYTE buffer1[328] ;
UINT br,bw;
// FATFS fs;
FIL infile;
// FILINFO finfo;
// DIR dirs;
int a;
SD_capp = SD_GetSectorCount();
SD_capp = SD_capp*512;
SD_capp = (SD_capp/1024)/1024;
com1_send_str("????4G??????????TF?¨??????\r\n");
com1_send_str("TF?¨??????");
USART_SendData(USART1,(SD_capp%10000)/1000+'0');
while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
USART_SendData(USART1,(SD_capp%1000)/100+'0');
while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
USART_SendData(USART1,(SD_capp%100)/10+'0');
while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
USART_SendData(USART1,SD_capp%10+'0');
while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
com1_send_str("MB\r\n");
/* rc=f_open(&infile,"text1/12.txt",FA_WRITE | FA_CREATE_ALWAYS);
if(rc==FR_OK)
{
do
{
rc = f_write(&infile, buffer,100,&bw);
if(rc)
{
com1_send_str("write error : %d\r\n");
break;
}
}while (bw < 100);
f_close(&infile);
}*/
rc=f_open(&infile,"text1/12.txt",FA_READ);
if(!rc)
{
com1_send_str("open SD.txt\r\n");
br=1;
for (;;)
{
for(a=0;a<329;a++) buffer1[a] =0;
rc=f_read(&infile,buffer1,300,&br);
com1_send(&buffer1,300) ;
if (rc || br <300) break;
}
}
f_close(&infile);
}
|
|