X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fhp-3457a%2Fapi.c;h=9f006df5600f43889b8a58bfde775c079c49c14d;hb=2881eef6ff9b33741337017045d4f98153a91f1c;hp=f828cfd817f3743c7c764561c8ac8c5737285cff;hpb=9417f26fd47556c4b4f6ecaa08a2860672664eb9;p=libsigrok.git diff --git a/src/hardware/hp-3457a/api.c b/src/hardware/hp-3457a/api.c index f828cfd8..9f006df5 100644 --- a/src/hardware/hp-3457a/api.c +++ b/src/hardware/hp-3457a/api.c @@ -52,12 +52,9 @@ static int create_front_channel(struct sr_dev_inst *sdi, int chan_idx) TRUE, "Front"); channel->priv = chanc; - front = g_malloc0(sizeof(*front)); - front->name = g_strdup("Front"); + front = sr_channel_group_new(sdi, "Front", NULL); front->channels = g_slist_append(front->channels, channel); - sdi->channel_groups = g_slist_append(sdi->channel_groups, front); - return chan_idx; } @@ -74,10 +71,7 @@ static int create_rear_channels(struct sr_dev_inst *sdi, int chan_idx, if (!card) return chan_idx; - group = g_malloc0(sizeof(*group)); - group->priv = NULL; - group->name = g_strdup(card->cg_name); - sdi->channel_groups = g_slist_append(sdi->channel_groups, group); + group = sr_channel_group_new(sdi, card->cg_name, NULL); for (i = 0; i < card->num_channels; i++) { @@ -127,6 +121,14 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) struct sr_dev_inst *sdi; struct dev_context *devc; + /* + * 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. + */ + /* * This command ensures we receive an EOI after every response, so that * we don't wait the entire timeout after the response is received. @@ -170,6 +172,14 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) 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); }