- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 FatFs 库在 SD 卡上创建和管理文件系统。目标是识别包含引导加载程序更新(或不更新)设备的固件的文件。
我遵循的程序如下:
DIR directory;
FILINFO filinfo;
f_findfirst(&directory, &filinfo, "", "firmware_");
据我了解,应识别以 "firmware_"
开头的第一个文件,并将信息存储在 filinfo
中。这确实有效,但是当我尝试从 filinfo.fname
中提取名称时,已提取的名称如下:"\0IRMWA~1.BIN"
.
我不知道为什么以这种格式提取文件的命名。我们的想法是稍后获取文件的第二部分:“firmware_01_01_01
”并执行 char 到 int 的转换来处理版本号,但我无法提取文件名的完整字符串。
最佳答案
我也遇到了类似的问题。这是我的代码。希望您觉得这有帮助
#define FW_FOLDER "fw"
#define FW_PATH "0:/" FW_FOLDER
#define FW_BIN "*.bin"
FRESULT res;
DIR dir;
FILINFO fno;
static char fw_path[128];
// Find first item
res = f_findfirst(&dir, &fno, FW_PATH, FW_BIN);
// Create directory (optional)
if (res == FR_NO_PATH)
{
printf("Creating %s directory!\n", FW_FOLDER);
f_mkdir(FW_FOLDER);
}
// Repeat until proper item is found
while (res == FR_OK)
{
// Make sure file name is valid
if (fno.fname[0] == 0)
break;
// Debugging
printf("Scanning: %s\n", fno.fname);
// Make sure it is not a directory
if (!(fno.fattrib & AM_DIR))
{
// Success!
printf("Found: %s\n", fno.fname);
// Construct file path
sprintf(fw_path, "%s/%s", FW_PATH, fno.fname);
break;
}
// Move to the next one
res = f_findnext(&dir, &fno);
}
// Close directory
f_closedir(&dir);
是的,您需要在 fatfs 库中启用 FF_USE_FIND == 1
。如果您决定将 2
用于 FF_USE_FIND
,则必须检查 altname
作为 fno
的一部分。
此外,我最终必须将文件验证更新到此代码段
// Make sure file name is alpha numeric
if (!isalnum(fat_fno.fname[0]))
break;
关于c - FatFS:f_findfirst 返回一个与找到的文件不对应的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58798894/
我有一个在 STM32F7 上运行的数据记录系统,它使用 ChaN 的 FatFs 将数据存储到 SD 卡中: http://elm-chan.org/fsw/ff/00index_e.html 每组
我在 C 中有以下函数: char* AUDIO_GetFile(FIL* fil, DIR* dir, FILINFO* fno) { FRESULT res; res = f_re
我在基于 Cortex M4 的平台上运行的 C++ 应用程序中集成了 FatFS。 我的应用程序包括将数据记录为一种名为 MDF 的数据格式. 在实现方面,我将数据(到给定文件)记录在缓冲区的批处理
我有一个用 Atmel Studio 编写的代码,用于从 SD 卡读取/写入数据。我在这里使用 FatFs。我的问题是,当我在 FatFs 中使用某些函数(f_chdir、f_getcwd...)时,
我是嵌入式开发新手,负责在 SPI 闪存上实现文件系统。我在 STM32CubeIDE 上使用 w25qxx 芯片和 STM32F4xx。我已经通过 SPI 成功地为 w25 创建了基本的 i/o,能
我在 ZedBoard 上,我想在 SD 卡上写。我在嵌入式系统上工作,我没有任何操作系统,我正在运行裸机。 我可以从 SD 卡上正常读取,它们没问题。 但是当我尝试阅读时,我有一些奇怪的行为: f_
我在 ZedBoard 上,我想在 SD 卡上写。我在嵌入式系统上工作,我没有任何操作系统,我正在运行裸机。 我可以从 SD 卡上正常读取,它们没问题。 但是当我尝试阅读时,我有一些奇怪的行为: f_
我正在使用 FatFs 库在 SD 卡上创建和管理文件系统。目标是识别包含引导加载程序更新(或不更新)设备的固件的文件。 我遵循的程序如下: DIR directory; FILINFO filin
使用 FatFs 及其 API ,我正在尝试为驱动器的其余部分预分配文件系统空间以写入未知大小的文件。在文件写入过程结束时,任何未使用的空间都会被截断 (f_truncate)。但是,当文件系统在删除
所以我正在使用 STM32F407 并尝试使用 FATFS 写入 SD 卡。我使用 CubeMX 生成 FAT 层和 4 位 SDIO 配置软件的代码。我在main中添加了以下代码来测试代码是否有效。
晚上好, 我使用 Atmega32(2kB RAM),频率为 14.7456MHz,通过运行频率约为 1.5MHz 的 SPI 将数据记录到 SD 卡。 FatFs 设置为 FF_FS_TINY 0(
我正在为 STM32F0(Keil uVision 5)编程。 我尝试使用 FatFs 库来管理文件系统(SD 卡)。我已经编写了每个初始化函数,并且项目正在编译,没有任何错误/警告。但是第一个函数
我目前正在使用 Micrium OS-II 为 ST32 (STM32F103xC) 开发应用程序。到目前为止,一切都很顺利,但我现在遇到了障碍,无法继续。 开发板配置为使用 SD 卡作为 USB 存
我的 SD 卡有问题。我正在使用 FatFs 库版本 R0.10b 来访问 SD 卡。 我的代码: // .... // FATFS fatfs; FIL plik;
我开始使用 stm32l0 开发板,在我可以使用一些更有趣的功能之前一切都很好。我从来没有在 windows 之外读取 SD 卡,我找到了 Pins 链接并开始阅读有关 SPI 的信息,这可能是我们项
嗨,我是 fatfs 文件系统的新手,我想使用 fat 文件系统库读取数据并将数据写入我的笔式驱动器。我能够读取和写入单个文件,但我的项目需要我一次打开两个文件并向其中写入一些内容。但这样做会返回 F
我正在使用 STM32F407 Discovery Board 来连接 USB OTG FS。我使用 CubeMx 和 Keil 进行开发。 首先,我已启用 PC0 - USB_Power(用于 Di
我正在研究 TI 为其 MSP530 LaunchPad 微 Controller 开发套件提供的 SD 卡应用代码示例。似乎该示例将目录数和文件数限制为每个 10 个(总共 100 个文件),这对于
在我的工作中,我无法重现该错误。它只发生在“领域”。我构建了一个记录设备,用于记录 GPS 和机器人增量传感器的数据。 记录 2/3 分钟后,它会停止。每次记录的数据量约为175kB。您有搜索或调试此
我正在尝试在 USB 闪存上使用 FatFs 创建一个文件,但我的 f_open 调用尝试读取引导扇区以进行首次文件系统装载时卡在该函数上。 DRESULT disk_read (
我是一名优秀的程序员,十分优秀!