This patch adds get_enable functions to read current enable status.
The type of enable was changed to boolean.
Change-Id: Ida7f8437ad452f96bf29bc4a1a1d46b85b4eb50b
Signed-off-by: jino.cho <jino.cho@samsung.com>
+gboolean handle_pwm_get_enable(
+ PeripheralIoGdbusPwm *pwm,
+ GDBusMethodInvocation *invocation,
+ gint handle,
+ gpointer user_data)
+{
+ peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
+ pb_pwm_data_h pwm_handle = GUINT_TO_POINTER(handle);
+ bool enable;
+
+ ret = peripheral_bus_pwm_get_enable(pwm_handle, &enable);
+
+ peripheral_io_gdbus_pwm_complete_get_enable(pwm, invocation, enable, ret);
+
+ return true;
+}
+
gboolean handle_uart_open(
PeripheralIoGdbusUart *uart,
GDBusMethodInvocation *invocation,
gboolean handle_uart_open(
PeripheralIoGdbusUart *uart,
GDBusMethodInvocation *invocation,
"handle-set-enable",
G_CALLBACK(handle_pwm_set_enable),
pb_data);
"handle-set-enable",
G_CALLBACK(handle_pwm_set_enable),
pb_data);
+ g_signal_connect(pb_data->pwm_skeleton,
+ "handle-get-enable",
+ G_CALLBACK(handle_pwm_get_enable),
+ pb_data);
manager = g_dbus_object_manager_server_new(PERIPHERAL_GDBUS_PWM_PATH);
manager = g_dbus_object_manager_server_new(PERIPHERAL_GDBUS_PWM_PATH);
return pwm_get_duty_cycle(pwm->device, pwm->channel, duty_cycle);
}
return pwm_get_duty_cycle(pwm->device, pwm->channel, duty_cycle);
}
-int peripheral_bus_pwm_set_enable(pb_pwm_data_h pwm, int enable)
+int peripheral_bus_pwm_set_enable(pb_pwm_data_h pwm, bool enable)
{
return pwm_set_enable(pwm->device, pwm->channel, enable);
}
{
return pwm_set_enable(pwm->device, pwm->channel, enable);
}
+int peripheral_bus_pwm_get_enable(pb_pwm_data_h pwm, bool *enable)
+{
+ return pwm_get_enable(pwm->device, pwm->channel, enable);
+}
int peripheral_bus_pwm_get_period(pb_pwm_data_h pwm, int *period);
int peripheral_bus_pwm_set_duty_cycle(pb_pwm_data_h pwm, int duty_cycle);
int peripheral_bus_pwm_get_duty_cycle(pb_pwm_data_h pwm, int *duty_cycle);
int peripheral_bus_pwm_get_period(pb_pwm_data_h pwm, int *period);
int peripheral_bus_pwm_set_duty_cycle(pb_pwm_data_h pwm, int duty_cycle);
int peripheral_bus_pwm_get_duty_cycle(pb_pwm_data_h pwm, int *duty_cycle);
-int peripheral_bus_pwm_set_enable(pb_pwm_data_h pwm, int enable);
+int peripheral_bus_pwm_set_enable(pb_pwm_data_h pwm, bool enable);
+int peripheral_bus_pwm_get_enable(pb_pwm_data_h pwm, bool *enable);
#endif /* __PERIPHERAL_BUS_PWM_H__ */
#endif /* __PERIPHERAL_BUS_PWM_H__ */
</method>
<method name="SetEnable">
<arg type="u" name="handle" direction="in"/>
</method>
<method name="SetEnable">
<arg type="u" name="handle" direction="in"/>
- <arg type="i" name="enable" direction="in"/>
+ <arg type="b" name="enable" direction="in"/>
+ <arg type="i" name="result" direction="out"/>
+ </method>
+ <method name="GetEnable">
+ <arg type="u" name="handle" direction="in"/>
+ <arg type="b" name="enable" direction="out"/>
<arg type="i" name="result" direction="out"/>
</method>
</interface>
<arg type="i" name="result" direction="out"/>
</method>
</interface>
* @param[in] enable pwm enable/disabled state value
* @return On success, 0 is returned. On failure, a negative value is returned.
*/
* @param[in] enable pwm enable/disabled state value
* @return On success, 0 is returned. On failure, a negative value is returned.
*/
-int pwm_set_enable(int device, int channel, int enable);
+int pwm_set_enable(int device, int channel, bool enable);
/**
* @brief pwm_get_enable() checks if pwm state is enabled.
/**
* @brief pwm_get_enable() checks if pwm state is enabled.
* @param[out] enable pwm enable/disabled state value
* @return On success, 0 is returned. On failure, a negative value is returned.
*/
* @param[out] enable pwm enable/disabled state value
* @return On success, 0 is returned. On failure, a negative value is returned.
*/
-int pwm_get_enable(int device, int channel, int *enable);
+int pwm_get_enable(int device, int channel, bool *enable);
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include "pwm.h"
#include "peripheral_common.h"
#include "pwm.h"
#include "peripheral_common.h"
-int pwm_set_enable(int device, int channel, int enable)
+int pwm_set_enable(int device, int channel, bool enable)
{
int fd, len, status;
char pwm_buf[PWM_BUF_MAX] = {0};
{
int fd, len, status;
char pwm_buf[PWM_BUF_MAX] = {0};
-int pwm_get_enable(int device, int channel, int *enable)
+int pwm_get_enable(int device, int channel, bool *enable)
{
int fd, result, status;
char pwm_buf[PWM_BUF_MAX] = {0};
{
int fd, result, status;
char pwm_buf[PWM_BUF_MAX] = {0};
return -EIO;
}
result = atoi(pwm_buf);
return -EIO;
}
result = atoi(pwm_buf);