diff --git a/hardware/common/serial.c b/hardware/common/serial.c index cd7002b8..822b4ccd 100644 --- a/hardware/common/serial.c +++ b/hardware/common/serial.c @@ -297,13 +297,13 @@ SR_PRIV int serial_set_params(int fd, int baudrate, int bits, int parity, term.c_iflag &= ~IGNPAR; term.c_cflag &= ~(PARODD | PARENB); switch (parity) { - case 0: + case SERIAL_PARITY_NONE: term.c_iflag |= IGNPAR; break; - case 1: + case SERIAL_PARITY_EVEN: term.c_cflag |= PARENB; break; - case 2: + case SERIAL_PARITY_ODD: term.c_cflag |= PARENB | PARODD; break; default: diff --git a/hardware/openbench-logic-sniffer/ols.c b/hardware/openbench-logic-sniffer/ols.c index fd932c57..65a04f1a 100644 --- a/hardware/openbench-logic-sniffer/ols.c +++ b/hardware/openbench-logic-sniffer/ols.c @@ -398,7 +398,7 @@ static int hw_init(const char *devinfo) fd = serial_open(l->data, O_RDWR | O_NONBLOCK); if (fd != -1) { serial_params[devcnt] = serial_backup_params(fd); - serial_set_params(fd, 115200, 8, 0, 1, 2); + serial_set_params(fd, 115200, 8, SERIAL_PARITY_NONE, 1, 2); ret = SR_OK; for (i = 0; i < 5; i++) { if ((ret = send_shortcommand(fd, diff --git a/sigrok-internal.h b/sigrok-internal.h index fde076bb..94ca2bc9 100644 --- a/sigrok-internal.h +++ b/sigrok-internal.h @@ -48,6 +48,9 @@ struct sr_usb_dev_inst { }; #endif +#define SERIAL_PARITY_NONE 0 +#define SERIAL_PARITY_EVEN 1 +#define SERIAL_PARITY_ODD 2 struct sr_serial_dev_inst { char *port; int fd;