Files
smod_atsc_app/atsc_app/task/upgrade.c
T

72 lines
1.5 KiB
C

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "../inc/upgrade.h"
#include "../inc/isys_com.h"
extern int executeCMD(const char *cmd, char *result, u16 result_size);
static uint8 gb_upgrade_flg = 0;
void set_upgrade_flg(uint8 flg)
{
gb_upgrade_flg = flg;
}
uint8 get_upgrade_flg(void)
{
return gb_upgrade_flg;
}
void sys_upgrade(void)
{
char msg[20] = {0};
int ret = 0;
int result = 0xff;
ret = executeCMD(CHECK_UPGRADE_PACKAGE, msg, sizeof(msg));
log_printf(LOG_DEBUG,I_NOUSED,"check package return %d , %s\n",ret, msg);
for(int j=0;j<20;j++){
printf(" 0x%02x", msg[j]);
}
printf("\n");
if(ret==0){
result = atoi(msg);
//usleep(1000000);
if(result == 0){
log_printf(LOG_DEBUG,I_NOUSED,"run upgrade sh, and will reboot\n");
system(DO_UPGRADE_RUN);
log_printf(LOG_DEBUG,I_NOUSED,"system rebooting....\n");
// reboot in runme.sh
}
}
}
void* imx_up_thr(void * args)
{
uint8 flg_ok = 0;
log_printf(LOG_DEBUG,I_NOUSED,"[.thr.] imx_up_thr Start.\n");
while(1)
{
flg_ok = get_upgrade_flg();
//printf("get flg_ok=%d\n",flg_ok);
if(0 != flg_ok) // web upload file ok
{
log_printf(LOG_DEBUG,I_NOUSED,"------------------------------------------\n");
log_printf(LOG_DEBUG,I_NOUSED,"get upgrade flg!!!!!!!!!!!!\n");
sys_upgrade();
//set_upgrade_flg(0);
}
usleep(1000000);
}
return 0;
}