Skip to content

Commit 7c5fcf2

Browse files
committed
pbio/port_lump: Fix ColorLightMatrix.
It turns out the ColorLightMatrix needs the NACK to get going at all, so make sure we always send one before we start waiting on the timeout. In b17e503, we removed grace period of 6 keep-alive messages to go unanswered, which was essentially masking this issue so the device worked before.
1 parent 3198a85 commit 7c5fcf2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/pbio/src/port_lump.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -917,16 +917,19 @@ pbio_error_t pbio_port_lump_data_send_thread(pbio_os_state_t *state, pbio_port_l
917917

918918
PBIO_OS_ASYNC_BEGIN(state);
919919

920-
pbio_os_timer_set(timer, EV3_UART_DATA_KEEP_ALIVE_TIMEOUT);
920+
// Some devices need the NACK keep-alive signal before doing anything, so
921+
// initially set the timer to expire soon.
922+
pbio_os_timer_set(timer, 1);
921923

922924
for (;;) {
923925

924926
PBIO_OS_AWAIT_UNTIL(state, pbio_os_timer_is_expired(timer) || lump_dev->mode_switch.requested || lump_dev->data_set->size > 0);
925927

926928
// Handle keep alive timeout
927929
if (pbio_os_timer_is_expired(timer)) {
928-
// make sure we are receiving data
929-
if (!lump_dev->data_rec) {
930+
// Make sure we are receiving data. The first time around, we allow
931+
// not having any data yet.
932+
if (!lump_dev->data_rec && timer->duration == EV3_UART_DATA_KEEP_ALIVE_TIMEOUT) {
930933
debug_pr("No data since last keepalive\n");
931934
lump_dev->status = PBDRV_LEGODEV_LUMP_STATUS_ERR;
932935
return PBIO_ERROR_TIMEDOUT;

0 commit comments

Comments
 (0)