From: Segwon Date: Mon, 20 Nov 2017 08:27:30 +0000 (+0900) Subject: [1/5] fd passing: do not communicate with Lib from gdbus except for the open. X-Git-Tag: submit/tizen_4.0/20171220.125806^2~30 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4d3389e2f39d31bded581e65d05f4ed1776c9c5c;p=platform%2Fcore%2Fsystem%2Fperipheral-bus.git [1/5] fd passing: do not communicate with Lib from gdbus except for the open. Change-Id: Idf4dddf501f2c14c1a28d8a27d4354ac3ad9cd8d Signed-off-by: Segwon --- diff --git a/src/daemon/include/peripheral_bus_gdbus_gpio.h b/src/daemon/include/peripheral_bus_gdbus_gpio.h index 68c655c..4eb59df 100644 --- a/src/daemon/include/peripheral_bus_gdbus_gpio.h +++ b/src/daemon/include/peripheral_bus_gdbus_gpio.h @@ -25,55 +25,4 @@ gboolean handle_gpio_open( gint pin, gpointer user_data); -gboolean handle_gpio_close( - PeripheralIoGdbusGpio *gpio, - GDBusMethodInvocation *invocation, - gint handle, - gpointer user_data); - -gboolean handle_gpio_set_direction( - PeripheralIoGdbusGpio *gpio, - GDBusMethodInvocation *invocation, - gint handle, - gint direction, - gpointer user_data); - -gboolean handle_gpio_set_edge_mode( - PeripheralIoGdbusGpio *gpio, - GDBusMethodInvocation *invocation, - gint handle, - gint edge, - gpointer user_data); - -gboolean handle_gpio_set_interrupted_cb( - PeripheralIoGdbusGpio *gpio, - GDBusMethodInvocation *invocation, - gint handle, - gpointer user_data); - -gboolean handle_gpio_unset_interrupted_cb( - PeripheralIoGdbusGpio *gpio, - GDBusMethodInvocation *invocation, - gint handle, - gpointer user_data); - -void peripheral_bus_emit_interrupted_cb( - PeripheralIoGdbusGpio *gpio, - gint pin, - gint value, - guint64 timestamp); - -gboolean handle_gpio_read( - PeripheralIoGdbusGpio *gpio, - GDBusMethodInvocation *invocation, - gint handle, - gpointer user_data); - -gboolean handle_gpio_write( - PeripheralIoGdbusGpio *gpio, - GDBusMethodInvocation *invocation, - gint handle, - gint value, - gpointer user_data); - #endif /* __PERIPHERAL_BUS_GDBUS_GPIO_H__ */ diff --git a/src/daemon/include/peripheral_bus_gdbus_i2c.h b/src/daemon/include/peripheral_bus_gdbus_i2c.h index 72f3004..9a40a9b 100644 --- a/src/daemon/include/peripheral_bus_gdbus_i2c.h +++ b/src/daemon/include/peripheral_bus_gdbus_i2c.h @@ -26,35 +26,4 @@ gboolean handle_i2c_open( gint address, gpointer user_data); -gboolean handle_i2c_close( - PeripheralIoGdbusI2c *i2c, - GDBusMethodInvocation *invocation, - gint handle, - gpointer user_data); - -gboolean handle_i2c_read( - PeripheralIoGdbusI2c *i2c, - GDBusMethodInvocation *invocation, - gint handle, - gint length, - gpointer user_data); - -gboolean handle_i2c_write( - PeripheralIoGdbusI2c *i2c, - GDBusMethodInvocation *invocation, - gint handle, - gint length, - GVariant *data_array, - gpointer user_data); - -gboolean handle_i2c_smbus_ioctl( - PeripheralIoGdbusI2c *i2c, - GDBusMethodInvocation *invocation, - gint handle, - guchar read_write, - guchar command, - guint size, - guint16 data_in, - gpointer user_data); - #endif /* __PERIPHERAL_BUS_GDBUS_I2C_H__ */ diff --git a/src/daemon/include/peripheral_bus_gdbus_pwm.h b/src/daemon/include/peripheral_bus_gdbus_pwm.h index aa159dd..1694123 100644 --- a/src/daemon/include/peripheral_bus_gdbus_pwm.h +++ b/src/daemon/include/peripheral_bus_gdbus_pwm.h @@ -26,38 +26,4 @@ gboolean handle_pwm_open( gint pin, gpointer user_data); -gboolean handle_pwm_close( - PeripheralIoGdbusPwm *pwm, - GDBusMethodInvocation *invocation, - gint handle, - gpointer user_data); - -gboolean handle_pwm_set_period( - PeripheralIoGdbusPwm *pwm, - GDBusMethodInvocation *invocation, - gint handle, - gint period, - gpointer user_data); - -gboolean handle_pwm_set_duty_cycle( - PeripheralIoGdbusPwm *pwm, - GDBusMethodInvocation *invocation, - gint handle, - gint duty_cycle, - gpointer user_data); - -gboolean handle_pwm_set_polarity( - PeripheralIoGdbusPwm *pwm, - GDBusMethodInvocation *invocation, - gint handle, - gint polarity, - gpointer user_data); - -gboolean handle_pwm_set_enable( - PeripheralIoGdbusPwm *pwm, - GDBusMethodInvocation *invocation, - gint handle, - gint enable, - gpointer user_data); - #endif /* __PERIPHERAL_BUS_GDBUS_PWM_H__ */ diff --git a/src/daemon/include/peripheral_bus_gdbus_spi.h b/src/daemon/include/peripheral_bus_gdbus_spi.h index ac70aba..54a02e5 100644 --- a/src/daemon/include/peripheral_bus_gdbus_spi.h +++ b/src/daemon/include/peripheral_bus_gdbus_spi.h @@ -26,61 +26,4 @@ gboolean handle_spi_open( gint cs, gpointer user_data); -gboolean handle_spi_close( - PeripheralIoGdbusSpi *spi, - GDBusMethodInvocation *invocation, - gint handle, - gpointer user_data); - -gboolean handle_spi_set_mode( - PeripheralIoGdbusSpi *spi, - GDBusMethodInvocation *invocation, - gint handle, - guchar mode, - gpointer user_data); - -gboolean handle_spi_set_bit_order( - PeripheralIoGdbusSpi *spi, - GDBusMethodInvocation *invocation, - gint handle, - gboolean lsb, - gpointer user_data); - -gboolean handle_spi_set_bits_per_word( - PeripheralIoGdbusSpi *spi, - GDBusMethodInvocation *invocation, - gint handle, - guchar bits, - gpointer user_data); - -gboolean handle_spi_set_frequency( - PeripheralIoGdbusSpi *spi, - GDBusMethodInvocation *invocation, - gint handle, - guint freq, - gpointer user_data); - -gboolean handle_spi_read( - PeripheralIoGdbusSpi *spi, - GDBusMethodInvocation *invocation, - gint handle, - gint length, - gpointer user_data); - -gboolean handle_spi_write( - PeripheralIoGdbusSpi *spi, - GDBusMethodInvocation *invocation, - gint handle, - gint length, - GVariant *data_array, - gpointer user_data); - -gboolean handle_spi_transfer( - PeripheralIoGdbusSpi *spi, - GDBusMethodInvocation *invocation, - gint handle, - gint length, - GVariant *tx_data_array, - gpointer user_data); - #endif /* __PERIPHERAL_BUS_GDBUS_SPI_H__ */ diff --git a/src/daemon/include/peripheral_bus_gdbus_uart.h b/src/daemon/include/peripheral_bus_gdbus_uart.h index 5ada2e0..639caa0 100644 --- a/src/daemon/include/peripheral_bus_gdbus_uart.h +++ b/src/daemon/include/peripheral_bus_gdbus_uart.h @@ -25,61 +25,4 @@ gboolean handle_uart_open( gint port, gpointer user_data); -gboolean handle_uart_close( - PeripheralIoGdbusUart *uart, - GDBusMethodInvocation *invocation, - gint handle, - gpointer user_data); - -gboolean handle_uart_set_baud_rate( - PeripheralIoGdbusUart *uart, - GDBusMethodInvocation *invocation, - gint handle, - guint baudrate, - gpointer user_data); - -gboolean handle_uart_set_byte_size( - PeripheralIoGdbusUart *uart, - GDBusMethodInvocation *invocation, - gint handle, - guint byte_size, - gpointer user_data); - -gboolean handle_uart_set_parity( - PeripheralIoGdbusUart *uart, - GDBusMethodInvocation *invocation, - gint handle, - guint parity, - gpointer user_data); - -gboolean handle_uart_set_stop_bits( - PeripheralIoGdbusUart *uart, - GDBusMethodInvocation *invocation, - gint handle, - guint stop_bits, - gpointer user_data); - -gboolean handle_uart_set_flow_control( - PeripheralIoGdbusUart *uart, - GDBusMethodInvocation *invocation, - gint handle, - gboolean xonxoff, - gboolean rtscts, - gpointer user_data); - -gboolean handle_uart_read( - PeripheralIoGdbusUart *uart, - GDBusMethodInvocation *invocation, - gint handle, - gint length, - gpointer user_data); - -gboolean handle_uart_write( - PeripheralIoGdbusUart *uart, - GDBusMethodInvocation *invocation, - gint handle, - gint length, - GVariant *data_array, - gpointer user_data); - #endif /* __PERIPHERAL_BUS_GDBUS_UART_H__ */ diff --git a/src/daemon/peripheral_bus.c b/src/daemon/peripheral_bus.c index de5c80e..6c18e58 100644 --- a/src/daemon/peripheral_bus.c +++ b/src/daemon/peripheral_bus.c @@ -53,34 +53,6 @@ static gboolean __gpio_init(peripheral_bus_s *pb_data) "handle-open", G_CALLBACK(handle_gpio_open), pb_data); - g_signal_connect(pb_data->gpio_skeleton, - "handle-close", - G_CALLBACK(handle_gpio_close), - pb_data); - g_signal_connect(pb_data->gpio_skeleton, - "handle-set-direction", - G_CALLBACK(handle_gpio_set_direction), - pb_data); - g_signal_connect(pb_data->gpio_skeleton, - "handle-set-edge-mode", - G_CALLBACK(handle_gpio_set_edge_mode), - pb_data); - g_signal_connect(pb_data->gpio_skeleton, - "handle-set-interrupted-cb", - G_CALLBACK(handle_gpio_set_interrupted_cb), - pb_data); - g_signal_connect(pb_data->gpio_skeleton, - "handle-unset-interrupted-cb", - G_CALLBACK(handle_gpio_unset_interrupted_cb), - pb_data); - g_signal_connect(pb_data->gpio_skeleton, - "handle-read", - G_CALLBACK(handle_gpio_read), - pb_data); - g_signal_connect(pb_data->gpio_skeleton, - "handle-write", - G_CALLBACK(handle_gpio_write), - pb_data); manager = g_dbus_object_manager_server_new(PERIPHERAL_GDBUS_GPIO_PATH); @@ -112,22 +84,6 @@ static gboolean __i2c_init(peripheral_bus_s *pb_data) "handle-open", G_CALLBACK(handle_i2c_open), pb_data); - g_signal_connect(pb_data->i2c_skeleton, - "handle-close", - G_CALLBACK(handle_i2c_close), - pb_data); - g_signal_connect(pb_data->i2c_skeleton, - "handle-read", - G_CALLBACK(handle_i2c_read), - pb_data); - g_signal_connect(pb_data->i2c_skeleton, - "handle-write", - G_CALLBACK(handle_i2c_write), - pb_data); - g_signal_connect(pb_data->i2c_skeleton, - "handle-smbus-ioctl", - G_CALLBACK(handle_i2c_smbus_ioctl), - pb_data); manager = g_dbus_object_manager_server_new(PERIPHERAL_GDBUS_I2C_PATH); @@ -159,26 +115,6 @@ static gboolean __pwm_init(peripheral_bus_s *pb_data) "handle-open", G_CALLBACK(handle_pwm_open), pb_data); - g_signal_connect(pb_data->pwm_skeleton, - "handle-close", - G_CALLBACK(handle_pwm_close), - pb_data); - g_signal_connect(pb_data->pwm_skeleton, - "handle-set-period", - G_CALLBACK(handle_pwm_set_period), - pb_data); - g_signal_connect(pb_data->pwm_skeleton, - "handle-set-duty-cycle", - G_CALLBACK(handle_pwm_set_duty_cycle), - pb_data); - g_signal_connect(pb_data->pwm_skeleton, - "handle-set-polarity", - G_CALLBACK(handle_pwm_set_polarity), - pb_data); - g_signal_connect(pb_data->pwm_skeleton, - "handle-set-enable", - G_CALLBACK(handle_pwm_set_enable), - pb_data); manager = g_dbus_object_manager_server_new(PERIPHERAL_GDBUS_PWM_PATH); @@ -210,38 +146,6 @@ static gboolean __uart_init(peripheral_bus_s *pb_data) "handle-open", G_CALLBACK(handle_uart_open), pb_data); - g_signal_connect(pb_data->uart_skeleton, - "handle-close", - G_CALLBACK(handle_uart_close), - pb_data); - g_signal_connect(pb_data->uart_skeleton, - "handle-set-baud-rate", - G_CALLBACK(handle_uart_set_baud_rate), - pb_data); - g_signal_connect(pb_data->uart_skeleton, - "handle-set-byte-size", - G_CALLBACK(handle_uart_set_byte_size), - pb_data); - g_signal_connect(pb_data->uart_skeleton, - "handle-set-parity", - G_CALLBACK(handle_uart_set_parity), - pb_data); - g_signal_connect(pb_data->uart_skeleton, - "handle-set-stop-bits", - G_CALLBACK(handle_uart_set_stop_bits), - pb_data); - g_signal_connect(pb_data->uart_skeleton, - "handle-set-flow-control", - G_CALLBACK(handle_uart_set_flow_control), - pb_data); - g_signal_connect(pb_data->uart_skeleton, - "handle-read", - G_CALLBACK(handle_uart_read), - pb_data); - g_signal_connect(pb_data->uart_skeleton, - "handle-write", - G_CALLBACK(handle_uart_write), - pb_data); manager = g_dbus_object_manager_server_new(PERIPHERAL_GDBUS_UART_PATH); @@ -273,38 +177,6 @@ static gboolean __spi_init(peripheral_bus_s *pb_data) "handle-open", G_CALLBACK(handle_spi_open), pb_data); - g_signal_connect(pb_data->spi_skeleton, - "handle-close", - G_CALLBACK(handle_spi_close), - pb_data); - g_signal_connect(pb_data->spi_skeleton, - "handle-set-mode", - G_CALLBACK(handle_spi_set_mode), - pb_data); - g_signal_connect(pb_data->spi_skeleton, - "handle-set-bit-order", - G_CALLBACK(handle_spi_set_bit_order), - pb_data); - g_signal_connect(pb_data->spi_skeleton, - "handle-set-bits-per-word", - G_CALLBACK(handle_spi_set_bits_per_word), - pb_data); - g_signal_connect(pb_data->spi_skeleton, - "handle-set-frequency", - G_CALLBACK(handle_spi_set_frequency), - pb_data); - g_signal_connect(pb_data->spi_skeleton, - "handle-read", - G_CALLBACK(handle_spi_read), - pb_data); - g_signal_connect(pb_data->spi_skeleton, - "handle-write", - G_CALLBACK(handle_spi_write), - pb_data); - g_signal_connect(pb_data->spi_skeleton, - "handle-transfer", - G_CALLBACK(handle_spi_transfer), - pb_data); manager = g_dbus_object_manager_server_new(PERIPHERAL_GDBUS_SPI_PATH); diff --git a/src/daemon/peripheral_bus_gdbus_gpio.c b/src/daemon/peripheral_bus_gdbus_gpio.c index d52cac7..baf6f56 100644 --- a/src/daemon/peripheral_bus_gdbus_gpio.c +++ b/src/daemon/peripheral_bus_gdbus_gpio.c @@ -66,168 +66,4 @@ out: peripheral_io_gdbus_gpio_complete_open(gpio, invocation, GPOINTER_TO_UINT(gpio_handle), ret); return true; -} - -gboolean handle_gpio_close( - PeripheralIoGdbusGpio *gpio, - GDBusMethodInvocation *invocation, - gint handle, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h gpio_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, gpio_handle, pb_data->gpio_list) != 0) { - _E("gpio handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else { - g_bus_unwatch_name(gpio_handle->watch_id); - ret = peripheral_bus_gpio_close(gpio_handle); - } - - peripheral_io_gdbus_gpio_complete_close(gpio, invocation, ret); - - return true; -} - -gboolean handle_gpio_set_direction( - PeripheralIoGdbusGpio *gpio, - GDBusMethodInvocation *invocation, - gint handle, - gint direction, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h gpio_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, gpio_handle, pb_data->gpio_list) != 0) { - _E("gpio handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_gpio_set_direction(gpio_handle, direction); - - peripheral_io_gdbus_gpio_complete_set_direction(gpio, invocation, ret); - - return true; -} - -gboolean handle_gpio_set_edge_mode( - PeripheralIoGdbusGpio *gpio, - GDBusMethodInvocation *invocation, - gint handle, - gint edge, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h gpio_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, gpio_handle, pb_data->gpio_list) != 0) { - _E("gpio handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_gpio_set_edge(gpio_handle, edge); - - peripheral_io_gdbus_gpio_complete_set_edge_mode(gpio, invocation, ret); - - return true; -} - -gboolean handle_gpio_set_interrupted_cb( - PeripheralIoGdbusGpio *gpio, - GDBusMethodInvocation *invocation, - gint handle, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h gpio_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, gpio_handle, pb_data->gpio_list) != 0) { - _E("gpio handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_gpio_set_interrupted_cb(gpio_handle); - - peripheral_io_gdbus_gpio_complete_set_interrupted_cb(gpio, invocation, ret); - - return true; -} - -gboolean handle_gpio_unset_interrupted_cb( - PeripheralIoGdbusGpio *gpio, - GDBusMethodInvocation *invocation, - gint handle, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h gpio_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, gpio_handle, pb_data->gpio_list) != 0) { - _E("gpio handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_gpio_unset_interrupted_cb(gpio_handle); - - peripheral_io_gdbus_gpio_complete_unset_interrupted_cb(gpio, invocation, ret); - - return true; -} - -void peripheral_bus_emit_interrupted_cb( - PeripheralIoGdbusGpio *gpio, - gint pin, - gint value, - guint64 timestamp) -{ - g_assert(gpio != NULL); - - peripheral_io_gdbus_gpio_emit_interrupted_cb(gpio, pin, value, timestamp); -} - -gboolean handle_gpio_read( - PeripheralIoGdbusGpio *gpio, - GDBusMethodInvocation *invocation, - gint handle, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h gpio_handle = GUINT_TO_POINTER(handle); - gint read_value = 0; - - if (peripheral_bus_handle_is_valid(invocation, gpio_handle, pb_data->gpio_list) != 0) { - _E("gpio handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_gpio_read(gpio_handle, &read_value); - - peripheral_io_gdbus_gpio_complete_read(gpio, invocation, read_value, ret); - - return true; -} - -gboolean handle_gpio_write( - PeripheralIoGdbusGpio *gpio, - GDBusMethodInvocation *invocation, - gint handle, - gint value, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h gpio_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, gpio_handle, pb_data->gpio_list) != 0) { - _E("gpio handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_gpio_write(gpio_handle, value); - - peripheral_io_gdbus_gpio_complete_write(gpio, invocation, ret); - - return true; -} +} \ No newline at end of file diff --git a/src/daemon/peripheral_bus_gdbus_i2c.c b/src/daemon/peripheral_bus_gdbus_i2c.c index 37db07b..e162031 100644 --- a/src/daemon/peripheral_bus_gdbus_i2c.c +++ b/src/daemon/peripheral_bus_gdbus_i2c.c @@ -69,100 +69,3 @@ out: return true; } - -gboolean handle_i2c_close( - PeripheralIoGdbusI2c *i2c, - GDBusMethodInvocation *invocation, - gint handle, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h i2c_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, i2c_handle, pb_data->i2c_list) != 0) { - _E("i2c handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else { - g_bus_unwatch_name(i2c_handle->watch_id); - ret = peripheral_bus_i2c_close(i2c_handle); - } - - peripheral_io_gdbus_i2c_complete_close(i2c, invocation, ret); - - return true; -} - -gboolean handle_i2c_read( - PeripheralIoGdbusI2c *i2c, - GDBusMethodInvocation *invocation, - gint handle, - gint length, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h i2c_handle = GUINT_TO_POINTER(handle); - GVariant *data_array = NULL; - uint8_t err_buf[2] = {0, }; - - if (peripheral_bus_handle_is_valid(invocation, i2c_handle, pb_data->i2c_list) != 0) { - _E("i2c handle is not valid"); - data_array = peripheral_bus_build_variant_ay(err_buf, sizeof(err_buf)); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_i2c_read(i2c_handle, length, &data_array); - - peripheral_io_gdbus_i2c_complete_read(i2c, invocation, data_array, ret); - - return true; -} - -gboolean handle_i2c_write( - PeripheralIoGdbusI2c *i2c, - GDBusMethodInvocation *invocation, - gint handle, - gint length, - GVariant *data_array, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h i2c_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, i2c_handle, pb_data->i2c_list) != 0) { - _E("i2c handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_i2c_write(i2c_handle, length, data_array); - - peripheral_io_gdbus_i2c_complete_write(i2c, invocation, ret); - - return true; -} - -gboolean handle_i2c_smbus_ioctl( - PeripheralIoGdbusI2c *i2c, - GDBusMethodInvocation *invocation, - gint handle, - guchar read_write, - guchar command, - guint size, - guint16 data_in, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h i2c_handle = GUINT_TO_POINTER(handle); - uint16_t data = 0xFFFF; - - if (peripheral_bus_handle_is_valid(invocation, i2c_handle, pb_data->i2c_list) != 0) { - _E("i2c handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_i2c_smbus_ioctl(i2c_handle, read_write, command, size, data_in, &data); - - peripheral_io_gdbus_i2c_complete_smbus_ioctl(i2c, invocation, data, ret); - - return true; -} diff --git a/src/daemon/peripheral_bus_gdbus_pwm.c b/src/daemon/peripheral_bus_gdbus_pwm.c index 47f0c18..21518c2 100644 --- a/src/daemon/peripheral_bus_gdbus_pwm.c +++ b/src/daemon/peripheral_bus_gdbus_pwm.c @@ -69,114 +69,3 @@ out: return true; } - -gboolean handle_pwm_close( - PeripheralIoGdbusPwm *pwm, - GDBusMethodInvocation *invocation, - gint handle, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h pwm_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, pwm_handle, pb_data->pwm_list) != 0) { - _E("pwm handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else { - g_bus_unwatch_name(pwm_handle->watch_id); - ret = peripheral_bus_pwm_close(pwm_handle); - } - - peripheral_io_gdbus_pwm_complete_close(pwm, invocation, ret); - - return true; -} - -gboolean handle_pwm_set_period( - PeripheralIoGdbusPwm *pwm, - GDBusMethodInvocation *invocation, - gint handle, - gint period, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h pwm_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, pwm_handle, pb_data->pwm_list) != 0) { - _E("pwm handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_pwm_set_period(pwm_handle, period); - - peripheral_io_gdbus_pwm_complete_set_period(pwm, invocation, ret); - - return true; -} - -gboolean handle_pwm_set_duty_cycle( - PeripheralIoGdbusPwm *pwm, - GDBusMethodInvocation *invocation, - gint handle, - gint duty_cycle, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h pwm_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, pwm_handle, pb_data->pwm_list) != 0) { - _E("pwm handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_pwm_set_duty_cycle(pwm_handle, duty_cycle); - - peripheral_io_gdbus_pwm_complete_set_duty_cycle(pwm, invocation, ret); - - return true; -} - -gboolean handle_pwm_set_polarity( - PeripheralIoGdbusPwm *pwm, - GDBusMethodInvocation *invocation, - gint handle, - gint polarity, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h pwm_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, pwm_handle, pb_data->pwm_list) != 0) { - _E("pwm handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_pwm_set_polarity(pwm_handle, polarity); - - peripheral_io_gdbus_pwm_complete_set_polarity(pwm, invocation, ret); - - return true; -} - -gboolean handle_pwm_set_enable( - PeripheralIoGdbusPwm *pwm, - GDBusMethodInvocation *invocation, - gint handle, - gint enable, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h pwm_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, pwm_handle, pb_data->pwm_list) != 0) { - _E("pwm handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_pwm_set_enable(pwm_handle, enable); - - peripheral_io_gdbus_pwm_complete_set_enable(pwm, invocation, ret); - - return true; -} diff --git a/src/daemon/peripheral_bus_gdbus_spi.c b/src/daemon/peripheral_bus_gdbus_spi.c index 043d94b..2246996 100644 --- a/src/daemon/peripheral_bus_gdbus_spi.c +++ b/src/daemon/peripheral_bus_gdbus_spi.c @@ -69,188 +69,3 @@ out: return true; } - -gboolean handle_spi_close( - PeripheralIoGdbusSpi *spi, - GDBusMethodInvocation *invocation, - gint handle, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h spi_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, spi_handle, pb_data->spi_list) != 0) { - _E("spi handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else { - g_bus_unwatch_name(spi_handle->watch_id); - ret = peripheral_bus_spi_close(spi_handle); - } - - peripheral_io_gdbus_spi_complete_close(spi, invocation, ret); - - return true; -} - -gboolean handle_spi_set_mode( - PeripheralIoGdbusSpi *spi, - GDBusMethodInvocation *invocation, - gint handle, - guchar mode, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h spi_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, spi_handle, pb_data->spi_list) != 0) { - _E("spi handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_spi_set_mode(spi_handle, mode); - - peripheral_io_gdbus_spi_complete_set_mode(spi, invocation, ret); - - return true; -} - -gboolean handle_spi_set_bit_order( - PeripheralIoGdbusSpi *spi, - GDBusMethodInvocation *invocation, - gint handle, - gboolean lsb, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h spi_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, spi_handle, pb_data->spi_list) != 0) { - _E("spi handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_spi_set_bit_order(spi_handle, lsb); - - peripheral_io_gdbus_spi_complete_set_bit_order(spi, invocation, ret); - - return true; -} - -gboolean handle_spi_set_bits_per_word( - PeripheralIoGdbusSpi *spi, - GDBusMethodInvocation *invocation, - gint handle, - guchar bits, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h spi_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, spi_handle, pb_data->spi_list) != 0) { - _E("spi handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_spi_set_bits_per_word(spi_handle, bits); - - peripheral_io_gdbus_spi_complete_set_bits_per_word(spi, invocation, ret); - - return true; -} - -gboolean handle_spi_set_frequency( - PeripheralIoGdbusSpi *spi, - GDBusMethodInvocation *invocation, - gint handle, - guint freq, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h spi_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, spi_handle, pb_data->spi_list) != 0) { - _E("spi handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_spi_set_frequency(spi_handle, freq); - - peripheral_io_gdbus_spi_complete_set_frequency(spi, invocation, ret); - - return true; -} - -gboolean handle_spi_read( - PeripheralIoGdbusSpi *spi, - GDBusMethodInvocation *invocation, - gint handle, - gint length, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h spi_handle = GUINT_TO_POINTER(handle); - GVariant *data_array = NULL; - uint8_t err_buf[2] = {0, }; - - if (peripheral_bus_handle_is_valid(invocation, spi_handle, pb_data->spi_list) != 0) { - _E("spi handle is not valid"); - data_array = peripheral_bus_build_variant_ay(err_buf, sizeof(err_buf)); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_spi_read(spi_handle, &data_array, length); - - peripheral_io_gdbus_spi_complete_read(spi, invocation, data_array, ret); - - return true; -} - -gboolean handle_spi_write( - PeripheralIoGdbusSpi *spi, - GDBusMethodInvocation *invocation, - gint handle, - gint length, - GVariant *data_array, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h spi_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, spi_handle, pb_data->spi_list) != 0) { - _E("spi handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_spi_write(spi_handle, data_array, length); - - peripheral_io_gdbus_spi_complete_write(spi, invocation, ret); - - return true; -} - -gboolean handle_spi_transfer( - PeripheralIoGdbusSpi *spi, - GDBusMethodInvocation *invocation, - gint handle, - gint length, - GVariant *tx_data_array, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h spi_handle = GUINT_TO_POINTER(handle); - GVariant *rx_data_array = NULL; - uint8_t err_buf[2] = {0, }; - - if (peripheral_bus_handle_is_valid(invocation, spi_handle, pb_data->spi_list) != 0) { - _E("spi handle is not valid"); - rx_data_array = peripheral_bus_build_variant_ay(err_buf, sizeof(err_buf)); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_spi_transfer(spi_handle, tx_data_array, &rx_data_array, length); - - peripheral_io_gdbus_spi_complete_transfer(spi, invocation, rx_data_array, ret); - - return true; -} diff --git a/src/daemon/peripheral_bus_gdbus_uart.c b/src/daemon/peripheral_bus_gdbus_uart.c index 12f346f..e2ba4a0 100644 --- a/src/daemon/peripheral_bus_gdbus_uart.c +++ b/src/daemon/peripheral_bus_gdbus_uart.c @@ -68,187 +68,3 @@ out: return true; } - -gboolean handle_uart_close( - PeripheralIoGdbusUart *uart, - GDBusMethodInvocation *invocation, - gint handle, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h uart_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, uart_handle, pb_data->uart_list) != 0) { - _E("uart handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else { - g_bus_unwatch_name(uart_handle->watch_id); - ret = peripheral_bus_uart_close(uart_handle); - } - - peripheral_io_gdbus_uart_complete_close(uart, invocation, ret); - - return true; -} - -gboolean handle_uart_set_baud_rate( - PeripheralIoGdbusUart *uart, - GDBusMethodInvocation *invocation, - gint handle, - guint baud_rate, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h uart_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, uart_handle, pb_data->uart_list) != 0) { - _E("uart handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_uart_set_baud_rate(uart_handle, baud_rate); - - peripheral_io_gdbus_uart_complete_set_baud_rate(uart, invocation, ret); - - return true; -} - -gboolean handle_uart_set_byte_size( - PeripheralIoGdbusUart *uart, - GDBusMethodInvocation *invocation, - gint handle, - guint byte_size, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h uart_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, uart_handle, pb_data->uart_list) != 0) { - _E("uart handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_uart_set_byte_size(uart_handle, byte_size); - - peripheral_io_gdbus_uart_complete_set_byte_size(uart, invocation, ret); - - return true; -} - -gboolean handle_uart_set_parity( - PeripheralIoGdbusUart *uart, - GDBusMethodInvocation *invocation, - gint handle, - guint parity, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h uart_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, uart_handle, pb_data->uart_list) != 0) { - _E("uart handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_uart_set_parity(uart_handle, parity); - - peripheral_io_gdbus_uart_complete_set_parity(uart, invocation, ret); - - return true; -} - -gboolean handle_uart_set_stop_bits( - PeripheralIoGdbusUart *uart, - GDBusMethodInvocation *invocation, - gint handle, - guint stop_bits, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h uart_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, uart_handle, pb_data->uart_list) != 0) { - _E("uart handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_uart_set_stop_bits(uart_handle, stop_bits); - - peripheral_io_gdbus_uart_complete_set_stop_bits(uart, invocation, ret); - - return true; -} - -gboolean handle_uart_set_flow_control( - PeripheralIoGdbusUart *uart, - GDBusMethodInvocation *invocation, - gint handle, - gboolean xonxoff, - gboolean rtscts, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h uart_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, uart_handle, pb_data->uart_list) != 0) { - _E("uart handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_uart_set_flow_control(uart_handle, xonxoff, rtscts); - - peripheral_io_gdbus_uart_complete_set_flow_control(uart, invocation, ret); - - return true; -} - -gboolean handle_uart_read( - PeripheralIoGdbusUart *uart, - GDBusMethodInvocation *invocation, - gint handle, - gint length, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h uart_handle = GUINT_TO_POINTER(handle); - uint8_t err_buf[2] = {0, }; - GVariant *data_array = NULL; - - if (peripheral_bus_handle_is_valid(invocation, uart_handle, pb_data->uart_list) != 0) { - _E("uart handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_uart_read(uart_handle, &data_array, length); - - if (!data_array) - data_array = peripheral_bus_build_variant_ay(err_buf, sizeof(err_buf)); - - peripheral_io_gdbus_uart_complete_read(uart, invocation, data_array, ret); - - return true; -} - -gboolean handle_uart_write( - PeripheralIoGdbusUart *uart, - GDBusMethodInvocation *invocation, - gint handle, - gint length, - GVariant *data_array, - gpointer user_data) -{ - peripheral_bus_s *pb_data = (peripheral_bus_s*)user_data; - peripheral_error_e ret = PERIPHERAL_ERROR_NONE; - pb_data_h uart_handle = GUINT_TO_POINTER(handle); - - if (peripheral_bus_handle_is_valid(invocation, uart_handle, pb_data->uart_list) != 0) { - _E("uart handle is not valid"); - ret = PERIPHERAL_ERROR_INVALID_PARAMETER; - } else - ret = peripheral_bus_uart_write(uart_handle, data_array, length); - - peripheral_io_gdbus_uart_complete_write(uart, invocation, ret); - - return true; -} diff --git a/src/daemon/peripheral_bus_gpio.c b/src/daemon/peripheral_bus_gpio.c index 41ba5bb..f2a7bb5 100644 --- a/src/daemon/peripheral_bus_gpio.c +++ b/src/daemon/peripheral_bus_gpio.c @@ -196,6 +196,7 @@ int peripheral_bus_gpio_close(pb_data_h handle) return ret;; } +// TODO : This function will be removed. int peripheral_bus_gpio_set_direction(pb_data_h handle, gint direction) { peripheral_bus_gpio_s *gpio = &handle->dev.gpio; @@ -211,6 +212,7 @@ int peripheral_bus_gpio_set_direction(pb_data_h handle, gint direction) return PERIPHERAL_ERROR_NONE; } +// TODO : This function will be removed. int peripheral_bus_gpio_set_edge(pb_data_h handle, gint edge) { peripheral_bus_gpio_s *gpio = &handle->dev.gpio; @@ -226,11 +228,12 @@ int peripheral_bus_gpio_set_edge(pb_data_h handle, gint edge) return PERIPHERAL_ERROR_NONE; } +// TODO : This function will be removed. static gboolean peripheral_bus_interrupted_cb(GIOChannel *io, GIOCondition condition, gpointer data) { peripheral_bus_gpio_s *gpio_data = (peripheral_bus_gpio_s *)data; struct timeval time; - unsigned long long timestamp; + // unsigned long long timestamp; GIOStatus status; gchar* strval; int value; @@ -270,12 +273,13 @@ static gboolean peripheral_bus_interrupted_cb(GIOChannel *io, GIOCondition cond else if (gpio_data->edge == PERIPHERAL_GPIO_EDGE_FALLING && value == 1) return TRUE; - timestamp = (unsigned long long)time.tv_sec * 1000000 + time.tv_usec; - peripheral_bus_emit_interrupted_cb(gpio_data->gpio_skeleton, gpio_data->pin, value, timestamp); + //timestamp = (unsigned long long)time.tv_sec * 1000000 + time.tv_usec; + //peripheral_bus_emit_interrupted_cb(gpio_data->gpio_skeleton, gpio_data->pin, value, timestamp); return TRUE; } +// TODO : This function will be removed. int peripheral_bus_gpio_set_interrupted_cb(pb_data_h handle) { peripheral_bus_gpio_s *gpio = &handle->dev.gpio; @@ -322,6 +326,7 @@ err_open_isr: return PERIPHERAL_ERROR_UNKNOWN; } +// TODO : This function will be removed. int peripheral_bus_gpio_unset_interrupted_cb(pb_data_h handle) { peripheral_bus_gpio_s *gpio = &handle->dev.gpio; @@ -339,6 +344,7 @@ int peripheral_bus_gpio_unset_interrupted_cb(pb_data_h handle) return PERIPHERAL_ERROR_NONE; } +// TODO : This function will be removed. int peripheral_bus_gpio_read(pb_data_h handle, gint *value) { peripheral_bus_gpio_s *gpio = &handle->dev.gpio; @@ -352,6 +358,7 @@ int peripheral_bus_gpio_read(pb_data_h handle, gint *value) return PERIPHERAL_ERROR_NONE; } +// TODO : This function will be removed. int peripheral_bus_gpio_write(pb_data_h handle, gint value) { peripheral_bus_gpio_s *gpio = &handle->dev.gpio; diff --git a/src/daemon/peripheral_io.xml b/src/daemon/peripheral_io.xml index 281c551..5f3aa84 100644 --- a/src/daemon/peripheral_io.xml +++ b/src/daemon/peripheral_io.xml @@ -6,43 +6,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -51,35 +14,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -88,30 +22,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -119,52 +29,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -173,56 +37,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -