aboutsummaryrefslogtreecommitdiff
path: root/projects/hsm/mgmt-misc.c
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2016-12-20 21:44:13 -0500
committerRob Austein <sra@hactrn.net>2016-12-20 21:44:13 -0500
commitde945510ca6304f3a2cf447567981784e6244dab (patch)
treea9c5bd2b975babddd2fa5d616ef380675391e237 /projects/hsm/mgmt-misc.c
parenteb8c7d7cd26608a0f2825b89a1eca5008d7e3f66 (diff)
parentfe94d97f705846ef809d4109b310c96d0b3bb1ac (diff)
Merge branch 'master' into ksng
Bootloader DFU fixes.
Diffstat (limited to 'projects/hsm/mgmt-misc.c')
-rw-r--r--projects/hsm/mgmt-misc.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/projects/hsm/mgmt-misc.c b/projects/hsm/mgmt-misc.c
index 31a1c49..250dc7a 100644
--- a/projects/hsm/mgmt-misc.c
+++ b/projects/hsm/mgmt-misc.c
@@ -51,14 +51,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 okay;
}
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);
@@ -73,7 +73,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);
@@ -83,7 +83,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 okay;
}
counter++;
@@ -99,7 +99,13 @@ 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");
}
+ okay:
+ control_mgmt_uart_dma_rx(DMA_RX_START);
return CLI_OK;
+
+ fail:
+ control_mgmt_uart_dma_rx(DMA_RX_START);
+ return CLI_ERROR;
}
static int cmd_reboot(struct cli_def *cli, const char *command, char *argv[], int argc)