uint32_t time_diff = 0;
if (current_timestamp >= folder_timestamp) {
time_diff = current_timestamp - folder_timestamp;
- } else {
- time_diff = folder_timestamp - current_timestamp;
- }
-
+ }
+ // else {
+ // time_diff = folder_timestamp - current_timestamp;
+ // }
+ // printf("current_timestamp:%d,folder_timestamp:%d,time_diff : %d\n",current_timestamp,folder_timestamp,time_diff);
// 检查是否在24小时内
- if (time_diff < 86400) { // 24小时 = 86400秒
+ if (time_diff < 86400 && time_diff > 0) // 24小时 = 86400秒
+ {
// 构建完整路径以检查文件数量
char full_folder_path[512];
int path_ret = snprintf(full_folder_path, sizeof(full_folder_path), "%s/%s", PGNSS_DATA_PATH, entry->d_name);
// 检查文件数量是否为26个
if (file_count >= 20) {
found_valid_folder = 1;
- if (time_diff < min_time_diff) {
- min_time_diff = time_diff;
- // 更新全局变量,存储最接近的时间戳文件夹路径
- if (g_current_agnss_folder != NULL) {
- free(g_current_agnss_folder);
- g_current_agnss_folder = NULL;
- }
- g_current_agnss_folder = malloc(256);
- if (g_current_agnss_folder != NULL) {
- int ret = snprintf(g_current_agnss_folder, 256, "%s/%s", PGNSS_DATA_PATH, entry->d_name);
- if (ret < 0 || ret >= 256) {
- printf("ERROR: snprintf failed or buffer overflow for g_current_agnss_folder\n");
+ if (time_diff < min_time_diff) {
+ min_time_diff = time_diff;
+ // 更新全局变量,存储最接近的时间戳文件夹路径
+ if (g_current_agnss_folder != NULL) {
free(g_current_agnss_folder);
g_current_agnss_folder = NULL;
}
- } else {
- printf("ERROR: Failed to allocate memory for g_current_agnss_folder\n");
+ g_current_agnss_folder = malloc(256);
+ if (g_current_agnss_folder != NULL) {
+ int ret = snprintf(g_current_agnss_folder, 256, "%s/%s", PGNSS_DATA_PATH, entry->d_name);
+ if (ret < 0 || ret >= 256) {
+ printf("ERROR: snprintf failed or buffer overflow for g_current_agnss_folder\n");
+ free(g_current_agnss_folder);
+ g_current_agnss_folder = NULL;
+ }
+ } else {
+ printf("ERROR: Failed to allocate memory for g_current_agnss_folder\n");
+ }
}
- }
- printf("Found valid AGNSS folder: %s (time diff: %u seconds, file count: %d)\n",
- entry->d_name, time_diff, file_count);
+ printf("Found valid AGNSS folder: %s (time diff: %u seconds, file count: %d)\n",
+ entry->d_name, time_diff, file_count);
} else {
printf("Found AGNSS folder with invalid file count: %s (time diff: %u seconds, file count: %d/26)\n",
entry->d_name, time_diff, file_count);
printf("Cycle %d: Checking %s - file count: %d/26\n",
current_cycle, candidate_folder_name, file_count);
- if (file_count == 26) {
+ if (file_count >= 20)
+ {
printf("SUCCESS: AGNSS folder now has 26 files! %s\n", candidate_folder_name);
// 更新全局变量,存储有效的文件夹路径