]> sigrok.org Git - libserialport.git/commitdiff
Retrieve current control line settings in start_config.
authorMartin Ling <redacted>
Thu, 14 Nov 2013 21:27:06 +0000 (21:27 +0000)
committerMartin Ling <redacted>
Fri, 15 Nov 2013 11:43:07 +0000 (11:43 +0000)
serialport.c

index 58880d4c4cd868a2b729a44639ef2daf0fb49137..83cb52913687e94c3bd50b0a0cdc798cb7bb4038 100644 (file)
@@ -504,8 +504,24 @@ static int start_config(struct sp_port *port, struct sp_port_data *data)
        if (!GetCommState(port->hdl, &data->dcb))
                return SP_ERR_FAIL;
 #else
+       int controlbits;
+
        if (tcgetattr(port->fd, &data->term) < 0)
                return SP_ERR_FAIL;
+
+       if (ioctl(port->fd, TIOCMGET, &controlbits) < 0)
+               return SP_ERR_FAIL;
+
+       if (data->term.c_cflag & CRTSCTS) {
+               data->rts = SP_RTS_FLOW_CONTROL;
+               data->cts = SP_CTS_FLOW_CONTROL;
+       } else {
+               data->rts = (controlbits & TIOCM_RTS) ? SP_RTS_ON : SP_RTS_OFF;
+               data->cts = SP_CTS_IGNORE;
+       }
+
+       data->dtr = (controlbits & TIOCM_DTR) ? SP_DTR_ON : SP_DTR_OFF;
+       data->dsr = SP_DSR_IGNORE;
 #endif
        return SP_OK;
 }