Apply a default baudrate when the OS does not provide one.

Handle the situation when the OS does not provide a baudrate in the code
path which opens the serial port. See bug #1632 and PR #6 for details.

  https://sigrok.org/bugzilla/show_bug.cgi?id=1632
  https://github.com/sigrokproject/libserialport/pull/6

This resolves bug #1632.

[ gsi: adjust comment style, rephrase comment and commit message ]
This commit is contained in:
Jerry Jacobs 2021-06-14 18:22:58 +02:00 committed by Gerhard Sittig
parent a06a765515
commit 1abec20502
1 changed files with 9 additions and 0 deletions

View 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;