rigol-ds: split out vertical config reading in its own function for re-use.
This commit is contained in:
parent
5d8b3913d4
commit
8719638f5a
|
@ -813,29 +813,9 @@ SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi)
|
|||
return SR_ERR;
|
||||
sr_dbg("Current timebase %g", devc->timebase);
|
||||
|
||||
/* Vertical gain. */
|
||||
for (i = 0; i < devc->model->analog_channels; i++) {
|
||||
cmd = g_strdup_printf(":CHAN%d:SCAL?", i + 1);
|
||||
res = sr_scpi_get_float(sdi->conn, cmd, &devc->vdiv[i]);
|
||||
g_free(cmd);
|
||||
if (res != SR_OK)
|
||||
return SR_ERR;
|
||||
}
|
||||
sr_dbg("Current vertical gain:");
|
||||
for (i = 0; i < devc->model->analog_channels; i++)
|
||||
sr_dbg("CH%d %g", i + 1, devc->vdiv[i]);
|
||||
|
||||
/* Vertical offset. */
|
||||
for (i = 0; i < devc->model->analog_channels; i++) {
|
||||
cmd = g_strdup_printf(":CHAN%d:OFFS?", i + 1);
|
||||
res = sr_scpi_get_float(sdi->conn, cmd, &devc->vert_offset[i]);
|
||||
g_free(cmd);
|
||||
if (res != SR_OK)
|
||||
return SR_ERR;
|
||||
}
|
||||
sr_dbg("Current vertical offset:");
|
||||
for (i = 0; i < devc->model->analog_channels; i++)
|
||||
sr_dbg("CH%d %g", i + 1, devc->vert_offset[i]);
|
||||
/* Vertical gain and offset. */
|
||||
if (rigol_ds_get_dev_cfg_vertical(sdi) != SR_OK)
|
||||
return SR_ERR;
|
||||
|
||||
/* Coupling. */
|
||||
for (i = 0; i < devc->model->analog_channels; i++) {
|
||||
|
@ -866,3 +846,39 @@ SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi)
|
|||
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
SR_PRIV int rigol_ds_get_dev_cfg_vertical(const struct sr_dev_inst *sdi)
|
||||
{
|
||||
struct dev_context *devc;
|
||||
char *cmd;
|
||||
unsigned int i;
|
||||
int res;
|
||||
|
||||
devc = sdi->priv;
|
||||
|
||||
/* Vertical gain. */
|
||||
for (i = 0; i < devc->model->analog_channels; i++) {
|
||||
cmd = g_strdup_printf(":CHAN%d:SCAL?", i + 1);
|
||||
res = sr_scpi_get_float(sdi->conn, cmd, &devc->vdiv[i]);
|
||||
g_free(cmd);
|
||||
if (res != SR_OK)
|
||||
return SR_ERR;
|
||||
}
|
||||
sr_dbg("Current vertical gain:");
|
||||
for (i = 0; i < devc->model->analog_channels; i++)
|
||||
sr_dbg("CH%d %g", i + 1, devc->vdiv[i]);
|
||||
|
||||
/* Vertical offset. */
|
||||
for (i = 0; i < devc->model->analog_channels; i++) {
|
||||
cmd = g_strdup_printf(":CHAN%d:OFFS?", i + 1);
|
||||
res = sr_scpi_get_float(sdi->conn, cmd, &devc->vert_offset[i]);
|
||||
g_free(cmd);
|
||||
if (res != SR_OK)
|
||||
return SR_ERR;
|
||||
}
|
||||
sr_dbg("Current vertical offset:");
|
||||
for (i = 0; i < devc->model->analog_channels; i++)
|
||||
sr_dbg("CH%d %g", i + 1, devc->vert_offset[i]);
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
|
|
@ -153,5 +153,6 @@ SR_PRIV int rigol_ds_capture_start(const struct sr_dev_inst *sdi);
|
|||
SR_PRIV int rigol_ds_channel_start(const struct sr_dev_inst *sdi);
|
||||
SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data);
|
||||
SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi);
|
||||
SR_PRIV int rigol_ds_get_dev_cfg_vertical(const struct sr_dev_inst *sdi);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue