]> sigrok.org Git - libsigrok.git/commitdiff
serial: Full baudrate support on Windows/MinGW.
authorUwe Hermann <redacted>
Sun, 2 Dec 2012 12:56:13 +0000 (13:56 +0100)
committerUwe Hermann <redacted>
Sun, 2 Dec 2012 12:56:13 +0000 (13:56 +0100)
hardware/common/serial.c

index 6c8f63b0fe75d8289e7840d9bf59717b546e527f..580bca7e1ee768f40cfc67438277584ba0b602fd 100644 (file)
@@ -329,31 +329,58 @@ SR_PRIV int serial_set_params(struct sr_serial_dev_inst *serial, int baudrate,
                return SR_ERR;
 
        switch (baudrate) {
-       case 115200:
-               dcb.BaudRate = CBR_115200;
+       /*
+        * The baudrates 50/75/134/150/200/1800/230400/460800 do not seem to
+        * have documented CBR_* macros.
+        */
+       case 110:
+               dcb.BaudRate = CBR_110;
                break;
-       case 57600:
-               dcb.BaudRate = CBR_57600;
+       case 300:
+               dcb.BaudRate = CBR_300;
                break;
-       case 38400:
-               dcb.BaudRate = CBR_38400;
+       case 600:
+               dcb.BaudRate = CBR_600;
                break;
-       case 19200:
-               dcb.BaudRate = CBR_19200;
+       case 1200:
+               dcb.BaudRate = CBR_1200;
                break;
-       case 9600:
-               dcb.BaudRate = CBR_9600;
+       case 2400:
+               dcb.BaudRate = CBR_2400;
                break;
        case 4800:
                dcb.BaudRate = CBR_4800;
                break;
-       case 2400:
-               dcb.BaudRate = CBR_2400;
+       case 9600:
+               dcb.BaudRate = CBR_9600;
+               break;
+       case 14400:
+               dcb.BaudRate = CBR_14400; /* Not available on Unix? */
+               break;
+       case 19200:
+               dcb.BaudRate = CBR_19200;
+               break;
+       case 38400:
+               dcb.BaudRate = CBR_38400;
+               break;
+       case 57600:
+               dcb.BaudRate = CBR_57600;
+               break;
+       case 115200:
+               dcb.BaudRate = CBR_115200;
+               break;
+       case 128000:
+               dcb.BaudRate = CBR_128000; /* Not available on Unix? */
+               break;
+       case 256000:
+               dcb.BaudRate = CBR_256000; /* Not available on Unix? */
                break;
        default:
-               sr_err("Unsupported baudrate %d.", baudrate);
+               sr_err("Unsupported baudrate: %d.", baudrate);
                return SR_ERR;
        }
+       sr_spew("Configuring baudrate to %d (%d).", baudrate, dcb.BaudRate);
+
        dcb.ByteSize = bits;
        dcb.Parity = NOPARITY; /* TODO: Don't hardcode. */
        dcb.StopBits = ONESTOPBIT; /* TODO: Don't hardcode. */
@@ -448,7 +475,7 @@ SR_PRIV int serial_set_params(struct sr_serial_dev_inst *serial, int baudrate,
                break;
 #endif
        default:
-               sr_err("Unsupported baudrate %d.", baudrate);
+               sr_err("Unsupported baudrate: %d.", baudrate);
                return SR_ERR;
        }