From eb08bae192a7d89029cee707c92a6fa39412995b Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Mon, 21 Jun 2021 14:57:12 +0200 Subject: [PATCH] pbio/iodev: Drop input/output flags. The input flags are never used. The output flag(s) are only checked to assert that we can write data to this mode. This capability will be encoded in the data type in the next commit. --- lib/pbio/drv/ioport/ioport_lpf2.c | 10 ----- lib/pbio/include/pbio/iodev.h | 8 ---- lib/pbio/src/uartdev.c | 9 ++-- lib/pbio/test/src/uartdev.c | 71 ------------------------------- 4 files changed, 6 insertions(+), 92 deletions(-) diff --git a/lib/pbio/drv/ioport/ioport_lpf2.c b/lib/pbio/drv/ioport/ioport_lpf2.c index 39c89cab7..8cea8ed1d 100644 --- a/lib/pbio/drv/ioport/ioport_lpf2.c +++ b/lib/pbio/drv/ioport/ioport_lpf2.c @@ -63,8 +63,6 @@ static const basic_info_t basic_infos[] = { .mode = { .num_values = 1, .data_type = PBIO_IODEV_DATA_TYPE_INT8, - .input_flags = 0, - .output_flags = LPF2_MAPPING_FLAG_ABSOLUTE, }, }, [PBIO_IODEV_TYPE_ID_LPF2_TRAIN] = { @@ -76,8 +74,6 @@ static const basic_info_t basic_infos[] = { .mode = { .num_values = 1, .data_type = PBIO_IODEV_DATA_TYPE_INT8, - .input_flags = 0, - .output_flags = LPF2_MAPPING_FLAG_RELATIVE | LPF2_MAPPING_FLAG_ABSOLUTE, }, }, [PBIO_IODEV_TYPE_ID_LPF2_LIGHT] = { @@ -89,8 +85,6 @@ static const basic_info_t basic_infos[] = { .mode = { .num_values = 1, .data_type = PBIO_IODEV_DATA_TYPE_INT8, - .input_flags = 0, - .output_flags = LPF2_MAPPING_FLAG_DISCRETE | LPF2_MAPPING_FLAG_ABSOLUTE, }, }, [PBIO_IODEV_TYPE_ID_LPF2_LIGHT1] = { @@ -102,8 +96,6 @@ static const basic_info_t basic_infos[] = { .mode = { .num_values = 1, .data_type = PBIO_IODEV_DATA_TYPE_INT8, - .input_flags = 0, - .output_flags = LPF2_MAPPING_FLAG_DISCRETE | LPF2_MAPPING_FLAG_ABSOLUTE, }, }, [PBIO_IODEV_TYPE_ID_LPF2_LIGHT2] = { @@ -115,8 +107,6 @@ static const basic_info_t basic_infos[] = { .mode = { .num_values = 1, .data_type = PBIO_IODEV_DATA_TYPE_INT8, - .input_flags = 0, - .output_flags = LPF2_MAPPING_FLAG_DISCRETE | LPF2_MAPPING_FLAG_ABSOLUTE, }, }, }; diff --git a/lib/pbio/include/pbio/iodev.h b/lib/pbio/include/pbio/iodev.h index 466d2eaf9..b2f2cc8ef 100644 --- a/lib/pbio/include/pbio/iodev.h +++ b/lib/pbio/include/pbio/iodev.h @@ -262,14 +262,6 @@ typedef struct { * The binary format of the data for this mode. */ pbio_iodev_data_type_t data_type; - /** - * Input value mapping flags. - */ - pbio_iodev_mapping_flag_t input_flags; - /** - * Output value mapping flags. - */ - pbio_iodev_mapping_flag_t output_flags; } pbio_iodev_mode_t; /** diff --git a/lib/pbio/src/uartdev.c b/lib/pbio/src/uartdev.c index b5cc8c13f..bff341b01 100644 --- a/lib/pbio/src/uartdev.c +++ b/lib/pbio/src/uartdev.c @@ -491,8 +491,10 @@ static void pbio_uartdev_parse_msg(uartdev_port_data_t *data) { goto err; } - data->info->mode_info[mode].input_flags = data->rx_msg[2]; - data->info->mode_info[mode].output_flags = data->rx_msg[3]; + // Check that mode supports writing. + if (data->rx_msg[3]) { + // TODO: Store write capability + } debug_pr("mapping: in %02x out %02x\n", data->rx_msg[2], data->rx_msg[3]); @@ -1091,7 +1093,8 @@ static pbio_error_t ev3_uart_set_data_begin(pbio_iodev_t *iodev, const uint8_t * uint8_t size; // not all modes support setting data - if (!mode->output_flags) { + bool writable = 0; // TODO: Check write capability + if (!writable) { return PBIO_ERROR_INVALID_OP; } diff --git a/lib/pbio/test/src/uartdev.c b/lib/pbio/test/src/uartdev.c index 3f9f8641b..9a5d9366b 100644 --- a/lib/pbio/test/src/uartdev.c +++ b/lib/pbio/test/src/uartdev.c @@ -360,60 +360,36 @@ static PT_THREAD(test_boost_color_distance_sensor(struct pt *pt)) { tt_want_uint_op(iodev->info->capability_flags, ==, PBIO_IODEV_CAPABILITY_FLAG_NONE); tt_want_uint_op(iodev->mode, ==, 0); - tt_want_uint_op(iodev->info->mode_info[0].input_flags, ==, - LPF2_MAPPING_FLAG_NULL | LPF2_MAPPING_FLAG_2_0 | LPF2_MAPPING_FLAG_DISCRETE); - tt_want_uint_op(iodev->info->mode_info[0].output_flags, ==, 0); tt_want_uint_op(iodev->info->mode_info[0].num_values, ==, 1); tt_want_uint_op(iodev->info->mode_info[0].data_type, ==, PBIO_IODEV_DATA_TYPE_INT8); - tt_want_uint_op(iodev->info->mode_info[1].input_flags, ==, - LPF2_MAPPING_FLAG_2_0 | LPF2_MAPPING_FLAG_ABSOLUTE); - tt_want_uint_op(iodev->info->mode_info[1].output_flags, ==, 0); tt_want_uint_op(iodev->info->mode_info[1].num_values, ==, 1); tt_want_uint_op(iodev->info->mode_info[1].data_type, ==, PBIO_IODEV_DATA_TYPE_INT8); - tt_want_uint_op(iodev->info->mode_info[2].input_flags, ==, LPF2_MAPPING_FLAG_RELATIVE); - tt_want_uint_op(iodev->info->mode_info[2].output_flags, ==, 0); tt_want_uint_op(iodev->info->mode_info[2].num_values, ==, 1); tt_want_uint_op(iodev->info->mode_info[2].data_type, ==, PBIO_IODEV_DATA_TYPE_INT32); - tt_want_uint_op(iodev->info->mode_info[3].input_flags, ==, LPF2_MAPPING_FLAG_ABSOLUTE); - tt_want_uint_op(iodev->info->mode_info[3].output_flags, ==, 0); tt_want_uint_op(iodev->info->mode_info[3].num_values, ==, 1); tt_want_uint_op(iodev->info->mode_info[3].data_type, ==, PBIO_IODEV_DATA_TYPE_INT8); - tt_want_uint_op(iodev->info->mode_info[4].input_flags, ==, LPF2_MAPPING_FLAG_ABSOLUTE); - tt_want_uint_op(iodev->info->mode_info[4].output_flags, ==, 0); tt_want_uint_op(iodev->info->mode_info[4].num_values, ==, 1); tt_want_uint_op(iodev->info->mode_info[4].data_type, ==, PBIO_IODEV_DATA_TYPE_INT8); - tt_want_uint_op(iodev->info->mode_info[5].input_flags, ==, 0); - tt_want_uint_op(iodev->info->mode_info[5].output_flags, ==, LPF2_MAPPING_FLAG_DISCRETE); tt_want_uint_op(iodev->info->mode_info[5].num_values, ==, 1); tt_want_uint_op(iodev->info->mode_info[5].data_type, ==, PBIO_IODEV_DATA_TYPE_INT8); - tt_want_uint_op(iodev->info->mode_info[6].input_flags, ==, LPF2_MAPPING_FLAG_ABSOLUTE); - tt_want_uint_op(iodev->info->mode_info[6].output_flags, ==, 0); tt_want_uint_op(iodev->info->mode_info[6].num_values, ==, 3); tt_want_uint_op(iodev->info->mode_info[6].data_type, ==, PBIO_IODEV_DATA_TYPE_INT16); - tt_want_uint_op(iodev->info->mode_info[7].input_flags, ==, 0); - tt_want_uint_op(iodev->info->mode_info[7].output_flags, ==, LPF2_MAPPING_FLAG_DISCRETE); tt_want_uint_op(iodev->info->mode_info[7].num_values, ==, 1); tt_want_uint_op(iodev->info->mode_info[7].data_type, ==, PBIO_IODEV_DATA_TYPE_INT16); - tt_want_uint_op(iodev->info->mode_info[8].input_flags, ==, 0); - tt_want_uint_op(iodev->info->mode_info[8].output_flags, ==, 0); tt_want_uint_op(iodev->info->mode_info[8].num_values, ==, 4); tt_want_uint_op(iodev->info->mode_info[8].data_type, ==, PBIO_IODEV_DATA_TYPE_INT8); - tt_want_uint_op(iodev->info->mode_info[9].input_flags, ==, LPF2_MAPPING_FLAG_ABSOLUTE); - tt_want_uint_op(iodev->info->mode_info[9].output_flags, ==, 0); tt_want_uint_op(iodev->info->mode_info[9].num_values, ==, 2); tt_want_uint_op(iodev->info->mode_info[9].data_type, ==, PBIO_IODEV_DATA_TYPE_INT16); - tt_want_uint_op(iodev->info->mode_info[10].input_flags, ==, LPF2_MAPPING_FLAG_ABSOLUTE); - tt_want_uint_op(iodev->info->mode_info[10].output_flags, ==, 0); tt_want_uint_op(iodev->info->mode_info[10].num_values, ==, 8); tt_want_uint_op(iodev->info->mode_info[10].data_type, ==, PBIO_IODEV_DATA_TYPE_INT16); @@ -631,24 +607,15 @@ static PT_THREAD(test_boost_interactive_motor(struct pt *pt)) { PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_SPEED | PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_REL_POS); tt_want_uint_op(iodev->mode, ==, 0); - tt_want_uint_op(iodev->info->mode_info[0].input_flags, ==, 0); - tt_want_uint_op(iodev->info->mode_info[0].output_flags, ==, - LPF2_MAPPING_FLAG_2_0 | LPF2_MAPPING_FLAG_ABSOLUTE); tt_want_uint_op(iodev->info->mode_info[0].num_values, ==, 1); tt_want_uint_op(iodev->info->mode_info[0].data_type, ==, PBIO_IODEV_DATA_TYPE_INT8); - tt_want_uint_op(iodev->info->mode_info[1].input_flags, ==, LPF2_MAPPING_FLAG_ABSOLUTE); - tt_want_uint_op(iodev->info->mode_info[1].output_flags, ==, 0); tt_want_uint_op(iodev->info->mode_info[1].num_values, ==, 1); tt_want_uint_op(iodev->info->mode_info[1].data_type, ==, PBIO_IODEV_DATA_TYPE_INT8); - tt_want_uint_op(iodev->info->mode_info[2].input_flags, ==, LPF2_MAPPING_FLAG_RELATIVE); - tt_want_uint_op(iodev->info->mode_info[2].output_flags, ==, 0); tt_want_uint_op(iodev->info->mode_info[2].num_values, ==, 1); tt_want_uint_op(iodev->info->mode_info[2].data_type, ==, PBIO_IODEV_DATA_TYPE_INT32); - tt_want_uint_op(iodev->info->mode_info[3].input_flags, ==, 0); - tt_want_uint_op(iodev->info->mode_info[3].output_flags, ==, 0); tt_want_uint_op(iodev->info->mode_info[3].num_values, ==, 5); tt_want_uint_op(iodev->info->mode_info[3].data_type, ==, PBIO_IODEV_DATA_TYPE_INT16); @@ -843,40 +810,21 @@ static PT_THREAD(test_technic_large_motor(struct pt *pt)) { | PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_REL_POS | PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_ABS_POS); tt_want_uint_op(iodev->mode, ==, 0); - tt_want_uint_op(iodev->info->mode_info[0].input_flags, ==, 0); - tt_want_uint_op(iodev->info->mode_info[0].output_flags, ==, - LPF2_MAPPING_FLAG_2_0 | LPF2_MAPPING_FLAG_ABSOLUTE); tt_want_uint_op(iodev->info->mode_info[0].num_values, ==, 1); tt_want_uint_op(iodev->info->mode_info[0].data_type, ==, PBIO_IODEV_DATA_TYPE_INT8); - tt_want_uint_op(iodev->info->mode_info[1].input_flags, ==, - LPF2_MAPPING_FLAG_UNKNOWN_BIT5 | LPF2_MAPPING_FLAG_ABSOLUTE); - tt_want_uint_op(iodev->info->mode_info[1].output_flags, ==, - LPF2_MAPPING_FLAG_2_0 | LPF2_MAPPING_FLAG_UNKNOWN_BIT5 | LPF2_MAPPING_FLAG_ABSOLUTE); tt_want_uint_op(iodev->info->mode_info[1].num_values, ==, 1); tt_want_uint_op(iodev->info->mode_info[1].data_type, ==, PBIO_IODEV_DATA_TYPE_INT8); - tt_want_uint_op(iodev->info->mode_info[2].input_flags, ==, - LPF2_MAPPING_FLAG_UNKNOWN_BIT5 | LPF2_MAPPING_FLAG_RELATIVE); - tt_want_uint_op(iodev->info->mode_info[2].output_flags, ==, - LPF2_MAPPING_FLAG_2_0 | LPF2_MAPPING_FLAG_UNKNOWN_BIT5 | LPF2_MAPPING_FLAG_RELATIVE); tt_want_uint_op(iodev->info->mode_info[2].num_values, ==, 1); tt_want_uint_op(iodev->info->mode_info[2].data_type, ==, PBIO_IODEV_DATA_TYPE_INT32); - tt_want_uint_op(iodev->info->mode_info[3].input_flags, ==, - LPF2_MAPPING_FLAG_UNKNOWN_BIT5 | LPF2_MAPPING_FLAG_ABSOLUTE | LPF2_MAPPING_FLAG_UNKNOWN_BIT1); - tt_want_uint_op(iodev->info->mode_info[3].output_flags, ==, - LPF2_MAPPING_FLAG_UNKNOWN_BIT5 | LPF2_MAPPING_FLAG_ABSOLUTE | LPF2_MAPPING_FLAG_UNKNOWN_BIT1); tt_want_uint_op(iodev->info->mode_info[3].num_values, ==, 1); tt_want_uint_op(iodev->info->mode_info[3].data_type, ==, PBIO_IODEV_DATA_TYPE_INT16); - tt_want_uint_op(iodev->info->mode_info[4].input_flags, ==, 0); - tt_want_uint_op(iodev->info->mode_info[4].output_flags, ==, 0); tt_want_uint_op(iodev->info->mode_info[4].num_values, ==, 2); tt_want_uint_op(iodev->info->mode_info[4].data_type, ==, PBIO_IODEV_DATA_TYPE_INT16); - tt_want_uint_op(iodev->info->mode_info[5].input_flags, ==, 0); - tt_want_uint_op(iodev->info->mode_info[5].output_flags, ==, 0); tt_want_uint_op(iodev->info->mode_info[5].num_values, ==, 14); tt_want_uint_op(iodev->info->mode_info[5].data_type, ==, PBIO_IODEV_DATA_TYPE_INT16); @@ -1071,40 +1019,21 @@ static PT_THREAD(test_technic_xl_motor(struct pt *pt)) { | PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_REL_POS | PBIO_IODEV_CAPABILITY_FLAG_HAS_MOTOR_ABS_POS); tt_want_uint_op(iodev->mode, ==, 0); - tt_want_uint_op(iodev->info->mode_info[0].input_flags, ==, 0); - tt_want_uint_op(iodev->info->mode_info[0].output_flags, ==, - LPF2_MAPPING_FLAG_2_0 | LPF2_MAPPING_FLAG_ABSOLUTE); tt_want_uint_op(iodev->info->mode_info[0].num_values, ==, 1); tt_want_uint_op(iodev->info->mode_info[0].data_type, ==, PBIO_IODEV_DATA_TYPE_INT8); - tt_want_uint_op(iodev->info->mode_info[1].input_flags, ==, - LPF2_MAPPING_FLAG_UNKNOWN_BIT5 | LPF2_MAPPING_FLAG_ABSOLUTE); - tt_want_uint_op(iodev->info->mode_info[1].output_flags, ==, - LPF2_MAPPING_FLAG_2_0 | LPF2_MAPPING_FLAG_UNKNOWN_BIT5 | LPF2_MAPPING_FLAG_ABSOLUTE); tt_want_uint_op(iodev->info->mode_info[1].num_values, ==, 1); tt_want_uint_op(iodev->info->mode_info[1].data_type, ==, PBIO_IODEV_DATA_TYPE_INT8); - tt_want_uint_op(iodev->info->mode_info[2].input_flags, ==, - LPF2_MAPPING_FLAG_UNKNOWN_BIT5 | LPF2_MAPPING_FLAG_RELATIVE); - tt_want_uint_op(iodev->info->mode_info[2].output_flags, ==, - LPF2_MAPPING_FLAG_2_0 | LPF2_MAPPING_FLAG_UNKNOWN_BIT5 | LPF2_MAPPING_FLAG_RELATIVE); tt_want_uint_op(iodev->info->mode_info[2].num_values, ==, 1); tt_want_uint_op(iodev->info->mode_info[2].data_type, ==, PBIO_IODEV_DATA_TYPE_INT32); - tt_want_uint_op(iodev->info->mode_info[3].input_flags, ==, - LPF2_MAPPING_FLAG_UNKNOWN_BIT5 | LPF2_MAPPING_FLAG_ABSOLUTE | LPF2_MAPPING_FLAG_UNKNOWN_BIT1); - tt_want_uint_op(iodev->info->mode_info[3].output_flags, ==, - LPF2_MAPPING_FLAG_UNKNOWN_BIT5 | LPF2_MAPPING_FLAG_ABSOLUTE | LPF2_MAPPING_FLAG_UNKNOWN_BIT1); tt_want_uint_op(iodev->info->mode_info[3].num_values, ==, 1); tt_want_uint_op(iodev->info->mode_info[3].data_type, ==, PBIO_IODEV_DATA_TYPE_INT16); - tt_want_uint_op(iodev->info->mode_info[4].input_flags, ==, 0); - tt_want_uint_op(iodev->info->mode_info[4].output_flags, ==, 0); tt_want_uint_op(iodev->info->mode_info[4].num_values, ==, 2); tt_want_uint_op(iodev->info->mode_info[4].data_type, ==, PBIO_IODEV_DATA_TYPE_INT16); - tt_want_uint_op(iodev->info->mode_info[5].input_flags, ==, 0); - tt_want_uint_op(iodev->info->mode_info[5].output_flags, ==, 0); tt_want_uint_op(iodev->info->mode_info[5].num_values, ==, 14); tt_want_uint_op(iodev->info->mode_info[5].data_type, ==, PBIO_IODEV_DATA_TYPE_INT16);