fix flags for serial passthrough on unix

This commit is contained in:
Aleš Hakl
2023-09-15 16:49:33 +02:00
parent b3dbfcfc9a
commit 129950b5af

View File

@@ -149,7 +149,7 @@ plat_serpt_set_params(void *priv)
BAUDRATE_RANGE(dev->baudrate, 57600, 115200, B57600); BAUDRATE_RANGE(dev->baudrate, 57600, 115200, B57600);
BAUDRATE_RANGE(dev->baudrate, 115200, 0xFFFFFFFF, B115200); BAUDRATE_RANGE(dev->baudrate, 115200, 0xFFFFFFFF, B115200);
term_attr.c_cflag &= CSIZE; term_attr.c_cflag &= ~CSIZE;
switch (dev->data_bits) { switch (dev->data_bits) {
case 8: case 8:
default: default:
@@ -165,13 +165,13 @@ plat_serpt_set_params(void *priv)
term_attr.c_cflag |= CS5; term_attr.c_cflag |= CS5;
break; break;
} }
term_attr.c_cflag &= CSTOPB; term_attr.c_cflag &= ~CSTOPB;
if (dev->serial->lcr & 0x04) if (dev->serial->lcr & 0x04)
term_attr.c_cflag |= CSTOPB; term_attr.c_cflag |= CSTOPB;
#if !defined(__linux__) #if !defined(__linux__)
term_attr.c_cflag &= PARENB | PARODD; term_attr.c_cflag &= ~(PARENB | PARODD);
#else #else
term_attr.c_cflag &= PARENB | PARODD | CMSPAR; term_attr.c_cflag &= ~(PARENB | PARODD | CMSPAR);
#endif #endif
if (dev->serial->lcr & 0x08) { if (dev->serial->lcr & 0x08) {
term_attr.c_cflag |= PARENB; term_attr.c_cflag |= PARENB;
@@ -182,6 +182,7 @@ plat_serpt_set_params(void *priv)
term_attr.c_cflag |= CMSPAR; term_attr.c_cflag |= CMSPAR;
#endif #endif
} }
printf("c_cflag=%08x\n", term_attr.c_cflag);
tcsetattr(dev->master_fd, TCSANOW, &term_attr); tcsetattr(dev->master_fd, TCSANOW, &term_attr);
#undef BAUDRATE_RANGE #undef BAUDRATE_RANGE
} }