X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fpce-322a%2Fapi.c;h=e6c6fda04bf004531c26529022127295b786e23f;hb=f670835f1fbc03525e995d6970a5495976ab7c1a;hp=e53723c7873cdfb285dc2acb674f1ef9ce293149;hpb=bee2b0168c087676c1b365861d8c2d4714afa9b9;p=libsigrok.git diff --git a/src/hardware/pce-322a/api.c b/src/hardware/pce-322a/api.c index e53723c7..e6c6fda0 100644 --- a/src/hardware/pce-322a/api.c +++ b/src/hardware/pce-322a/api.c @@ -2,6 +2,7 @@ * This file is part of the libsigrok project. * * Copyright (C) 2016 George Hopkins + * Copyright (C) 2016 Matthieu Guillaumin * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,6 +39,7 @@ static const uint32_t devopts[] = { SR_CONF_SPL_WEIGHT_TIME | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, SR_CONF_SPL_MEASUREMENT_RANGE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, SR_CONF_POWER_OFF | SR_CONF_GET | SR_CONF_SET, + SR_CONF_DATA_SOURCE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, }; static const char *weight_freq[] = { @@ -57,6 +59,11 @@ static const uint64_t meas_ranges[][2] = { { 80, 130 }, }; +static const char *data_sources[] = { + "Live", + "Memory", +}; + static GSList *scan(struct sr_dev_driver *di, GSList *options) { struct dev_context *devc; @@ -149,6 +156,12 @@ static int config_get(uint32_t key, GVariant **data, case SR_CONF_POWER_OFF: *data = g_variant_new_boolean(FALSE); break; + case SR_CONF_DATA_SOURCE: + if (devc->cur_data_source == DATA_SOURCE_LIVE) + *data = g_variant_new_string("Live"); + else + *data = g_variant_new_string("Memory"); + break; default: return SR_ERR_NA; } @@ -215,6 +228,15 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd if (g_variant_get_boolean(data)) ret = pce_322a_power_off(sdi); break; + case SR_CONF_DATA_SOURCE: + tmp_str = g_variant_get_string(data, NULL); + if (!strcmp(tmp_str, "Live")) + devc->cur_data_source = DATA_SOURCE_LIVE; + else if (!strcmp(tmp_str, "Memory")) + devc->cur_data_source = DATA_SOURCE_MEMORY; + else + return SR_ERR; + break; default: ret = SR_ERR_NA; } @@ -268,6 +290,9 @@ static int config_list(uint32_t key, GVariant **data, } *data = g_variant_builder_end(&gvb); break; + case SR_CONF_DATA_SOURCE: + *data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources)); + break; default: return SR_ERR_NA; } @@ -303,11 +328,9 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) struct dev_context *devc; struct sr_serial_dev_inst *serial; - if (sdi->status != SR_ST_ACTIVE) - return SR_ERR_DEV_CLOSED; - devc = sdi->priv; devc->buffer_len = 0; + devc->memory_state = MEM_STATE_REQUEST_MEMORY_USAGE; std_session_send_df_header(sdi); @@ -319,12 +342,6 @@ 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, dev_close, - sdi->conn); -} - static struct sr_dev_driver pce_322a_driver_info = { .name = "pce-322a", .longname = "PCE PCE-322A", @@ -340,7 +357,7 @@ static struct sr_dev_driver pce_322a_driver_info = { .dev_open = dev_open, .dev_close = 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(pce_322a_driver_info);