Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
flashDB
RT-Thread一般讨论
flashdb kvdb结构体参数存储问题
发布于 2024-05-18 10:19:48 浏览:857
订阅该版
基于Flashdb的例程,添加一个结构体类型数据在default_kv表中;如下。 ```c struct index { uint8_t protocolVersion; char hardwareID[5]; }; static struct index index00; /* default KV nodes */ static struct fdb_default_kv_node default_kv_table[] = { {"index", &index00, sizeof(index00)}, {"username", "armink", 0}, /* string KV */ {"boot_count", &boot_count, sizeof(boot_count)}, /* int type KV */ {"boot_time", &boot_time, sizeof(boot_time)}, /* int array type KV */ ``` 然后在函数中使用fdb_kv_get_blob把数据保存在blob类型中,尝试打印出来。 ```c /*default table测试代码:打印结构体*/ struct STIndex_0x00 temp_index00; fdb_kv_get_blob(&kvdb, "index", fdb_blob_make(&blob, &temp_index00, sizeof(temp_index00))); if (blob.saved.len > 0) { FDB_INFO("get the 'index00' protocolVersion is: %d\n", temp_index00.protocolVersion); FDB_INFO("get the 'index00' hardwareID is: %s\n", temp_index00.hardwareID); } /*default table测试代码:开机次数*/ uint32_t temp_boot_count; fdb_kv_get_blob(&kvdb, "boot_count", fdb_blob_make(&blob, &temp_boot_count, sizeof(temp_boot_count))); if (blob.saved.len > 0) { FDB_INFO("get current boot count is: %d\n", temp_boot_count); } ``` 别的像 string, int 和array等数据都能打印正常(输出台如下), 但结构体好像没有储存正确。能帮忙看看具体哪里有错误吗? ```c [FlashDB][kv][file] (../packages/FlashDB-latest/src/fdb_kvdb.c:1638) KVDB size is 1048576 bytes. [FlashDB][FDB] get the username value is: armink [FlashDB][FDB] get first time is: 0 [FlashDB][FDB] get second time is: 1 [FlashDB][FDB] get current boot count is: 41 [FlashDB][sample][kvdb][basic] ==================== kvdb_basic_sample ========= [FlashDB][sample][kvdb][basic] get the 'boot_count' value is 41 [FlashDB][sample][kvdb][basic] set the 'boot_count' value to 42 [FlashDB][sample][kvdb][basic]================================================== ```
查看更多
1
个回答
默认排序
按发布时间排序
Ziegler小陈
2024-09-02
这家伙很懒,什么也没写!
尝试一下fdb_kv_set_default(kvdb)重置数据库未默认值,在打印前
撰写答案
登录
注册新账号
关注者
0
被浏览
857
关于作者
张文彬
这家伙很懒,什么也没写!
提问
8
回答
5
被采纳
0
关注TA
发私信
相关问题
1
有关动态模块加载的一篇论文
2
最近的调程序总结
3
晕掉了,这么久都不见layer2的踪影啊
4
继续K9ii的历程
5
[GUI相关] FreeType 2
6
[GUI相关]嵌入式系统中文输入法的设计
7
20081101 RT-Thread开发者聚会总结
8
嵌入式系统基础
9
linux2.4.19在at91rm9200 上的寄存器设置
10
[转]基于嵌入式Linux的通用触摸屏校准程序
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
国产MCU移植系列教程汇总,欢迎查看!
4
机器人操作系统 (ROS2) 和 RT-Thread 通信
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
最新文章
1
【FRDM-MCXA156测评】- CherryUSB与hid鼠标设备模仿
2
【FRDM-MCXA156测评】- 硬件SPI模块
3
【NXP-MCXA156】恩智浦A156上的 IIC(硬件) 实践
4
【FRA156测评DM-MCX】- PWM模块
5
【FRDM-MCXA156 评测】CAN通讯
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
AT
Bootloader
Hardfault
CAN总线
FinSH
ART-Pi
DMA
USB
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
RTC
rt-smart
FAL
I2C_IIC
UART
ESP8266
cubemx
WIZnet_W5500
ota在线升级
PWM
BSP
flash
freemodbus
packages_软件包
潘多拉开发板_Pandora
定时器
GD32
ADC
flashDB
编译报错
socket
中断
Debug
rt_mq_消息队列_msg_queue
keil_MDK
ulog
SFUD
msh
C++_cpp
MicroPython
本月问答贡献
出出啊
1520
个答案
343
次被采纳
小小李sunny
1444
个答案
290
次被采纳
张世争
813
个答案
177
次被采纳
crystal266
550
个答案
161
次被采纳
whj467467222
1222
个答案
149
次被采纳
本月文章贡献
出出啊
1
篇文章
5
次点赞
小小李sunny
1
篇文章
1
次点赞
张世争
1
篇文章
3
次点赞
crystal266
2
篇文章
1
次点赞
whj467467222
2
篇文章
2
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部