};
static const uint32_t devopts[] = {
- /*
- * TODO Enable/disable multiple channel groups at once.
- * SR_CONF_ENABLED | SR_CONF_SET,
- */
+ SR_CONF_CONN | SR_CONF_GET,
+ SR_CONF_ENABLED | SR_CONF_SET,
};
static const uint32_t devopts_cg[] = {
size_t idx, nr;
struct sr_channel_group *cg;
+ /*
+ * The device cannot get identified by means of SCPI queries.
+ * Neither shall non-SCPI requests get emitted before reliable
+ * identification of the device. Assume that we only get here
+ * when user specs led us to believe it's safe to communicate
+ * to the expected kind of device.
+ */
+
sdi = g_malloc0(sizeof(*sdi));
sdi->vendor = g_strdup("Hewlett-Packard");
sdi->model = g_strdup("59306A");
sdi->conn = scpi;
sdi->driver = &hp_59306a_driver_info;
sdi->inst_type = SR_INST_SCPI;
+ if (sr_scpi_connection_id(scpi, &sdi->connection_id) != SR_OK) {
+ g_free(sdi->connection_id);
+ sdi->connection_id = NULL;
+ }
devc = g_malloc0(sizeof(*devc));
sdi->priv = devc;
nr = idx + 1;
cg = g_malloc0(sizeof(*cg));
- cg->name = g_strdup_printf("CH%zu", nr);
+ cg->name = g_strdup_printf("R%zu", nr);
cgc = g_malloc0(sizeof(*cgc));
cgc->number = nr;
static GSList *scan(struct sr_dev_driver *di, GSList *options)
{
+ const char *conn;
+
+ /* Only scan for a device when conn= was specified. */
+ conn = NULL;
+ (void)sr_serial_extract_options(options, &conn, NULL);
+ if (!conn)
+ return NULL;
+
return sr_scpi_scan(di->context, options, probe_device);
}
return sr_scpi_close(sdi->conn);
}
+static int config_get(uint32_t key, GVariant **data,
+ const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
+{
+ (void)cg;
+
+ if (!sdi || !data)
+ return SR_ERR_ARG;
+
+ switch (key) {
+ case SR_CONF_CONN:
+ *data = g_variant_new_string(sdi->connection_id);
+ break;
+ default:
+ return SR_ERR_NA;
+ }
+
+ return SR_OK;
+}
+
static int config_set(uint32_t key, GVariant *data,
const struct sr_dev_inst *sdi, const struct sr_channel_group *cg)
{
if (!cg) {
switch (key) {
- /* TODO: Enable/disbale multiple channel groups at once. */
case SR_CONF_ENABLED:
+ /* Enable/disable all channels at the same time. */
+ on = g_variant_get_boolean(data);
+ return hp_59306a_switch_cg(sdi, cg, on);
default:
return SR_ERR_NA;
}
static struct sr_dev_driver hp_59306a_driver_info = {
.name = "hp-59306a",
- .longname = "hp-59306a",
+ .longname = "HP 59306A",
.api_version = 1,
.init = std_init,
.cleanup = std_cleanup,
.scan = scan,
.dev_list = std_dev_list,
.dev_clear = std_dev_clear,
- .config_get = NULL,
+ .config_get = config_get,
.config_set = config_set,
.config_list = config_list,
.dev_open = dev_open,