write_addr = 0;
res=f_lseek (file,write_addr);//指定写入的地址
sprintf(buf, "2:/History20%02d%02d%02d%02d%02d.csv", HldReg[YEAR],HldReg[MONTH],HldReg[DAY],HldReg[HOUR],HldReg[MINUTE]);
res=f_open (file,buf, FA_OPEN_ALWAYS | FA_WRITE);// FA_CREATE_ALWAYS | FA_WRITE);
sprintf(buf, "序号,时间,压力,浓度,流量,温度,累计流量\r\n");
f_write (file, buf, sizeof(buf), &bww);
write_addr += sizeof(buf);
res=f_lseek (file,write_addr);//指定写入的地址
for (i=0; i<10; i++)
{
sprintf(buf,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\r\n",text[0],text[1],text[2],text[3],text[4],text[5],text[6],text[7],text[8],text[9]);
}
f_write (file, buf, sizeof(buf), &bww);
write_addr += sizeof(buf);
res=f_lseek (file,write_addr);//指定写入的地址
for (i=0; i<10; i++)
{
text+=100;
sprintf(buf,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\r\n",text[0],text[1],text[2],text[3],text[4],text[5],text[6],text[7],text[8],text[9]);
}
f_write (file, buf, sizeof(buf), &bww);
f_close(file);
序号 | 时间 | 压力 | 浓度 | 流量 | 温度 | 累计流量 | | | | 脋 ? 1 j 5? @圚 ? 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 脋 ? 1 j 5? @圚 ? 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 脋 ? 1 j 5? @圚 ? | | | | | | | | | |
很简单的测试,总是在结束的时候出现一串乱码。
谢谢!
|