Route sr_source_add for all serial devices through a serial_source_add wrapper.

This commit is contained in:
Martin Ling 2013-11-30 12:54:02 +00:00
parent b4936bae0a
commit abc4b3356d
17 changed files with 23 additions and 15 deletions

View File

@ -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. */ /* Poll every 100ms, or whenever some data comes in. */
serial = sdi->conn; 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; return SR_OK;
} }

View File

@ -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. */ /* Poll every 50ms, or whenever some data comes in. */
serial = sdi->conn; 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); brymen_dmm_receive_data, (void *)sdi);
return SR_OK; return SR_OK;

View File

@ -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. */ /* Poll every 100ms, or whenever some data comes in. */
serial = sdi->conn; 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); (void *)sdi);
return SR_OK; return SR_OK;

View File

@ -257,7 +257,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
/* Poll every 500ms, or whenever some data comes in. */ /* Poll every 500ms, or whenever some data comes in. */
serial = sdi->conn; 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); center_devs[idx].receive_data, (void *)sdi);
return SR_OK; return SR_OK;

View File

@ -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. */ /* Poll every 150ms, or whenever some data comes in. */
serial = sdi->conn; 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); (void *)sdi);
return SR_OK; return SR_OK;

View File

@ -53,7 +53,7 @@ SR_PRIV int scpi_serial_source_add(void *priv, int events, int timeout,
{ {
struct sr_serial_dev_inst *serial = priv; 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) SR_PRIV int scpi_serial_source_remove(void *priv)

View File

@ -638,3 +638,9 @@ SR_PRIV int sr_serial_extract_options(GSList *options, const char **serial_devic
return SR_OK; 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);
}

View File

@ -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. */ /* Poll every 100ms, or whenever some data comes in. */
serial = sdi->conn; 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) { if (serial_write(serial, "QM\r", 3) == -1) {
sr_err("Unable to send QM: %s.", strerror(errno)); sr_err("Unable to send QM: %s.", strerror(errno));

View File

@ -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. */ /* Poll every 40ms, or whenever some data comes in. */
serial = sdi->conn; 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); (void *)sdi);
return SR_OK; return SR_OK;

View File

@ -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'. */ /* Our first probe is analog, the other 8 are of type 'logic'. */
/* TODO. */ /* 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; return SR_OK;
} }

View File

@ -259,7 +259,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
/* Poll every 100ms, or whenever some data comes in. */ /* Poll every 100ms, or whenever some data comes in. */
serial = sdi->conn; 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); mic_devs[idx].receive_data, (void *)sdi);
return SR_OK; return SR_OK;

View File

@ -293,7 +293,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
/* Poll every 100ms, or whenever some data comes in. */ /* Poll every 100ms, or whenever some data comes in. */
serial = sdi->conn; 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); (void *)sdi);
return SR_OK; return SR_OK;

View File

@ -537,7 +537,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
/* Send header packet to the session bus. */ /* Send header packet to the session bus. */
std_session_send_df_header(cb_data, LOG_PREFIX); 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; return SR_OK;
} }

View File

@ -495,7 +495,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
/* Poll every 50ms, or whenever some data comes in. */ /* Poll every 50ms, or whenever some data comes in. */
serial = sdi->conn; 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); dmms[dmm].receive_data, (void *)sdi);
return SR_OK; return SR_OK;

View File

@ -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); std_session_send_df_header(cb_data, LOG_PREFIX);
/* Poll every 50ms, or whenever some data comes in. */ /* 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; return SR_OK;
} }

View File

@ -223,7 +223,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
/* Poll every 500ms, or whenever some data comes in. */ /* Poll every 500ms, or whenever some data comes in. */
serial = sdi->conn; 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); tondaj_sl_814_receive_data, (void *)sdi);
return SR_OK; return SR_OK;

View File

@ -228,6 +228,8 @@ SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial,
uint64_t timeout_ms, int baudrate); uint64_t timeout_ms, int baudrate);
SR_PRIV int sr_serial_extract_options(GSList *options, const char **serial_device, SR_PRIV int sr_serial_extract_options(GSList *options, const char **serial_device,
const char **serial_options); 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 #endif
/*--- hardware/common/ezusb.c -----------------------------------------------*/ /*--- hardware/common/ezusb.c -----------------------------------------------*/