hp-3478a: Shorten some functions.

This commit is contained in:
Uwe Hermann 2018-02-18 23:14:51 +01:00
parent 6ddedf5bac
commit 04c4a6776f
2 changed files with 8 additions and 44 deletions

View File

@ -104,25 +104,12 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
static int dev_open(struct sr_dev_inst *sdi)
{
struct sr_scpi_dev_inst *scpi;
scpi = sdi->conn;
if (sr_scpi_open(scpi) != SR_OK)
return SR_ERR;
return SR_OK;
return sr_scpi_open(sdi->conn);
}
static int dev_close(struct sr_dev_inst *sdi)
{
struct sr_scpi_dev_inst *scpi;
scpi = sdi->conn;
sr_scpi_close(scpi);
return SR_OK;
return sr_scpi_close(sdi->conn);
}
static int config_get(uint32_t key, GVariant **data,
@ -241,12 +228,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
/* Get device status. */
hp_3478a_get_status_bytes(sdi);
ret = sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 100,
return sr_scpi_source_add(sdi->session, scpi, G_IO_IN, 100,
hp_3478a_receive_data, (void *)sdi);
if (ret != SR_OK)
return ret;
return SR_OK;
}
static int dev_acquisition_stop(struct sr_dev_inst *sdi)

View File

@ -38,46 +38,27 @@ static const struct {
static int set_mq_volt(struct sr_scpi_dev_inst *scpi, enum sr_mqflag flags)
{
const char *cmd;
if ((flags & SR_MQFLAG_AC) != SR_MQFLAG_AC &&
(flags & SR_MQFLAG_DC) != SR_MQFLAG_DC)
return SR_ERR_NA;
if ((flags & SR_MQFLAG_AC) == SR_MQFLAG_AC)
cmd = "F2";
else
cmd = "F1";
return sr_scpi_send(scpi, "%s", cmd);
return sr_scpi_send(scpi, "%s",
((flags & SR_MQFLAG_AC) == SR_MQFLAG_AC) ? "F2" : "F1");
}
static int set_mq_amp(struct sr_scpi_dev_inst *scpi, enum sr_mqflag flags)
{
const char *cmd;
if ((flags & SR_MQFLAG_AC) != SR_MQFLAG_AC &&
(flags & SR_MQFLAG_DC) != SR_MQFLAG_DC)
return SR_ERR_NA;
if (flags & SR_MQFLAG_AC)
cmd = "F6";
else
cmd = "F5";
return sr_scpi_send(scpi, "%s", cmd);
return sr_scpi_send(scpi, "%s", (flags & SR_MQFLAG_AC) ? "F6" : "F5");
}
static int set_mq_ohm(struct sr_scpi_dev_inst *scpi, enum sr_mqflag flags)
{
const char *cmd;
if (flags & SR_MQFLAG_FOUR_WIRE)
cmd = "F4";
else
cmd = "F3";
return sr_scpi_send(scpi, "%s", cmd);
return sr_scpi_send(scpi, "%s",
(flags & SR_MQFLAG_FOUR_WIRE) ? "F4" : "F3");
}
SR_PRIV int hp_3478a_set_mq(const struct sr_dev_inst *sdi, enum sr_mq mq,