部分日志信息

This commit is contained in:
sc committed 2026-01-01 15:00:09 +08:00
1 parent 7f6c30553b
commit 0a20e23704
5 files changed
+58 -20

No files matched your search

+50 -13
View File
@@ -14,11 +14,46 @@
#define INI_config "/sys/828config.ini"
int read_write_sample(void)
#define DBG_TAG "INI.config"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>
void write_sample(void)
{
//检查文件
if (access(INI_config, F_OK) != 0)
{
LOG_E("NOT 828config");
int fd = open(INI_config, O_WRONLY | O_CREAT);//创建文件
close(fd);
}
// 初始化INI解析器
INI_File *ini = ini_init();
if (!ini) {
return;
}
// 解析INI文件
if (ini_parse(ini, INI_config) != 0)
{
LOG_E("Analysis failed");
ini_free(ini);
return;
}
LOG_I("write config");
// 写入各种类型的值
ini_set_value(ini,"CONFIG", "ID",machine_ID);
ini_set_value(ini,"CONFIG", "NAME",machine_name);
ini_save(ini,INI_config);
// 清理资源
ini_free(ini);
}
int read_sample(void)
{
//检查文件
if (access(INI_config, F_OK) != 0)
{
LOG_E("NOT 828config");
int fd = open(INI_config, O_WRONLY | O_CREAT);//创建文件
close(fd);
}
@@ -28,22 +63,24 @@ int read_write_sample(void)
return -1;
}
// 解析INI文件
if (ini_parse(ini, INI_config) != 0) {
rt_kprintf("2\n");
if (ini_parse(ini, INI_config) != 0)
{
LOG_E("Retry");
rt_thread_mdelay(100);
if (ini_parse(ini, INI_config) != 0)
{
LOG_E("Analysis failed");
ini_free(ini);
return -1;
}
}
LOG_I("read config");
// 读取各种类型的值
strncpy(machine_ID, ini_get_value(ini, "CONFIG", "ID","99"),sizeof(machine_ID));
machine_name = ini_get_value(ini, "CONFIG", "NAME","SC828");
//// ini_set_value(ini,"database", "host","192.168.9.1");
// ini_save(ini,INI_config);
// 清理资源
ini_free(ini);
return 0;
strncpy(machine_name, ini_get_value(ini, "CONFIG", "NAME","SC828"),sizeof(machine_name));
// 清理资源
ini_free(ini);
return 0;
}
INIT_APP_EXPORT(read_write_sample);
INIT_APP_EXPORT(read_sample);