From 36ab1dbf1ec15cc4153ce3189ffed03d08344f4f Mon Sep 17 00:00:00 2001 From: frux-c Date: Wed, 13 Mar 2024 19:32:57 -0600 Subject: [PATCH] forcing write to complete --- uhf_module.c | 11 ++--------- uhf_worker.c | 11 ++++++++--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/uhf_module.c b/uhf_module.c index 57dc5f45708..fa003b25312 100644 --- a/uhf_module.c +++ b/uhf_module.c @@ -307,15 +307,8 @@ M100ResponseType m100_write_label_data_storage( cmd[cmd_length - 2] = checksum(cmd + 1, cmd_length - 3); cmd[cmd_length - 1] = FRAME_END; // send cmd - // furi_hal_uart_set_irq_cb(FuriHalUartIdUSART1, rx_callback, module->uart->buffer); - // furi_hal_uart_tx(FuriHalUartIdUSART1, cmd, cmd_length); - // unsigned int delay = DELAY_MS / 2; - // unsigned int timeout = 15; - // while(!buffer_get_size(module->uart->buffer)) { - // furi_delay_ms(delay); - // if(!timeout--) break; - // } - setup_and_send_rx(module, cmd, cmd_length); + M100ResponseType rp_type = setup_and_send_rx(module, cmd, cmd_length); + if(rp_type != M100SuccessResponse) return rp_type; uint8_t* buff_data = uhf_buffer_get_data(module->uart->buffer); size_t buff_length = uhf_buffer_get_size(module->uart->buffer); if(buff_data[2] == 0xFF && buff_length == 8) diff --git a/uhf_worker.c b/uhf_worker.c index 78c07eb072b..8b3213d6083 100644 --- a/uhf_worker.c +++ b/uhf_worker.c @@ -63,15 +63,20 @@ UHFWorkerEvent write_single_card(UHFWorker* uhf_worker) { UHFTag* uhf_tag_des = send_polling_command(uhf_worker); if(uhf_tag_des == NULL) return UHFWorkerEventAborted; UHFTag* uhf_tag_from = uhf_worker->uhf_tag_wrapper->uhf_tag; - while(m100_set_select(uhf_worker->module, uhf_tag_des) != M100SuccessResponse){} + M100ResponseType rp_type; + do{ + rp_type = m100_set_select(uhf_worker->module, uhf_tag_des); + if(uhf_worker->state == UHFWorkerStateStop) return UHFWorkerEventAborted; + if(rp_type == M100SuccessResponse) break; + }while(true); do { - M100ResponseType rp_type = m100_write_label_data_storage( + rp_type = m100_write_label_data_storage( uhf_worker->module, uhf_tag_from, uhf_tag_des, UserBank, 0, 0); if(uhf_worker->state == UHFWorkerStateStop) return UHFWorkerEventAborted; if(rp_type == M100SuccessResponse) break; } while(true); do { - M100ResponseType rp_type = m100_write_label_data_storage( + rp_type = m100_write_label_data_storage( uhf_worker->module, uhf_tag_from, uhf_tag_des, EPCBank, 0, 0); if(uhf_worker->state == UHFWorkerStateStop) return UHFWorkerEventAborted; if(rp_type == M100SuccessResponse) break;