]> sigrok.org Git - libsigrok.git/commitdiff
sr: use proper definitions for parity setting
authorBert Vermeulen <redacted>
Sun, 1 Jul 2012 20:31:31 +0000 (22:31 +0200)
committerBert Vermeulen <redacted>
Sun, 1 Jul 2012 20:31:31 +0000 (22:31 +0200)
ols driver fixed to use these as well.

hardware/common/serial.c
hardware/openbench-logic-sniffer/ols.c
sigrok-internal.h

index cd7002b8345d8be7e76d6624e7cac8a39fafa14f..822b4ccd5c97f0fcf14674f125b69e317b029bce 100644 (file)
@@ -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:
index fd932c57654f24b84bd0f28c7b57f7e69b0a3bc5..65a04f1a4233f10461bbd1240a27b843bde0d6cd 100644 (file)
@@ -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,
index fde076bb931ab4bbf09ff62f9649ac3409ad054f..94ca2bc90a94bd08be177075471795335b6ff344 100644 (file)
@@ -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;