diff --git a/components/bm1397/bm1366.c b/components/bm1397/bm1366.c index d73f28d3..6141acb5 100644 --- a/components/bm1397/bm1366.c +++ b/components/bm1397/bm1366.c @@ -649,7 +649,7 @@ void BM1366_send_work(void * pvParameters, bm_job * next_bm_job) asic_result * BM1366_receive_work(void) { // wait for a response, wait time is pretty arbitrary - int received = SERIAL_rx(asic_response_buffer, 11, 60000); + int received = SERIAL_rx(asic_response_buffer, 11, 20); if (received < 0) { ESP_LOGI(TAG, "Error in serial RX"); diff --git a/components/bm1397/serial.c b/components/bm1397/serial.c index dcc1b9a6..2ff61c9d 100644 --- a/components/bm1397/serial.c +++ b/components/bm1397/serial.c @@ -60,10 +60,11 @@ int SERIAL_send(uint8_t *data, int len, bool debug) return uart_write_bytes(UART_NUM_1, (const char *)data, len); } -/// @brief waits for a serial response from the device -/// @param buf buffer to read data into -/// @param buf number of ms to wait before timing out -/// @return number of bytes read, or -1 on error +/// @brief reads serial bytes into a buffer +/// @param buf +/// @param size +/// @param timeout_ms +/// @return int16_t SERIAL_rx(uint8_t *buf, uint16_t size, uint16_t timeout_ms) { int16_t bytes_read = uart_read_bytes(UART_NUM_1, buf, size, timeout_ms / portTICK_PERIOD_MS);