X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fmanson-hcs-3xxx%2Fapi.c;h=bc2700fa952ecca47fada9ce3ee67977c5f88e58;hb=3cc2028382637283884d03af7893003d85c9818a;hp=4a253a18ebfc40587efce9b661d2645a73bcb35f;hpb=c2fdcc25a47c4c8f25e3ea96ea36a674a151e839;p=libsigrok.git diff --git a/src/hardware/manson-hcs-3xxx/api.c b/src/hardware/manson-hcs-3xxx/api.c index 4a253a18..bc2700fa 100644 --- a/src/hardware/manson-hcs-3xxx/api.c +++ b/src/hardware/manson-hcs-3xxx/api.c @@ -19,10 +19,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/** @file - * Manson HCS-3xxx series power supply driver - * @internal - */ +/** + * @file + * + * Manson HCS-3xxx series power supply driver + * + * @internal + */ #include #include "protocol.h" @@ -73,23 +76,17 @@ static const struct hcs_model models[] = { ALL_ZERO }; -SR_PRIV struct sr_dev_driver manson_hcs_3xxx_driver_info; - static GSList *scan(struct sr_dev_driver *di, GSList *options) { int i, model_id; - struct drv_context *drvc; struct dev_context *devc; struct sr_dev_inst *sdi; struct sr_config *src; - GSList *devices, *l; + GSList *l; const char *conn, *serialcomm; struct sr_serial_dev_inst *serial; char reply[50], **tokens, *dummy; - drvc = di->context; - drvc->instances = NULL; - devices = NULL; conn = NULL; serialcomm = NULL; devc = NULL; @@ -149,7 +146,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) sdi->model = g_strdup(models[model_id].name); sdi->inst_type = SR_INST_SERIAL; sdi->conn = serial; - sdi->driver = di; sr_channel_new(sdi, 0, SR_CHANNEL_ANALOG, TRUE, "CH1"); @@ -180,14 +176,9 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) devc->voltage_max_device = g_strtod(tokens[0], &dummy) * devc->model->voltage[2]; g_strfreev(tokens); - drvc->instances = g_slist_append(drvc->instances, sdi); - devices = g_slist_append(devices, sdi); - serial_close(serial); - if (!devices) - sr_serial_dev_inst_free(serial); - return devices; + return std_scan_complete(di, g_slist_append(NULL, sdi)); exit_err: sr_dev_inst_free(sdi); @@ -250,6 +241,7 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd switch (key) { case SR_CONF_LIMIT_MSEC: + case SR_CONF_LIMIT_SAMPLES: return sr_sw_limits_config_set(&devc->limits, key, data); case SR_CONF_VOLTAGE_TARGET: dval = g_variant_get_double(data); @@ -368,7 +360,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) devc = sdi->priv; sr_sw_limits_acquisition_start(&devc->limits); - std_session_send_df_header(sdi, LOG_PREFIX); + std_session_send_df_header(sdi); devc->reply_pending = FALSE; devc->req_sent_at = 0; @@ -381,13 +373,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) return SR_OK; } -static int dev_acquisition_stop(struct sr_dev_inst *sdi) -{ - return std_serial_dev_acquisition_stop(sdi, - std_serial_dev_close, sdi->conn, LOG_PREFIX); -} - -SR_PRIV struct sr_dev_driver manson_hcs_3xxx_driver_info = { +static struct sr_dev_driver manson_hcs_3xxx_driver_info = { .name = "manson-hcs-3xxx", .longname = "Manson HCS-3xxx", .api_version = 1, @@ -401,6 +387,7 @@ SR_PRIV struct sr_dev_driver manson_hcs_3xxx_driver_info = { .dev_open = std_serial_dev_open, .dev_close = std_serial_dev_close, .dev_acquisition_start = dev_acquisition_start, - .dev_acquisition_stop = dev_acquisition_stop, + .dev_acquisition_stop = std_serial_dev_acquisition_stop, .context = NULL, }; +SR_REGISTER_DEV_DRIVER(manson_hcs_3xxx_driver_info);