]> sigrok.org Git - libserialport.git/blobdiff - serialport.c
Apply a default baudrate when the OS does not provide one.
[libserialport.git] / serialport.c
index d088398d9bbf226eb83d1c688871198b5ed0a9f4..e6097eeda975f914ec7b960f72c9e2df546e8281 100644 (file)
@@ -590,6 +590,15 @@ SP_API enum sp_return sp_open(struct sp_port *port, enum sp_mode flags)
                RETURN_CODEVAL(ret);
        }
 
+       /*
+        * Assume a default baudrate if the OS does not provide one.
+        * Cannot assign -1 here since Windows holds the baudrate in
+        * the DCB and does not configure the rate individually.
+        */
+       if (config.baudrate == 0) {
+               config.baudrate = 9600;
+       }
+
        /* Set sane port settings. */
 #ifdef _WIN32
        data.dcb.fBinary = TRUE;