FreeRTOS Add Boot Time

This commit is contained in:
2024-12-29 17:24:29 +08:00
parent dbfdce8ec9
commit f4f1772db6
8 changed files with 85 additions and 6 deletions

View File

@@ -189,6 +189,7 @@ int loop(int fd, CONF *conf, DATA *DATA)
}
}
// CO
if (strstr(receivedString, "CO")) {
@@ -246,6 +247,14 @@ int loop(int fd, CONF *conf, DATA *DATA)
printf("\n");
}
// Boot Time
if (strstr(receivedString, "Boot Time")) {
if (1 == (sscanf(receivedString, "Boot Time: %llu seconds\n", &DATA->boot_time_))) {
printf("Boot Time: %llu seconds\n", DATA->boot_time_);
}
}
}
receivedString[0] = '\0';
@@ -360,6 +369,7 @@ int main()
data->co_1st = 1;
data->co2_1st = 1;
data->_time = 180;
data->boot_time_ = 0;
redirect_stdout_to_file(logfd, "hc-12.log");
pthread_mutex_init(&mutex, NULL); // 初始化互斥锁

View File

@@ -48,6 +48,9 @@ typedef struct DATA {
float co2;
float ch4_;
// boot time
long long unsigned int boot_time_;
// 超过阈值次数
int ds18b20_num;
int ch4_num;