Skip to content

Commit 4f93169

Browse files
committed
pbio/port_lump: Increase initial read time out.
This races with the keep alive timeout as they are essentially testing for the same thing, so the timeout should match.
1 parent 61aa9f8 commit 4f93169

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

lib/pbio/src/port_lump.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <pbdrv/clock.h>
1818
#include <pbdrv/ioport.h>
1919

20-
#define DEBUG 0
20+
#define DEBUG 1
2121
#if DEBUG
2222
#include <stdio.h>
2323
#include <inttypes.h>
@@ -829,7 +829,7 @@ pbio_error_t pbio_port_lump_sync_thread(pbio_os_state_t *state, pbio_port_lump_d
829829
// read the message header
830830
PBIO_OS_AWAIT(state, &lump_dev->read_pt, err = pbdrv_uart_read(&lump_dev->read_pt, uart_dev, lump_dev->rx_msg, 1, EV3_UART_IO_TIMEOUT));
831831
if (err != PBIO_SUCCESS) {
832-
debug_pr("UART Rx end error during info header\n");
832+
debug_pr("UART Rx error during info header\n");
833833
return err;
834834
}
835835

@@ -847,7 +847,7 @@ pbio_error_t pbio_port_lump_sync_thread(pbio_os_state_t *state, pbio_port_lump_d
847847
if (lump_dev->rx_msg_size > 1) {
848848
PBIO_OS_AWAIT(state, &lump_dev->read_pt, err = pbdrv_uart_read(&lump_dev->read_pt, uart_dev, lump_dev->rx_msg + 1, lump_dev->rx_msg_size - 1, EV3_UART_IO_TIMEOUT));
849849
if (err != PBIO_SUCCESS) {
850-
debug_pr("UART Rx end error during info\n");
850+
debug_pr("UART Rx error during info\n");
851851
return err;
852852
}
853853
}
@@ -1020,9 +1020,14 @@ pbio_error_t pbio_port_lump_data_recv_thread(pbio_os_state_t *state, pbio_port_l
10201020
PBIO_OS_ASYNC_BEGIN(state);
10211021

10221022
while (true) {
1023-
PBIO_OS_AWAIT(state, &lump_dev->read_pt, err = pbdrv_uart_read(&lump_dev->read_pt, uart_dev, lump_dev->rx_msg, 1, EV3_UART_IO_TIMEOUT));
1023+
PBIO_OS_AWAIT(state, &lump_dev->read_pt, err = pbdrv_uart_read(&lump_dev->read_pt, uart_dev, lump_dev->rx_msg, 1,
1024+
// This is essentially the timeout for receiving the next data
1025+
// message, so we should allow at least as much timeout as allowed
1026+
// by missing messages rather than use a generic IO timeout.
1027+
EV3_UART_DATA_KEEP_ALIVE_TIMEOUT * (EV3_UART_DATA_KEEP_ALIVE_MAX_MISSED + 1)
1028+
));
10241029
if (err != PBIO_SUCCESS) {
1025-
debug_pr("UART Rx data header end error\n");
1030+
debug_pr("Did not receive UART Rx data header byte\n");
10261031
return err;
10271032
}
10281033

@@ -1042,7 +1047,7 @@ pbio_error_t pbio_port_lump_data_recv_thread(pbio_os_state_t *state, pbio_port_l
10421047

10431048
PBIO_OS_AWAIT(state, &lump_dev->read_pt, err = pbdrv_uart_read(&lump_dev->read_pt, uart_dev, lump_dev->rx_msg + 1, lump_dev->rx_msg_size - 1, EV3_UART_IO_TIMEOUT));
10441049
if (err != PBIO_SUCCESS) {
1045-
debug_pr("UART Rx data end error\n");
1050+
debug_pr("UART Rx data error\n");
10461051
return err;
10471052
}
10481053

0 commit comments

Comments
 (0)