[FL-2955], [FL-2953] SubGhz: fix RAW "Send never ends" (#1979)

* SubGhz: fix RAW "Send never ends"
* SubGhz: delete comments
* SubGhz: RAW file parsing speed increase
* SubGhz: fix level_duration_is_wait
* SubGhz: modification furi_hal_subghz_async_tx_refill
* SubGhz: furi_hal_subghz_stop_async_rx
* SubGhz: hal unit test and better async tx yield handling
* FuriHal: proper async tx end in subghz, vibro on power off
* FuriHal: variable naming in subghz
* SubGhz,FuriHal: extreme timings in subghz hal unit tests, remove memset in async tx buffer fill routine
* FuriHal: small refinements in subghz

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Skorpionm
2022-11-30 15:41:23 +04:00
committed by GitHub
parent 0ab14c37c9
commit 2a6a3a1bf7
5 changed files with 204 additions and 44 deletions

View File

@@ -18,6 +18,7 @@ struct SubGhzFileEncoderWorker {
volatile bool worker_running;
volatile bool worker_stoping;
bool level;
bool is_storage_slow;
FuriString* str_data;
FuriString* file_path;
@@ -86,7 +87,7 @@ LevelDuration subghz_file_encoder_worker_get_level_duration(void* context) {
if(ret == sizeof(int32_t)) {
LevelDuration level_duration = {.level = LEVEL_DURATION_RESET};
if(duration < 0) {
level_duration = level_duration_make(false, duration * -1);
level_duration = level_duration_make(false, -duration);
} else if(duration > 0) {
level_duration = level_duration_make(true, duration);
} else if(duration == 0) {
@@ -96,7 +97,7 @@ LevelDuration subghz_file_encoder_worker_get_level_duration(void* context) {
}
return level_duration;
} else {
FURI_LOG_E(TAG, "Slow flash read");
instance->is_storage_slow = true;
return level_duration_wait();
}
}
@@ -110,6 +111,7 @@ static int32_t subghz_file_encoder_worker_thread(void* context) {
SubGhzFileEncoderWorker* instance = context;
FURI_LOG_I(TAG, "Worker start");
bool res = false;
instance->is_storage_slow = false;
Stream* stream = flipper_format_get_raw_stream(instance->flipper_format);
do {
if(!flipper_format_file_open_existing(
@@ -139,21 +141,21 @@ static int32_t subghz_file_encoder_worker_thread(void* context) {
furi_string_trim(instance->str_data);
if(!subghz_file_encoder_worker_data_parse(
instance, furi_string_get_cstr(instance->str_data))) {
//to stop DMA correctly
subghz_file_encoder_worker_add_level_duration(instance, LEVEL_DURATION_RESET);
subghz_file_encoder_worker_add_level_duration(instance, LEVEL_DURATION_RESET);
break;
}
} else {
subghz_file_encoder_worker_add_level_duration(instance, LEVEL_DURATION_RESET);
subghz_file_encoder_worker_add_level_duration(instance, LEVEL_DURATION_RESET);
break;
}
} else {
furi_delay_ms(1);
}
furi_delay_ms(5);
}
//waiting for the end of the transfer
if(instance->is_storage_slow) {
FURI_LOG_E(TAG, "Storage is slow");
}
FURI_LOG_I(TAG, "End read file");
while(!furi_hal_subghz_is_async_tx_complete() && instance->worker_running) {
furi_delay_ms(5);