]> sigrok.org Git - libsigrok.git/blobdiff - src/serial.c
hwdriver: Add SR_CONF_DUTY_CYCLE & SR_CONF_PHASE.
[libsigrok.git] / src / serial.c
index 8ffba7956b09cd4e248627528d72bd56c674fd0a..1b76c935e3a0e1b73874b875185a18105f1f7f37 100644 (file)
@@ -561,6 +561,37 @@ SR_PRIV int serial_set_params(struct sr_serial_dev_inst *serial,
        return ret;
 }
 
+/**
+ * Manipulate handshake state for the specified serial port.
+ *
+ * @param serial Previously initialized serial port structure.
+ * @param[in] rts Status of RTS line (0 or 1; or -1 to ignore).
+ * @param[in] dtr Status of DTR line (0 or 1; or -1 to ignore).
+ *
+ * @retval SR_OK Success.
+ * @retval SR_ERR Failure.
+ *
+ * @private
+ */
+SR_PRIV int serial_set_handshake(struct sr_serial_dev_inst *serial,
+       int rts, int dtr)
+{
+       int ret;
+
+       if (!serial) {
+               sr_dbg("Invalid serial port.");
+               return SR_ERR;
+       }
+
+       sr_spew("Modifying serial parameters on port %s.", serial->port);
+
+       if (!serial->lib_funcs || !serial->lib_funcs->set_handshake)
+               return SR_ERR_NA;
+       ret = serial->lib_funcs->set_handshake(serial, rts, dtr);
+
+       return ret;
+}
+
 /**
  * Set serial parameters for the specified serial port from parameter string.
  *
@@ -836,7 +867,7 @@ SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial,
 
        *buflen = ibuf;
 
-       sr_err("Didn't find a valid packet (read %zu bytes).", *buflen);
+       sr_info("Didn't find a valid packet (read %zu bytes).", *buflen);
 
        return SR_ERR;
 }