Skip to content

Commit 36ab1db

Browse files
committed
forcing write to complete
1 parent 4d8aae4 commit 36ab1db

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

uhf_module.c

+2-9
Original file line numberDiff line numberDiff line change
@@ -307,15 +307,8 @@ M100ResponseType m100_write_label_data_storage(
307307
cmd[cmd_length - 2] = checksum(cmd + 1, cmd_length - 3);
308308
cmd[cmd_length - 1] = FRAME_END;
309309
// send cmd
310-
// furi_hal_uart_set_irq_cb(FuriHalUartIdUSART1, rx_callback, module->uart->buffer);
311-
// furi_hal_uart_tx(FuriHalUartIdUSART1, cmd, cmd_length);
312-
// unsigned int delay = DELAY_MS / 2;
313-
// unsigned int timeout = 15;
314-
// while(!buffer_get_size(module->uart->buffer)) {
315-
// furi_delay_ms(delay);
316-
// if(!timeout--) break;
317-
// }
318-
setup_and_send_rx(module, cmd, cmd_length);
310+
M100ResponseType rp_type = setup_and_send_rx(module, cmd, cmd_length);
311+
if(rp_type != M100SuccessResponse) return rp_type;
319312
uint8_t* buff_data = uhf_buffer_get_data(module->uart->buffer);
320313
size_t buff_length = uhf_buffer_get_size(module->uart->buffer);
321314
if(buff_data[2] == 0xFF && buff_length == 8)

uhf_worker.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,20 @@ UHFWorkerEvent write_single_card(UHFWorker* uhf_worker) {
6363
UHFTag* uhf_tag_des = send_polling_command(uhf_worker);
6464
if(uhf_tag_des == NULL) return UHFWorkerEventAborted;
6565
UHFTag* uhf_tag_from = uhf_worker->uhf_tag_wrapper->uhf_tag;
66-
while(m100_set_select(uhf_worker->module, uhf_tag_des) != M100SuccessResponse){}
66+
M100ResponseType rp_type;
67+
do{
68+
rp_type = m100_set_select(uhf_worker->module, uhf_tag_des);
69+
if(uhf_worker->state == UHFWorkerStateStop) return UHFWorkerEventAborted;
70+
if(rp_type == M100SuccessResponse) break;
71+
}while(true);
6772
do {
68-
M100ResponseType rp_type = m100_write_label_data_storage(
73+
rp_type = m100_write_label_data_storage(
6974
uhf_worker->module, uhf_tag_from, uhf_tag_des, UserBank, 0, 0);
7075
if(uhf_worker->state == UHFWorkerStateStop) return UHFWorkerEventAborted;
7176
if(rp_type == M100SuccessResponse) break;
7277
} while(true);
7378
do {
74-
M100ResponseType rp_type = m100_write_label_data_storage(
79+
rp_type = m100_write_label_data_storage(
7580
uhf_worker->module, uhf_tag_from, uhf_tag_des, EPCBank, 0, 0);
7681
if(uhf_worker->state == UHFWorkerStateStop) return UHFWorkerEventAborted;
7782
if(rp_type == M100SuccessResponse) break;

0 commit comments

Comments
 (0)