X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fsiglent-sds%2Fapi.c;h=846399b678c4a8a3af56864e99ffbf27173b9d87;hb=HEAD;hp=9811ac0c84ebc87d42447a69e323cf507c23853b;hpb=c90065a9499768f1663771136da10ee05e641677;p=libsigrok.git diff --git a/src/hardware/siglent-sds/api.c b/src/hardware/siglent-sds/api.c index 9811ac0c..76955e6d 100644 --- a/src/hardware/siglent-sds/api.c +++ b/src/hardware/siglent-sds/api.c @@ -50,7 +50,7 @@ static const uint32_t devopts[] = { SR_CONF_SAMPLERATE | SR_CONF_GET, SR_CONF_LIMIT_FRAMES | SR_CONF_GET | SR_CONF_SET, SR_CONF_DATA_SOURCE | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, - SR_CONF_AVERAGING | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, + SR_CONF_AVERAGING | SR_CONF_GET | SR_CONF_SET, SR_CONF_AVG_SAMPLES | SR_CONF_GET | SR_CONF_SET | SR_CONF_LIST, }; @@ -149,6 +149,10 @@ static const uint64_t probe_factor[] = { 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, }; +static const uint64_t averages[] = { + 4, 16, 32, 64, 128, 256, 512, 1024, +}; + /* Do not change the order of entries. */ static const char *data_sources[] = { "Display", @@ -197,35 +201,35 @@ static const struct siglent_sds_series supported_series[] = { #define SERIES(x) &supported_series[x] /* series, model, min timebase, analog channels, digital */ static const struct siglent_sds_model supported_models[] = { - { SERIES(SDS1000CML), "SDS1152CML", { 20, 1000000000 }, 2, false, 0 }, - { SERIES(SDS1000CML), "SDS1102CML", { 10, 1000000000 }, 2, false, 0 }, - { SERIES(SDS1000CML), "SDS1072CML", { 5, 1000000000 }, 2, false, 0 }, - { SERIES(SDS1000CNL), "SDS1202CNL", { 20, 1000000000 }, 2, false, 0 }, - { SERIES(SDS1000CNL), "SDS1102CNL", { 10, 1000000000 }, 2, false, 0 }, - { SERIES(SDS1000CNL), "SDS1072CNL", { 5, 1000000000 }, 2, false, 0 }, - { SERIES(SDS1000DL), "SDS1202DL", { 20, 1000000000 }, 2, false, 0 }, - { SERIES(SDS1000DL), "SDS1102DL", { 10, 1000000000 }, 2, false, 0 }, - { SERIES(SDS1000DL), "SDS1022DL", { 5, 1000000000 }, 2, false, 0 }, - { SERIES(SDS1000DL), "SDS1052DL", { 5, 1000000000 }, 2, false, 0 }, - { SERIES(SDS1000DL), "SDS1052DL+", { 5, 1000000000 }, 2, false, 0 }, - { SERIES(SDS1000X), "SDS1102X", { 2, 1000000000 }, 2, false, 0 }, - { SERIES(SDS1000XP), "SDS1102X+", { 2, 1000000000 }, 2, false, 0 }, - { SERIES(SDS1000X), "SDS1202X", { 2, 1000000000 }, 2, false, 0 }, - { SERIES(SDS1000XP), "SDS1202X+", { 2, 1000000000 }, 2, false, 0 }, - { SERIES(SDS1000XE), "SDS1202X-E", { 1, 1000000000 }, 2, false, 0 }, - { SERIES(SDS1000XE), "SDS1104X-E", { 1, 1000000000 }, 4, true, 16 }, - { SERIES(SDS1000XE), "SDS1204X-E", { 1, 1000000000 }, 4, true, 16 }, - { SERIES(SDS2000X), "SDS2072X", { 2, 1000000000 }, 2, false, 0 }, - { SERIES(SDS2000X), "SDS2074X", { 2, 1000000000 }, 4, false, 0 }, - { SERIES(SDS2000X), "SDS2102X", { 2, 1000000000 }, 2, false, 0 }, - { SERIES(SDS2000X), "SDS2104X", { 2, 1000000000 }, 4, false, 0 }, - { SERIES(SDS2000X), "SDS2202X", { 2, 1000000000 }, 2, false, 0 }, - { SERIES(SDS2000X), "SDS2204X", { 2, 1000000000 }, 4, false, 0 }, - { SERIES(SDS2000X), "SDS2302X", { 2, 1000000000 }, 2, false, 0 }, - { SERIES(SDS2000X), "SDS2304X", { 2, 1000000000 }, 4, false, 0 }, + { SERIES(SDS1000CML), "SDS1152CML", { 20, 1000000000 }, 2, FALSE, 0 }, + { SERIES(SDS1000CML), "SDS1102CML", { 10, 1000000000 }, 2, FALSE, 0 }, + { SERIES(SDS1000CML), "SDS1072CML", { 5, 1000000000 }, 2, FALSE, 0 }, + { SERIES(SDS1000CNL), "SDS1202CNL", { 20, 1000000000 }, 2, FALSE, 0 }, + { SERIES(SDS1000CNL), "SDS1102CNL", { 10, 1000000000 }, 2, FALSE, 0 }, + { SERIES(SDS1000CNL), "SDS1072CNL", { 5, 1000000000 }, 2, FALSE, 0 }, + { SERIES(SDS1000DL), "SDS1202DL", { 20, 1000000000 }, 2, FALSE, 0 }, + { SERIES(SDS1000DL), "SDS1102DL", { 10, 1000000000 }, 2, FALSE, 0 }, + { SERIES(SDS1000DL), "SDS1022DL", { 5, 1000000000 }, 2, FALSE, 0 }, + { SERIES(SDS1000DL), "SDS1052DL", { 5, 1000000000 }, 2, FALSE, 0 }, + { SERIES(SDS1000DL), "SDS1052DL+", { 5, 1000000000 }, 2, FALSE, 0 }, + { SERIES(SDS1000X), "SDS1102X", { 2, 1000000000 }, 2, FALSE, 0 }, + { SERIES(SDS1000XP), "SDS1102X+", { 2, 1000000000 }, 2, FALSE, 0 }, + { SERIES(SDS1000X), "SDS1202X", { 2, 1000000000 }, 2, FALSE, 0 }, + { SERIES(SDS1000XP), "SDS1202X+", { 2, 1000000000 }, 2, FALSE, 0 }, + { SERIES(SDS1000XE), "SDS1202X-E", { 1, 1000000000 }, 2, FALSE, 0 }, + { SERIES(SDS1000XE), "SDS1104X-E", { 1, 1000000000 }, 4, TRUE, 16 }, + { SERIES(SDS1000XE), "SDS1204X-E", { 1, 1000000000 }, 4, TRUE, 16 }, + { SERIES(SDS2000X), "SDS2072X", { 2, 1000000000 }, 2, FALSE, 0 }, + { SERIES(SDS2000X), "SDS2074X", { 2, 1000000000 }, 4, FALSE, 0 }, + { SERIES(SDS2000X), "SDS2102X", { 2, 1000000000 }, 2, FALSE, 0 }, + { SERIES(SDS2000X), "SDS2104X", { 2, 1000000000 }, 4, FALSE, 0 }, + { SERIES(SDS2000X), "SDS2202X", { 2, 1000000000 }, 2, FALSE, 0 }, + { SERIES(SDS2000X), "SDS2204X", { 2, 1000000000 }, 4, FALSE, 0 }, + { SERIES(SDS2000X), "SDS2302X", { 2, 1000000000 }, 2, FALSE, 0 }, + { SERIES(SDS2000X), "SDS2304X", { 2, 1000000000 }, 4, FALSE, 0 }, }; -SR_PRIV struct sr_dev_driver siglent_sds_driver_info; +static struct sr_dev_driver siglent_sds_driver_info; static void clear_helper(void *priv) { @@ -253,10 +257,6 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) const struct siglent_sds_model *model; gchar *channel_name; - sr_dbg("Setting Communication Headers to off."); - if (sr_scpi_send(scpi, "CHDR OFF") != SR_OK) - return NULL; - if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK) { sr_info("Couldn't get IDN response, retrying."); sr_scpi_close(scpi); @@ -280,6 +280,10 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) return NULL; } + sr_dbg("Setting Communication Headers to off."); + if (sr_scpi_send(scpi, "CHDR OFF") != SR_OK) + return NULL; + sdi = g_malloc0(sizeof(struct sr_dev_inst)); sdi->vendor = g_strdup(model->series->vendor->name); sdi->model = g_strdup(model->name); @@ -301,17 +305,13 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) channel_name = g_strdup_printf("CH%d", i + 1); ch = sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_name); - devc->analog_groups[i] = g_malloc0(sizeof(struct sr_channel_group)); - - devc->analog_groups[i]->name = channel_name; + devc->analog_groups[i] = sr_channel_group_new(sdi, + channel_name, NULL); devc->analog_groups[i]->channels = g_slist_append(NULL, ch); - sdi->channel_groups = g_slist_append(sdi->channel_groups, - devc->analog_groups[i]); } if (devc->model->has_digital) { - devc->digital_group = g_malloc0(sizeof(struct sr_channel_group)); - + devc->digital_group = sr_channel_group_new(sdi, "LA", NULL); for (i = 0; i < ARRAY_SIZE(devc->digital_channels); i++) { channel_name = g_strdup_printf("D%d", i); ch = sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, channel_name); @@ -319,9 +319,6 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) devc->digital_group->channels = g_slist_append( devc->digital_group->channels, ch); } - devc->digital_group->name = g_strdup("LA"); - sdi->channel_groups = g_slist_append(sdi->channel_groups, - devc->digital_group); } for (i = 0; i < ARRAY_SIZE(timebases); i++) { @@ -514,6 +511,12 @@ static int config_get(uint32_t key, GVariant **data, } *data = g_variant_new_uint64(devc->attenuation[analog_channel]); break; + case SR_CONF_AVERAGING: + *data = g_variant_new_boolean(devc->average_enabled); + break; + case SR_CONF_AVG_SAMPLES: + *data = g_variant_new_uint64(devc->average_samples); + break; default: return SR_ERR_NA; } @@ -774,8 +777,8 @@ static int config_list(uint32_t key, GVariant **data, case SR_CONF_NUM_HDIV: *data = g_variant_new_int32(devc->model->series->num_horizontal_divs); break; - case SR_CONF_AVERAGING: - *data = g_variant_new_boolean(devc->average_enabled); + case SR_CONF_AVG_SAMPLES: + *data = std_gvar_array_u64(ARRAY_AND_SIZE(averages)); break; default: return SR_ERR_NA; @@ -789,7 +792,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) struct sr_scpi_dev_inst *scpi; struct dev_context *devc; struct sr_channel *ch; - struct sr_datafeed_packet packet; gboolean some_digital; GSList *l, *d; @@ -890,8 +892,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) return SR_ERR; /* Start of first frame. */ - packet.type = SR_DF_FRAME_BEGIN; - sr_session_send(sdi, &packet); + std_session_send_df_frame_begin(sdi); return SR_OK; } @@ -913,7 +914,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi) return SR_OK; } -SR_PRIV struct sr_dev_driver siglent_sds_driver_info = { +static struct sr_dev_driver siglent_sds_driver_info = { .name = "siglent-sds", .longname = "Siglent SDS1000/SDS2000", .api_version = 1, @@ -931,5 +932,4 @@ SR_PRIV struct sr_dev_driver siglent_sds_driver_info = { .dev_acquisition_stop = dev_acquisition_stop, .context = NULL, }; - SR_REGISTER_DEV_DRIVER(siglent_sds_driver_info);