Record timestamp of gpio interrupt 90/138390/8
authorjino.cho <jino.cho@samsung.com>
Wed, 12 Jul 2017 04:45:55 +0000 (13:45 +0900)
committerHyeongsik Min <hyeongsik.min@samsung.com>
Thu, 13 Jul 2017 01:07:57 +0000 (01:07 +0000)
This patch records the timestamp of the gpio interrupt and
adds it to signal argument.

Change-Id: Ia79ebcbcaade7436d683a25623e10632e1d5c0c5
Signed-off-by: jino.cho <jino.cho@samsung.com>
src/daemon/peripheral_bus.c
src/daemon/peripheral_bus.h
src/daemon/peripheral_bus_gpio.c
src/daemon/peripheral_io.xml

index 89574df..38cbdae 100644 (file)
@@ -1277,13 +1277,15 @@ gboolean handle_spi_read_write(
        return true;
 }
 
-void peripheral_bus_emit_gpio_changed(PeripheralIoGdbusGpio *gpio,
-                                                                       gint pin,
-                                                                       gint state)
+void peripheral_bus_emit_gpio_changed(
+               PeripheralIoGdbusGpio *gpio,
+               gint pin,
+               gint value,
+               guint64 timestamp)
 {
        g_assert(gpio != NULL);
 
-       peripheral_io_gdbus_gpio_emit_gpio_changed(gpio, pin, state);
+       peripheral_io_gdbus_gpio_emit_gpio_changed(gpio, pin, value, timestamp);
 }
 
 static gboolean __gpio_init(peripheral_bus_s *pb_data)
index 716ba16..a547f92 100644 (file)
@@ -124,5 +124,6 @@ typedef peripheral_bus_data_s *pb_data_h;
 
 void peripheral_bus_emit_gpio_changed(PeripheralIoGdbusGpio *gpio,
                                                                        gint pin,
-                                                                       gint state);
+                                                                       gint value,
+                                                                       guint64 timestamp);
 #endif /* __PERIPHERAL_BUS_H__ */
index c0d89e4..a853863 100644 (file)
@@ -282,6 +282,8 @@ int peripheral_bus_gpio_read(pb_data_h handle, gint *value)
 static gboolean  peripheral_bus_gpio_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;
        GIOStatus status;
        gchar* strval;
        int value;
@@ -293,6 +295,8 @@ static gboolean  peripheral_bus_gpio_cb(GIOChannel *io, GIOCondition condition,
                || gpio_data->edge == PERIPHERAL_GPIO_EDGE_NONE)
                return TRUE;
 
+       gettimeofday(&time, NULL);
+
        g_io_channel_seek_position(io, 0, G_SEEK_SET, NULL);
        status = g_io_channel_read_line(io, &strval, NULL, NULL, NULL);
        if (status != G_IO_STATUS_NORMAL) {
@@ -319,7 +323,8 @@ static gboolean  peripheral_bus_gpio_cb(GIOChannel *io, GIOCondition condition,
        else if (gpio_data->edge == PERIPHERAL_GPIO_EDGE_FALLING && value == 1)
                return TRUE;
 
-       peripheral_bus_emit_gpio_changed(gpio_data->gpio_skeleton, gpio_data->pin, value);
+       timestamp = (unsigned long long)(time.tv_sec * 1000000 + time.tv_usec);
+       peripheral_bus_emit_gpio_changed(gpio_data->gpio_skeleton, gpio_data->pin, value, timestamp);
 
        return TRUE;
 }
index 16b3cd2..878fb5c 100644 (file)
@@ -50,7 +50,8 @@
                </method>
                <signal name='GpioChanged'>
                        <arg type='i' name='pin'/>
-                       <arg type='i' name='state'/>
+                       <arg type='i' name='value'/>
+                       <arg type='t' name='timestamp'/>
                </signal>
        </interface>
        <interface name="org.tizen.peripheral_io.i2c">