部分日志信息
This commit is contained in:
1 parent
7f6c30553b
commit
0a20e23704
5 files changed
+55
-17
No files matched your search
+47
-10
@@ -14,11 +14,46 @@
|
|||||||
|
|
||||||
#define INI_config "/sys/828config.ini"
|
#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)
|
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);//创建文件
|
int fd = open(INI_config, O_WRONLY | O_CREAT);//创建文件
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
@@ -28,22 +63,24 @@ int read_write_sample(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
// 解析INI文件
|
// 解析INI文件
|
||||||
if (ini_parse(ini, INI_config) != 0) {
|
if (ini_parse(ini, INI_config) != 0)
|
||||||
rt_kprintf("2\n");
|
{
|
||||||
|
LOG_E("Retry");
|
||||||
|
rt_thread_mdelay(100);
|
||||||
|
if (ini_parse(ini, INI_config) != 0)
|
||||||
|
{
|
||||||
|
LOG_E("Analysis failed");
|
||||||
ini_free(ini);
|
ini_free(ini);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
LOG_I("read config");
|
||||||
// 读取各种类型的值
|
// 读取各种类型的值
|
||||||
strncpy(machine_ID, ini_get_value(ini, "CONFIG", "ID","99"),sizeof(machine_ID));
|
strncpy(machine_ID, ini_get_value(ini, "CONFIG", "ID","99"),sizeof(machine_ID));
|
||||||
machine_name = ini_get_value(ini, "CONFIG", "NAME","SC828");
|
strncpy(machine_name, ini_get_value(ini, "CONFIG", "NAME","SC828"),sizeof(machine_name));
|
||||||
|
|
||||||
//// ini_set_value(ini,"database", "host","192.168.9.1");
|
|
||||||
|
|
||||||
// ini_save(ini,INI_config);
|
|
||||||
|
|
||||||
// 清理资源
|
// 清理资源
|
||||||
ini_free(ini);
|
ini_free(ini);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
INIT_APP_EXPORT(read_write_sample);
|
INIT_APP_EXPORT(read_sample);
|
||||||
@@ -17,7 +17,7 @@ int pow_dev2;//设备电压,其它
|
|||||||
char *DATA_dat;
|
char *DATA_dat;
|
||||||
char DATA_machins[3];
|
char DATA_machins[3];
|
||||||
char DATA_api[5];
|
char DATA_api[5];
|
||||||
char *machine_name;
|
char machine_name[16];
|
||||||
char machine_ID[3];
|
char machine_ID[3];
|
||||||
|
|
||||||
// 状态标志
|
// 状态标志
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ extern int pow_dev2;//设备电压,其它
|
|||||||
extern char *DATA_dat;
|
extern char *DATA_dat;
|
||||||
extern char DATA_machins[3];
|
extern char DATA_machins[3];
|
||||||
extern char DATA_api[5];
|
extern char DATA_api[5];
|
||||||
extern char *machine_name;
|
extern char machine_name[16];
|
||||||
extern char machine_ID[3];
|
extern char machine_ID[3];
|
||||||
|
|
||||||
// ===== 布尔变量 =====
|
// ===== 布尔变量 =====
|
||||||
|
|||||||
@@ -136,11 +136,11 @@ static rt_int32_t ads1115_raw_to_mv(rt_int16_t raw)
|
|||||||
*/
|
*/
|
||||||
static void ads1115_thread_entry(void *parameter)
|
static void ads1115_thread_entry(void *parameter)
|
||||||
{
|
{
|
||||||
rt_int16_t raw = 0 ,mt = 3600;
|
rt_int16_t raw = 0 ,mt = 900;
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if(mt>3600)
|
if(mt>900)
|
||||||
{
|
{
|
||||||
if (ads1115_read_channel(0, &raw) == RT_EOK)
|
if (ads1115_read_channel(0, &raw) == RT_EOK)
|
||||||
{
|
{
|
||||||
@@ -155,6 +155,7 @@ static void ads1115_thread_entry(void *parameter)
|
|||||||
{
|
{
|
||||||
mt = 0;
|
mt = 0;
|
||||||
}
|
}
|
||||||
|
rt_thread_mdelay(1000);
|
||||||
|
|
||||||
if (ads1115_read_channel(1, &raw) == RT_EOK)
|
if (ads1115_read_channel(1, &raw) == RT_EOK)
|
||||||
{
|
{
|
||||||
@@ -164,6 +165,7 @@ static void ads1115_thread_entry(void *parameter)
|
|||||||
{
|
{
|
||||||
LOG_E("Failed to read ADS1115 P_CODE");
|
LOG_E("Failed to read ADS1115 P_CODE");
|
||||||
}
|
}
|
||||||
|
rt_thread_mdelay(1000);
|
||||||
|
|
||||||
if (ads1115_read_channel(2, &raw) == RT_EOK)
|
if (ads1115_read_channel(2, &raw) == RT_EOK)
|
||||||
{
|
{
|
||||||
@@ -173,6 +175,7 @@ static void ads1115_thread_entry(void *parameter)
|
|||||||
{
|
{
|
||||||
LOG_E("Failed to read ADS1115 P_DEV1");
|
LOG_E("Failed to read ADS1115 P_DEV1");
|
||||||
}
|
}
|
||||||
|
rt_thread_mdelay(1000);
|
||||||
|
|
||||||
if (ads1115_read_channel(3, &raw) == RT_EOK)
|
if (ads1115_read_channel(3, &raw) == RT_EOK)
|
||||||
{
|
{
|
||||||
@@ -182,8 +185,6 @@ static void ads1115_thread_entry(void *parameter)
|
|||||||
{
|
{
|
||||||
LOG_E("Failed to read ADS1115 P_DEV2");
|
LOG_E("Failed to read ADS1115 P_DEV2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
rt_thread_mdelay(1000); // 每 秒读取一次
|
rt_thread_mdelay(1000); // 每 秒读取一次
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ static rt_err_t aht20_init_sensor(void)
|
|||||||
/* 读取状态字节(可选) */
|
/* 读取状态字节(可选) */
|
||||||
if (aht20_read_data(&status, 1) == RT_EOK)
|
if (aht20_read_data(&status, 1) == RT_EOK)
|
||||||
{
|
{
|
||||||
LOG_D("AHT20 status: 0x%02X", status);
|
LOG_I("AHT20 status: 0x%02X", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
return RT_EOK;
|
return RT_EOK;
|
||||||
|
|||||||
Reference in new issue
Block a user