Просмотр исходного кода

searching for error with tmp file being open

David Lee 2 лет назад
Родитель
Сommit
c934ddd49e

+ 6 - 3
helpers/meal_pager_storage.c

@@ -15,17 +15,20 @@ static void meal_pager_close_config_file(FlipperFormat* file) {
     flipper_format_free(file);
 }
 
-FlipperFormat* meal_pager_save_subghz_buffer_file_start(void* context) {
+FlipperFormat* meal_pager_save_subghz_buffer_file_start(void* context, Storage* storage) {
     // SubGhz TXRX can only be loaded with files, makes sense as to save RAM
     Meal_Pager* app = context;
     UNUSED(app);
     FURI_LOG_D(TAG, "Creating Temp File");
-    Storage* storage = furi_record_open(RECORD_STORAGE);
+    //Storage* storage = furi_record_open(RECORD_STORAGE);
     FlipperFormat* ff = flipper_format_file_alloc(storage);
 
     // Overwrite wont work, so delete first
     if(storage_file_exists(storage, MEAL_PAGER_TMP_FILE)) {
-        storage_simply_remove(storage, MEAL_PAGER_TMP_FILE);
+        bool stored = storage_simply_remove(storage, MEAL_PAGER_TMP_FILE);
+        if (!stored) {
+            FURI_LOG_D(TAG, "Cannot remove file, seems to be open");
+        }
     }
 
     // Open File, create if not exists

+ 1 - 1
helpers/meal_pager_storage.h

@@ -27,7 +27,7 @@
 #define MEAL_PAGER_SUBGHZ_FILE_PRESET "FuriHalSubGhzPresetOok650Async"
 #define MEAL_PAGER_SUBGHZ_FILE_Protocol "RAW"
 
-FlipperFormat* meal_pager_save_subghz_buffer_file_start(void* context);
+FlipperFormat* meal_pager_save_subghz_buffer_file_start(void* context, Storage* storage);
 
 void meal_pager_save_subghz_buffer_stop(void* context, FlipperFormat* ff);
 

+ 3 - 1
helpers/retekess/meal_pager_retekess_t119.c

@@ -186,7 +186,8 @@ void meal_pager_retekess_t119_generate_all(void* context) {
     app->current_pager = 1;
     app->current_station = app->first_station;
 
-    FlipperFormat* ff = meal_pager_save_subghz_buffer_file_start(app);
+    Storage* storage = furi_record_open(RECORD_STORAGE);
+    FlipperFormat* ff = meal_pager_save_subghz_buffer_file_start(app, storage);
 
     for (u_int32_t i = app->current_station;i <= app->last_station; i++) {
         meal_pager_retekess_t119_generate_station(app, i, ff);
@@ -197,5 +198,6 @@ void meal_pager_retekess_t119_generate_all(void* context) {
     }
 
     meal_pager_save_subghz_buffer_stop(app, ff);
+    furi_record_close(RECORD_STORAGE);
 }
 

+ 4 - 4
helpers/subghz/subghz.c

@@ -30,7 +30,7 @@ void subghz_send(void* context) {
 
     subghz_load_protocol_from_file(subghz);
 
-    Storage* storage = furi_record_open(RECORD_STORAGE);
+    /*Storage* storage = furi_record_open(RECORD_STORAGE);
     FlipperFormat* ff = flipper_format_file_alloc(storage);
 
     if(!flipper_format_file_open_existing(ff, MEAL_PAGER_TMP_FILE)) {
@@ -38,16 +38,16 @@ void subghz_send(void* context) {
         FURI_LOG_E(TAG, "Error reading Temp File %s", MEAL_PAGER_TMP_FILE);
         furi_record_close(RECORD_STORAGE);
         return;
-    }
+    }*/
 
     //subghz_txrx_tx_start(subghz->txrx, ff);
     subghz_txrx_tx_start(subghz->txrx, subghz_txrx_get_fff_data(subghz->txrx)); //Seems like it must be done this way
 
-    flipper_format_rewind(ff);
+    /*flipper_format_rewind(ff);
     flipper_format_file_close(ff);
     flipper_format_free(ff);
 
-    furi_record_close(RECORD_STORAGE);
+    furi_record_close(RECORD_STORAGE);*/
 
 
     subghz_free(subghz);