SR_PRIV int std_dummy_set_params(struct sr_serial_dev_inst *serial,
int baudrate, int bits, int parity, int stopbits,
int flowcontrol, int rts, int dtr);
+SR_PRIV int std_dummy_set_handshake(struct sr_serial_dev_inst *serial,
+ int rts, int dtr);
/*--- resource.c ------------------------------------------------------------*/
serial_rx_chunk_callback cb, void *cb_data);
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);
+SR_PRIV int serial_set_handshake(struct sr_serial_dev_inst *serial,
+ int rts, int dtr);
SR_PRIV int serial_set_paramstr(struct sr_serial_dev_inst *serial,
const char *paramstr);
SR_PRIV int serial_readline(struct sr_serial_dev_inst *serial, char **buf,
int (*set_params)(struct sr_serial_dev_inst *serial,
int baudrate, int bits, int parity, int stopbits,
int flowcontrol, int rts, int dtr);
+ int (*set_handshake)(struct sr_serial_dev_inst *serial,
+ int rts, int dtr);
int (*setup_source_add)(struct sr_session *session,
struct sr_serial_dev_inst *serial,
int events, int timeout,
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.
*
* here, since the caller will cache/register them already.
*/
.set_params = std_dummy_set_params,
+ .set_handshake = std_dummy_set_handshake,
.setup_source_add = ser_bt_setup_source_add,
.setup_source_remove = ser_bt_setup_source_remove,
.list = ser_bt_list,
.write = ser_hid_write,
.read = ser_hid_read,
.set_params = ser_hid_set_params,
+ .set_handshake = std_dummy_set_handshake,
.setup_source_add = ser_hid_setup_source_add,
.setup_source_remove = ser_hid_setup_source_remove,
.list = ser_hid_list,
return SR_OK;
}
+static int sr_ser_libsp_set_handshake(struct sr_serial_dev_inst *serial,
+ int rts, int dtr)
+{
+ int ret;
+
+ if (!serial->sp_data) {
+ sr_dbg("Cannot configure unopened serial port %s.", serial->port);
+ return SR_ERR;
+ }
+
+ if (rts >= 0) {
+ ret = sp_set_rts(serial->sp_data, rts ? SP_RTS_ON : SP_RTS_OFF);
+ if (ret != SP_OK)
+ return SR_ERR;
+ }
+ if (dtr >= 0) {
+ ret = sp_set_dtr(serial->sp_data, dtr ? SP_DTR_ON : SP_DTR_OFF);
+ if (ret != SP_OK)
+ return SR_ERR;
+ }
+
+ return SR_OK;
+}
+
#ifdef G_OS_WIN32
typedef HANDLE event_handle;
#else
.write = sr_ser_libsp_write,
.read = sr_ser_libsp_read,
.set_params = sr_ser_libsp_set_params,
+ .set_handshake = sr_ser_libsp_set_handshake,
.setup_source_add = sr_ser_libsp_source_add,
.setup_source_remove = sr_ser_libsp_source_remove,
.list = sr_ser_libsp_list,
return SR_OK;
}
+SR_PRIV int std_dummy_set_handshake(struct sr_serial_dev_inst *serial,
+ int rts, int dtr)
+{
+ (void)serial;
+ (void)rts;
+ (void)dtr;
+
+ return SR_OK;
+}