Skip to content

Commit

Permalink
pbio/uartdev: disallow mode setting on motors
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
laurensvalk committed Dec 23, 2020
1 parent 31dc102 commit 0f65f4b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/pbio/src/uartdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 0f65f4b

Please sign in to comment.