diff --git a/hardware/agilent-dmm/api.c b/hardware/agilent-dmm/api.c index e67f0e02..d4c9427d 100644 --- a/hardware/agilent-dmm/api.c +++ b/hardware/agilent-dmm/api.c @@ -280,7 +280,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) /* Poll every 100ms, or whenever some data comes in. */ serial = sdi->conn; - sr_source_add(serial->fd, G_IO_IN, 100, agdmm_receive_data, (void *)sdi); + serial_source_add(serial, G_IO_IN, 100, agdmm_receive_data, (void *)sdi); return SR_OK; } diff --git a/hardware/brymen-dmm/api.c b/hardware/brymen-dmm/api.c index c03ed668..c676d47e 100644 --- a/hardware/brymen-dmm/api.c +++ b/hardware/brymen-dmm/api.c @@ -261,7 +261,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) /* Poll every 50ms, or whenever some data comes in. */ serial = sdi->conn; - sr_source_add(serial->fd, G_IO_IN, 50, + serial_source_add(serial, G_IO_IN, 50, brymen_dmm_receive_data, (void *)sdi); return SR_OK; diff --git a/hardware/cem-dt-885x/api.c b/hardware/cem-dt-885x/api.c index 6628d93d..9ff8e089 100644 --- a/hardware/cem-dt-885x/api.c +++ b/hardware/cem-dt-885x/api.c @@ -415,7 +415,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) /* Poll every 100ms, or whenever some data comes in. */ serial = sdi->conn; - sr_source_add(serial->fd, G_IO_IN, 150, cem_dt_885x_receive_data, + serial_source_add(serial, G_IO_IN, 150, cem_dt_885x_receive_data, (void *)sdi); return SR_OK; diff --git a/hardware/center-3xx/api.c b/hardware/center-3xx/api.c index 4cd8ab12..0960af82 100644 --- a/hardware/center-3xx/api.c +++ b/hardware/center-3xx/api.c @@ -257,7 +257,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, /* Poll every 500ms, or whenever some data comes in. */ serial = sdi->conn; - sr_source_add(serial->fd, G_IO_IN, 500, + serial_source_add(serial, G_IO_IN, 500, center_devs[idx].receive_data, (void *)sdi); return SR_OK; diff --git a/hardware/colead-slm/api.c b/hardware/colead-slm/api.c index 98472004..9848cc59 100644 --- a/hardware/colead-slm/api.c +++ b/hardware/colead-slm/api.c @@ -227,7 +227,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) /* Poll every 150ms, or whenever some data comes in. */ serial = sdi->conn; - sr_source_add(serial->fd, G_IO_IN, 150, colead_slm_receive_data, + serial_source_add(serial, G_IO_IN, 150, colead_slm_receive_data, (void *)sdi); return SR_OK; diff --git a/hardware/common/scpi_serial.c b/hardware/common/scpi_serial.c index 0b1e30d8..5c07c43c 100644 --- a/hardware/common/scpi_serial.c +++ b/hardware/common/scpi_serial.c @@ -53,7 +53,7 @@ SR_PRIV int scpi_serial_source_add(void *priv, int events, int timeout, { struct sr_serial_dev_inst *serial = priv; - return sr_source_add(serial->fd, events, timeout, cb, cb_data); + return serial_source_add(serial, events, timeout, cb, cb_data); } SR_PRIV int scpi_serial_source_remove(void *priv) diff --git a/hardware/common/serial.c b/hardware/common/serial.c index e181f233..a0de0de5 100644 --- a/hardware/common/serial.c +++ b/hardware/common/serial.c @@ -638,3 +638,9 @@ SR_PRIV int sr_serial_extract_options(GSList *options, const char **serial_devic return SR_OK; } + +SR_PRIV int serial_source_add(struct sr_serial_dev_inst *serial, int events, + int timeout, sr_receive_data_callback_t cb, void *cb_data) +{ + return sr_source_add(serial->fd, events, timeout, cb, cb_data); +} diff --git a/hardware/fluke-dmm/api.c b/hardware/fluke-dmm/api.c index 604d65f4..0e6c938a 100644 --- a/hardware/fluke-dmm/api.c +++ b/hardware/fluke-dmm/api.c @@ -313,7 +313,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) /* Poll every 100ms, or whenever some data comes in. */ serial = sdi->conn; - sr_source_add(serial->fd, G_IO_IN, 50, fluke_receive_data, (void *)sdi); + serial_source_add(serial, G_IO_IN, 50, fluke_receive_data, (void *)sdi); if (serial_write(serial, "QM\r", 3) == -1) { sr_err("Unable to send QM: %s.", strerror(errno)); diff --git a/hardware/gmc-mh-1x-2x/api.c b/hardware/gmc-mh-1x-2x/api.c index 42969412..615209ec 100644 --- a/hardware/gmc-mh-1x-2x/api.c +++ b/hardware/gmc-mh-1x-2x/api.c @@ -363,7 +363,7 @@ static int dev_acq_start_1x_2x_rs232(const struct sr_dev_inst *sdi, /* Poll every 40ms, or whenever some data comes in. */ serial = sdi->conn; - sr_source_add(serial->fd, G_IO_IN, 40, gmc_mh_1x_2x_receive_data, + serial_source_add(serial, G_IO_IN, 40, gmc_mh_1x_2x_receive_data, (void *)sdi); return SR_OK; diff --git a/hardware/link-mso19/api.c b/hardware/link-mso19/api.c index 6a93ba94..56d7700a 100644 --- a/hardware/link-mso19/api.c +++ b/hardware/link-mso19/api.c @@ -473,7 +473,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) /* Our first probe is analog, the other 8 are of type 'logic'. */ /* TODO. */ - sr_source_add(devc->serial->fd, G_IO_IN, -1, mso_receive_data, cb_data); + serial_source_add(devc->serial, G_IO_IN, -1, mso_receive_data, cb_data); return SR_OK; } diff --git a/hardware/mic-985xx/api.c b/hardware/mic-985xx/api.c index 5785e4eb..7983c4ae 100644 --- a/hardware/mic-985xx/api.c +++ b/hardware/mic-985xx/api.c @@ -259,7 +259,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, /* Poll every 100ms, or whenever some data comes in. */ serial = sdi->conn; - sr_source_add(serial->fd, G_IO_IN, 100, + serial_source_add(serial, G_IO_IN, 100, mic_devs[idx].receive_data, (void *)sdi); return SR_OK; diff --git a/hardware/norma-dmm/api.c b/hardware/norma-dmm/api.c index 6523e93a..ed8378ca 100644 --- a/hardware/norma-dmm/api.c +++ b/hardware/norma-dmm/api.c @@ -293,7 +293,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, /* Poll every 100ms, or whenever some data comes in. */ serial = sdi->conn; - sr_source_add(serial->fd, G_IO_IN, 100, norma_dmm_receive_data, + serial_source_add(serial, G_IO_IN, 100, norma_dmm_receive_data, (void *)sdi); return SR_OK; diff --git a/hardware/openbench-logic-sniffer/api.c b/hardware/openbench-logic-sniffer/api.c index a38bbf83..e199f09b 100644 --- a/hardware/openbench-logic-sniffer/api.c +++ b/hardware/openbench-logic-sniffer/api.c @@ -537,7 +537,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, /* Send header packet to the session bus. */ std_session_send_df_header(cb_data, LOG_PREFIX); - sr_source_add(serial->fd, G_IO_IN, -1, ols_receive_data, cb_data); + serial_source_add(serial, G_IO_IN, -1, ols_receive_data, cb_data); return SR_OK; } diff --git a/hardware/serial-dmm/api.c b/hardware/serial-dmm/api.c index ef57f318..9ec347d7 100644 --- a/hardware/serial-dmm/api.c +++ b/hardware/serial-dmm/api.c @@ -495,7 +495,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, /* Poll every 50ms, or whenever some data comes in. */ serial = sdi->conn; - sr_source_add(serial->fd, G_IO_IN, 50, + serial_source_add(serial, G_IO_IN, 50, dmms[dmm].receive_data, (void *)sdi); return SR_OK; diff --git a/hardware/teleinfo/api.c b/hardware/teleinfo/api.c index d129987d..861f4104 100644 --- a/hardware/teleinfo/api.c +++ b/hardware/teleinfo/api.c @@ -283,7 +283,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) std_session_send_df_header(cb_data, LOG_PREFIX); /* Poll every 50ms, or whenever some data comes in. */ - sr_source_add(serial->fd, G_IO_IN, 50, teleinfo_receive_data, (void *)sdi); + serial_source_add(serial, G_IO_IN, 50, teleinfo_receive_data, (void *)sdi); return SR_OK; } diff --git a/hardware/tondaj-sl-814/api.c b/hardware/tondaj-sl-814/api.c index bb13e289..533f69fb 100644 --- a/hardware/tondaj-sl-814/api.c +++ b/hardware/tondaj-sl-814/api.c @@ -223,7 +223,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, /* Poll every 500ms, or whenever some data comes in. */ serial = sdi->conn; - sr_source_add(serial->fd, G_IO_IN, 500, + serial_source_add(serial, G_IO_IN, 500, tondaj_sl_814_receive_data, (void *)sdi); return SR_OK; diff --git a/libsigrok-internal.h b/libsigrok-internal.h index e81170c7..e4eef91e 100644 --- a/libsigrok-internal.h +++ b/libsigrok-internal.h @@ -228,6 +228,8 @@ SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial, uint64_t timeout_ms, int baudrate); SR_PRIV int sr_serial_extract_options(GSList *options, const char **serial_device, const char **serial_options); +SR_PRIV int serial_source_add(struct sr_serial_dev_inst *serial, int events, + int timeout, sr_receive_data_callback_t cb, void *cb_data); #endif /*--- hardware/common/ezusb.c -----------------------------------------------*/