- save the received fds to handle.
- it only receive fds when the open function is run.
Change-Id: Iaa3c87adaab0254c519b2f695068ae79850e3a23
Signed-off-by: Segwon <segwon.han@samsung.com>
#include <stdio.h>
#include <stdlib.h>
+#include <gio/gunixfdlist.h>
#include "peripheral_io.h"
#include "peripheral_gdbus.h"
#include "peripheral_internal.h"
#include "peripheral_io_gdbus.h"
+#define GPIO_FD_INDEX_DIRECTION 0
+#define GPIO_FD_INDEX_EDGE 1
+#define GPIO_FD_INDEX_VALUE 2
+
extern int peripheral_gpio_interrupted_cb_handler(int pin, int value, unsigned long long timestamp, int err);
static PeripheralIoGdbusGpio *gpio_proxy = NULL;
{
GError *error = NULL;
gint32 ret = PERIPHERAL_ERROR_NONE;
+ GUnixFDList *fd_list = NULL;
if (gpio_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
if (peripheral_io_gdbus_gpio_call_open_sync(
gpio_proxy,
gpio->pin,
+ NULL,
&gpio->handle,
&ret,
+ &fd_list,
NULL,
&error) == FALSE) {
_E("Error in %s() : %s", __func__, error->message);
return PERIPHERAL_ERROR_UNKNOWN;
}
+ gpio->fd_direction = g_unix_fd_list_get(fd_list, GPIO_FD_INDEX_DIRECTION, &error);
+ if (gpio->fd_direction < 0) {
+ _E("Failed to get fd for gpio direction : %s", error->message);
+ g_error_free(error);
+ ret = PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ gpio->fd_edge = g_unix_fd_list_get(fd_list, GPIO_FD_INDEX_EDGE, &error);
+ if (gpio->fd_edge < 0) {
+ _E("Failed to get fd for gpio edge : %s", error->message);
+ g_error_free(error);
+ ret = PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ gpio->fd_value = g_unix_fd_list_get(fd_list, GPIO_FD_INDEX_VALUE, &error);
+ if (gpio->fd_value < 0) {
+ _E("Failed to get fd for gpio value : %s", error->message);
+ g_error_free(error);
+ ret = PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ g_object_unref(fd_list);
+
return ret;
}
#include <stdio.h>
#include <stdlib.h>
+#include <gio/gunixfdlist.h>
#include "peripheral_io.h"
#include "peripheral_gdbus.h"
#include "peripheral_internal.h"
#include "peripheral_io_gdbus.h"
+#define I2C_FD_INDEX 0
+
static PeripheralIoGdbusI2c *i2c_proxy = NULL;
void i2c_proxy_init(void)
{
GError *error = NULL;
peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+ GUnixFDList *fd_list = NULL;
if (i2c_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
i2c_proxy,
bus,
address,
+ NULL,
&i2c->handle,
&ret,
+ &fd_list,
NULL,
&error) == FALSE) {
_E("Error in %s() : %s", __func__, error->message);
return PERIPHERAL_ERROR_UNKNOWN;
}
+ i2c->fd = g_unix_fd_list_get(fd_list, I2C_FD_INDEX, &error);
+ if (i2c->fd < 0) {
+ _E("Failed to get fd for i2c : %s", error->message);
+ g_error_free(error);
+ ret = PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ g_object_unref(fd_list);
+
return ret;
}
#include <stdio.h>
#include <stdlib.h>
+#include <gio/gunixfdlist.h>
#include "peripheral_io.h"
#include "peripheral_gdbus.h"
#include "peripheral_internal.h"
#include "peripheral_io_gdbus.h"
+#define PWM_FD_INDEX_PERIOD 0
+#define PWM_FD_INDEX_DUTY_CYCLE 1
+#define PWM_FD_INDEX_POLARITY 2
+#define PWM_FD_INDEX_ENABLE 3
+
static PeripheralIoGdbusPwm *pwm_proxy = NULL;
void pwm_proxy_init(void)
{
GError *error = NULL;
peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+ GUnixFDList *fd_list = NULL;
if (pwm_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
pwm_proxy,
chip,
pin,
+ NULL,
&pwm->handle,
&ret,
+ &fd_list,
NULL,
&error) == FALSE) {
_E("%s", error->message);
return PERIPHERAL_ERROR_UNKNOWN;
}
+ pwm->fd_period = g_unix_fd_list_get(fd_list, PWM_FD_INDEX_PERIOD, &error);
+ if (pwm->fd_period < 0) {
+ _E("Failed to get fd for pwm period : %s", error->message);
+ g_error_free(error);
+ ret = PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ pwm->fd_duty_cycle = g_unix_fd_list_get(fd_list, PWM_FD_INDEX_DUTY_CYCLE, &error);
+ if (pwm->fd_duty_cycle < 0) {
+ _E("Failed to get fd for pwm duty cycle : %s", error->message);
+ g_error_free(error);
+ ret = PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ pwm->fd_polarity = g_unix_fd_list_get(fd_list, PWM_FD_INDEX_POLARITY, &error);
+ if (pwm->fd_polarity < 0) {
+ _E("Failed to get fd for pwm polarity : %s", error->message);
+ g_error_free(error);
+ ret = PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ pwm->fd_enable = g_unix_fd_list_get(fd_list, PWM_FD_INDEX_ENABLE, &error);
+ if (pwm->fd_enable < 0) {
+ _E("Failed to get fd for pwm enable : %s", error->message);
+ g_error_free(error);
+ ret = PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ g_object_unref(fd_list);
+
return ret;
}
#include <stdio.h>
#include <stdlib.h>
+#include <gio/gunixfdlist.h>
#include "peripheral_io.h"
#include "peripheral_gdbus.h"
#include "peripheral_internal.h"
#include "peripheral_io_gdbus.h"
+#define SPI_FD_INDEX 0
+
static PeripheralIoGdbusSpi *spi_proxy = NULL;
void spi_proxy_init(void)
{
GError *error = NULL;
peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+ GUnixFDList *fd_list = NULL;
if (spi_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
spi_proxy,
bus,
cs,
+ NULL,
&spi->handle,
&ret,
+ &fd_list,
NULL,
&error) == FALSE) {
_E("%s", error->message);
return PERIPHERAL_ERROR_UNKNOWN;
}
+ spi->fd = g_unix_fd_list_get(fd_list, SPI_FD_INDEX, &error);
+ if (spi->fd < 0) {
+ _E("Failed to get fd for spi : %s", error->message);
+ g_error_free(error);
+ ret = PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ g_object_unref(fd_list);
+
return ret;
}
#include <stdio.h>
#include <stdlib.h>
+#include <gio/gunixfdlist.h>
#include "peripheral_io.h"
#include "peripheral_gdbus.h"
#include "peripheral_internal.h"
#include "peripheral_io_gdbus.h"
+#define UART_FD_INDEX 0
+
static PeripheralIoGdbusUart *uart_proxy = NULL;
void uart_proxy_init(void)
{
GError *error = NULL;
peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+ GUnixFDList *fd_list = NULL;
if (uart_proxy == NULL) return PERIPHERAL_ERROR_UNKNOWN;
if (peripheral_io_gdbus_uart_call_open_sync(
uart_proxy,
port,
+ NULL,
&uart->handle,
&ret,
+ &fd_list,
NULL,
&error) == FALSE) {
_E("Error in %s() : %s", __func__, error->message);
return PERIPHERAL_ERROR_UNKNOWN;
}
+ uart->fd = g_unix_fd_list_get(fd_list, UART_FD_INDEX, &error);
+ if (uart->fd < 0) {
+ _E("Failed to get fd for uart : %s", error->message);
+ g_error_free(error);
+ ret = PERIPHERAL_ERROR_UNKNOWN;
+ }
+
+ g_object_unref(fd_list);
+
return ret;
}
<node>
<interface name="org.tizen.peripheral_io.gpio">
<method name="Open">
+ <annotation name="org.gtk.GDBus.C.UnixFD" value="true"/>
<arg type="i" name="pin" direction="in"/>
<arg type="u" name="handle" direction="out"/>
<arg type="i" name="result" direction="out"/>
</interface>
<interface name="org.tizen.peripheral_io.i2c">
<method name="Open">
+ <annotation name="org.gtk.GDBus.C.UnixFD" value="true"/>
<arg type="i" name="bus" direction="in"/>
<arg type="i" name="address" direction="in"/>
<arg type="u" name="handle" direction="out"/>
</interface>
<interface name="org.tizen.peripheral_io.pwm">
<method name="Open">
+ <annotation name="org.gtk.GDBus.C.UnixFD" value="true"/>
<arg type="i" name="chip" direction="in"/>
<arg type="i" name="pin" direction="in"/>
<arg type="u" name="handle" direction="out"/>
</interface>
<interface name="org.tizen.peripheral_io.uart">
<method name="Open">
+ <annotation name="org.gtk.GDBus.C.UnixFD" value="true"/>
<arg type="i" name="port" direction="in"/>
<arg type="u" name="handle" direction="out"/>
<arg type="i" name="result" direction="out"/>
</interface>
<interface name="org.tizen.peripheral_io.spi">
<method name="Open">
+ <annotation name="org.gtk.GDBus.C.UnixFD" value="true"/>
<arg type="i" name="bus" direction="in"/>
<arg type="i" name="cs" direction="in"/>
<arg type="u" name="handle" direction="out"/>