[Cryptech-Commits] [sw/stm32] 02/03: cli_receive_data: re-enable UART DMA before returning

git at cryptech.is git at cryptech.is
Mon Aug 15 13:26:45 UTC 2016


This is an automated email from the git hooks/post-receive script.

fredrik at thulin.net pushed a commit to branch master
in repository sw/stm32.

commit ae8ebceb7c47d38949a92a2f495c990e772d4e51
Author: Fredrik Thulin <fredrik at thulin.net>
AuthorDate: Mon Aug 15 15:24:50 2016 +0200

    cli_receive_data: re-enable UART DMA before returning
    
    Bugfix after new port of libcli where this enabling doesn't happen after
    every command anymore.
---
 projects/cli-test/mgmt-misc.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/projects/cli-test/mgmt-misc.c b/projects/cli-test/mgmt-misc.c
index 535f0af..b7b4fcc 100644
--- a/projects/cli-test/mgmt-misc.c
+++ b/projects/cli-test/mgmt-misc.c
@@ -58,14 +58,14 @@ int cli_receive_data(struct cli_def *cli, uint8_t *buf, size_t len, cli_data_cal
 
     if (! control_mgmt_uart_dma_rx(DMA_RX_STOP)) {
 	cli_print(cli, "Failed stopping DMA");
-	return CLI_OK;
+	goto fail;
     }
 
     cli_print(cli, "OK, write size (4 bytes), data in %li byte chunks, CRC-32 (4 bytes)", (uint32_t) n);
 
     if (uart_receive_bytes(STM_UART_MGMT, (void *) &filesize, 4, 1000) != HAL_OK) {
 	cli_print(cli, "Receive timed out");
-	return CLI_ERROR;
+	goto fail;
     }
 
     cli_print(cli, "Send %li bytes of data", filesize);
@@ -80,7 +80,7 @@ int cli_receive_data(struct cli_def *cli, uint8_t *buf, size_t len, cli_data_cal
 
 	if (uart_receive_bytes(STM_UART_MGMT, (void *) buf, n, 1000) != HAL_OK) {
 	    cli_print(cli, "Receive timed out");
-	    return CLI_ERROR;
+	    goto fail;
 	}
 	filesize -= n;
 	my_crc = update_crc(my_crc, buf, n);
@@ -90,7 +90,7 @@ int cli_receive_data(struct cli_def *cli, uint8_t *buf, size_t len, cli_data_cal
 	 */
 	if (data_callback != NULL && ! data_callback(buf, (size_t) n)) {
 	    cli_print(cli, "Data processing failed");
-	    return CLI_OK;
+	    goto fail;
 	}
 
 	counter++;
@@ -106,6 +106,8 @@ int cli_receive_data(struct cli_def *cli, uint8_t *buf, size_t len, cli_data_cal
 	cli_print(cli, "CRC checksum did NOT match");
     }
 
+ fail:
+    control_mgmt_uart_dma_rx(DMA_RX_START);
     return CLI_OK;
 }
 



More information about the Commits mailing list