diff --git a/code/application/source/cardv/SrcCode/System/SysMain_Exe.c b/code/application/source/cardv/SrcCode/System/SysMain_Exe.c index a479a460c..e52e84f72 100755 --- a/code/application/source/cardv/SrcCode/System/SysMain_Exe.c +++ b/code/application/source/cardv/SrcCode/System/SysMain_Exe.c @@ -158,7 +158,7 @@ INT32 System_GetBootFirstMode(void) { return PRIMARY_MODE_USBMSDC; } - else if((PWR_ON_SETUP != PowerOnMode) /*|| (sf_get_fw_update())*/) + else if((PWR_ON_SETUP != PowerOnMode) && (PWR_ON_MCU_UPDATA != PowerOnMode)/*|| (sf_get_fw_update())*/) { return PRIMARY_MODE_TRANSCODE; } diff --git a/code/application/source/cardv/SrcCode/System/SysStrg_Exe.c b/code/application/source/cardv/SrcCode/System/SysStrg_Exe.c index 5d21b03ee..fe4a9b0f2 100644 --- a/code/application/source/cardv/SrcCode/System/SysStrg_Exe.c +++ b/code/application/source/cardv/SrcCode/System/SysStrg_Exe.c @@ -424,6 +424,7 @@ void System_OnStrgInit_FS(void) cfg.LogBuffSize2 = gLogFile_Buff2_Size; #endif LogFile_Config(&cfg); + DBG_DUMP("LogFile_Config ...\n"); } #endif @@ -1064,7 +1065,7 @@ INT32 System_OnStrgAttach(VControl *pCtrl, UINT32 paramNum, UINT32 *paramArray) logOpenParm.maxFileNum = maxFileNum; logOpenParm.maxFileSize = maxFileSize; - logOpenParm.isPreAllocAllFiles = TRUE; + logOpenParm.isPreAllocAllFiles = FALSE; #if defined(__FREERTOS) logOpenParm.isSaveLastTimeSysErrLog = wdt_getResetNum()>0 ? TRUE : FALSE; #else //defined(__LINUX_USER__) diff --git a/code/application/source/sf_app/code/include/sf_param_enum.h b/code/application/source/sf_app/code/include/sf_param_enum.h index 0e39a30f5..17ca545c8 100755 --- a/code/application/source/sf_app/code/include/sf_param_enum.h +++ b/code/application/source/sf_app/code/include/sf_param_enum.h @@ -321,7 +321,8 @@ typedef enum sf_STARTUP_TYPE_E SF_MCU_STARTUP_RESET = 0x0A,/*power on to reset(reserve)*/ SF_MCU_STARTUP_SYN_PARAM = 0x0B,/*power on to syn param(reserve)*/ SF_MCU_STARTUP_BATCH_SEND= 0x0C,/*power on to send batch*/ - SF_MCU_STARTUP_BUTT = 0X0D, + SF_MCU_STARTUP_MCU_UPDATA= 0x0F,/*power on to send batch*/ + SF_MCU_STARTUP_BUTT = 0X10, } SF_STARTUP_TYPE_E; typedef enum sfPOWEROFF_TYPE_E diff --git a/code/application/source/sf_app/code/source/app/sf_service.c b/code/application/source/sf_app/code/source/app/sf_service.c index 08ca4989c..c1dc92b39 100755 --- a/code/application/source/sf_app/code/source/app/sf_service.c +++ b/code/application/source/sf_app/code/source/app/sf_service.c @@ -1829,7 +1829,8 @@ static SINT32 app_Register_Net_startup_mode(SF_FN_PARAM_S *pfnParam) s32ret = sf_get_utc(); - if ((SF_ON == pCustomerParam->GpsSwitch)) { + if ((SF_ON == pCustomerParam->GpsSwitch) || (pCustomerParam->FristSendDailyAndGps)) + { s32ret = open_gps(s32ret); } if (0 != sf_get_cq_signal()) { @@ -1867,7 +1868,8 @@ static SINT32 app_Register_Net_startup_mode(SF_FN_PARAM_S *pfnParam) set_at_parament(); sf_USB_net_init(); - if ((SF_ON == pCustomerParam->GpsSwitch)) { + if ((SF_ON == pCustomerParam->GpsSwitch) || (pCustomerParam->FristSendDailyAndGps)) + { const int KEEP_SERACHING_TIMEOUT_MS = 2000; const int KEEP_SERACHING_PERIOD_MS = 200; // keep_seraching_gps_location(KEEP_SERACHING_TIMEOUT_S); diff --git a/code/application/source/sf_app/code/source/paramMng/sf_param_common.c b/code/application/source/sf_app/code/source/paramMng/sf_param_common.c index a10a9797f..5ff399edb 100755 --- a/code/application/source/sf_app/code/source/paramMng/sf_param_common.c +++ b/code/application/source/sf_app/code/source/paramMng/sf_param_common.c @@ -995,6 +995,8 @@ const SF_CHAR* sf_poweron_type_string(SF_STARTUP_TYPE_E enType) return "SF_MCU_STARTUP_SYN_PARAM"; case SF_MCU_STARTUP_BATCH_SEND: return "SF_MCU_STARTUP_BATCH_SEND"; + case SF_MCU_STARTUP_MCU_UPDATA: + return "SF_MCU_STARTUP_MCU_UPDATA"; default: return "unknown poweron type!!!"; } diff --git a/code/application/source/sf_app/code/source/systemMng/sf_commu_mcu.c b/code/application/source/sf_app/code/source/systemMng/sf_commu_mcu.c index 17300097f..151de0b01 100755 --- a/code/application/source/sf_app/code/source/systemMng/sf_commu_mcu.c +++ b/code/application/source/sf_app/code/source/systemMng/sf_commu_mcu.c @@ -40,6 +40,7 @@ #include "kwrap/debug.h" #include "kwrap/util.h" #include +#include "sf_system.h" #define SERIAL_DEVICE_PATH "/dev/ttyS2" #ifdef __cplusplus @@ -707,7 +708,7 @@ unsigned int sf_get_mcu_reg_ack_depack_many(unsigned char reg[], unsigned char v int sf_commu_wait(unsigned char cmd) { - if(sf_mcu_flag_wait_done_timeout(cmd, 60)) + if(sf_mcu_flag_wait_done_timeout(cmd, 100)) { sf_commu_reset(); return - 1; @@ -963,7 +964,17 @@ unsigned char sf_commu_parse_mcu_data(unsigned char * src, unsigned int len) { sf_set_pir_statu_flag(0); sf_set_module_sleep_flag(0); - sf_com_message_send_to_cardv(&stMessageBuf); + if((PWR_ON_SETUP != sf_convert_power_on_mode()) && (PWR_ON_USB!= sf_convert_power_on_mode())) + { + printf("[power off] %s(%d)\n", __FUNCTION__, __LINE__); + sf_set_power_off_flag(1); + sf_app_battery_stop(); + system("reboot"); + } + else + { + sf_com_message_send_to_cardv(&stMessageBuf); + } } else if(0 == stMessageBuf.arg3) //ON->OFF { diff --git a/code/lib/source/sifar/code/include/sf_mcu.h b/code/lib/source/sifar/code/include/sf_mcu.h index 3bbd3516c..93b14f808 100644 --- a/code/lib/source/sifar/code/include/sf_mcu.h +++ b/code/lib/source/sifar/code/include/sf_mcu.h @@ -51,6 +51,7 @@ #define PWR_ON_GPRS_INIT 0x0A #define PWR_ON_TIME_SYNC 0x0B #define PWR_ON_TIME_SEND 0x0C +#define PWR_ON_MCU_UPDATA 0x0F /*REG FUNCTION_SWTICH*/ #define PIR_OFF 0x00 diff --git a/code/lib/source/sifar/code/source/mcu/sf_mcu_client.c b/code/lib/source/sifar/code/source/mcu/sf_mcu_client.c index 0125885b7..028855846 100644 --- a/code/lib/source/sifar/code/source/mcu/sf_mcu_client.c +++ b/code/lib/source/sifar/code/source/mcu/sf_mcu_client.c @@ -46,6 +46,7 @@ #include #include "UIInfo/UIInfo.h" #include "sf_param_enum.h" +#include "GxUSB.h" //#include "../../../application/source/cardv/SrcCode/PrjInc.h" @@ -1910,7 +1911,11 @@ BOOL sf_get_mode_flag(void) BOOL sf_is_usb_flag(void) { - return GxUSB_GetIsUSBPlug(); + if(GxUSB_GetConnectType() == 1) + { + return 1; + } + return 0;//GxUSB_GetIsUSBPlug(); } void sf_calculate_daily_report(UINT8*dailyHour, UINT8*dailyMin) @@ -2144,7 +2149,7 @@ void sf_set_power_on_mode(UINT8 data) ModeFlag = 0; PowerOnMode = data; PowerOnMode &= 0x0f; - if(1 == PowerOnMode) + if((1 == PowerOnMode) || 15 == PowerOnMode) { ConfigureModeFlag = 1; } diff --git a/rtos/code/driver/na51089/source/mcu/sf_commu_mcu.c b/rtos/code/driver/na51089/source/mcu/sf_commu_mcu.c index 1e80ee3c4..3030c01dd 100644 --- a/rtos/code/driver/na51089/source/mcu/sf_commu_mcu.c +++ b/rtos/code/driver/na51089/source/mcu/sf_commu_mcu.c @@ -486,7 +486,7 @@ unsigned int sf_get_mcu_reg_ack_depack_many(unsigned char reg[], unsigned char v int sf_commu_wait(unsigned char cmd) { //sf_mcu_flag_set_done(cmd); - if(sf_mcu_flag_wait_done_timeout(cmd, 30)) + if(sf_mcu_flag_wait_done_timeout(cmd, 100)) { sf_commu_reset(); return - 1; diff --git a/rtos/code/driver/na51089/source/mcu/sf_mcu.c b/rtos/code/driver/na51089/source/mcu/sf_mcu.c index 258aa0731..b0866f118 100755 --- a/rtos/code/driver/na51089/source/mcu/sf_mcu.c +++ b/rtos/code/driver/na51089/source/mcu/sf_mcu.c @@ -691,13 +691,14 @@ UINT8 sf_get_power_on_mode(void) if(gpio_getIntStatus(GPIO_INT_USBPLUGIN)) { PowerOnMode = PWR_ON_USB; + ConfigureModeFlag = 1; } else{ //PowerOnMode = sf_mcu_power_on_para_get(SF_MCU_POWERON); PowerOnMode = sf_mcu_power_on_para_get(SF_MCU_STARTMODE); //PowerOnMode &= 0x0f; //sf_is_night_mode(1); - if(1 == PowerOnMode) + if((PWR_ON_SETUP == PowerOnMode) || (PWR_ON_MCU_UPDATA == PowerOnMode)) { ConfigureModeFlag = 1; }