Commit a9d72472 authored by DESKTOP-MC5UL36\dell's avatar DESKTOP-MC5UL36\dell

hardware_iic读取失败会导致不上线,python文件下载的bug

parent dcbd8165
...@@ -77,11 +77,9 @@ int hardware_iic_write(uint8_t device_addr, uint8_t reg_addr, const uint8_t *dat ...@@ -77,11 +77,9 @@ int hardware_iic_write(uint8_t device_addr, uint8_t reg_addr, const uint8_t *dat
my_zlog_warn("错误:向设备 0x%02X 寄存器 0x%02X 写入数据失败。", device_addr, reg_addr); my_zlog_warn("错误:向设备 0x%02X 寄存器 0x%02X 写入数据失败。", device_addr, reg_addr);
break; break;
} }
ret = 0; // 成功
pthread_mutex_unlock(&i2c_mutex);
ret = 0; // 成功
}while(0); }while(0);
pthread_mutex_unlock(&i2c_mutex);
// my_zlog_info("成功向设备 0x%02X 寄存器 0x%02X 写入 %d 字节数据。", device_addr, reg_addr, len); // my_zlog_info("成功向设备 0x%02X 寄存器 0x%02X 写入 %d 字节数据。", device_addr, reg_addr, len);
return ret; return ret;
} }
......
...@@ -290,79 +290,78 @@ int go_deploy_check_and_update(void) { ...@@ -290,79 +290,78 @@ int go_deploy_check_and_update(void) {
if (access(target_file_path, F_OK) == 0) { if (access(target_file_path, F_OK) == 0) {
chmod(target_file_path, 0777); chmod(target_file_path, 0777);
} }
}
// --------------------------------------------------------- // 处理 video_proxy.7z
// 处理 video_proxy.7z cJSON *pythonUrl = cJSON_GetObjectItem(moreInfo, "pythonUrl");
// --------------------------------------------------------- if (pythonUrl && cJSON_IsString(pythonUrl) && strlen(pythonUrl->valuestring) > 0) {
cJSON *pythonUrl = cJSON_GetObjectItem(moreInfo, "pythonUrl"); char target_7z_path[512];
if (pythonUrl && cJSON_IsString(pythonUrl) && strlen(pythonUrl->valuestring) > 0) { snprintf(target_7z_path, sizeof(target_7z_path), "%s/video_proxy.7z", target_dir);
char target_7z_path[512];
snprintf(target_7z_path, sizeof(target_7z_path), "%s/video_proxy.7z", target_dir); int need_download_7z = 0;
int need_download_7z = 0; // 检查文件是否存在
my_zlog_info("target_7z_path:%s",target_7z_path);
// 检查文件是否存在 if (access(target_7z_path, F_OK) != 0) {
if (access(target_7z_path, F_OK) != 0) { my_zlog_info("video_proxy.7z not found, need download.");
my_zlog_info("video_proxy.7z not found, need download."); need_download_7z = 1;
need_download_7z = 1; } else {
} else { // 检查 Hash (使用 pythonHash)
// 检查 Hash (使用 pythonHash) cJSON *pythonHash = cJSON_GetObjectItem(moreInfo, "pythonHash");
cJSON *pythonHash = cJSON_GetObjectItem(moreInfo, "pythonHash"); if (pythonHash && cJSON_IsString(pythonHash)) {
if (pythonHash && cJSON_IsString(pythonHash)) { char local_hash[65] = {0};
char local_hash[65] = {0}; if (calculate_file_hash(target_7z_path, local_hash) == 0) {
if (calculate_file_hash(target_7z_path, local_hash) == 0) { if (strcasecmp(local_hash, pythonHash->valuestring) != 0) {
if (strcasecmp(local_hash, pythonHash->valuestring) != 0) { my_zlog_info("7z Hash mismatch. Local: %s, Cloud: %s. Re-downloading...", local_hash, goHash->valuestring);
my_zlog_info("7z Hash mismatch. Local: %s, Cloud: %s. Re-downloading...", local_hash, goHash->valuestring); need_download_7z = 1;
need_download_7z = 1; } else {
my_zlog_info("7z Hash verified.");
}
} else { } else {
my_zlog_info("7z Hash verified."); my_zlog_error("Failed to calculate 7z local hash");
need_download_7z = 1;
} }
} else { } else {
my_zlog_error("Failed to calculate 7z local hash"); my_zlog_warn("goHash missing for 7z check");
need_download_7z = 1;
} }
} else {
my_zlog_warn("goHash missing for 7z check");
} }
}
if (need_download_7z) { if (need_download_7z) {
my_zlog_info("Downloading 7z from: %s", pythonUrl->valuestring); my_zlog_info("Downloading 7z from: %s", pythonUrl->valuestring);
if (download_file(pythonUrl->valuestring, target_7z_path) == 0) { if (download_file(pythonUrl->valuestring, target_7z_path) == 0) {
my_zlog_info("Download 7z success. Preparing to extract..."); my_zlog_info("Download 7z success. Preparing to extract...");
// 检查 7z 是否安装 // 检查 7z 是否安装
if (system("which 7z > /dev/null 2>&1") != 0) { if (system("which 7z > /dev/null 2>&1") != 0) {
my_zlog_info("7z not found. Installing p7zip-full..."); my_zlog_info("7z not found. Installing p7zip-full...");
// 尝试安装 p7zip-full (Ubuntu) // 尝试安装 p7zip-full (Ubuntu)
int install_ret = system("sudo apt-get update && sudo apt-get install -y p7zip-full"); int install_ret = system("sudo apt-get update && sudo apt-get install -y p7zip-full");
if (install_ret != 0) { if (install_ret != 0) {
my_zlog_error("Failed to install p7zip-full, return code: %d", install_ret); my_zlog_error("Failed to install p7zip-full, return code: %d", install_ret);
} else { } else {
my_zlog_info("p7zip-full installation completed successfully."); my_zlog_info("p7zip-full installation completed successfully.");
}
} }
}
// 解压 // 解压
char cmd[1024]; char cmd[1024];
// 使用密码 fcrs2025606 解压, -y 自动覆盖, -o 指定输出目录 // 使用密码 fcrs2025606 解压, -y 自动覆盖, -o 指定输出目录
snprintf(cmd, sizeof(cmd), "7z x \"%s\" -o\"%s\" -pfcrs2025606 -y", target_7z_path, target_dir); snprintf(cmd, sizeof(cmd), "7z x \"%s\" -o\"%s\" -pfcrs2025606 -y", target_7z_path, target_dir);
my_zlog_info("Executing: %s", cmd); my_zlog_info("Executing: %s", cmd);
int extract_ret = system(cmd); int extract_ret = system(cmd);
if (extract_ret == 0) { if (extract_ret == 0) {
my_zlog_info("Extraction success."); my_zlog_info("Extraction success.");
} else {
my_zlog_error("Extraction failed with code: %d", extract_ret);
}
} else { } else {
my_zlog_error("Extraction failed with code: %d", extract_ret); my_zlog_error("Download 7z failed.");
} }
} else {
my_zlog_error("Download 7z failed.");
} }
} }
}
}
} }
cJSON_Delete(root); cJSON_Delete(root);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment