From: Uwe Hermann Date: Sun, 2 Dec 2012 12:56:13 +0000 (+0100) Subject: serial: Full baudrate support on Windows/MinGW. X-Git-Tag: dsupstream~520 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=5ae35c29a7010cd018e43d04a809e1c60b7b72fa;p=libsigrok.git serial: Full baudrate support on Windows/MinGW. --- diff --git a/hardware/common/serial.c b/hardware/common/serial.c index 6c8f63b0..580bca7e 100644 --- a/hardware/common/serial.c +++ b/hardware/common/serial.c @@ -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; }