From 7df794ea2fe0e5f3b058b803635afecfbbe8284a Mon Sep 17 00:00:00 2001 From: Hyeongsik Min Date: Mon, 24 Jul 2017 11:15:12 +0900 Subject: [PATCH] Print log messages in case of wrong write access Writing value is not permitted when the pin is in input direction mode. Just in case, this patch fixes error number and adds log message to let user know the cause. Change-Id: Ie40fabeba06b832eaa0585130af8702ba8fcb8b5 Signed-off-by: Hyeongsik Min --- src/daemon/peripheral_bus_gpio.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/daemon/peripheral_bus_gpio.c b/src/daemon/peripheral_bus_gpio.c index c6854ce..c1011e9 100644 --- a/src/daemon/peripheral_bus_gpio.c +++ b/src/daemon/peripheral_bus_gpio.c @@ -253,9 +253,11 @@ int peripheral_bus_gpio_write(pb_data_h handle, gint value) peripheral_bus_gpio_s *gpio = &handle->dev.gpio; int ret; - /* Return error if direction is input mode */ - if (gpio->direction == GPIO_DIRECTION_IN) - return PERIPHERAL_ERROR_IO_ERROR; + /* Return error if direction of the pin is input mode */ + if (gpio->direction == GPIO_DIRECTION_IN) { + _E("The direction of the pin is INPUT mode, Cannot write"); + return PERIPHERAL_ERROR_INVALID_OPERATION; + } if ((ret = gpio_write(gpio->pin, value)) < 0) { _E("gpio_write error (%d)", ret); -- 2.7.4