scpi-pps: Use only standard SCPI for Rigol DP800 series.
This commit is contained in:
parent
ae431bc8d6
commit
60475cd788
|
@ -130,8 +130,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi)
|
||||||
sdi->channel_groups = g_slist_append(sdi->channel_groups, cg);
|
sdi->channel_groups = g_slist_append(sdi->channel_groups, cg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SCPI devices commonly lock the panel keys when accessed remotely. */
|
scpi_cmd(sdi, SCPI_CMD_LOCAL);
|
||||||
scpi_cmd(sdi, SCPI_CMD_KEY_UNLOCK);
|
|
||||||
sr_scpi_close(scpi);
|
sr_scpi_close(scpi);
|
||||||
|
|
||||||
return sdi;
|
return sdi;
|
||||||
|
@ -165,6 +164,8 @@ static int dev_open(struct sr_dev_inst *sdi)
|
||||||
|
|
||||||
sdi->status = SR_ST_ACTIVE;
|
sdi->status = SR_ST_ACTIVE;
|
||||||
|
|
||||||
|
scpi_cmd(sdi, SCPI_CMD_REMOTE);
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +178,7 @@ static int dev_close(struct sr_dev_inst *sdi)
|
||||||
|
|
||||||
scpi = sdi->conn;
|
scpi = sdi->conn;
|
||||||
if (scpi) {
|
if (scpi) {
|
||||||
scpi_cmd(sdi, SCPI_CMD_KEY_UNLOCK);
|
scpi_cmd(sdi, SCPI_CMD_LOCAL);
|
||||||
sr_scpi_close(scpi);
|
sr_scpi_close(scpi);
|
||||||
sdi->status = SR_ST_INACTIVE;
|
sdi->status = SR_ST_INACTIVE;
|
||||||
}
|
}
|
||||||
|
@ -194,19 +195,15 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
||||||
const struct sr_channel_group *cg)
|
const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct sr_scpi_dev_inst *scpi;
|
|
||||||
struct sr_channel *ch;
|
|
||||||
struct pps_channel *pch;
|
|
||||||
const GVariantType *gvtype;
|
const GVariantType *gvtype;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int cmd, ret;
|
int cmd, ret;
|
||||||
char *s;
|
const char *s;
|
||||||
|
|
||||||
if (!sdi)
|
if (!sdi)
|
||||||
return SR_ERR_ARG;
|
return SR_ERR_ARG;
|
||||||
|
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
scpi = sdi->conn;
|
|
||||||
|
|
||||||
if (cg) {
|
if (cg) {
|
||||||
/*
|
/*
|
||||||
|
@ -226,9 +223,6 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ch = cg->channels->data;
|
|
||||||
pch = ch->priv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gvtype = NULL;
|
gvtype = NULL;
|
||||||
|
@ -282,30 +276,32 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
||||||
gvtype = G_VARIANT_TYPE_BOOLEAN;
|
gvtype = G_VARIANT_TYPE_BOOLEAN;
|
||||||
cmd = SCPI_CMD_GET_OVER_TEMPERATURE_PROTECTION;
|
cmd = SCPI_CMD_GET_OVER_TEMPERATURE_PROTECTION;
|
||||||
break;
|
break;
|
||||||
|
case SR_CONF_OUTPUT_REGULATION:
|
||||||
|
gvtype = G_VARIANT_TYPE_STRING;
|
||||||
|
cmd = SCPI_CMD_GET_OUTPUT_REGULATION;
|
||||||
}
|
}
|
||||||
if (gvtype) {
|
if (gvtype) {
|
||||||
if (cg)
|
if (cg)
|
||||||
ret = scpi_cmd_resp(sdi, data, gvtype, cmd, pch->hwname);
|
select_channel(sdi, cg->channels->data);
|
||||||
else
|
ret = scpi_cmd_resp(sdi, data, gvtype, cmd);
|
||||||
ret = scpi_cmd_resp(sdi, data, gvtype, cmd);
|
|
||||||
} else if (cg) {
|
if (gvtype == G_VARIANT_TYPE_STRING && ret == SR_OK) {
|
||||||
switch (key) {
|
/* Non-standard data type responses. */
|
||||||
case SR_CONF_OUTPUT_REGULATION:
|
switch (key) {
|
||||||
ret = SR_ERR;
|
case SCPI_CMD_GET_OUTPUT_REGULATION:
|
||||||
if (scpi_cmd(sdi, SCPI_CMD_GET_OUTPUT_REGULATION, pch->hwname) == SR_OK) {
|
/*
|
||||||
if (sr_scpi_get_string(scpi, NULL, &s) == SR_OK) {
|
* This is specific to the Rigol DP800 series.
|
||||||
if (strcmp(s, "CC") && strcmp(s, "CV") && strcmp(s, "UR")) {
|
* We return the same string for now until more
|
||||||
sr_dbg("Unknown response to SCPI_CMD_GET_OUTPUT_REGULATION: %s", s);
|
* models with this key are supported. Do a check
|
||||||
} else {
|
* just for the hell of it.
|
||||||
*data = g_variant_new_string(s);
|
*/
|
||||||
g_free(s);
|
s = g_variant_get_string(*data, NULL);
|
||||||
ret = SR_OK;
|
if (strcmp(s, "CC") && strcmp(s, "CV") && strcmp(s, "UR")) {
|
||||||
}
|
sr_dbg("Unknown response to SCPI_CMD_GET_OUTPUT_REGULATION: %s", s);
|
||||||
|
ret = SR_ERR_DATA;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ret = SR_ERR_NA;
|
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
ret = SR_ERR_NA;
|
ret = SR_ERR_NA;
|
||||||
|
@ -316,8 +312,6 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s
|
||||||
static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
|
static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
|
||||||
const struct sr_channel_group *cg)
|
const struct sr_channel_group *cg)
|
||||||
{
|
{
|
||||||
struct sr_channel *ch;
|
|
||||||
struct pps_channel *pch;
|
|
||||||
double d;
|
double d;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -327,81 +321,54 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
|
||||||
if (sdi->status != SR_ST_ACTIVE)
|
if (sdi->status != SR_ST_ACTIVE)
|
||||||
return SR_ERR_DEV_CLOSED;
|
return SR_ERR_DEV_CLOSED;
|
||||||
|
|
||||||
ret = SR_OK;
|
if (cg)
|
||||||
if (!cg) {
|
|
||||||
switch (key) {
|
|
||||||
/* No channel group: global options. */
|
|
||||||
case SR_CONF_OUTPUT_ENABLED:
|
|
||||||
if (g_variant_get_boolean(data))
|
|
||||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OUTPUT_ENABLE);
|
|
||||||
else
|
|
||||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OUTPUT_DISABLE);
|
|
||||||
break;
|
|
||||||
case SR_CONF_OUTPUT_VOLTAGE_TARGET:
|
|
||||||
d = g_variant_get_double(data);
|
|
||||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_VOLTAGE_TARGET, d);
|
|
||||||
break;
|
|
||||||
case SR_CONF_OUTPUT_CURRENT_LIMIT:
|
|
||||||
d = g_variant_get_double(data);
|
|
||||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_CURRENT_LIMIT, d);
|
|
||||||
break;
|
|
||||||
case SR_CONF_OVER_TEMPERATURE_PROTECTION:
|
|
||||||
if (g_variant_get_boolean(data))
|
|
||||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_ENABLE);
|
|
||||||
else
|
|
||||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_DISABLE);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ret = SR_ERR_NA;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* Channel group specified. */
|
/* Channel group specified. */
|
||||||
ch = cg->channels->data;
|
select_channel(sdi, cg->channels->data);
|
||||||
pch = ch->priv;
|
|
||||||
switch (key) {
|
ret = SR_OK;
|
||||||
case SR_CONF_OUTPUT_ENABLED:
|
switch (key) {
|
||||||
if (g_variant_get_boolean(data))
|
case SR_CONF_OUTPUT_ENABLED:
|
||||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OUTPUT_ENABLE, pch->hwname);
|
if (g_variant_get_boolean(data))
|
||||||
else
|
ret = scpi_cmd(sdi, SCPI_CMD_SET_OUTPUT_ENABLE);
|
||||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OUTPUT_DISABLE, pch->hwname);
|
else
|
||||||
break;
|
ret = scpi_cmd(sdi, SCPI_CMD_SET_OUTPUT_DISABLE);
|
||||||
case SR_CONF_OUTPUT_VOLTAGE_TARGET:
|
break;
|
||||||
d = g_variant_get_double(data);
|
case SR_CONF_OUTPUT_VOLTAGE_TARGET:
|
||||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_VOLTAGE_TARGET, pch->hwname, d);
|
d = g_variant_get_double(data);
|
||||||
break;
|
ret = scpi_cmd(sdi, SCPI_CMD_SET_VOLTAGE_TARGET, d);
|
||||||
case SR_CONF_OUTPUT_CURRENT_LIMIT:
|
break;
|
||||||
d = g_variant_get_double(data);
|
case SR_CONF_OUTPUT_CURRENT_LIMIT:
|
||||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_CURRENT_LIMIT, pch->hwname, d);
|
d = g_variant_get_double(data);
|
||||||
break;
|
ret = scpi_cmd(sdi, SCPI_CMD_SET_CURRENT_LIMIT, d);
|
||||||
case SR_CONF_OVER_VOLTAGE_PROTECTION_ENABLED:
|
break;
|
||||||
if (g_variant_get_boolean(data))
|
case SR_CONF_OVER_VOLTAGE_PROTECTION_ENABLED:
|
||||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_ENABLE,
|
if (g_variant_get_boolean(data))
|
||||||
pch->hwname);
|
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_ENABLE);
|
||||||
else
|
else
|
||||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_DISABLE,
|
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_DISABLE);
|
||||||
pch->hwname);
|
break;
|
||||||
break;
|
case SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD:
|
||||||
case SR_CONF_OVER_VOLTAGE_PROTECTION_THRESHOLD:
|
d = g_variant_get_double(data);
|
||||||
d = g_variant_get_double(data);
|
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, d);
|
||||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD,
|
break;
|
||||||
pch->hwname, d);
|
case SR_CONF_OVER_CURRENT_PROTECTION_ENABLED:
|
||||||
break;
|
if (g_variant_get_boolean(data))
|
||||||
case SR_CONF_OVER_CURRENT_PROTECTION_ENABLED:
|
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLE);
|
||||||
if (g_variant_get_boolean(data))
|
else
|
||||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLE,
|
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_CURRENT_PROTECTION_DISABLE);
|
||||||
pch->hwname);
|
break;
|
||||||
else
|
case SR_CONF_OVER_CURRENT_PROTECTION_THRESHOLD:
|
||||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_CURRENT_PROTECTION_DISABLE,
|
d = g_variant_get_double(data);
|
||||||
pch->hwname);
|
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_CURRENT_PROTECTION_THRESHOLD, d);
|
||||||
break;
|
break;
|
||||||
case SR_CONF_OVER_CURRENT_PROTECTION_THRESHOLD:
|
case SR_CONF_OVER_TEMPERATURE_PROTECTION:
|
||||||
d = g_variant_get_double(data);
|
if (g_variant_get_boolean(data))
|
||||||
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_CURRENT_PROTECTION_THRESHOLD,
|
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_ENABLE);
|
||||||
pch->hwname, d);
|
else
|
||||||
break;
|
ret = scpi_cmd(sdi, SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_DISABLE);
|
||||||
default:
|
break;
|
||||||
ret = SR_ERR_NA;
|
default:
|
||||||
}
|
ret = SR_ERR_NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -527,7 +494,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
|
||||||
/* Prime the pipe with the first channel's fetch. */
|
/* Prime the pipe with the first channel's fetch. */
|
||||||
ch = sdi->channels->data;
|
ch = sdi->channels->data;
|
||||||
pch = ch->priv;
|
pch = ch->priv;
|
||||||
devc->cur_channel = ch;
|
select_channel(sdi, ch);
|
||||||
if (pch->mq == SR_MQ_VOLTAGE)
|
if (pch->mq == SR_MQ_VOLTAGE)
|
||||||
cmd = SCPI_CMD_GET_MEAS_VOLTAGE;
|
cmd = SCPI_CMD_GET_MEAS_VOLTAGE;
|
||||||
else if (pch->mq == SR_MQ_CURRENT)
|
else if (pch->mq == SR_MQ_CURRENT)
|
||||||
|
|
|
@ -82,33 +82,35 @@ struct channel_group_spec rigol_dp800_cg[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct scpi_command rigol_dp800_cmd[] = {
|
struct scpi_command rigol_dp800_cmd[] = {
|
||||||
{ SCPI_CMD_KEY_UNLOCK, "SYST:KLOCK OFF" },
|
{ SCPI_CMD_REMOTE, "SYST:REMOTE" },
|
||||||
{ SCPI_CMD_GET_MEAS_VOLTAGE, ":MEAS:VOLT? CH%s" },
|
{ SCPI_CMD_LOCAL, "SYST:LOCAL" },
|
||||||
{ SCPI_CMD_GET_MEAS_CURRENT, ":MEAS:CURR? CH%s" },
|
{ SCPI_CMD_SELECT_CHANNEL, ":INST:NSEL %s" },
|
||||||
{ SCPI_CMD_GET_MEAS_POWER, ":MEAS:POWE? CH%s" },
|
{ SCPI_CMD_GET_MEAS_VOLTAGE, ":MEAS:VOLT?" },
|
||||||
{ SCPI_CMD_GET_VOLTAGE_TARGET, ":SOUR%s:VOLT?" },
|
{ SCPI_CMD_GET_MEAS_CURRENT, ":MEAS:CURR?" },
|
||||||
{ SCPI_CMD_SET_VOLTAGE_TARGET, ":SOUR%s:VOLT %.6f" },
|
{ SCPI_CMD_GET_MEAS_POWER, ":MEAS:POWE?" },
|
||||||
{ SCPI_CMD_GET_CURRENT_LIMIT, ":SOUR%s:CURR?" },
|
{ SCPI_CMD_GET_VOLTAGE_TARGET, ":SOUR:VOLT?" },
|
||||||
{ SCPI_CMD_SET_CURRENT_LIMIT, ":SOUR%s:CURR %.6f" },
|
{ SCPI_CMD_SET_VOLTAGE_TARGET, ":SOUR:VOLT %.6f" },
|
||||||
{ SCPI_CMD_GET_OUTPUT_ENABLED, ":OUTP? CH%s" },
|
{ SCPI_CMD_GET_CURRENT_LIMIT, ":SOUR:CURR?" },
|
||||||
{ SCPI_CMD_SET_OUTPUT_ENABLE, ":OUTP CH%s,ON" },
|
{ SCPI_CMD_SET_CURRENT_LIMIT, ":SOUR:CURR %.6f" },
|
||||||
{ SCPI_CMD_SET_OUTPUT_DISABLE, ":OUTP CH%s,OFF" },
|
{ SCPI_CMD_GET_OUTPUT_ENABLED, ":OUTP?" },
|
||||||
{ SCPI_CMD_GET_OUTPUT_REGULATION, ":OUTP:MODE? CH%s" },
|
{ SCPI_CMD_SET_OUTPUT_ENABLE, ":OUTP ON" },
|
||||||
|
{ SCPI_CMD_SET_OUTPUT_DISABLE, ":OUTP OFF" },
|
||||||
|
{ SCPI_CMD_GET_OUTPUT_REGULATION, ":OUTP:MODE?" },
|
||||||
{ SCPI_CMD_GET_OVER_TEMPERATURE_PROTECTION, ":SYST:OTP?" },
|
{ SCPI_CMD_GET_OVER_TEMPERATURE_PROTECTION, ":SYST:OTP?" },
|
||||||
{ SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_ENABLE, ":SYST:OTP ON" },
|
{ SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_ENABLE, ":SYST:OTP ON" },
|
||||||
{ SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_DISABLE, ":SYST:OTP OFF" },
|
{ SCPI_CMD_SET_OVER_TEMPERATURE_PROTECTION_DISABLE, ":SYST:OTP OFF" },
|
||||||
{ SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ENABLED, ":OUTP:OVP? CH%s" },
|
{ SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ENABLED, ":OUTP:OVP?" },
|
||||||
{ SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_ENABLE, ":OUTP:OVP CH%s,ON" },
|
{ SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_ENABLE, ":OUTP:OVP ON" },
|
||||||
{ SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_DISABLE, ":OUTP:OVP CH%s,OFF" },
|
{ SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_DISABLE, ":OUTP:OVP OFF" },
|
||||||
{ SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ACTIVE, ":OUTP:OVP:QUES? CH%s" },
|
{ SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_ACTIVE, ":OUTP:OVP:QUES?" },
|
||||||
{ SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":OUTP:OVP:VAL? CH%s" },
|
{ SCPI_CMD_GET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":OUTP:OVP:VAL?" },
|
||||||
{ SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":OUTP:OVP:VAL CH%s,%.6f" },
|
{ SCPI_CMD_SET_OVER_VOLTAGE_PROTECTION_THRESHOLD, ":OUTP:OVP:VAL %.6f" },
|
||||||
{ SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ENABLED, ":OUTP:OCP? CH%s" },
|
{ SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ENABLED, ":OUTP:OCP?" },
|
||||||
{ SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLE, ":OUTP:OCP CH%s,ON" },
|
{ SCPI_CMD_SET_OVER_CURRENT_PROTECTION_ENABLE, ":OUTP:OCP:STAT ON" },
|
||||||
{ SCPI_CMD_SET_OVER_CURRENT_PROTECTION_DISABLE, ":OUTP:OCP CH%s,OFF" },
|
{ SCPI_CMD_SET_OVER_CURRENT_PROTECTION_DISABLE, ":OUTP:OCP:STAT OFF" },
|
||||||
{ SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ACTIVE, ":OUTP:OCP:QUES? CH%s" },
|
{ SCPI_CMD_GET_OVER_CURRENT_PROTECTION_ACTIVE, ":OUTP:OCP:QUES?" },
|
||||||
{ SCPI_CMD_GET_OVER_CURRENT_PROTECTION_THRESHOLD, ":OUTP:OCP:VAL? CH%s" },
|
{ SCPI_CMD_GET_OVER_CURRENT_PROTECTION_THRESHOLD, ":OUTP:OCP:VAL?" },
|
||||||
{ SCPI_CMD_SET_OVER_CURRENT_PROTECTION_THRESHOLD, ":OUTP:OCP:VAL CH%s,%.6f" },
|
{ SCPI_CMD_SET_OVER_CURRENT_PROTECTION_THRESHOLD, ":OUTP:OCP:VAL %.6f" },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* HP 663xx series */
|
/* HP 663xx series */
|
||||||
|
|
|
@ -100,12 +100,33 @@ SR_PRIV int scpi_cmd_resp(const struct sr_dev_inst *sdi, GVariant **gvar,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SR_PRIV int select_channel(const struct sr_dev_inst *sdi, struct sr_channel *ch)
|
||||||
|
{
|
||||||
|
struct dev_context *devc;
|
||||||
|
struct pps_channel *pch;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (g_slist_length(sdi->channels) == 1)
|
||||||
|
return SR_OK;
|
||||||
|
|
||||||
|
devc = sdi->priv;
|
||||||
|
if (ch == devc->cur_channel)
|
||||||
|
return SR_OK;
|
||||||
|
|
||||||
|
pch = ch->priv;
|
||||||
|
if ((ret = scpi_cmd(sdi, SCPI_CMD_SELECT_CHANNEL, pch->hwname)) == SR_OK)
|
||||||
|
devc->cur_channel = ch;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data)
|
SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data)
|
||||||
{
|
{
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
struct sr_datafeed_packet packet;
|
struct sr_datafeed_packet packet;
|
||||||
struct sr_datafeed_analog analog;
|
struct sr_datafeed_analog analog;
|
||||||
const struct sr_dev_inst *sdi;
|
const struct sr_dev_inst *sdi;
|
||||||
|
struct sr_channel *next_channel;
|
||||||
struct sr_scpi_dev_inst *scpi;
|
struct sr_scpi_dev_inst *scpi;
|
||||||
struct pps_channel *pch;
|
struct pps_channel *pch;
|
||||||
GSList *l;
|
GSList *l;
|
||||||
|
@ -143,14 +164,22 @@ SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data)
|
||||||
g_slist_free(analog.channels);
|
g_slist_free(analog.channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find next enabled channel. */
|
if (g_slist_length(sdi->channels) > 1) {
|
||||||
do {
|
/* Find next enabled channel. */
|
||||||
l = g_slist_find(sdi->channels, devc->cur_channel);
|
next_channel = devc->cur_channel;
|
||||||
if (l->next)
|
do {
|
||||||
devc->cur_channel = l->next->data;
|
l = g_slist_find(sdi->channels, next_channel);
|
||||||
else
|
if (l->next)
|
||||||
devc->cur_channel = sdi->channels->data;
|
next_channel = l->next->data;
|
||||||
} while (!devc->cur_channel->enabled);
|
else
|
||||||
|
next_channel = sdi->channels->data;
|
||||||
|
} while (!next_channel->enabled);
|
||||||
|
select_channel(sdi, next_channel);
|
||||||
|
if (devc->cur_channel != next_channel) {
|
||||||
|
sr_err("Failed to select channel %s", next_channel->name);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pch = devc->cur_channel->priv;
|
pch = devc->cur_channel->priv;
|
||||||
if (pch->mq == SR_MQ_VOLTAGE)
|
if (pch->mq == SR_MQ_VOLTAGE)
|
||||||
|
|
|
@ -28,7 +28,9 @@
|
||||||
#define LOG_PREFIX "scpi-pps"
|
#define LOG_PREFIX "scpi-pps"
|
||||||
|
|
||||||
enum pps_scpi_cmds {
|
enum pps_scpi_cmds {
|
||||||
SCPI_CMD_KEY_UNLOCK,
|
SCPI_CMD_REMOTE,
|
||||||
|
SCPI_CMD_LOCAL,
|
||||||
|
SCPI_CMD_SELECT_CHANNEL,
|
||||||
SCPI_CMD_GET_MEAS_VOLTAGE,
|
SCPI_CMD_GET_MEAS_VOLTAGE,
|
||||||
SCPI_CMD_GET_MEAS_CURRENT,
|
SCPI_CMD_GET_MEAS_CURRENT,
|
||||||
SCPI_CMD_GET_MEAS_POWER,
|
SCPI_CMD_GET_MEAS_POWER,
|
||||||
|
@ -146,6 +148,7 @@ SR_PRIV char *scpi_cmd_get(const struct sr_dev_inst *sdi, int command);
|
||||||
SR_PRIV int scpi_cmd(const struct sr_dev_inst *sdi, int command, ...);
|
SR_PRIV int scpi_cmd(const struct sr_dev_inst *sdi, int command, ...);
|
||||||
SR_PRIV int scpi_cmd_resp(const struct sr_dev_inst *sdi, GVariant **gvar,
|
SR_PRIV int scpi_cmd_resp(const struct sr_dev_inst *sdi, GVariant **gvar,
|
||||||
const GVariantType *gvtype, int command, ...);
|
const GVariantType *gvtype, int command, ...);
|
||||||
|
SR_PRIV int select_channel(const struct sr_dev_inst *sdi, struct sr_channel *ch);
|
||||||
SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data);
|
SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue