From 68c0b40b32e27f8f79078a23cf155504914106bb Mon Sep 17 00:00:00 2001 From: payton Date: Wed, 17 Jan 2024 11:27:56 +0800 Subject: [PATCH 1/3] =?UTF-8?q?1.=E5=8D=A1=E5=BE=AA=E7=8E=AF=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../source/sf_app/code/include/sf_storeMng.h | 1 + .../source/sf_app/code/source/4gMng/sf_sms.c | 36 +++++------------ .../source/sf_app/code/source/app/sf_common.c | 2 +- .../sf_app/code/source/storeMng/sf_storeMng.c | 40 ++++++++++++++++++- 4 files changed, 51 insertions(+), 28 deletions(-) diff --git a/code/application/source/sf_app/code/include/sf_storeMng.h b/code/application/source/sf_app/code/include/sf_storeMng.h index 5683b9c31..dedfa40af 100644 --- a/code/application/source/sf_app/code/include/sf_storeMng.h +++ b/code/application/source/sf_app/code/include/sf_storeMng.h @@ -91,6 +91,7 @@ MMC_DEV_TYPE sf_get_strg_dev(void); char *sf_root_path_strcat(char *path_name); char *sf_get_root_path(void); +SINT32 sf_activity_info_get(SF_STORE_ATTR_S *pstoreattrs); SINT32 sf_sd_info_get(SF_STORE_ATTR_S *pstoreattrs); SINT32 sf_emmc_info_get(SF_STORE_ATTR_S *pstoreattrs); SINT32 sf_sd_remove_file(const char *path,SINT32 threshold) ; diff --git a/code/application/source/sf_app/code/source/4gMng/sf_sms.c b/code/application/source/sf_app/code/source/4gMng/sf_sms.c index fc0f023f5..7ea692a44 100755 --- a/code/application/source/sf_app/code/source/4gMng/sf_sms.c +++ b/code/application/source/sf_app/code/source/4gMng/sf_sms.c @@ -2676,9 +2676,8 @@ SINT32 sf_power_off_check_sd(void) { UIMenuStoreInfo *puiPara = sf_app_ui_para_get(); SF_STORE_ATTR_S storeattrs = {0}; - MMC_DEV_TYPE mmc_dev = MMC_DEV_NO; + SF_STORE_ATTR_S SDstoreattrs = {0}; - mmc_dev = sf_get_strg_dev(); /******************** SD cycle *************************/ if((0 == sf_check_sd()) || (sf_get_mode_flag() == 1)) { @@ -2692,10 +2691,10 @@ SINT32 sf_power_off_check_sd(void) /*check disk free size*/ sf_emmc_info_get(&storeattrs); - + sf_sd_info_get(&SDstoreattrs); if((puiPara->SdLoopSwitch) && (!sf_get_mode_flag())) { - if((storeattrs.SDStatus == 0) & (storeattrs.SDFree < SDLOOP_REMAIN_SPACE)) + if((storeattrs.SDStatus == 0) & (storeattrs.SDFree < SDLOOP_REMAIN_SPACE) && (SDstoreattrs.SDFree < 30)) { // sf_sd_loopremove(SF_DCIM_DIR); sf_app_sd_loop(); @@ -2704,29 +2703,14 @@ SINT32 sf_power_off_check_sd(void) } } printf("Emmc free=%dM/%dM\n", storeattrs.SDFree, storeattrs.SDTotalSize); - if(mmc_dev != MMC_DEV_EMMC) + printf("SD free=%dM/%dM\n", SDstoreattrs.SDFree, SDstoreattrs.SDTotalSize); + + if((SDstoreattrs.SDFree < 30) && (storeattrs.SDFree < 30)) /* 30MB */ { - sf_sd_info_get(&storeattrs); - printf("SD free=%dM/%dM\n", storeattrs.SDFree, storeattrs.SDTotalSize); - if(storeattrs.SDFree < 30) /* 30MB */ - { - sf_set_card_full(1); - puiPara->SdFailCount++; - sf_sleep_ms(100); - } - } - else if(storeattrs.SDFree < 30) /* 30MB */ - { - if(puiPara->SdLoopSwitch == 0) - { - sf_set_card_full(1); - puiPara->SdFailCount++; - sf_sleep_ms(100); - } - if(mmc_dev == MMC_DEV_EMMC) - { - printf("eMMC is FULL!\n"); - } + sf_set_card_full(1); + puiPara->SdFailCount++; + sf_sleep_ms(100); + printf("card is FULL!\n"); } else { diff --git a/code/application/source/sf_app/code/source/app/sf_common.c b/code/application/source/sf_app/code/source/app/sf_common.c index b0ceaae2d..42952aa33 100755 --- a/code/application/source/sf_app/code/source/app/sf_common.c +++ b/code/application/source/sf_app/code/source/app/sf_common.c @@ -616,7 +616,7 @@ static SINT32 sfStrgDevOnActionMount(int dev_id, int result) if(SF_MCU_STARTUP_ONKEY == startup) { SF_STORE_ATTR_S storeattrs = {0}; - sf_sd_info_get(&storeattrs); + sf_activity_info_get(&storeattrs); printf("SD free=%dM/%dM\n", storeattrs.SDFree, storeattrs.SDTotalSize); if (storeattrs.SDFree < 30) /* 30MB */ { diff --git a/code/application/source/sf_app/code/source/storeMng/sf_storeMng.c b/code/application/source/sf_app/code/source/storeMng/sf_storeMng.c index 17effaf85..8def81ef8 100644 --- a/code/application/source/sf_app/code/source/storeMng/sf_storeMng.c +++ b/code/application/source/sf_app/code/source/storeMng/sf_storeMng.c @@ -152,7 +152,7 @@ char *sf_root_path_strcat(char *path_name) return tmp; } -SINT32 sf_sd_info_get(SF_STORE_ATTR_S *pstoreattrs) +SINT32 sf_activity_info_get(SF_STORE_ATTR_S *pstoreattrs) { SF_COMM_CHECK_POINTER(pstoreattrs,SF_FAILURE); @@ -195,6 +195,44 @@ SINT32 sf_sd_info_get(SF_STORE_ATTR_S *pstoreattrs) return SF_FAILURE; } + MLOGD("ActiveStorage:Status = %d,Free = %d MB,TotalSize = %d MB\n", pstoreattrs->SDStatus, pstoreattrs->SDFree,pstoreattrs->SDTotalSize); + return SF_SUCCESS; +} +SINT32 sf_sd_info_get(SF_STORE_ATTR_S *pstoreattrs) +{ + SF_COMM_CHECK_POINTER(pstoreattrs,SF_FAILURE); + + SINT32 fd = -1; + fd = open(SF_SD_ROOT, O_RDONLY,0); + if(fd >= 0) + { + struct statfs diskInfo; + statfs(SF_SD_ROOT, &diskInfo); + if(diskInfo.f_bsize > 1024) + { + pstoreattrs->SDTotalSize = (diskInfo.f_blocks * (diskInfo.f_bsize >> 10)) >> 10 ; //blocks * 4096 / 1024 /1024 = MB + pstoreattrs->SDFree = (diskInfo.f_bavail * (diskInfo.f_bsize >> 10)) >> 10 ; + } + else + { + pstoreattrs->SDTotalSize = (diskInfo.f_blocks * diskInfo.f_bsize) >> 10 ; //blocks * 4096 / 1024 /1024 = MB + pstoreattrs->SDFree = (diskInfo.f_bavail * diskInfo.f_bsize) >> 10 ; + } + close(fd); + + if(pstoreattrs->SDTotalSize > 0) + pstoreattrs->SDStatus = 0; //SD card SUCESS + else + pstoreattrs->SDStatus = 2; //SD card ERROR + } + else + { + pstoreattrs->SDStatus = 1; //SD card not insert + pstoreattrs->SDFree = 0; + pstoreattrs->SDTotalSize = 0; + return SF_FAILURE; + } + MLOGD("SDStatus = %d,SDFree = %d MB,SDTotalSize = %d MB\n", pstoreattrs->SDStatus, pstoreattrs->SDFree,pstoreattrs->SDTotalSize); return SF_SUCCESS; } From 13c9931f127ceb724574b6e20e504f07756d04b2 Mon Sep 17 00:00:00 2001 From: payton Date: Wed, 17 Jan 2024 11:29:27 +0800 Subject: [PATCH 2/3] =?UTF-8?q?1.=E5=86=85=E5=AD=98=E5=8F=91=E9=80=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../source/sf_app/code/include/sf_device.h | 2 ++ .../source/sf_app/code/source/4gMng/sf_ftp.c | 27 ++++++++++++------- .../source/sf_app/code/source/app/sf_device.c | 17 +++++++++++- .../sf_app/code/source/app/sf_service.c | 10 +++---- .../sf_app/code/source/fileMng/sf_file.c | 17 ++++++++++-- 5 files changed, 56 insertions(+), 17 deletions(-) diff --git a/code/application/source/sf_app/code/include/sf_device.h b/code/application/source/sf_app/code/include/sf_device.h index 1cff97ec6..2edccbb32 100644 --- a/code/application/source/sf_app/code/include/sf_device.h +++ b/code/application/source/sf_app/code/include/sf_device.h @@ -47,6 +47,8 @@ SINT32 app_led_pin_init(void); SINT32 sf_in_card_exist(void); +SINT32 sf_in_emmc_exist(void); + SINT32 sf_is_card_full(void); void sf_set_card_full(SINT32 vol); 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 1f30153e7..cd556e262 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 @@ -3168,7 +3168,7 @@ SINT32 sf_mem_send_file_to_ftp(void) printf("netGeneration:%dG,tempPicSize=%d,piccount=%d,pic=%d\n", sf_get_net_generation(), tempPicSize, piccount, pic); sprintf((char *)ftpFileName, "%sN-E1000001.JPG", cameraID); - sprintf((char *)filePath, "UFS:MEMPHOTO.JPG"); + sprintf((char *)filePath, "/tmp/MEMPHOTO.JPG"); printf("%s:%d ftpFileName:%s filePath:%s \n", __FUNCTION__, __LINE__, ftpFileName, filePath); @@ -3177,18 +3177,27 @@ SINT32 sf_mem_send_file_to_ftp(void) gprsMode = 0;//puiPara->GprsMode; printf("[%s:%d] ssl:%d,GprsMode:%d\n", __FUNCTION__, __LINE__, ssl, gprsMode); - - ret1 = sf_mem_ftp_config(ssl, gprsMode, timeout); + ret1 = sf_ftp_config(ssl, gprsMode, timeout); if(SF_SUCCESS == ret1) { - ret1 = sf_mem_ftp_send(ftpFileName, filePath, timeout); - } + ret1 = sf_ftp_send(ftpFileName, filePath, timeout); + } + /* + else { + ret1 = sf_mem_ftp_config(ssl, gprsMode, timeout); + + if(SF_SUCCESS == ret1) + { + ret1 = sf_mem_ftp_send(ftpFileName, filePath, timeout); + } + + if(ret1 != SF_FTP_ERROR_TERM) + { + ret2 = sf_mem_ftp_stop(ssl, gprsMode); + } + }*/ - if(ret1 != SF_FTP_ERROR_TERM) - { - ret2 = sf_mem_ftp_stop(ssl, gprsMode); - } MLOGD(" end ret1:[0x%08X],ret2:[0x%08X]\n", ret1, ret2); diff --git a/code/application/source/sf_app/code/source/app/sf_device.c b/code/application/source/sf_app/code/source/app/sf_device.c index 1f7a5afc7..7913b8af4 100755 --- a/code/application/source/sf_app/code/source/app/sf_device.c +++ b/code/application/source/sf_app/code/source/app/sf_device.c @@ -531,6 +531,13 @@ SINT32 sf_in_card_exist(void) return (regValue & 0xFF) ? 0:1; } +SINT32 sf_in_emmc_exist(void) +{ + if (access("/dev/mmcblk1p1", F_OK) == SUCCESS) { + return 1; + } + return 0; +} SINT32 sf_is_card_full(void) { @@ -539,7 +546,15 @@ SINT32 sf_is_card_full(void) void sf_set_card_full(SINT32 vol) { - IsCardFull = vol; + UIMenuStoreInfo *puiPara = sf_app_ui_para_get(); + if((0 == puiPara->SendType) && (!sf_get_mode_flag())) + { + MLOGW("The memory sending function has been enabled, but the identification is not effective. IsCardFull:%d\n",vol); + IsCardFull = 0; + } + else { + IsCardFull = vol; + } } SINT32 sf_is_card(void) 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 caa5a1bd3..9256e2f22 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 @@ -2429,11 +2429,11 @@ int sf_check_sd(void) { UINT8 i = 0; int ret = SF_SUCCESS; - // if(0 == sf_in_card_exist()) - // { - // NET_SLOGE("NO SD\r\n"); - // return SF_FAILURE; - // } + if(0 == sf_in_card_exist() && (0 == sf_in_emmc_exist())) + { + NET_SLOGE("NO SD\r\n"); + return SF_FAILURE; + } if (sf_sd_status_get() != SF_SD_OK) { ret = SF_FAILURE; for (i = 0; i < 20; i++) 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 36d962269..84628ccf5 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 @@ -1924,7 +1924,7 @@ SINT32 sf_mem_upload_file_to_module(UINT32 MemPhotoAddr, UINT32 MemPhotosize) sf_test_uploadFsize = 0; ret = sf_hal_ttyusb2_write((SF_CHAR *)MemPhotoAddr, MemPhotosize); - if(ret != SF_FAILURE) + if(ret != (SINT32)MemPhotosize) { printf("[%s:%d]Upload data error\n", __FUNCTION__, __LINE__); } @@ -1976,11 +1976,24 @@ UINT32 MemPhotoAddr , MemPhotosize; SINT32 sf_usr_mem_photo_ch(void) { SYS_USRMEM usrmem = {0}; + UINT32 fd = 0; if(sys_usrmem_init(&usrmem) == 0){ if(sys_usrmem_read_photo(&usrmem, &MemPhotoAddr, &MemPhotosize) == 0){ SLOGI("photo address %lx, size %lx", MemPhotoAddr, MemPhotosize); - return sf_mem_upload_file_to_module(MemPhotoAddr, MemPhotosize); + + fd = open("/tmp/MEMPHOTO.JPG", O_WRONLY | O_CREAT); + if(fd) + { + lseek(fd, 0, SEEK_END); + write(fd, MemPhotoAddr, MemPhotosize); + close(fd); + system("sync"); + return 0; + } + else { + return 1;//sf_mem_upload_file_to_module(MemPhotoAddr, MemPhotosize); + } } else{ SLOGE("read photo failed\n"); From cb00e6c4face69162a0a96c374b5e693a319cfd4 Mon Sep 17 00:00:00 2001 From: payton Date: Wed, 17 Jan 2024 13:40:27 +0800 Subject: [PATCH 3/3] =?UTF-8?q?1.emmc=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cardv/SrcCode/System/SF_SysStrgMng.c | 10 +++------- .../cardv/SrcCode/UIApp/Photo/UIAppPhoto_Exe.c | 18 ++++++------------ .../UIFlowPhoto/UIFlowPhotoEventCallback.c | 18 +++++++++++++----- .../source/sifar/code/include/sf_sd_common.h | 2 +- .../sifar/code/source/common/sf_sd_common.c | 7 +++++++ 5 files changed, 30 insertions(+), 25 deletions(-) diff --git a/code/application/source/cardv/SrcCode/System/SF_SysStrgMng.c b/code/application/source/cardv/SrcCode/System/SF_SysStrgMng.c index b0f60ce24..e75b8d901 100755 --- a/code/application/source/cardv/SrcCode/System/SF_SysStrgMng.c +++ b/code/application/source/cardv/SrcCode/System/SF_SysStrgMng.c @@ -130,18 +130,14 @@ static UINT32 SF_StrgSpaceCheckFull(MMC_DEV_TYPE mmc_dev) } #endif /*check disk free size*/ - if(mmc_dev == MMC_DEV_SD) + if((mmc_dev == MMC_DEV_SD) && (sf_in_card_exist() == TRUE)) { - if(sf_in_card_exist()) - { - diskFree = FileSys_GetDiskInfoEx('A', FST_INFO_FREE_SPACE); - } + diskFree = FileSys_GetDiskInfoEx('A', FST_INFO_FREE_SPACE); } - else + else if((mmc_dev == MMC_DEV_EMMC) && (sf_in_emmc_exist())) { diskFree = FileSys_GetDiskInfoEx('B', FST_INFO_FREE_SPACE); } - diskFree = diskFree/1024/1024; if(diskFree < MIN_DISK_FREE_SIZE_MB) /* 30MB */ diff --git a/code/application/source/cardv/SrcCode/UIApp/Photo/UIAppPhoto_Exe.c b/code/application/source/cardv/SrcCode/UIApp/Photo/UIAppPhoto_Exe.c index c264be46b..9e93efb2c 100755 --- a/code/application/source/cardv/SrcCode/UIApp/Photo/UIAppPhoto_Exe.c +++ b/code/application/source/cardv/SrcCode/UIApp/Photo/UIAppPhoto_Exe.c @@ -721,14 +721,11 @@ UINT32 PhotoExe_GetFreePicNum(void) //uiFreeSpace = FileSys_GetDiskInfo(FST_INFO_FREE_SPACE); #if USE_MMC_DEV_CHECK - if(mmc_dev->dev_type == MMC_DEV_SD) + if((mmc_dev->dev_type == MMC_DEV_SD) && (sf_in_card_exist() == TRUE)) { - if(sf_in_card_exist() == TRUE) - { - uiFreeSpace = FileSys_GetDiskInfoEx('A', FST_INFO_FREE_SPACE); - } + uiFreeSpace = FileSys_GetDiskInfoEx('A', FST_INFO_FREE_SPACE); } - else if(mmc_dev->dev_type == MMC_DEV_EMMC) + else if((mmc_dev->dev_type == MMC_DEV_EMMC) && (sf_in_emmc_exist())) { uiFreeSpace = FileSys_GetDiskInfoEx('B', FST_INFO_FREE_SPACE); } @@ -792,14 +789,11 @@ UINT32 PhotoExe_GetTotalPicNum(void) #if USE_MMC_DEV_CHECK - if(mmc_dev->dev_type == MMC_DEV_SD) + if((mmc_dev->dev_type == MMC_DEV_SD) && (sf_in_card_exist() == TRUE)) { - if(sf_in_card_exist() == TRUE) - { - uiSpace = FileSys_GetDiskInfoEx('A', FST_INFO_DISK_SIZE); - } + uiSpace = FileSys_GetDiskInfoEx('A', FST_INFO_DISK_SIZE); } - else if(mmc_dev->dev_type == MMC_DEV_EMMC) + else if((mmc_dev->dev_type == MMC_DEV_EMMC) && (sf_in_emmc_exist())) { uiSpace = FileSys_GetDiskInfoEx('B', FST_INFO_DISK_SIZE); } diff --git a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowPhoto/UIFlowPhotoEventCallback.c b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowPhoto/UIFlowPhotoEventCallback.c index cbdec2782..a9aafb0b7 100755 --- a/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowPhoto/UIFlowPhotoEventCallback.c +++ b/code/application/source/cardv/SrcCode/UIWnd/LVGL_SPORTCAM/UIFlowLVGL/UIFlowPhoto/UIFlowPhotoEventCallback.c @@ -740,8 +740,8 @@ static void update_sd_emmc_status(void) UINT64 diskSizeSd = 0; UINT64 diskFreeSd = 0; - UINT64 diskSizeEmmc = FileSys_GetDiskInfoEx('B', FST_INFO_DISK_SIZE); - UINT64 diskFreeEmmc = FileSys_GetDiskInfoEx('B', FST_INFO_FREE_SPACE); + UINT64 diskSizeEmmc = 0; + UINT64 diskFreeEmmc = 0; char * textLabel; char * textLabelError; UINT16 idLeft; @@ -749,7 +749,11 @@ static void update_sd_emmc_status(void) BOOL setWarning = false; BOOL showError = true; - + if(sf_in_emmc_exist()) + { + diskSizeEmmc = FileSys_GetDiskInfoEx('B', FST_INFO_DISK_SIZE); + diskFreeEmmc = FileSys_GetDiskInfoEx('B', FST_INFO_FREE_SPACE); + } lv_obj_set_hidden(label_7_scr_uiflowphoto, showError); //lv_obj_set_pos(label_7_scr_uiflowphoto, 65, 171); lv_label_set_text(label_7_scr_uiflowphoto, ""); @@ -805,8 +809,12 @@ static void update_sd_emmc_status(void) } else{ - diskSizeSd = FileSys_GetDiskInfoEx('A', FST_INFO_DISK_SIZE); - diskFreeSd = FileSys_GetDiskInfoEx('A', FST_INFO_FREE_SPACE); + if(sf_in_card_exist() == TRUE) + { + diskSizeSd = FileSys_GetDiskInfoEx('A', FST_INFO_DISK_SIZE); + diskFreeSd = FileSys_GetDiskInfoEx('A', FST_INFO_FREE_SPACE); + } + //printf("[%s]sd card disk size: %lld,free size: %lld\n", __FUNCTION__, diskSizeSd, diskFreeSd); //printf("[%s]emmc card disk size: %lld,free size: %lld\n", __FUNCTION__, diskSizeEmmc, diskFreeEmmc); diff --git a/code/lib/source/sifar/code/include/sf_sd_common.h b/code/lib/source/sifar/code/include/sf_sd_common.h index 708c03366..ad70ad5ff 100644 --- a/code/lib/source/sifar/code/include/sf_sd_common.h +++ b/code/lib/source/sifar/code/include/sf_sd_common.h @@ -16,7 +16,7 @@ typedef BOOL (*SF_CALLBACK_SD_CMD)(void); void sf_sd_exist_reg_cb(SF_CALLBACK_SD_CMD fpCB); BOOL sf_in_card_exist(void); - +SINT32 sf_in_emmc_exist(void); void sf_set_card_statu(UINT32 val); UINT32 sf_get_card_statu(void); diff --git a/code/lib/source/sifar/code/source/common/sf_sd_common.c b/code/lib/source/sifar/code/source/common/sf_sd_common.c index 39a4ae4c9..2205e3c58 100644 --- a/code/lib/source/sifar/code/source/common/sf_sd_common.c +++ b/code/lib/source/sifar/code/source/common/sf_sd_common.c @@ -68,6 +68,13 @@ BOOL sf_in_card_exist(void) } +SINT32 sf_in_emmc_exist(void) +{ + if (access("/dev/mmcblk1p1", F_OK) == SUCCESS) { + return 1; + } + return 0; +} void sf_set_card_statu(UINT32 val) { formatSD = val;