serial: RTS/DTR support on Windows/MinGW.
This commit is contained in:
parent
a54dd31e38
commit
39e5d79826
|
@ -305,7 +305,8 @@ SR_PRIV int serial_read(struct sr_serial_dev_inst *serial, void *buf,
|
|||
* @return SR_OK upon success, SR_ERR upon failure.
|
||||
*/
|
||||
SR_PRIV int serial_set_params(struct sr_serial_dev_inst *serial, int baudrate,
|
||||
int bits, int parity, int stopbits, int flowcontrol, int rts, int dtr)
|
||||
int bits, int parity, int stopbits,
|
||||
int flowcontrol, int rts, int dtr)
|
||||
{
|
||||
if (!serial) {
|
||||
sr_dbg("Invalid serial port.");
|
||||
|
@ -357,6 +358,22 @@ SR_PRIV int serial_set_params(struct sr_serial_dev_inst *serial, int baudrate,
|
|||
dcb.Parity = NOPARITY; /* TODO: Don't hardcode. */
|
||||
dcb.StopBits = ONESTOPBIT; /* TODO: Don't hardcode. */
|
||||
|
||||
if (rts != -1) {
|
||||
sr_spew("Setting RTS %s.", rts ? "high" : "low");
|
||||
if (rts)
|
||||
dcb.fRtsControl = RTS_CONTROL_ENABLE;
|
||||
else
|
||||
dcb.fRtsControl = RTS_CONTROL_DISABLE;
|
||||
}
|
||||
|
||||
if (dtr != -1) {
|
||||
sr_spew("Setting DTR %s.", dtr ? "high" : "low");
|
||||
if (rts)
|
||||
dcb.fDtrControl = DTR_CONTROL_ENABLE;
|
||||
else
|
||||
dcb.fDtrControl = DTR_CONTROL_DISABLE;
|
||||
}
|
||||
|
||||
if (!SetCommState(hdl, &dcb))
|
||||
return SR_ERR;
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue