Skip to content

Commit d20da6e

Browse files
vigneshraja123717root
authored andcommitted
uart stop bits configurable
1 parent 707217f commit d20da6e

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

lib/platform/linux-uart.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ struct switchtec_uart{
119119
#define UART_MAX_READ_BYTES 1024
120120
#define RETRY_NUM 3
121121
#define SWITCHTEC_UART_BAUDRATE (B230400)
122+
#define SWITCHTEC_UART_STOP_BITS (2)
122123

123124
static int send_cmd(int fd, const char *fmt, int write_bytes, ...)
124125
{
@@ -461,7 +462,7 @@ static const struct switchtec_ops uart_ops = {
461462
.write_from_gas = uart_write_from_gas,
462463
};
463464

464-
static int set_uart_attribs(int fd, int speed, int parity)
465+
static int set_uart_attribs(int fd, int speed, int parity, int stop_bits)
465466
{
466467
int ret;
467468
struct termios uart_attribs;
@@ -482,7 +483,10 @@ static int set_uart_attribs(int fd, int speed, int parity)
482483
uart_attribs.c_cflag |= (CLOCAL | CREAD);
483484
uart_attribs.c_cflag &= ~(PARENB | PARODD);
484485
uart_attribs.c_cflag |= parity;
485-
uart_attribs.c_cflag |= CSTOPB;
486+
if(stop_bits == 1)
487+
uart_attribs.c_cflag &= ~CSTOPB;
488+
else if (stop_bits == 2)
489+
uart_attribs.c_cflag |= CSTOPB;
486490
uart_attribs.c_cflag &= ~CRTSCTS;
487491
uart_attribs.c_cc[VMIN] = 0;
488492
uart_attribs.c_cc[VTIME] = 50;
@@ -511,7 +515,7 @@ struct switchtec_dev *switchtec_open_uart(int fd)
511515
if (ret)
512516
goto err_close_free;
513517

514-
ret = set_uart_attribs(udev->fd, SWITCHTEC_UART_BAUDRATE, 0);
518+
ret = set_uart_attribs(udev->fd, SWITCHTEC_UART_BAUDRATE, 0, SWITCHTEC_UART_STOP_BITS);
515519
if (ret)
516520
goto err_close_free;
517521

lib/switchtec.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,11 +1497,9 @@ static int log_d_to_file(struct switchtec_dev *dev, int sub_cmd_id, int fd)
14971497
cmd.req_seq = 0;
14981498
res.data[1] = 0;
14991499

1500-
printf("calling ftdc MRPC command\n");
15011500
while ( !(res.data[1]) ) {
15021501
ret = switchtec_cmd(dev, MRPC_FTDC_LOG_DUMP, &cmd, sizeof(cmd),
15031502
&res, sizeof(res));
1504-
printf("ftdc ret %d\n", ret);
15051503
if (ret)
15061504
return -1;
15071505

0 commit comments

Comments
 (0)