From 9d6866678e949d8f0daa9ec0bf1713b407c2481a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Mon, 16 Aug 2021 18:42:53 +0100 Subject: [PATCH] Update implementation of WP_ReceiveBytes - Following #2012. --- .../Maxim/_common/WireProtocol_HAL_Interface.c | 13 +++++-------- .../ST/_common/WireProtocol_HAL_Interface.c | 8 +++----- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/targets/AzureRTOS/Maxim/_common/WireProtocol_HAL_Interface.c b/targets/AzureRTOS/Maxim/_common/WireProtocol_HAL_Interface.c index f95731f22e..820d03b879 100644 --- a/targets/AzureRTOS/Maxim/_common/WireProtocol_HAL_Interface.c +++ b/targets/AzureRTOS/Maxim/_common/WireProtocol_HAL_Interface.c @@ -41,7 +41,7 @@ void UART_TxCallback(mxc_uart_req_t *req, int error) } } -uint8_t WP_ReceiveBytes(uint8_t *ptr, uint32_t *size) +void WP_ReceiveBytes(uint8_t **ptr, uint32_t *size) { // save for later comparison uint32_t requestedSize = *size; @@ -58,7 +58,7 @@ uint8_t WP_ReceiveBytes(uint8_t *ptr, uint32_t *size) NanoUART_InitRequest(&rxRequest); rxRequest.uart = MXC_UART_GET_UART(WIRE_PROTOCOL_UART); - rxRequest.rxData = ptr; + rxRequest.rxData = *ptr; rxRequest.rxLen = requestedSize; rxRequest.callback = UART_RxCallback; @@ -80,23 +80,20 @@ uint8_t WP_ReceiveBytes(uint8_t *ptr, uint32_t *size) goto abort_rx; } - ptr += receivedBytes; + *ptr += receivedBytes; *size -= receivedBytes; TRACE(TRACE_STATE, "RXMSG: Expecting %d bytes, received %d.\n", requestedSize, receivedBytes); - - // check if any bytes where read - return receivedBytes > 0; } - return true; + return; abort_rx: // abort any ongoing UART operation NanoUART_AbortAsync(MXC_UART_GET_UART(WIRE_PROTOCOL_UART)); // done here - return false; + return; } uint8_t WP_TransmitMessage(WP_Message *message) diff --git a/targets/AzureRTOS/ST/_common/WireProtocol_HAL_Interface.c b/targets/AzureRTOS/ST/_common/WireProtocol_HAL_Interface.c index cf93153c67..e7bfb2ebd0 100644 --- a/targets/AzureRTOS/ST/_common/WireProtocol_HAL_Interface.c +++ b/targets/AzureRTOS/ST/_common/WireProtocol_HAL_Interface.c @@ -11,7 +11,7 @@ #include -uint8_t WP_ReceiveBytes(uint8_t *ptr, uint32_t *size) +void WP_ReceiveBytes(uint8_t **ptr, uint32_t *size) { volatile uint32_t read; @@ -23,7 +23,7 @@ uint8_t WP_ReceiveBytes(uint8_t *ptr, uint32_t *size) if (*size) { // non blocking read from serial port with 20ms timeout - read = chnReadTimeout(&SERIAL_DRIVER, ptr, requestedSize, OSAL_MS2I(20)); + read = chnReadTimeout(&SERIAL_DRIVER, *ptr, requestedSize, OSAL_MS2I(20)); TRACE(TRACE_STATE, "RXMSG: Expecting %d bytes, received %d.\n", requestedSize, read); @@ -33,11 +33,9 @@ uint8_t WP_ReceiveBytes(uint8_t *ptr, uint32_t *size) return false; } - ptr += read; + *ptr += read; *size -= read; } - - return true; } uint8_t WP_TransmitMessage(WP_Message *message)