Skip to content

Commit

Permalink
pbio/iodev: Drop input/output flags.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
laurensvalk committed Jun 22, 2021
1 parent 5201e3a commit eb08bae
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 92 deletions.
10 changes: 0 additions & 10 deletions lib/pbio/drv/ioport/ioport_lpf2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {
Expand All @@ -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] = {
Expand All @@ -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] = {
Expand All @@ -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] = {
Expand All @@ -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,
},
},
};
Expand Down
8 changes: 0 additions & 8 deletions lib/pbio/include/pbio/iodev.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
9 changes: 6 additions & 3 deletions lib/pbio/src/uartdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down Expand Up @@ -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;
}

Expand Down
71 changes: 0 additions & 71 deletions lib/pbio/test/src/uartdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit eb08bae

Please sign in to comment.