int peripheral_interface_uart_close(peripheral_uart_h uart)
{
- int status;
+ int ret;
- status = peripheral_interface_uart_flush(uart);
- CHECK_ERROR(status);
+ peripheral_interface_uart_flush(uart);
- status = close(uart->fd);
- CHECK_ERROR(status);
+ ret = close(uart->fd);
+ CHECK_ERROR(ret != 0);
return 0;
}
int peripheral_interface_uart_flush(peripheral_uart_h uart)
{
int ret = tcflush(uart->fd, TCIOFLUSH);
- CHECK_ERROR(ret);
+ CHECK_ERROR(ret != 0);
return 0;
}
struct termios tio;
ret = tcgetattr(uart->fd, &tio);
- CHECK_ERROR(ret);
+ CHECK_ERROR(ret != 0);
tio.c_cflag = peripheral_uart_br[baud];
tio.c_iflag = IGNPAR;
peripheral_interface_uart_flush(uart);
ret = tcsetattr(uart->fd, TCSANOW, &tio);
- CHECK_ERROR(ret);
+ CHECK_ERROR(ret != 0);
return 0;
}
struct termios tio;
ret = tcgetattr(uart->fd, &tio);
- CHECK_ERROR(ret);
+ CHECK_ERROR(ret != 0);
/* set byte size */
tio.c_cflag &= ~CSIZE;
peripheral_interface_uart_flush(uart);
ret = tcsetattr(uart->fd, TCSANOW, &tio);
- CHECK_ERROR(ret);
+ CHECK_ERROR(ret != 0);
return 0;
}
struct termios tio;
ret = tcgetattr(uart->fd, &tio);
- CHECK_ERROR(ret);
+ CHECK_ERROR(ret != 0);
/* set parity info */
switch (parity) {
peripheral_interface_uart_flush(uart);
ret = tcsetattr(uart->fd, TCSANOW, &tio);
- CHECK_ERROR(ret);
+ CHECK_ERROR(ret != 0);
return 0;
}
struct termios tio;
ret = tcgetattr(uart->fd, &tio);
- CHECK_ERROR(ret);
+ CHECK_ERROR(ret != 0);
/* set stop bit */
switch (stop_bits) {
peripheral_interface_uart_flush(uart);
ret = tcsetattr(uart->fd, TCSANOW, &tio);
- CHECK_ERROR(ret);
+ CHECK_ERROR(ret != 0);
return 0;
}
struct termios tio;
ret = tcgetattr(uart->fd, &tio);
- CHECK_ERROR(ret);
+ CHECK_ERROR(ret != 0);
if (rtscts == PERIPHERAL_UART_HARDWARE_FLOW_CONTROL_AUTO_RTSCTS)
tio.c_cflag |= CRTSCTS;
return -EINVAL;
ret = tcsetattr(uart->fd, TCSANOW, &tio);
- CHECK_ERROR(ret);
+ CHECK_ERROR(ret != 0);
return 0;
}
int peripheral_interface_uart_read(peripheral_uart_h uart, uint8_t *buf, uint32_t length)
{
int ret = read(uart->fd, (void *)buf, length);
- CHECK_ERROR(ret);
+ CHECK_ERROR(ret != length);
return ret;
}
int peripheral_interface_uart_write(peripheral_uart_h uart, uint8_t *buf, uint32_t length)
{
int ret = write(uart->fd, buf, length);
- CHECK_ERROR(ret);
+ CHECK_ERROR(ret != length);
return ret;
}