serial: Full baudrate support on Windows/MinGW.

This commit is contained in:
Uwe Hermann 2012-12-02 13:56:13 +01:00
parent 39e5d79826
commit 5ae35c29a7
1 changed files with 43 additions and 16 deletions

View 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;
break;
case 9600:
dcb.BaudRate = CBR_9600;
break;
case 4800:
dcb.BaudRate = CBR_4800;
case 1200:
dcb.BaudRate = CBR_1200;
break;
case 2400:
dcb.BaudRate = CBR_2400;
break;
case 4800:
dcb.BaudRate = CBR_4800;
break;
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;
}