From 0f65f4b4f6912dfb207372941b65dfbfd06e825d Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Fri, 11 Dec 2020 15:20:26 +0100 Subject: [PATCH] pbio/uartdev: disallow mode setting on motors We currently do not support changing mode if it is already in combo mode. Doing so currently causes the runtime to hang since the mode change never completes. This changes makes the error explicit and avoids the hang. --- lib/pbio/src/uartdev.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/pbio/src/uartdev.c b/lib/pbio/src/uartdev.c index 8a20da689..cb9e5355b 100644 --- a/lib/pbio/src/uartdev.c +++ b/lib/pbio/src/uartdev.c @@ -1130,6 +1130,11 @@ static pbio_error_t ev3_uart_set_mode_begin(pbio_iodev_t *iodev, uint8_t mode) { uartdev_port_data_t *port_data = PBIO_CONTAINER_OF(iodev, uartdev_port_data_t, iodev); pbio_error_t err; + // User mode change for motors is not supported + if (PBIO_IODEV_IS_FEEDBACK_MOTOR(iodev)) { + return PBIO_ERROR_NOT_SUPPORTED; + } + err = ev3_uart_begin_tx_msg(port_data, LUMP_MSG_TYPE_CMD, LUMP_CMD_SELECT, &mode, 1); if (err != PBIO_SUCCESS) { return err;