Previous checking privilege was done by peripheral-bus daemon.
After changing to use direct API, it was needed to add code
checking privilege but it was not added.
Change-Id: Ib893f5fe71995f3cb5e54a0dcf196057af1f09b9
Signed-off-by: TaeminYeom <taemin.yeom@samsung.com>
PROJECT(${fw_name})
-SET(dependents "dlog glib-2.0 capi-base-common capi-system-info libudev")
+SET(dependents "dlog glib-2.0 capi-base-common capi-system-info libudev cynara-client cynara-session")
SET(pc_dependents "capi-base-common")
SET(CMAKE_INSTALL_PREFIX ${prefix})
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(cynara-client)
+BuildRequires: pkgconfig(cynara-session)
BuildRequires: pkgconfig(libudev)
%if 0%{?gcov:1}
BuildRequires: lcov
-#include "common.h"
#include <assert.h>
#include <libudev.h>
#include <poll.h>
#include <stdio.h>
+#include <stdlib.h>
#include <sys/file.h>
+
#include <system_info.h>
+#include <cynara-client.h>
+#include <cynara-session.h>
+
+#include "common.h"
#define UDEV_MONITOR_POLL_TIMEOUT_MILISECONDS 100
#define UDEV_MONITOR_POLL_ITERATIONS 10 //! How many times to poll? Affects the total timeout.
+#define BUFF_MAX 255
+#define UID_MAX_LENGTH 16
+#define PRIVILEGE_PERIPHERALIO "http://tizen.org/privilege/peripheralio"
int peripheral_lock(const char *file_name)
{
return *feature_state == PERIPHERAL_FEATURE_TRUE;
}
+bool peripheral_is_privilege_supported(void)
+{
+ cynara *cynara = NULL;
+ FILE *fp = NULL;
+ char uid[UID_MAX_LENGTH];
+ char *session = NULL;
+ char smack_label[BUFF_MAX] = {0, };
+ int ret;
+
+ if (cynara_initialize(&cynara, NULL) != CYNARA_API_SUCCESS) {
+ _E("failed to initialize cynara");
+ return false;
+ }
+
+ fp = fopen("/proc/self/attr/current", "r");
+ if (fp != NULL) {
+ int ch = 0;
+ int idx = 0;
+ while (EOF != (ch = fgetc(fp))) {
+ smack_label[idx] = ch;
+ idx++;
+ }
+ fclose(fp);
+ }
+
+ pid_t pid = getpid();
+ session = cynara_session_from_pid(pid);
+ snprintf(uid, UID_MAX_LENGTH, "%d", getuid());
+ uid[UID_MAX_LENGTH - 1] = '\0';
+
+ ret = cynara_check(cynara, smack_label, session, uid, PRIVILEGE_PERIPHERALIO);
+ if (session)
+ free(session);
+ if (cynara)
+ cynara_finish(cynara);
+ if (ret != CYNARA_API_ACCESS_ALLOWED) {
+ _E("'%s' privilege is not supported", PRIVILEGE_PERIPHERALIO);
+ return false;
+ }
+
+ return true;
+}
+
int peripheral_create_udev_monitor(struct udev **udev, struct udev_monitor **monitor, const char *filter_name)
{
struct udev_monitor *_monitor = NULL;
return feature == PERIPHERAL_FEATURE_TRUE; \
}
+bool peripheral_is_privilege_supported(void);
int peripheral_create_udev_monitor(struct udev **udev, struct udev_monitor **monitor, const char *filter_name);
typedef bool (*UdevCompareFunc)(struct udev_device *, void *);
*/
int peripheral_adc_open(int device, int channel, peripheral_adc_h *adc)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "ADC feature is not supported");
RETVM_IF(adc == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid adc handle");
RETVM_IF(device < 0, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid adc device number");
*/
int peripheral_adc_close(peripheral_adc_h adc)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "ADC feature is not supported");
RETVM_IF(adc == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "adc handle is NULL");
*/
int peripheral_adc_read(peripheral_adc_h adc, uint32_t *value)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "ADC feature is not supported");
RETVM_IF(adc == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "adc handle is NULL");
RETVM_IF(value == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "adc read value is invalid");
{
int ret = PERIPHERAL_ERROR_NONE;
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "GPIO feature is not supported");
RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid gpio handle");
RETVM_IF(gpio_pin < 0, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid gpio pin number");
*/
int peripheral_gpio_close(peripheral_gpio_h gpio)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "GPIO feature is not supported");
RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
*/
int peripheral_gpio_set_direction(peripheral_gpio_h gpio, peripheral_gpio_direction_e direction)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "GPIO feature is not supported");
RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
RETVM_IF((direction < PERIPHERAL_GPIO_DIRECTION_IN) || (direction > PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid direction input");
*/
int peripheral_gpio_set_edge_mode(peripheral_gpio_h gpio, peripheral_gpio_edge_e edge)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "GPIO feature is not supported");
RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
RETVM_IF((edge < PERIPHERAL_GPIO_EDGE_NONE) || (edge > PERIPHERAL_GPIO_EDGE_BOTH), PERIPHERAL_ERROR_INVALID_PARAMETER, "edge input is invalid");
*/
int peripheral_gpio_set_interrupted_cb(peripheral_gpio_h gpio, peripheral_gpio_interrupted_cb callback, void *user_data)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "GPIO feature is not supported");
RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
RETVM_IF(callback == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio interrupted callback is NULL");
*/
int peripheral_gpio_unset_interrupted_cb(peripheral_gpio_h gpio)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "GPIO feature is not supported");
RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
*/
int peripheral_gpio_read(peripheral_gpio_h gpio, uint32_t *value)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "GPIO feature is not supported");
RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
RETVM_IF(value == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio read value is invalid");
*/
int peripheral_gpio_write(peripheral_gpio_h gpio, uint32_t value)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "GPIO feature is not supported");
RETVM_IF(gpio == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio handle is NULL");
RETVM_IF((value != 0) && (value != 1), PERIPHERAL_ERROR_INVALID_PARAMETER, "gpio value is invalid");
int ret;
char path[DEV_PATH_FMT_MAX_SIZE] = {0, }; /* space for /dev/i2c-%d */
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid i2c handle");
RETVM_IF(bus < 0 || address < 0, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
int peripheral_i2c_close(peripheral_i2c_h i2c)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
int peripheral_i2c_read(peripheral_i2c_h i2c, uint8_t *data_out, uint32_t length)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
RETVM_IF(data_out == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
int peripheral_i2c_write(peripheral_i2c_h i2c, uint8_t *data_in, uint32_t length)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
RETVM_IF(data_in == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
int peripheral_i2c_read_register_byte(peripheral_i2c_h i2c, uint8_t reg, uint8_t *data_out)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
RETVM_IF(data_out == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
int peripheral_i2c_write_register_byte(peripheral_i2c_h i2c, uint8_t reg, uint8_t data_in)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
int peripheral_i2c_read_register_word(peripheral_i2c_h i2c, uint8_t reg, uint16_t *data_out)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
RETVM_IF(data_out == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
int peripheral_i2c_write_register_word(peripheral_i2c_h i2c, uint8_t reg, uint16_t data_in)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "I2C feature is not supported");
RETVM_IF(i2c == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "i2c handle is NULL");
{
int ret = PERIPHERAL_ERROR_NONE;
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "PWM feature is not supported");
RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid pwm handle");
RETVM_IF(chip < 0 || pin < 0, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
int peripheral_pwm_close(peripheral_pwm_h pwm)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "PWM feature is not supported");
RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
int peripheral_pwm_set_period(peripheral_pwm_h pwm, uint32_t period_ns)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "PWM feature is not supported");
RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
int peripheral_pwm_set_duty_cycle(peripheral_pwm_h pwm, uint32_t duty_cycle_ns)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "PWM feature is not supported");
RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
int peripheral_pwm_set_polarity(peripheral_pwm_h pwm, peripheral_pwm_polarity_e polarity)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "PWM feature is not supported");
RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
RETVM_IF((polarity < PERIPHERAL_PWM_POLARITY_ACTIVE_HIGH) || (polarity > PERIPHERAL_PWM_POLARITY_ACTIVE_LOW), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid polarity parameter");
int peripheral_pwm_set_enabled(peripheral_pwm_h pwm, bool enable)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "PWM feature is not supported");
RETVM_IF(pwm == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "pwm handle is NULL");
int peripheral_spi_open(int bus, int cs, peripheral_spi_h *spi)
{
-
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid spi handle");
RETVM_IF(bus < 0 || cs < 0, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
int peripheral_spi_close(peripheral_spi_h spi)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
int peripheral_spi_set_mode(peripheral_spi_h spi, peripheral_spi_mode_e mode)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
RETVM_IF((mode < PERIPHERAL_SPI_MODE_0) || (mode > PERIPHERAL_SPI_MODE_3), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid spi mode parameter");
int peripheral_spi_set_bit_order(peripheral_spi_h spi, peripheral_spi_bit_order_e bit_order)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
RETVM_IF((bit_order < PERIPHERAL_SPI_BIT_ORDER_MSB) || (bit_order > PERIPHERAL_SPI_BIT_ORDER_LSB), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid bit order parameter");
int peripheral_spi_set_bits_per_word(peripheral_spi_h spi, uint8_t bits)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
int peripheral_spi_set_frequency(peripheral_spi_h spi, uint32_t freq_hz)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
int peripheral_spi_read(peripheral_spi_h spi, uint8_t *data, uint32_t length)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
RETVM_IF(data == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
int peripheral_spi_write(peripheral_spi_h spi, uint8_t *data, uint32_t length)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
RETVM_IF(data == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
int peripheral_spi_transfer(peripheral_spi_h spi, uint8_t *txdata, uint8_t *rxdata, uint32_t length)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "SPI feature is not supported");
RETVM_IF(spi == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "spi handle is NULL");
RETVM_IF(txdata == NULL || rxdata == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
*/
int peripheral_uart_open_flags(int port, peripheral_open_flags_e flags, peripheral_uart_h *uart)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid uart handle");
RETVM_IF(port < 0, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid port number");
int peripheral_uart_flush(peripheral_uart_h uart)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
int peripheral_uart_drain(peripheral_uart_h uart)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
*/
int peripheral_uart_close(peripheral_uart_h uart)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
*/
int peripheral_uart_set_baud_rate(peripheral_uart_h uart, peripheral_uart_baud_rate_e baud)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
RETVM_IF((baud < PERIPHERAL_UART_BAUD_RATE_0) || (baud > PERIPHERAL_UART_BAUD_RATE_230400), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid baud input");
int peripheral_uart_set_byte_size(peripheral_uart_h uart, peripheral_uart_byte_size_e byte_size)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
RETVM_IF((byte_size < PERIPHERAL_UART_BYTE_SIZE_5BIT) || (byte_size > PERIPHERAL_UART_BYTE_SIZE_8BIT), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
int peripheral_uart_set_parity(peripheral_uart_h uart, peripheral_uart_parity_e parity)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
RETVM_IF((parity < PERIPHERAL_UART_PARITY_NONE) || (parity > PERIPHERAL_UART_PARITY_ODD), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
int peripheral_uart_set_stop_bits(peripheral_uart_h uart, peripheral_uart_stop_bits_e stop_bits)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
RETVM_IF((stop_bits < PERIPHERAL_UART_STOP_BITS_1BIT) || (stop_bits > PERIPHERAL_UART_STOP_BITS_2BIT), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
*/
int peripheral_uart_set_flow_control(peripheral_uart_h uart, peripheral_uart_software_flow_control_e sw_flow_control, peripheral_uart_hardware_flow_control_e hw_flow_control)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
RETVM_IF((sw_flow_control < PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_NONE) || (sw_flow_control > PERIPHERAL_UART_SOFTWARE_FLOW_CONTROL_XONXOFF), PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid sw_flow_control parameter");
*/
int peripheral_uart_read(peripheral_uart_h uart, uint8_t *data, uint32_t length)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
RETVM_IF(data == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
*/
int peripheral_uart_write(peripheral_uart_h uart, uint8_t *data, uint32_t length)
{
+ RETVM_IF(!peripheral_is_privilege_supported(), PERIPHERAL_ERROR_PERMISSION_DENIED, "Peripheral-io privilege is not supported");
RETVM_IF(!__is_feature_supported(), PERIPHERAL_ERROR_NOT_SUPPORTED, "UART feature is not supported");
RETVM_IF(uart == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "uart handle is NULL");
RETVM_IF(data == NULL, PERIPHERAL_ERROR_INVALID_PARAMETER, "Invalid parameter");