调整固件升级

This commit is contained in:
modehua 2023-10-21 03:19:18 -07:00
parent 07548a90f3
commit c5a5723200
1 changed files with 12 additions and 13 deletions

View File

@ -507,7 +507,7 @@ int main(int argc, char *argv[])
// break; // break;
case USBCommand::PRE_UPGRADE: case USBCommand::PRE_UPGRADE:
{ {
LOG("start PRE_UPGRADE \n"); printf("start PRE_UPGRADE \n");
updatePkg.open("/home/root/update.zip", ios::out | ios::binary); updatePkg.open("/home/root/update.zip", ios::out | ios::binary);
m_scanner->SetLEDStatus(LedStatus::Updating); m_scanner->SetLEDStatus(LedStatus::Updating);
total_length = usbcb.Length; total_length = usbcb.Length;
@ -536,12 +536,13 @@ int main(int argc, char *argv[])
case USBCommand::UPDATE_FINISHED: case USBCommand::UPDATE_FINISHED:
{ {
LOG("PRE_UPGRADE finished \n"); printf("PRE_UPGRADE finished \n");
if (total_length < (1024 * 1024 * 5)) if (total_length < (1024 * 1024 * 5))
this_thread::sleep_for(std::chrono::seconds(10)); this_thread::sleep_for(std::chrono::seconds(10));
m_scanner->SetLEDStatus(LedStatus::UpdateDone); m_scanner->SetLEDStatus(LedStatus::UpdateDone);
updatePkg.close(); updatePkg.close();
system("sh /mnt/flash-disk/upgrade_firmware.sh"); //system("sh /mnt/flash-disk/upgrade_firmware.sh &");
printf("PRE_UPGRADE finished exit!!!!!!!!!!!!! \n");
} }
break; break;
@ -600,18 +601,16 @@ int main(int argc, char *argv[])
break; break;
case USBCommand::GET_UPDATE_RESULT: case USBCommand::GET_UPDATE_RESULT:
{ {
fstream updateResult("/mnt/flash-disk/updata_status.txt"); int ret = get_devs_status("/mnt/flash-disk/update_status.txt");
if (!updateResult.is_open()) printf("GET_UPDATE_RESULT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n");
usbcb.Data = 0; printf("ret:%d\r\n",ret);
else
{
updateResult >> usbcb.Data;
updateResult.close();
}
printf("usbcb.Data:%d\r\n",usbcb.Data); usbcb.Data = ret;
if (ret == -1)
{
usbcb.Data = 100;
}
m_scanner->write_bulk(&usbcb, sizeof(usbcb)); m_scanner->write_bulk(&usbcb, sizeof(usbcb));
this_thread::sleep_for(std::chrono::milliseconds(1000));
if (usbcb.Data == 0) if (usbcb.Data == 0)
system("reboot"); system("reboot");