修改了Web后台的部分界面,增加了HAmqtt中的总电量传感器,后台新增mqtt上报频率设置
43
mico-os/libraries/filesystem/FatFs/doc/img/app1.c
Normal file
@@ -0,0 +1,43 @@
|
||||
/*------------------------------------------------------------/
|
||||
/ Open or create a file in append mode
|
||||
/------------------------------------------------------------*/
|
||||
|
||||
FRESULT open_append (
|
||||
FIL* fp, /* [OUT] File object to create */
|
||||
const char* path /* [IN] File name to be opened */
|
||||
)
|
||||
{
|
||||
FRESULT fr;
|
||||
|
||||
/* Opens an existing file. If not exist, creates a new file. */
|
||||
fr = f_open(fp, path, FA_WRITE | FA_OPEN_ALWAYS);
|
||||
if (fr == FR_OK) {
|
||||
/* Seek to end of the file to append data */
|
||||
fr = f_lseek(fp, f_size(fp));
|
||||
if (fr != FR_OK)
|
||||
f_close(fp);
|
||||
}
|
||||
return fr;
|
||||
}
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
FRESULT fr;
|
||||
FATFS fs;
|
||||
FIL fil;
|
||||
|
||||
/* Open or create a log file and ready to append */
|
||||
f_mount(&fs, "", 0);
|
||||
fr = open_append(&fil, "logfile.txt");
|
||||
if (fr != FR_OK) return 1;
|
||||
|
||||
/* Append a line */
|
||||
f_printf(&fil, "%02u/%02u/%u, %2u:%02u\n", Mday, Mon, Year, Hour, Min);
|
||||
|
||||
/* Close the file */
|
||||
f_close(&fil);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
70
mico-os/libraries/filesystem/FatFs/doc/img/app2.c
Normal file
@@ -0,0 +1,70 @@
|
||||
/*------------------------------------------------------------/
|
||||
/ Remove all contents of a directory
|
||||
/ This function works regardless of _FS_RPATH.
|
||||
/------------------------------------------------------------*/
|
||||
|
||||
|
||||
FRESULT empty_directory (
|
||||
char* path /* Working buffer filled with start directory */
|
||||
)
|
||||
{
|
||||
UINT i, j;
|
||||
FRESULT fr;
|
||||
DIR dir;
|
||||
FILINFO fno;
|
||||
|
||||
#if _USE_LFN
|
||||
fno.lfname = 0; /* Eliminate LFN output */
|
||||
#endif
|
||||
fr = f_opendir(&dir, path);
|
||||
if (fr == FR_OK) {
|
||||
for (i = 0; path[i]; i++) ;
|
||||
path[i++] = '/';
|
||||
for (;;) {
|
||||
fr = f_readdir(&dir, &fno);
|
||||
if (fr != FR_OK || !fno.fname[0]) break;
|
||||
if (fno.fname[0] == '.') continue;
|
||||
j = 0;
|
||||
do
|
||||
path[i+j] = fno.fname[j];
|
||||
while (fno.fname[j++]);
|
||||
if (fno.fattrib & AM_DIR) {
|
||||
fr = empty_directory(path);
|
||||
if (fr != FR_OK) break;
|
||||
}
|
||||
fr = f_unlink(path);
|
||||
if (fr != FR_OK) break;
|
||||
}
|
||||
path[--i] = '\0';
|
||||
closedir(&dir);
|
||||
}
|
||||
|
||||
return fr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
FRESULT fr;
|
||||
FATFS fs;
|
||||
char buff[64]; /* Working buffer */
|
||||
|
||||
|
||||
|
||||
f_mount(&fs, "", 0);
|
||||
|
||||
strcpy(buff, "/"); /* Directory to be emptied */
|
||||
fr = empty_directory(buff);
|
||||
|
||||
if (fr) {
|
||||
printf("Function failed. (%u)\n", fr);
|
||||
return 1;
|
||||
} else {
|
||||
printf("All contents in the %s are successfully removed.\n", buff);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
106
mico-os/libraries/filesystem/FatFs/doc/img/app3.c
Normal file
@@ -0,0 +1,106 @@
|
||||
/*----------------------------------------------------------------------/
|
||||
/ Allocate a contiguous area to the file
|
||||
/-----------------------------------------------------------------------/
|
||||
/ This function checks if the file is contiguous with desired size.
|
||||
/ If not, a block of contiguous sectors is allocated to the file.
|
||||
/ If the file has been opened without FA_WRITE flag, it only checks if
|
||||
/ the file is contiguous and returns the resulut. */
|
||||
|
||||
#if _FATFS != 80960 /* Check if R0.10 */
|
||||
#error This function may not be compatible with this revision of FatFs module.
|
||||
#endif
|
||||
|
||||
/* Declarations of FatFs internal functions accessible from applications.
|
||||
/ This is intended to be used for disk checking/fixing or dirty hacks :-) */
|
||||
DWORD clust2sect (FATFS* fs, DWORD clst);
|
||||
DWORD get_fat (FATFS* fs, DWORD clst);
|
||||
FRESULT put_fat (FATFS* fs, DWORD clst, DWORD val);
|
||||
|
||||
|
||||
DWORD allocate_contiguous_clusters ( /* Returns the first sector in LBA (0:error or not contiguous) */
|
||||
FIL* fp, /* Pointer to the open file object */
|
||||
DWORD len /* Number of bytes to allocate */
|
||||
)
|
||||
{
|
||||
DWORD csz, tcl, ncl, ccl, cl;
|
||||
|
||||
|
||||
if (f_lseek(fp, 0) || !len) /* Check if the given parameters are valid */
|
||||
return 0;
|
||||
csz = 512UL * fp->fs->csize; /* Cluster size in unit of byte (assuming 512 bytes/sector) */
|
||||
tcl = (len + csz - 1) / csz; /* Total number of clusters required */
|
||||
len = tcl * csz; /* Round-up file size to the cluster boundary */
|
||||
|
||||
/* Check if the existing cluster chain is contiguous */
|
||||
if (len == fp->fsize) {
|
||||
ncl = 0; ccl = fp->sclust;
|
||||
do {
|
||||
cl = get_fat(fp->fs, ccl); /* Get the cluster status */
|
||||
if (cl + 1 < 3) return 0; /* Hard error? */
|
||||
if (cl != ccl + 1 &&; cl < fp->fs->n_fatent) break; /* Not contiguous? */
|
||||
ccl = cl;
|
||||
} while (++ncl < tcl);
|
||||
if (ncl == tcl) /* Is the file contiguous? */
|
||||
return clust2sect(fp->fs, fp->sclust); /* Return file start sector */
|
||||
}
|
||||
#if _FS_READONLY
|
||||
return 0;
|
||||
#else
|
||||
if (f_truncate(fp)) return 0; /* Remove the existing chain */
|
||||
|
||||
/* Find a free contiguous area */
|
||||
ccl = cl = 2; ncl = 0;
|
||||
do {
|
||||
if (cl >= fp->fs->n_fatent) return 0; /* No contiguous area is found. */
|
||||
if (get_fat(fp->fs, cl)) { /* Encounterd a cluster in use */
|
||||
do { /* Skip the block of used clusters */
|
||||
cl++;
|
||||
if (cl >= fp->fs->n_fatent) return 0; /* No contiguous area is found. */
|
||||
} while (get_fat(fp->fs, cl));
|
||||
ccl = cl; ncl = 0;
|
||||
}
|
||||
cl++; ncl++;
|
||||
} while (ncl < tcl);
|
||||
|
||||
/* Create a contiguous cluster chain */
|
||||
fp->fs->last_clust = ccl - 1;
|
||||
if (f_lseek(fp, len)) return 0;
|
||||
|
||||
return clust2sect(fp->fs, fp->sclust); /* Return file start sector */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
FRESULT fr;
|
||||
DRESULT dr;
|
||||
FATFS fs;
|
||||
FIL fil;
|
||||
DWORD org;
|
||||
|
||||
|
||||
/* Open or create a file */
|
||||
f_mount(&fs, "", 0);
|
||||
fr = f_open(&fil, "swapfile.sys", FA_READ | FA_WRITE | FA_OPEN_ALWAYS);
|
||||
if (fr) return 1;
|
||||
|
||||
/* Check if the file is 64MB in size and occupies a contiguous area.
|
||||
/ If not, a contiguous area will be re-allocated to the file. */
|
||||
org = allocate_contiguous_clusters(&fil, 0x4000000);
|
||||
if (!org) {
|
||||
printf("Function failed due to any error or insufficient contiguous area.\n");
|
||||
f_close(&fil);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Now you can read/write the file with disk functions bypassing the file system layer. */
|
||||
|
||||
dr = disk_write(fil.fs->drv, Buff, org, 1024); /* Write 512Ki bytes from top of the file */
|
||||
|
||||
...
|
||||
|
||||
f_close(&fil);
|
||||
return 0;
|
||||
}
|
||||
|
||||
BIN
mico-os/libraries/filesystem/FatFs/doc/img/f1.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
mico-os/libraries/filesystem/FatFs/doc/img/f2.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
mico-os/libraries/filesystem/FatFs/doc/img/f3.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
mico-os/libraries/filesystem/FatFs/doc/img/f4.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
mico-os/libraries/filesystem/FatFs/doc/img/f5.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
mico-os/libraries/filesystem/FatFs/doc/img/f6.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
mico-os/libraries/filesystem/FatFs/doc/img/f7.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
mico-os/libraries/filesystem/FatFs/doc/img/layers.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
mico-os/libraries/filesystem/FatFs/doc/img/layers3.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
mico-os/libraries/filesystem/FatFs/doc/img/modules.png
Normal file
|
After Width: | Height: | Size: 8.4 KiB |
BIN
mico-os/libraries/filesystem/FatFs/doc/img/rwtest.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
mico-os/libraries/filesystem/FatFs/doc/img/rwtest2.png
Normal file
|
After Width: | Height: | Size: 8.0 KiB |
BIN
mico-os/libraries/filesystem/FatFs/doc/img/rwtest3.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |