diff --git a/code/application/source/sf_app/code/include/sf_file.h b/code/application/source/sf_app/code/include/sf_file.h index 32a2dc9d9..1655ced1d 100755 --- a/code/application/source/sf_app/code/include/sf_file.h +++ b/code/application/source/sf_app/code/include/sf_file.h @@ -45,6 +45,7 @@ UINT8 sf_get_send_file_total(void); SINT32 sf_mem_upload_file_to_module(UINT32 MemPhotoAddr, UINT32 MemPhotosize); SINT32 sf_usr_mem_photo_ch(void); UINT8 sf_save_sd_log(void); +void sf_log_error_code(char* buff); #ifdef __cplusplus #if __cplusplus } diff --git a/code/application/source/sf_app/code/source/4gMng/sf_eg91_sim.c b/code/application/source/sf_app/code/source/4gMng/sf_eg91_sim.c index dbdd40aee..3acbd8a7a 100755 --- a/code/application/source/sf_app/code/source/4gMng/sf_eg91_sim.c +++ b/code/application/source/sf_app/code/source/4gMng/sf_eg91_sim.c @@ -4532,6 +4532,8 @@ SINT32 sf_auto_net_reg(void) SLOGE(gsmPara); sprintf((char *)logStr, "AT+CGREG? Timeout,Error Code:0x%08X\n", ret); SLOGE(logStr); + SF_SPRINTF(logStr, "%x,", ret); + sf_log_error_code(logStr); goto SF_MODULE_END; } } @@ -4699,6 +4701,8 @@ SINT32 sf_auto_net_reg(void) SLOGE(gsmPara); sprintf((char *)logStr, "Error Code:0x%08X\n", ret); SLOGE(logStr); + SF_SPRINTF(logStr, "%x,", ret); + sf_log_error_code(logStr); goto SF_MODULE_END; } } @@ -4750,6 +4754,8 @@ SINT32 sf_auto_net_reg(void) SLOGE(gsmPara); sprintf((char *)logStr, "Error Code:0x%08X\n", ret); SLOGE(logStr); + SF_SPRINTF(logStr, "%x,", ret); + sf_log_error_code(logStr); goto SF_MODULE_END; } else @@ -4768,6 +4774,8 @@ SINT32 sf_auto_net_reg(void) SLOGE(gsmPara); sprintf((char *)logStr, "Error Code:0x%08X\n", ret); SLOGE(logStr); + SF_SPRINTF(logStr, "%x,", ret); + sf_log_error_code(logStr); goto SF_MODULE_END; } else diff --git a/code/application/source/sf_app/code/source/4gMng/sf_ftp.c b/code/application/source/sf_app/code/source/4gMng/sf_ftp.c index e372ae237..e2b2a439f 100755 --- a/code/application/source/sf_app/code/source/4gMng/sf_ftp.c +++ b/code/application/source/sf_app/code/source/4gMng/sf_ftp.c @@ -970,6 +970,8 @@ SINT32 sf_pic_send_ftp(void) //TIMEOUT //pSifarPara->picSendTimeoutCount++; printf("%s:%d err ftpFileName:%s filePath:%s picSendFailCount:%d sendThumbnailFailCount:%d\n", __FUNCTION__, __LINE__, ftpFileName[pic], filePath[pic],pSifarPara->picSendFailCount, pSifarPara->sendThumbnailFailCount); + SF_SPRINTF(logStr, "%x,", ret); + sf_log_error_code(logStr); } else { if(!sf_get_mode_flag()){ @@ -1084,6 +1086,8 @@ SINT32 sf_video_send_ftp(void) if(SF_SUCCESS != ret) { printf("%s:%d err ret: [0x%08X] ftpFileName:%s filePath:%s\n", __FUNCTION__, __LINE__, ret, ftpFileName, filePath); + SF_SPRINTF(logStr, "%x,", ret); + sf_log_error_code(logStr); } } @@ -1130,6 +1134,8 @@ SINT32 sf_ftp_dailyreport_send(void) if(SF_SUCCESS != ret) { printf("%s:%d err ret: [0x%08X] filePath:%s\n", __FUNCTION__, __LINE__, ret, filePath); + SF_SPRINTF(logStr, "%x,", ret); + sf_log_error_code(logStr); }else { DailyReportFtpSendSucess = 1; pSifarPara->picSendCount = 0; @@ -1147,6 +1153,7 @@ SINT32 sf_ftp_dailyreport_send(void) pSifarPara->videoSendFailCount = 0; pSifarPara->videoSendSucessCount = 0; pSifarPara->SendlowPowerWarnCnt = 0; + sf_file_remove(SF_ERROR_CODE); } sf_dailyReport_set(); } @@ -1513,6 +1520,11 @@ SINT32 sf_camera_ota_ftp(void) } sf_set_fw_update(0); } + else + { + SF_SPRINTF(logStr, "%x,", ret); + sf_log_error_code(logStr); + } } MLOGD(" end ret:[0x%08X]\n", ret); @@ -1645,6 +1657,8 @@ SINT32 sf_concentrated_ftp_send(void) goto SF_CONCENTRATED_MODULE_REBOOT; } timeoutCnt++; + SF_SPRINTF(logStr, "%x,", ret1); + sf_log_error_code(logStr); goto SF_CONCENTRATED_END; } else { @@ -1825,6 +1839,8 @@ SINT32 sf_hd_ftp_send(void) goto SF_HD_MODULE_REBOOT; } timeoutCnt++; + SF_SPRINTF(logStr, "%x,", ret1); + sf_log_error_code(logStr); goto SF_HD_END; } else { @@ -2056,6 +2072,8 @@ SINT32 sf_video_ftp_send(void) goto SF_VIDEO_MODULE_REBOOT; } timeoutCnt++; + SF_SPRINTF(logStr, "%x,", ret1); + sf_log_error_code(logStr); goto SF_VIDEO_END; } else { @@ -2172,6 +2190,8 @@ SINT32 sf_log_send_ftp(void) if(SF_SUCCESS != ret) { printf("%s:%d err ret: [0x%08X] filePath:%s\n", __FUNCTION__, __LINE__, ret, filePath); + SF_SPRINTF(logStr, "%x,", ret); + sf_log_error_code(logStr); } } } @@ -2230,6 +2250,8 @@ SINT32 sf_low_power_warn_send_ftp(void) if(SF_SUCCESS != ret) { printf("%s:%d err ret: [0x%08X] filePath:%s\n", __FUNCTION__, __LINE__, ret, filePath); + SF_SPRINTF(logStr, "%x,", ret); + sf_log_error_code(logStr); }else { pSifarPara->SendlowPowerWarnCnt++; } @@ -2285,6 +2307,8 @@ SINT32 sf_gps_send_ftp(void) if(SF_SUCCESS != ret) { printf("%s:%d err ret: [0x%08X] filePath:%s\n", __FUNCTION__, __LINE__, ret, filePath); + SF_SPRINTF(logStr, "%x,", ret); + sf_log_error_code(logStr); } else { //GPS send success,add gps send flag @@ -3075,6 +3099,8 @@ SINT32 sf_card_log_send_ftp(void) if(SF_SUCCESS != ret) { printf("%s:%d err ret: [0x%08X] filePath:%s\n", __FUNCTION__, __LINE__, ret, filePath); + SF_SPRINTF(logStr, "%x,", ret); + sf_log_error_code(logStr); } else { diff --git a/code/application/source/sf_app/code/source/fileMng/sf_file.c b/code/application/source/sf_app/code/source/fileMng/sf_file.c index 85e1c2710..1f6b8c702 100755 --- a/code/application/source/sf_app/code/source/fileMng/sf_file.c +++ b/code/application/source/sf_app/code/source/fileMng/sf_file.c @@ -1301,23 +1301,23 @@ UINT32 sf_create_dailyreport_file(void) if(sf_file_IsExsit(SF_ERROR_CODE) == SF_TRUE){ size = sf_get_file_size((UINT8 *)SF_ERROR_CODE); - } - fd1 = open(SF_ERROR_CODE, O_APPEND | O_WRONLY, S_IRUSR | S_IWUSR); - if(fd1) - { - //size = sp5kFsFileSizeGet(fd1); - buf = malloc(size); - - if (buf) + fd1 = open(SF_ERROR_CODE, O_RDONLY, S_IRUSR | S_IWUSR); + if(fd1) { - read(fd1, buf, size-1); - printf("error code size=%d\n",size); - write(fd, buf, size-1); - write(fd, (UINT8 *)"\r\n", SF_STRLEN("\r\n")); - free(buf); - } + //size = sp5kFsFileSizeGet(fd1); + buf = malloc(size); - close(fd1); + if (buf) + { + read(fd1, buf, size-1); + printf("error code size=%d\n",size); + write(fd, buf, size-1); + write(fd, (UINT8 *)"\r\n", SF_STRLEN("\r\n")); + free(buf); + } + + close(fd1); + } } szTmpsize=SF_STRLEN(cfgTmp); @@ -1881,6 +1881,30 @@ UINT8 sf_save_sd_log(void) return ret; } +/************************************************* + Function: sf_log_error_code + Description: save error code + Input: error code + Output: N/A + Return: N/A + Others: N/A +*************************************************/ +void sf_log_error_code(char* buff) +{ + UINT32 fd = 0; + + if(sf_in_card_exist()) + { + fd = open(SF_ERROR_CODE, O_WRONLY | O_CREAT); + if(fd) + { + lseek(fd, 0, SEEK_END); + write(fd, buff, strlen(buff)); + close(fd); + system("sync"); + } + } +} #ifdef __cplusplus #if __cplusplus }