X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fmanson-hcs-3xxx%2Fapi.c;h=c62500c011d12313f51da949b053bc52392f1c2d;hb=dd7a72ea697a172032f5473b0ddff5e8d47222f4;hp=a2f1feca229152993322b4502f3cd71cccb09079;hpb=55fb76b34826a287240bebeeda688e4c465b4751;p=libsigrok.git diff --git a/src/hardware/manson-hcs-3xxx/api.c b/src/hardware/manson-hcs-3xxx/api.c index a2f1feca..c62500c0 100644 --- a/src/hardware/manson-hcs-3xxx/api.c +++ b/src/hardware/manson-hcs-3xxx/api.c @@ -18,14 +18,6 @@ * along with this program; if not, see . */ -/** - * @file - * - * Manson HCS-3xxx series power supply driver - * - * @internal - */ - #include #include "protocol.h" @@ -35,18 +27,13 @@ static const uint32_t scanopts[] = { }; static const uint32_t drvopts[] = { - /* Device class */ SR_CONF_POWER_SUPPLY, }; static const uint32_t devopts[] = { - /* Device class */ - SR_CONF_POWER_SUPPLY, - /* Acquisition modes. */ SR_CONF_CONTINUOUS, SR_CONF_LIMIT_SAMPLES | SR_CONF_GET | SR_CONF_SET, SR_CONF_LIMIT_MSEC | SR_CONF_GET | SR_CONF_SET, - /* Device configuration */ SR_CONF_VOLTAGE | SR_CONF_GET, SR_CONF_VOLTAGE_TARGET | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, SR_CONF_CURRENT | SR_CONF_GET, @@ -138,7 +125,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) } g_strfreev(tokens); - /* Init device instance, etc. */ sdi = g_malloc0(sizeof(struct sr_dev_inst)); sdi->status = SR_ST_INACTIVE; sdi->vendor = g_strdup("Manson"); @@ -186,8 +172,8 @@ exit_err: return NULL; } -static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, - const struct sr_channel_group *cg) +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; @@ -224,8 +210,8 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s return SR_OK; } -static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi, - const struct sr_channel_group *cg) +static int config_set(uint32_t key, GVariant *data, + const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { struct dev_context *devc; gboolean bval; @@ -277,14 +263,11 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd return SR_OK; } -static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, - const struct sr_channel_group *cg) +static int config_list(uint32_t key, GVariant **data, + const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { + const double *a; struct dev_context *devc; - GVariant *gvar; - GVariantBuilder gvb; - double dval; - int idx; devc = (sdi) ? sdi->priv : NULL; @@ -293,30 +276,12 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * case SR_CONF_DEVICE_OPTIONS: return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); case SR_CONF_VOLTAGE_TARGET: - g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY); - /* Min, max, step. */ - for (idx = 0; idx < 3; idx++) { - if (idx == 1) - dval = devc->voltage_max_device; - else - dval = devc->model->voltage[idx]; - gvar = g_variant_new_double(dval); - g_variant_builder_add_value(&gvb, gvar); - } - *data = g_variant_builder_end(&gvb); + a = devc->model->voltage; + *data = std_gvar_min_max_step(a[0], devc->voltage_max_device, a[2]); break; case SR_CONF_CURRENT_LIMIT: - g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY); - /* Min, max, step. */ - for (idx = 0; idx < 3; idx++) { - if (idx == 1) - dval = devc->current_max_device; - else - dval = devc->model->current[idx]; - gvar = g_variant_new_double(dval); - g_variant_builder_add_value(&gvb, gvar); - } - *data = g_variant_builder_end(&gvb); + a = devc->model->current; + *data = std_gvar_min_max_step(a[0], devc->current_max_device, a[2]); break; default: return SR_ERR_NA; @@ -338,7 +303,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) devc->reply_pending = FALSE; devc->req_sent_at = 0; - /* Poll every 10ms, or whenever some data comes in. */ serial = sdi->conn; serial_source_add(sdi->session, serial, G_IO_IN, 10, hcs_receive_data, (void *)sdi);