mirror of
git://sigrok.org/libserialport
synced 2023-08-10 21:13:24 +03:00
Fix the build on NetBSD/OpenBSD/FreeBSD, possibly others.
Various termios flags used in sp_open() are Linux-specific (or even specific to certain architectures / drivers) and not available on all OSes (and/or versions or kernels thereof). Thus, #ifdef out flags that we know might not be available everywhere.
This commit is contained in:
parent
bccc7c9fa0
commit
c3e0509275
45
serialport.c
45
serialport.c
@ -671,8 +671,32 @@ enum sp_return sp_open(struct sp_port *port, enum sp_mode flags)
|
|||||||
data.dcb.fAbortOnError = TRUE;
|
data.dcb.fAbortOnError = TRUE;
|
||||||
#else
|
#else
|
||||||
/* Turn off all fancy termios tricks, give us a raw channel. */
|
/* Turn off all fancy termios tricks, give us a raw channel. */
|
||||||
data.term.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IUCLC|IMAXBEL);
|
data.term.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IMAXBEL);
|
||||||
data.term.c_oflag &= ~(OPOST|OLCUC|ONLCR|OCRNL|ONOCR|ONLRET|NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY);
|
#ifdef IUCLC
|
||||||
|
data.term.c_iflag &= ~IUCLC;
|
||||||
|
#endif
|
||||||
|
data.term.c_oflag &= ~(OPOST | ONLCR | OCRNL | ONOCR | ONLRET);
|
||||||
|
#ifdef OLCUC
|
||||||
|
data.term.c_oflag &= ~OLCUC;
|
||||||
|
#endif
|
||||||
|
#ifdef NLDLY
|
||||||
|
data.term.c_oflag &= ~NLDLY;
|
||||||
|
#endif
|
||||||
|
#ifdef CRDLY
|
||||||
|
data.term.c_oflag &= ~CRDLY;
|
||||||
|
#endif
|
||||||
|
#ifdef TABDLY
|
||||||
|
data.term.c_oflag &= ~TABDLY;
|
||||||
|
#endif
|
||||||
|
#ifdef BSDLY
|
||||||
|
data.term.c_oflag &= ~BSDLY;
|
||||||
|
#endif
|
||||||
|
#ifdef VTDLY
|
||||||
|
data.term.c_oflag &= ~VTDLY;
|
||||||
|
#endif
|
||||||
|
#ifdef FFDLY
|
||||||
|
data.term.c_oflag &= ~FFDLY;
|
||||||
|
#endif
|
||||||
#ifdef OFILL
|
#ifdef OFILL
|
||||||
data.term.c_oflag &= ~OFILL;
|
data.term.c_oflag &= ~OFILL;
|
||||||
#endif
|
#endif
|
||||||
@ -1166,8 +1190,10 @@ static enum sp_return get_config(struct sp_port *port, struct port_data *data,
|
|||||||
config->parity = SP_PARITY_NONE;
|
config->parity = SP_PARITY_NONE;
|
||||||
else if (!(data->term.c_cflag & PARENB) || (data->term.c_iflag & IGNPAR))
|
else if (!(data->term.c_cflag & PARENB) || (data->term.c_iflag & IGNPAR))
|
||||||
config->parity = -1;
|
config->parity = -1;
|
||||||
|
#ifdef CMSPAR
|
||||||
else if (data->term.c_cflag & CMSPAR)
|
else if (data->term.c_cflag & CMSPAR)
|
||||||
config->parity = (data->term.c_cflag & PARODD) ? SP_PARITY_MARK : SP_PARITY_SPACE;
|
config->parity = (data->term.c_cflag & PARODD) ? SP_PARITY_MARK : SP_PARITY_SPACE;
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
config->parity = (data->term.c_cflag & PARODD) ? SP_PARITY_ODD : SP_PARITY_EVEN;
|
config->parity = (data->term.c_cflag & PARODD) ? SP_PARITY_ODD : SP_PARITY_EVEN;
|
||||||
|
|
||||||
@ -1417,7 +1443,10 @@ static enum sp_return set_config(struct sp_port *port, struct port_data *data,
|
|||||||
|
|
||||||
if (config->parity >= 0) {
|
if (config->parity >= 0) {
|
||||||
data->term.c_iflag &= ~IGNPAR;
|
data->term.c_iflag &= ~IGNPAR;
|
||||||
data->term.c_cflag &= ~(PARENB | PARODD | CMSPAR);
|
data->term.c_cflag &= ~(PARENB | PARODD);
|
||||||
|
#ifdef CMSPAR
|
||||||
|
data->term.c_cflag &= ~CMSPAR;
|
||||||
|
#endif
|
||||||
switch (config->parity) {
|
switch (config->parity) {
|
||||||
case SP_PARITY_NONE:
|
case SP_PARITY_NONE:
|
||||||
data->term.c_iflag |= IGNPAR;
|
data->term.c_iflag |= IGNPAR;
|
||||||
@ -1429,10 +1458,16 @@ static enum sp_return set_config(struct sp_port *port, struct port_data *data,
|
|||||||
data->term.c_cflag |= PARENB | PARODD;
|
data->term.c_cflag |= PARENB | PARODD;
|
||||||
break;
|
break;
|
||||||
case SP_PARITY_MARK:
|
case SP_PARITY_MARK:
|
||||||
data->term.c_cflag |= PARENB | PARODD | CMSPAR;
|
data->term.c_cflag |= PARENB | PARODD;
|
||||||
|
#ifdef CMSPAR
|
||||||
|
data->term.c_cflag |= CMSPAR;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case SP_PARITY_SPACE:
|
case SP_PARITY_SPACE:
|
||||||
data->term.c_cflag |= PARENB | CMSPAR;
|
data->term.c_cflag |= PARENB;
|
||||||
|
#ifdef CMSPAR
|
||||||
|
data->term.c_cflag |= CMSPAR;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
RETURN_ERROR(SP_ERR_ARG, "Invalid parity setting");
|
RETURN_ERROR(SP_ERR_ARG, "Invalid parity setting");
|
||||||
|
Loading…
Reference in New Issue
Block a user