X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fscpi-pps%2Fapi.c;h=aea3bd5e26833c95cee54ea3c7e850dc98cfcd61;hb=584560f142e1b17b9f4ef9069bd3724f2f77e750;hp=9ca71d3d01872f4d5103ac512e44cc3908273511;hpb=01b0257aefc10874012e9bc066802a2c3a308801;p=libsigrok.git diff --git a/src/hardware/scpi-pps/api.c b/src/hardware/scpi-pps/api.c index 9ca71d3d..aea3bd5e 100644 --- a/src/hardware/scpi-pps/api.c +++ b/src/hardware/scpi-pps/api.c @@ -25,7 +25,7 @@ static struct sr_dev_driver *di = &scpi_pps_driver_info; extern unsigned int num_pps_profiles; extern const struct scpi_pps pps_profiles[]; -static const int32_t scanopts[] = { +static const uint32_t scanopts[] = { SR_CONF_CONN, SR_CONF_SERIALCOMM, }; @@ -56,7 +56,7 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) GMatchInfo *model_mi; GSList *l; uint64_t mask; - unsigned int ch_num, ch_idx, old_idx, i, j; + unsigned int ch_num, ch_idx, i, j; const char *vendor; char ch_name[16]; @@ -95,7 +95,6 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) ch_idx = 0; for (ch_num = 0; ch_num < device->num_channels; ch_num++) { /* Create one channel per measurable output unit. */ - old_idx = ch_idx; for (i = 0; i < ARRAY_SIZE(pci); i++) { if (!scpi_cmd_get(sdi, pci[i].command)) continue; @@ -109,14 +108,6 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) ch->priv = pch; sdi->channels = g_slist_append(sdi->channels, ch); } - if (ch_idx == old_idx) { - /* - * Didn't create any channels for this hardware output. - * This can happen if the device has no measurement capability. - */ - g_free(pch); - continue; - } } for (i = 0; i < device->num_channel_groups; i++) { @@ -199,7 +190,7 @@ static int cleanup(void) return SR_OK; } -static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi, +static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { struct dev_context *devc; @@ -322,7 +313,7 @@ static int config_get(int key, GVariant **data, const struct sr_dev_inst *sdi, return ret; } -static int config_set(int 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) { struct sr_channel *ch; @@ -331,6 +322,9 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi, int ret; const char *s; + if (!sdi) + return SR_ERR_ARG; + if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; @@ -359,10 +353,6 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi, } } else { /* Channel group specified. */ - if (!sdi) - return SR_ERR_ARG; - if (g_slist_length(cg->channels) > 1) - return SR_ERR_NA; ch = cg->channels->data; pch = ch->priv; switch (key) { @@ -406,7 +396,7 @@ static int config_set(int key, GVariant *data, const struct sr_dev_inst *sdi, return ret; } -static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, +static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { struct dev_context *devc; @@ -419,8 +409,8 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, /* Always available, even without sdi. */ if (key == SR_CONF_SCAN_OPTIONS) { - *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, - scanopts, ARRAY_SIZE(scanopts), sizeof(int32_t)); + *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, + scanopts, ARRAY_SIZE(scanopts), sizeof(uint32_t)); return SR_OK; } @@ -433,9 +423,9 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, /* No channel group: global options. */ switch (key) { case SR_CONF_DEVICE_OPTIONS: - *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, + *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, devc->device->devopts, devc->device->num_devopts, - sizeof(int32_t)); + sizeof(uint32_t)); break; case SR_CONF_OUTPUT_CHANNEL_CONFIG: /* Not used. */ @@ -470,9 +460,9 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi, switch (key) { case SR_CONF_DEVICE_OPTIONS: - *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, + *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, devc->device->devopts_cg, devc->device->num_devopts_cg, - sizeof(int32_t)); + sizeof(uint32_t)); break; case SR_CONF_OUTPUT_VOLTAGE_MAX: ch_spec = &(devc->device->channels[ch->index]);